[#7518] Support ALTER TABLE .. MODIFY ( ... ) (parenthesised modify clause)
This commit is contained in:
parent
c601410e45
commit
9c2a993020
@ -63,11 +63,15 @@ alterTableStatement = 'ALTER TABLE' [ 'IF EXISTS' ] tableName break
|
||||
| 'ADD' [ 'COLUMN' ] column
|
||||
| 'ADD' '(' ( 'CONSTRAINT' constraintName constraint | constraint | column )
|
||||
{ ',' ( 'CONSTRAINT' constraintName constraint | constraint | column ) } ')'
|
||||
| ( 'ALTER' | 'MODIFY' ) [ 'COLUMN' ] identifier
|
||||
(
|
||||
[ [ 'SET DATA' ] 'TYPE' ] dataType [ [ 'NOT' ] 'NULL' ]
|
||||
| ( 'SET' | 'DROP' ) 'NOT NULL'
|
||||
| [ 'RENAME' ] ( 'TO' | 'AS' ) identifier
|
||||
| ( 'ALTER' | 'MODIFY' )
|
||||
( [ 'COLUMN' ] identifier
|
||||
(
|
||||
[ [ 'SET DATA' ] 'TYPE' ] dataType [ [ 'NOT' ] 'NULL' ]
|
||||
| ( 'SET' | 'DROP' ) 'NOT NULL'
|
||||
| [ 'RENAME' ] ( 'TO' | 'AS' ) identifier
|
||||
)
|
||||
| column
|
||||
| '(' column ')'
|
||||
)
|
||||
| 'COMMENT' [ '=' ] stringLiteral
|
||||
| 'DROP' [ 'COLUMN' ] identifier [ 'CASCADE' | 'RESTRICT' ]
|
||||
|
||||
@ -3162,16 +3162,18 @@ final class ParserImpl implements Parser {
|
||||
}
|
||||
|
||||
private static final DDLQuery parseAlterTableAlterColumn(ParserContext ctx, AlterTableStep s1) {
|
||||
boolean paren = parseIf(ctx, '(');
|
||||
TableField<?, ?> field = parseFieldName(ctx);
|
||||
|
||||
if (parseKeywordIf(ctx, "DROP NOT NULL"))
|
||||
return s1.alter(field).dropNotNull();
|
||||
else if (parseKeywordIf(ctx, "SET NOT NULL"))
|
||||
return s1.alter(field).setNotNull();
|
||||
else if (parseKeywordIf(ctx, "TO") || parseKeywordIf(ctx, "RENAME TO") || parseKeywordIf(ctx, "RENAME AS"))
|
||||
return s1.renameColumn(field).to(parseFieldName(ctx));
|
||||
else if (parseKeywordIf(ctx, "TYPE") || parseKeywordIf(ctx, "SET DATA TYPE"))
|
||||
;
|
||||
if (!paren)
|
||||
if (parseKeywordIf(ctx, "DROP NOT NULL"))
|
||||
return s1.alter(field).dropNotNull();
|
||||
else if (parseKeywordIf(ctx, "SET NOT NULL"))
|
||||
return s1.alter(field).setNotNull();
|
||||
else if (parseKeywordIf(ctx, "TO") || parseKeywordIf(ctx, "RENAME TO") || parseKeywordIf(ctx, "RENAME AS"))
|
||||
return s1.renameColumn(field).to(parseFieldName(ctx));
|
||||
else if (parseKeywordIf(ctx, "TYPE") || parseKeywordIf(ctx, "SET DATA TYPE"))
|
||||
;
|
||||
|
||||
DataType<?> type = parseDataType(ctx);
|
||||
|
||||
@ -3180,6 +3182,9 @@ final class ParserImpl implements Parser {
|
||||
else if (parseKeywordIf(ctx, "NOT NULL"))
|
||||
type = type.nullable(false);
|
||||
|
||||
if (paren)
|
||||
parse(ctx, ')');
|
||||
|
||||
return s1.alter(field).set(type);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user