|
@@ -101,6 +101,7 @@ Type
|
|
function ParseCreateViewStatement(AParent: TSQLElement; IsAlter: Boolean): TSQLCreateOrAlterStatement;
|
|
function ParseCreateViewStatement(AParent: TSQLElement; IsAlter: Boolean): TSQLCreateOrAlterStatement;
|
|
function ParseCreateTriggerStatement(AParent: TSQLElement; IsAlter: Boolean): TSQLCreateOrAlterStatement;
|
|
function ParseCreateTriggerStatement(AParent: TSQLElement; IsAlter: Boolean): TSQLCreateOrAlterStatement;
|
|
function ParseSetGeneratorStatement(AParent: TSQLElement) : TSQLSetGeneratorStatement;
|
|
function ParseSetGeneratorStatement(AParent: TSQLElement) : TSQLSetGeneratorStatement;
|
|
|
|
+ function ParseSetISQLStatement(AParent: TSQLElement) : TSQLSetISQLStatement;
|
|
function ParseSetTermStatement(AParent: TSQLElement) : TSQLSetTermStatement;
|
|
function ParseSetTermStatement(AParent: TSQLElement) : TSQLSetTermStatement;
|
|
function ParseCreateDatabaseStatement(AParent: TSQLElement; IsAlter: Boolean ): TSQLCreateDatabaseStatement;
|
|
function ParseCreateDatabaseStatement(AParent: TSQLElement; IsAlter: Boolean ): TSQLCreateDatabaseStatement;
|
|
function ParseCreateShadowStatement(AParent: TSQLElement; IsAlter: Boolean ): TSQLCreateShadowStatement;
|
|
function ParseCreateShadowStatement(AParent: TSQLElement; IsAlter: Boolean ): TSQLCreateShadowStatement;
|
|
@@ -158,7 +159,9 @@ Type
|
|
Function ParseConnectStatement(AParent : TSQLElement) : TSQLConnectStatement;
|
|
Function ParseConnectStatement(AParent : TSQLElement) : TSQLConnectStatement;
|
|
Function ParseGrantStatement(AParent: TSQLElement): TSQLGrantStatement;
|
|
Function ParseGrantStatement(AParent: TSQLElement): TSQLGrantStatement;
|
|
Function ParseRevokeStatement(AParent: TSQLElement): TSQLGrantStatement;
|
|
Function ParseRevokeStatement(AParent: TSQLElement): TSQLGrantStatement;
|
|
|
|
+ // Parse single element
|
|
Function Parse : TSQLElement;
|
|
Function Parse : TSQLElement;
|
|
|
|
+ // Parse script containing 1 or more elements
|
|
Function ParseScript(AllowPartial : Boolean = False) : TSQLElementList;
|
|
Function ParseScript(AllowPartial : Boolean = False) : TSQLElementList;
|
|
// Gets statement terminator (as e.g. used in SET TERM) so statements like
|
|
// Gets statement terminator (as e.g. used in SET TERM) so statements like
|
|
// EXECUTE BLOCK or CREATE PROCEDURE that contain semicolons can be parsed
|
|
// EXECUTE BLOCK or CREATE PROCEDURE that contain semicolons can be parsed
|
|
@@ -2965,11 +2968,11 @@ begin
|
|
Consume(tsqlGenerator) ;
|
|
Consume(tsqlGenerator) ;
|
|
try
|
|
try
|
|
Result:=TSQLSetGeneratorStatement(CreateElement(TSQLSetGeneratorStatement,AParent));
|
|
Result:=TSQLSetGeneratorStatement(CreateElement(TSQLSetGeneratorStatement,AParent));
|
|
- expect(tsqlidentifier);
|
|
|
|
|
|
+ Expect(tsqlidentifier);
|
|
Result.ObjectName:=CreateIdentifier(Result,CurrentTokenString);
|
|
Result.ObjectName:=CreateIdentifier(Result,CurrentTokenString);
|
|
GetNextToken;
|
|
GetNextToken;
|
|
- consume(tsqlto);
|
|
|
|
- expect(tsqlIntegerNumber);
|
|
|
|
|
|
+ Consume(tsqlto);
|
|
|
|
+ Expect(tsqlIntegerNumber);
|
|
Result.NewValue:=StrToInt(CurrentTokenString);
|
|
Result.NewValue:=StrToInt(CurrentTokenString);
|
|
GetNextToken;
|
|
GetNextToken;
|
|
except
|
|
except
|
|
@@ -2978,6 +2981,37 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TSQLParser.ParseSetISQLStatement(AParent: TSQLElement
|
|
|
|
+ ): TSQLSetISQLStatement;
|
|
|
|
+begin
|
|
|
|
+ // On entry, we're on the first argument e.g. AUTODDL in SET AUTODDL
|
|
|
|
+ // for now, only support AutoDDL
|
|
|
|
+ //SET AUTODDL: ignore these isql commands for now
|
|
|
|
+ case CurrentToken of
|
|
|
|
+ tsqlAutoDDL:
|
|
|
|
+ begin
|
|
|
|
+ Result:=TSQLSetISQLStatement(CreateElement(TSQLSetISQLStatement,AParent));
|
|
|
|
+ // SET AUTODDL ON, SET AUTODDL OFF; optional arguments
|
|
|
|
+ if (PeekNextToken in [tsqlOn, tsqlOff]) then
|
|
|
|
+ begin
|
|
|
|
+ GetNextToken;
|
|
|
|
+ if CurrentToken=tsqlOFF then
|
|
|
|
+ Result.Arguments:='AUTODDL OFF'
|
|
|
|
+ else
|
|
|
|
+ Result.Arguments:='AUTODDL ON';
|
|
|
|
+ Consume([tsqlOn,tsqlOff]);
|
|
|
|
+ end
|
|
|
|
+ else
|
|
|
|
+ begin
|
|
|
|
+ Result.Arguments:='AUTODDL ON';
|
|
|
|
+ Consume(tsqlAutoDDL);
|
|
|
|
+ end;
|
|
|
|
+ end
|
|
|
|
+ else
|
|
|
|
+ UnexpectedToken;
|
|
|
|
+ end;
|
|
|
|
+end;
|
|
|
|
+
|
|
function TSQLParser.ParseSetTermStatement(AParent: TSQLElement
|
|
function TSQLParser.ParseSetTermStatement(AParent: TSQLElement
|
|
): TSQLSetTermStatement;
|
|
): TSQLSetTermStatement;
|
|
var
|
|
var
|
|
@@ -2987,23 +3021,29 @@ begin
|
|
Consume(tsqlTerm) ;
|
|
Consume(tsqlTerm) ;
|
|
try
|
|
try
|
|
Result:=TSQLSetTermStatement(CreateElement(TSQLSetTermStatement,AParent));
|
|
Result:=TSQLSetTermStatement(CreateElement(TSQLSetTermStatement,AParent));
|
|
- expect([tsqlSemiColon,tsqlStatementTerminator,tsqlSymbolString,tsqlString]);
|
|
|
|
|
|
+ Expect([tsqlSemiColon,tsqlStatementTerminator,tsqlSymbolString,tsqlString]);
|
|
// Already set the expression's new value to the new terminator, but do not
|
|
// Already set the expression's new value to the new terminator, but do not
|
|
// change tSQLStatementTerminator as GetNextToken etc need the old one to
|
|
// change tSQLStatementTerminator as GetNextToken etc need the old one to
|
|
// detect the closing terminator
|
|
// detect the closing terminator
|
|
case CurrentToken of
|
|
case CurrentToken of
|
|
- tsqlSemiColon, tsqlStatementTerminator: Result.NewValue:=TokenInfos[CurrentToken];
|
|
|
|
- tsqlSymbolString, tsqlString: Result.NewValue:=CurrentTokenString;
|
|
|
|
|
|
+ tsqlSemiColon, tsqlStatementTerminator: Result.NewTerminator:=TokenInfos[CurrentToken];
|
|
|
|
+ tsqlSymbolString, tsqlString: Result.NewTerminator:=CurrentTokenString;
|
|
end;
|
|
end;
|
|
// Expect the old terminator...
|
|
// Expect the old terminator...
|
|
GetNextToken;
|
|
GetNextToken;
|
|
// Parser will give tsqlSemicolon rather than tsqlStatementTerminator:
|
|
// Parser will give tsqlSemicolon rather than tsqlStatementTerminator:
|
|
if TokenInfos[tsqlStatementTerminator]=TokenInfos[tsqlSEMICOLON] then
|
|
if TokenInfos[tsqlStatementTerminator]=TokenInfos[tsqlSEMICOLON] then
|
|
- Expect(tsqlSEMICOLON)
|
|
|
|
|
|
+ begin
|
|
|
|
+ Expect(tsqlSEMICOLON);
|
|
|
|
+ Result.OldTerminator:=TokenInfos[tsqlSEMICOLON];
|
|
|
|
+ end
|
|
else
|
|
else
|
|
|
|
+ begin
|
|
Expect(tsqlStatementTerminator);
|
|
Expect(tsqlStatementTerminator);
|
|
|
|
+ Result.OldTerminator:=TokenInfos[tsqlStatementTerminator];
|
|
|
|
+ end;
|
|
//... and now set the new terminator:
|
|
//... and now set the new terminator:
|
|
- TokenInfos[tsqlStatementTerminator]:=Result.NewValue; //process new terminator value
|
|
|
|
|
|
+ TokenInfos[tsqlStatementTerminator]:=Result.NewTerminator; //process new terminator value
|
|
except
|
|
except
|
|
FreeAndNil(Result);
|
|
FreeAndNil(Result);
|
|
Raise;
|
|
Raise;
|
|
@@ -3414,20 +3454,7 @@ begin
|
|
Case CurrentToken of
|
|
Case CurrentToken of
|
|
tsqlGenerator : Result:=ParseSetGeneratorStatement(AParent); //SET GENERATOR
|
|
tsqlGenerator : Result:=ParseSetGeneratorStatement(AParent); //SET GENERATOR
|
|
tsqlTerm : Result:=ParseSetTermStatement(AParent); //SET TERM
|
|
tsqlTerm : Result:=ParseSetTermStatement(AParent); //SET TERM
|
|
- tsqlAutoDDL : //SET AUTODDL: ignore these isql commands for now
|
|
|
|
- begin
|
|
|
|
- // SET AUTODDL ON, SET AUTODDL OFF; optional arguments
|
|
|
|
- if (PeekNextToken in [tsqlOn, tsqlOff]) then
|
|
|
|
- begin
|
|
|
|
- GetNextToken;
|
|
|
|
- Consume([tsqlOn,tsqlOff]);
|
|
|
|
- end
|
|
|
|
- else
|
|
|
|
- begin
|
|
|
|
- Consume(tsqlAutoDDL);
|
|
|
|
- end;
|
|
|
|
- Result:=nil; //ignore
|
|
|
|
- end;
|
|
|
|
|
|
+ tsqlAutoDDL : Result:=ParseSetISQLStatement(AParent); //SET AUTODDL
|
|
else
|
|
else
|
|
// For the time being
|
|
// For the time being
|
|
UnexpectedToken;
|
|
UnexpectedToken;
|