bereng commented on a change in pull request #1422:
URL: https://github.com/apache/cassandra/pull/1422#discussion_r826779274
##########
File path: src/antlr/Parser.g
##########
@@ -915,37 +915,45 @@ dropTriggerStatement returns [DropTriggerStatement.Raw
stmt]
;
/**
- * ALTER KEYSPACE <KS> WITH <property> = <value>;
+ * ALTER KEYSPACE [IF EXISTS] <KS> WITH <property> = <value>;
*/
alterKeyspaceStatement returns [AlterKeyspaceStatement.Raw stmt]
- @init { KeyspaceAttributes attrs = new KeyspaceAttributes(); }
- : K_ALTER K_KEYSPACE ks=keyspaceName
- K_WITH properties[attrs] { $stmt = new AlterKeyspaceStatement.Raw(ks,
attrs); }
+ @init {
+ KeyspaceAttributes attrs = new KeyspaceAttributes();
+ boolean ifExists = false;
+ }
+ : K_ALTER K_KEYSPACE (K_IF K_EXISTS { ifExists = true; } )? ks=keyspaceName
+ K_WITH properties[attrs] { $stmt = new AlterKeyspaceStatement.Raw(ks,
attrs, ifExists); }
;
/**
* ALTER TABLE <table> ALTER <column> TYPE <newtype>;
- * ALTER TABLE <table> ADD <column> <newtype>; | ALTER TABLE <table> ADD
(<column> <newtype>,<column1> <newtype1>..... <column n> <newtype n>)
- * ALTER TABLE <table> DROP <column>; | ALTER TABLE <table> DROP (
<column>,<column1>.....<column n>)
- * ALTER TABLE <table> RENAME <column> TO <column>;
- * ALTER TABLE <table> WITH <property> = <value>;
+ * ALTER TABLE [IF EXISTS] <table> ADD [IF NOT EXISTS] <column> <newtype>; |
ALTER TABLE [IF EXISTS] <table> ADD [IF NOT EXISTS] (<column>
<newtype>,<column1> <newtype1>..... <column n> <newtype n>)
+ * ALTER TABLE [IF EXISTS] <table> DROP [IF EXISTS] <column>; | ALTER TABLE
[IF EXISTS] <table> DROP [IF EXISTS] ( <column>,<column1>.....<column n>)
+ * ALTER TABLE [IF EXISTS] <table> RENAME [IF EXISTS] <column> TO <column>;
+ * ALTER TABLE [IF EXISTS] <table> WITH <property> = <value>;
*/
alterTableStatement returns [AlterTableStatement.Raw stmt]
- : K_ALTER K_COLUMNFAMILY cf=columnFamilyName { $stmt = new
AlterTableStatement.Raw(cf); }
+ @init { boolean ifExists = false; }
+ : K_ALTER K_COLUMNFAMILY (K_IF K_EXISTS { ifExists = true; } )?
+ cf=columnFamilyName { $stmt = new AlterTableStatement.Raw(cf, ifExists);
}
Review comment:
Wouldn't it be nicer, instead of polluting the constructor, you had a
setter for `ifExists` like you do later on with the exists flags at column
level? It would be more consistent and I don't see a need to have that in the
ctor? wdyt?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]