* Patch from Dmitry Boyarintsev to support empty statements

git-svn-id: trunk@17545 -
This commit is contained in:
michael 2011-05-23 20:36:53 +00:00
parent a7b281b132
commit cbcece1ae6
2 changed files with 22 additions and 1 deletions

View File

@ -3758,6 +3758,10 @@ end;
function TSQLParser.Parse: TSQLElement;
begin
if CurrentToken=tsqlEOF then begin
Result:=nil;
Exit;
end;
GetNextToken;
Case CurrentToken of
tsqlSelect : Result:=ParseSelectStatement(Nil,[]);
@ -3775,6 +3779,7 @@ begin
tsqlDeclare : Result:=ParseDeclareStatement(Nil);
tsqlGrant : Result:=ParseGrantStatement(Nil);
tsqlRevoke : Result:=ParseRevokeStatement(Nil);
tsqlEOF : Result:=nil;
else
UnexpectedToken;
end;

View File

@ -831,10 +831,25 @@ type
procedure Test2RolesToUser;
end;
{ TTestGlobalParser }
TTestGlobalParser = Class(TTestSQLParser)
published
procedure TestEmpty;
end;
implementation
uses typinfo;
{ TTestGlobalParser }
procedure TTestGlobalParser.TestEmpty;
begin
CreateParser('');
AssertNull('Empty statement returns nil',Parser.Parse);
end;
{ --------------------------------------------------------------------
TTestParser
--------------------------------------------------------------------}
@ -7991,6 +8006,7 @@ initialization
TTestCreateTriggerParser,
TTestDeclareExternalFunctionParser,
TTestGrantParser,
TTestRevokeParser]);
TTestRevokeParser,
TTestGlobalParser]);
end.