mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-16 12:39:24 +02:00
* fcl-db: sql parser: fix failing STARTING WITH test committed in r27854
git-svn-id: trunk@27867 -
This commit is contained in:
parent
02014da511
commit
9ee1ec412f
@ -55,10 +55,12 @@ Type
|
|||||||
Function CreateElement(AElementClass : TSQLElementClass; APArent : TSQLElement) : TSQLElement; virtual;
|
Function CreateElement(AElementClass : TSQLElementClass; APArent : TSQLElement) : TSQLElement; virtual;
|
||||||
function CreateLiteral(AParent: TSQLElement): TSQLLiteral;
|
function CreateLiteral(AParent: TSQLElement): TSQLLiteral;
|
||||||
Function CreateIdentifier(AParent : TSQLElement; Const AName : TSQLStringType) : TSQLIdentifierName;
|
Function CreateIdentifier(AParent : TSQLElement; Const AName : TSQLStringType) : TSQLIdentifierName;
|
||||||
|
// Verify that current token is the expect token; raise error if not
|
||||||
procedure Expect(aToken: TSQLToken);
|
procedure Expect(aToken: TSQLToken);
|
||||||
procedure Expect(aTokens: TSQLTokens);
|
procedure Expect(aTokens: TSQLTokens);
|
||||||
|
// Expects aToken and eats it
|
||||||
procedure Consume(aToken: TSQLToken);
|
procedure Consume(aToken: TSQLToken);
|
||||||
Procedure Error(Msg : String);
|
procedure Error(Msg : String);
|
||||||
Procedure Error(Fmt : String; Args : Array of const);
|
Procedure Error(Fmt : String; Args : Array of const);
|
||||||
// Expression support
|
// Expression support
|
||||||
function ParseExprLevel1(AParent: TSQLElement; EO : TExpressionOptions): TSQLExpression;
|
function ParseExprLevel1(AParent: TSQLElement; EO : TExpressionOptions): TSQLExpression;
|
||||||
@ -156,6 +158,7 @@ Type
|
|||||||
// Auxiliary stuff
|
// Auxiliary stuff
|
||||||
Function CurrentToken : TSQLToken;
|
Function CurrentToken : TSQLToken;
|
||||||
Function CurrentTokenString : String;
|
Function CurrentTokenString : String;
|
||||||
|
// Gets next token; also sets FCurrent to that token
|
||||||
Function GetNextToken : TSQLToken;
|
Function GetNextToken : TSQLToken;
|
||||||
Function PeekNextToken : TSQLToken;
|
Function PeekNextToken : TSQLToken;
|
||||||
Function PreviousToken : TSQLToken;
|
Function PreviousToken : TSQLToken;
|
||||||
@ -2135,10 +2138,15 @@ begin
|
|||||||
if Not (tt in sqlInvertableComparisons) then
|
if Not (tt in sqlInvertableComparisons) then
|
||||||
Error(SErrUnexpectedToken,[CurrentTokenString]);
|
Error(SErrUnexpectedToken,[CurrentTokenString]);
|
||||||
GetNextToken;
|
GetNextToken;
|
||||||
|
// Step past expected STARTING WITH
|
||||||
If (tt=tsqlStarting) and (CurrentToken=tsqlWith) then
|
If (tt=tsqlStarting) and (CurrentToken=tsqlWith) then
|
||||||
GetNextToken;
|
GetNextToken;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
begin
|
||||||
|
// Step past expected STARTING WITH
|
||||||
|
If (tt=tsqlStarting) and (CurrentToken=tsqlWith) then
|
||||||
|
GetNextToken;
|
||||||
if (CurrentToken=tsqlNot) then
|
if (CurrentToken=tsqlNot) then
|
||||||
begin
|
begin
|
||||||
GetNextToken;
|
GetNextToken;
|
||||||
@ -2146,7 +2154,7 @@ begin
|
|||||||
UnexpectedToken;
|
UnexpectedToken;
|
||||||
I:=true;
|
I:=true;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
bw:=False;
|
bw:=False;
|
||||||
doin:=false;
|
doin:=false;
|
||||||
@ -2158,7 +2166,7 @@ begin
|
|||||||
tsqlEq : O:=boEq;
|
tsqlEq : O:=boEq;
|
||||||
tsqlNE : O:=boNE;
|
tsqlNE : O:=boNE;
|
||||||
tsqlLike : O:=boLike;
|
tsqlLike : O:=boLike;
|
||||||
tsqlIn : doin:=true;
|
tsqlIn : doIn:=true;
|
||||||
tsqlis : O:=boIs;
|
tsqlis : O:=boIs;
|
||||||
tsqlContaining : O:=boContaining;
|
tsqlContaining : O:=boContaining;
|
||||||
tsqlStarting : O:=boStarting;
|
tsqlStarting : O:=boStarting;
|
||||||
@ -3833,7 +3841,7 @@ end;
|
|||||||
function TSQLParser.GetNextToken: TSQLToken;
|
function TSQLParser.GetNextToken: TSQLToken;
|
||||||
begin
|
begin
|
||||||
FPrevious:=FCurrent;
|
FPrevious:=FCurrent;
|
||||||
If (FPeekToken<>tsqlunknown) then
|
If (FPeekToken<>tsqlUnknown) then
|
||||||
begin
|
begin
|
||||||
FCurrent:=FPeekToken;
|
FCurrent:=FPeekToken;
|
||||||
FCurrentString:=FPeekTokenString;
|
FCurrentString:=FPeekTokenString;
|
||||||
|
Loading…
Reference in New Issue
Block a user