parent
e7ad321665
commit
74649da33e
@ -80,10 +80,14 @@ alterSchemaStatement = 'ALTER SCHEMA' [ 'IF EXISTS' ] schemaName
|
||||
'RENAME TO' schemaName
|
||||
;
|
||||
|
||||
alterSequenceStatement = 'ALTER SEQUENCE' [ 'IF EXISTS' ] sequenceName
|
||||
alterSequenceStatement =
|
||||
(
|
||||
'RENAME TO' sequenceName
|
||||
| 'RESTART' [ 'WITH' unsignedInteger ]
|
||||
'ALTER SEQUENCE' [ 'IF EXISTS' ] sequenceName
|
||||
(
|
||||
'RENAME TO' sequenceName
|
||||
| 'RESTART' [ 'WITH' unsignedInteger ]
|
||||
)
|
||||
| 'SET GENERATOR' sequenceName 'TO' unsignedInteger
|
||||
)
|
||||
;
|
||||
|
||||
@ -112,7 +116,7 @@ createIndexStatement = 'CREATE' [ 'UNIQUE' ] 'INDEX' [ 'IF NOT EXISTS' ] indexNa
|
||||
createSchemaStatement = 'CREATE SCHEMA' [ 'IF NOT EXISTS' ] schemaName
|
||||
;
|
||||
|
||||
createSequenceStatement = 'CREATE SEQUENCE' [ 'IF NOT EXISTS' ] sequenceName
|
||||
createSequenceStatement = 'CREATE' ( 'SEQUENCE' | 'GENERATOR' ) [ 'IF NOT EXISTS' ] sequenceName
|
||||
;
|
||||
|
||||
createViewStatement = 'CREATE VIEW' [ 'IF NOT EXISTS' ] tableName
|
||||
@ -128,7 +132,7 @@ dropIndexStatement = 'DROP INDEX' [ 'IF EXISTS' ] indexName [ 'ON' tableName ]
|
||||
dropViewStatement = 'DROP VIEW' [ 'IF EXISTS' ] tableName
|
||||
;
|
||||
|
||||
dropSequenceStatement = 'DROP SEQUENCE' [ 'IF EXISTS' ] sequenceName
|
||||
dropSequenceStatement = 'DROP' ( 'SEQUENCE' | 'GENERATOR' ) [ 'IF EXISTS' ] sequenceName
|
||||
;
|
||||
|
||||
dropSchemaStatement = 'DROP SCHEMA' [ 'IF EXISTS' ] schemaName [ 'CASCADE' | 'RESTRICT' ]
|
||||
|
||||
@ -550,6 +550,8 @@ class ParserImpl implements Parser {
|
||||
case 'S':
|
||||
if (peekKeyword(ctx, "SELECT"))
|
||||
return parseSelect(ctx);
|
||||
else if (!resultQuery && peekKeyword(ctx, "SET"))
|
||||
return parseSet(ctx);
|
||||
|
||||
break;
|
||||
|
||||
@ -1207,6 +1209,15 @@ class ParserImpl implements Parser {
|
||||
return s3;
|
||||
}
|
||||
|
||||
private static final Query parseSet(ParserContext ctx) {
|
||||
parseKeyword(ctx, "SET");
|
||||
|
||||
if (parseKeywordIf(ctx, "GENERATOR"))
|
||||
return parseSetGenerator(ctx);
|
||||
else
|
||||
throw ctx.unexpectedToken();
|
||||
}
|
||||
|
||||
private static final DDLQuery parseCreate(ParserContext ctx) {
|
||||
parseKeyword(ctx, "CREATE");
|
||||
|
||||
@ -1214,6 +1225,8 @@ class ParserImpl implements Parser {
|
||||
return parseCreateTable(ctx, false);
|
||||
else if (parseKeywordIf(ctx, "TEMPORARY TABLE"))
|
||||
return parseCreateTable(ctx, true);
|
||||
else if (parseKeywordIf(ctx, "GENERATOR"))
|
||||
return parseCreateSequence(ctx);
|
||||
else if (parseKeywordIf(ctx, "GLOBAL TEMPORARY TABLE"))
|
||||
return parseCreateTable(ctx, true);
|
||||
else if (parseKeywordIf(ctx, "INDEX"))
|
||||
@ -1256,6 +1269,8 @@ class ParserImpl implements Parser {
|
||||
return parseDropIndex(ctx);
|
||||
else if (parseKeywordIf(ctx, "VIEW"))
|
||||
return parseDropView(ctx);
|
||||
else if (parseKeywordIf(ctx, "GENERATOR"))
|
||||
return parseDropSequence(ctx);
|
||||
else if (parseKeywordIf(ctx, "SEQUENCE"))
|
||||
return parseDropSequence(ctx);
|
||||
else if (parseKeywordIf(ctx, "SCHEMA"))
|
||||
@ -1499,6 +1514,12 @@ class ParserImpl implements Parser {
|
||||
throw ctx.unexpectedToken();
|
||||
}
|
||||
|
||||
private static final DDLQuery parseSetGenerator(ParserContext ctx) {
|
||||
Sequence<?> sequenceName = parseSequenceName(ctx);
|
||||
parseKeyword(ctx, "TO");
|
||||
return ctx.dsl.alterSequence((Sequence) sequenceName).restartWith(parseUnsignedInteger(ctx));
|
||||
}
|
||||
|
||||
private static final DDLQuery parseDropSequence(ParserContext ctx) {
|
||||
boolean ifExists = parseKeywordIf(ctx, "IF EXISTS");
|
||||
Sequence<?> sequenceName = parseSequenceName(ctx);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user