mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-23 01:50:35 +00:00
Fixes #2907 Fixes #3691 See Cassandra reference: https://apache.googlesource.com/cassandra/+/cassandra-3.6/src/antlr/Parser.g /** * ALTER COLUMN FAMILY <CF> ALTER <column> TYPE <newtype>; * ALTER COLUMN FAMILY <CF> ADD <column> <newtype>; | ALTER COLUMN FAMILY <CF> ADD (<column> <newtype>,<column1> <newtype1>..... <column n> <newtype n>) * ALTER COLUMN FAMILY <CF> DROP <column>; | ALTER COLUMN FAMILY <CF> DROP ( <column>,<column1>.....<column n>) * ALTER COLUMN FAMILY <CF> WITH <property> = <value>; * ALTER COLUMN FAMILY <CF> RENAME <column> TO <column>; */ alterTableStatement returns [shared_ptr<alter_table_statement> expr] @init { alter_table_statement::type type; auto props = make_shared<cql3::statements::cf_prop_defs>(); std::vector<alter_table_statement::column_change> column_changes; std::vector<std::pair<shared_ptr<cql3::column_identifier::raw>, shared_ptr<cql3::column_identifier::raw>>> renames; } : K_ALTER K_COLUMNFAMILY cf=columnFamilyName ( K_ALTER id=cident K_TYPE v=comparatorType { type = alter_table_statement::type::alter; column_changes.emplace_back(id, v); } | K_ADD { type = alter_table_statement::type::add; } ( id1=cident v1=comparatorType b1=cfisStatic { column_changes.emplace_back(id1, v1, b1); } | '(' id1=cident v1=comparatorType b1=cfisStatic { column_changes.emplace_back(id1, v1, b1); } (',' idn=cident vn=comparatorType bn=cfisStatic { column_changes.emplace_back(idn, vn, bn); } )* ')' ) | K_DROP id=cident { type = alter_table_statement::type::drop; column_changes.emplace_back(id); } | K_WITH properties[props] { type = alter_table_statement::type::opts; } | K_RENAME { type = alter_table_statement::type::rename; } id1=cident K_TO toId1=cident { renames.emplace_back(id1, toId1); } ( K_AND idn=cident K_TO toIdn=cident { renames.emplace_back(idn, toIdn); } )* ) { $expr = ::make_shared<alter_table_statement>(std::move(cf), type, std::move(column_changes), std::move(props), std::move(renames)); } ; Signed-off-by: Benny Halevy <bhalevy@scylladb.com>