fcl-db: fix parameter parsing in case, when in SQL follows two comments, where in 2nd commend is embeded quote char. Bug #22463

git-svn-id: trunk@31155 -
This commit is contained in:
lacak 2015-06-26 08:02:49 +00:00
parent 3a746b76fa
commit 2f97bc7f60
2 changed files with 6 additions and 3 deletions

View File

@ -235,9 +235,9 @@ begin
case p^ of
'''', '"', '`':
begin
Result := True;
// single quote, double quote or backtick delimited string
SkipQuotesString(p, p^, EscapeSlash, EscapeRepeat);
Result := True;
end;
'-': // possible start of -- comment
begin
@ -315,7 +315,7 @@ begin
p:=PChar(SQL);
BufStart:=p; // used to calculate ParamPart.Start values
repeat
SkipComments(p,EscapeSlash,EscapeRepeat);
while SkipComments(p,EscapeSlash,EscapeRepeat) do ;
case p^ of
':','?': // parameter
begin
@ -403,7 +403,7 @@ begin
Dec(NewQueryLength,p-ParamNameStart);
end;
end;
#0:Break;
#0:Break; // end of SQL
else
Inc(p);
end;

View File

@ -145,6 +145,9 @@ begin
// Bracketed comment
AssertEquals( 'select * from table where id=/*comment :c*/$1-$2',
Params.ParseSQL('select * from table where id=/*comment :c*/:a-:b', True, True, True, psPostgreSQL));
// Consecutive comments, with quote in second comment
AssertEquals( '--c1'#10'--c'''#10'select '':a'' from table where id=$1',
Params.ParseSQL('--c1'#10'--c'''#10'select '':a'' from table where id=:id', True, True, True, psPostgreSQL));
Params.Free;
end;