|
@@ -176,32 +176,37 @@ begin
|
|
|
Result := ParseSQL(SQL,DoCreate,ParameterStyle,ParamBinding, rs);
|
|
|
end;
|
|
|
|
|
|
-function SkipComments(var p: PChar) : boolean;
|
|
|
-begin
|
|
|
- result := false;
|
|
|
- case p^ of
|
|
|
- '''': // single quote delimited string
|
|
|
+function SkipComments(var p: PChar; EscapeSlash, EscapeRepeat : Boolean) : Boolean;
|
|
|
+var notRepeatEscaped : boolean;
|
|
|
+
|
|
|
+ procedure SkipQuotesString(QuoteChar : char);
|
|
|
+ begin
|
|
|
+ Inc(p);
|
|
|
+ Result := True;
|
|
|
+ repeat
|
|
|
+ notRepeatEscaped := True;
|
|
|
+ while not (p^ in [#0, QuoteChar]) do
|
|
|
begin
|
|
|
- Inc(p);
|
|
|
- Result := True;
|
|
|
- while not (p^ in [#0, '''']) do
|
|
|
- begin
|
|
|
- if p^='\' then Inc(p,2) // make sure we handle \' and \\ correct
|
|
|
- else Inc(p);
|
|
|
- end;
|
|
|
- if p^='''' then Inc(p); // skip final '
|
|
|
+ if EscapeSlash and (p^='\') then Inc(p,2) // make sure we handle \' and \\ correct
|
|
|
+ else Inc(p);
|
|
|
end;
|
|
|
- '"': // double quote delimited string
|
|
|
+ if p^=QuoteChar then
|
|
|
begin
|
|
|
- Inc(p);
|
|
|
- Result := True;
|
|
|
- while not (p^ in [#0, '"']) do
|
|
|
+ Inc(p); // skip final '
|
|
|
+ if (p^=QuoteChar) and EscapeRepeat then // Handle escaping by ''
|
|
|
begin
|
|
|
- if p^='\' then Inc(p,2) // make sure we handle \" and \\ correct
|
|
|
- else Inc(p);
|
|
|
- end;
|
|
|
- if p^='"' then Inc(p); // skip final "
|
|
|
+ notRepeatEscaped := False;
|
|
|
+ inc(p);
|
|
|
+ end
|
|
|
end;
|
|
|
+ until notRepeatEscaped;
|
|
|
+ end;
|
|
|
+
|
|
|
+begin
|
|
|
+ result := false;
|
|
|
+ case p^ of
|
|
|
+ '''': SkipQuotesString(''''); // single quote delimited string
|
|
|
+ '"': SkipQuotesString('"'); // double quote delimited string
|
|
|
'-': // possible start of -- comment
|
|
|
begin
|
|
|
Inc(p);
|
|
@@ -275,7 +280,7 @@ begin
|
|
|
p:=PChar(SQL);
|
|
|
BufStart:=p; // used to calculate ParamPart.Start values
|
|
|
repeat
|
|
|
- SkipComments(p);
|
|
|
+ SkipComments(p,ParameterStyle<>psPostgreSQL,ParameterStyle=psPostgreSQL);
|
|
|
case p^ of
|
|
|
':','?': // parameter
|
|
|
begin
|