[jOOQ/jOOQ#9775] [jOOQ/jOOQ#10105] Improved parser support
Support parsing ALTER { SEQUENCE | TABLE | TYPE | VIEW } .. OWNER TO ..
This commit is contained in:
parent
718a440692
commit
5961b40a1e
@ -3175,14 +3175,20 @@ final class ParserImpl implements Parser {
|
||||
private static final DDLQuery parseAlterView(ParserContext ctx) {
|
||||
boolean ifExists = parseKeywordIf(ctx, "IF EXISTS");
|
||||
Table<?> oldName = parseTableName(ctx);
|
||||
parseKeyword(ctx, "RENAME");
|
||||
if (!parseKeywordIf(ctx, "AS"))
|
||||
parseKeyword(ctx, "TO");
|
||||
Table<?> newName = parseTableName(ctx);
|
||||
|
||||
return ifExists
|
||||
? ctx.dsl.alterViewIfExists(oldName).renameTo(newName)
|
||||
: ctx.dsl.alterView(oldName).renameTo(newName);
|
||||
if (parseKeywordIf(ctx, "RENAME")) {
|
||||
if (!parseKeywordIf(ctx, "AS"))
|
||||
parseKeyword(ctx, "TO");
|
||||
Table<?> newName = parseTableName(ctx);
|
||||
|
||||
return ifExists
|
||||
? ctx.dsl.alterViewIfExists(oldName).renameTo(newName)
|
||||
: ctx.dsl.alterView(oldName).renameTo(newName);
|
||||
}
|
||||
else if (parseKeywordIf(ctx, "OWNER TO") && parseUser(ctx) != null)
|
||||
return IGNORE;
|
||||
else
|
||||
throw ctx.expected("OWNER TO", "RENAME");
|
||||
}
|
||||
|
||||
private static final DDLQuery parseDropView(ParserContext ctx) {
|
||||
@ -3251,6 +3257,9 @@ final class ParserImpl implements Parser {
|
||||
parseKeyword(ctx, "TO");
|
||||
return s.renameTo(parseSequenceName(ctx));
|
||||
}
|
||||
else if (parseKeywordIf(ctx, "OWNER TO") && parseUser(ctx) != null) {
|
||||
return IGNORE;
|
||||
}
|
||||
else {
|
||||
boolean found = false;
|
||||
AlterSequenceFlagsStep s1 = s;
|
||||
@ -3287,8 +3296,24 @@ final class ParserImpl implements Parser {
|
||||
break;
|
||||
found = true;
|
||||
}
|
||||
|
||||
if (!found)
|
||||
throw ctx.expected("CACHE", "CYCLE", "INCREMENT BY", "MAXVALUE", "MINVALUE", "NO CACHE", "NO CYCLE", "NO MAXVALUE", "NO MINVALUE", "RENAME TO", "RESTART", "START WITH");
|
||||
throw ctx.expected(
|
||||
"CACHE",
|
||||
"CYCLE",
|
||||
"INCREMENT BY",
|
||||
"MAXVALUE",
|
||||
"MINVALUE",
|
||||
"NO CACHE",
|
||||
"NO CYCLE",
|
||||
"NO MAXVALUE",
|
||||
"NO MINVALUE",
|
||||
"OWNER TO",
|
||||
"RENAME TO",
|
||||
"RESTART",
|
||||
"START WITH"
|
||||
);
|
||||
|
||||
return s1;
|
||||
}
|
||||
}
|
||||
@ -4145,6 +4170,13 @@ final class ParserImpl implements Parser {
|
||||
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
case 'O':
|
||||
if (parseKeywordIf(ctx, "OWNER TO") && parseUser(ctx) != null)
|
||||
return IGNORE;
|
||||
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
case 'R':
|
||||
if (parseKeywordIf(ctx, "RENAME")) {
|
||||
@ -4182,7 +4214,7 @@ final class ParserImpl implements Parser {
|
||||
break;
|
||||
}
|
||||
|
||||
throw ctx.expected("ADD", "ALTER", "COMMENT", "DROP", "MODIFY", "RENAME");
|
||||
throw ctx.expected("ADD", "ALTER", "COMMENT", "DROP", "MODIFY", "OWNER TO", "RENAME");
|
||||
}
|
||||
|
||||
private static final AlterTableFinalStep parseCascadeRestrictIf(ParserContext ctx, AlterTableDropStep step) {
|
||||
@ -4356,6 +4388,8 @@ final class ParserImpl implements Parser {
|
||||
|
||||
if (parseKeywordIf(ctx, "ADD VALUE"))
|
||||
return s1.addValue(parseStringLiteral(ctx));
|
||||
else if (parseKeywordIf(ctx, "OWNER TO") && parseUser(ctx) != null)
|
||||
return IGNORE;
|
||||
else if (parseKeywordIf(ctx, "RENAME TO"))
|
||||
return s1.renameTo(parseIdentifier(ctx));
|
||||
else if (parseKeywordIf(ctx, "RENAME VALUE"))
|
||||
@ -4363,8 +4397,7 @@ final class ParserImpl implements Parser {
|
||||
else if (parseKeywordIf(ctx, "SET SCHEMA"))
|
||||
return s1.setSchema(parseIdentifier(ctx));
|
||||
|
||||
|
||||
throw ctx.expected("ADD VALUE", "RENAME TO", "RENAME VALUE", "SET SCHEMA");
|
||||
throw ctx.expected("ADD VALUE", "OWNER TO", "RENAME TO", "RENAME VALUE", "SET SCHEMA");
|
||||
}
|
||||
|
||||
private static final DDLQuery parseRename(ParserContext ctx) {
|
||||
@ -4538,10 +4571,8 @@ final class ParserImpl implements Parser {
|
||||
AlterSchemaFinalStep s2 = s1.renameTo(newName);
|
||||
return s2;
|
||||
}
|
||||
else if (parseKeywordIf(ctx, "OWNER TO")) {
|
||||
parseUser(ctx);
|
||||
else if (parseKeywordIf(ctx, "OWNER TO") && parseUser(ctx) != null)
|
||||
return IGNORE;
|
||||
}
|
||||
else if (parseAlterDatabaseFlags(ctx, false))
|
||||
return IGNORE;
|
||||
else
|
||||
|
||||
Loading…
Reference in New Issue
Block a user