Benny Halevy
23fecc7e5e
cql3: allow adding or dropping multiple columns in ALTER TABLE statement
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>
2018-10-07 19:14:26 +03:00
..
2018-07-05 10:50:43 +02:00
2018-04-16 10:18:28 +02:00
2018-04-16 10:18:28 +02:00
2018-04-16 10:18:28 +02:00
2018-10-07 19:14:26 +03:00
2018-10-07 19:14:26 +03:00
2018-04-16 10:18:28 +02:00
2018-04-16 10:18:28 +02:00
2018-04-16 10:18:28 +02:00
2018-04-16 10:18:28 +02:00
2018-05-27 12:40:27 +03:00
2018-05-27 12:40:27 +03:00
2018-05-27 12:40:27 +03:00
2018-05-27 12:40:27 +03:00
2018-07-08 10:27:03 +01:00
2018-07-08 10:27:03 +01:00
2016-04-08 08:12:47 +03:00
2018-02-07 10:11:46 +00:00
2018-03-28 10:49:07 +03:00
2018-02-07 10:11:46 +00:00
2016-05-31 09:09:21 +03:00
2018-10-04 10:55:45 +01:00
2018-05-15 17:59:53 +03:00
2018-04-16 10:18:28 +02:00
2018-04-16 10:18:28 +02:00
2018-04-16 10:18:28 +02:00
2018-04-16 10:18:28 +02:00
2018-04-16 10:18:28 +02:00
2018-04-16 10:18:28 +02:00
2018-04-16 10:18:28 +02:00
2018-08-16 15:42:22 +03:00
2018-04-16 10:18:28 +02:00
2018-04-23 12:00:57 +02:00
2018-04-23 12:00:57 +02:00
2018-05-15 17:59:53 +03:00
2018-05-15 17:59:53 +03:00
2018-04-30 13:19:49 +03:00
2018-04-16 10:18:28 +02:00
2018-04-16 10:18:28 +02:00
2018-04-30 13:19:49 +03:00
2018-04-16 10:18:28 +02:00
2018-04-16 10:18:28 +02:00
2018-04-16 10:18:28 +02:00
2018-04-30 13:19:49 +03:00
2018-04-16 10:18:28 +02:00
2018-04-16 10:18:28 +02:00
2018-04-16 10:18:28 +02:00
2018-04-16 10:18:28 +02:00
2018-05-01 13:21:24 +03:00
2016-04-08 08:12:47 +03:00
2018-05-01 13:21:24 +03:00
2018-05-01 13:21:24 +03:00
2018-02-07 10:11:46 +00:00
2016-05-11 16:02:22 +03:00
2018-06-25 09:21:47 +01:00
2018-04-16 10:18:28 +02:00
2018-04-16 10:18:28 +02:00
2018-06-25 09:21:47 +01:00
2018-04-16 10:18:28 +02:00
2018-07-08 10:27:03 +01:00
2018-07-08 10:27:03 +01:00
2017-05-08 16:33:17 +03:00
2018-04-16 10:18:28 +02:00
2018-04-16 10:18:28 +02:00
2017-05-08 16:33:17 +03:00
2018-02-07 10:11:46 +00:00
2018-02-07 10:11:46 +00:00
2016-04-08 08:12:47 +03:00
2018-04-16 10:18:28 +02:00
2018-04-16 10:18:28 +02:00
2018-04-16 10:18:28 +02:00
2018-06-25 09:21:47 +01:00
2018-05-27 12:40:27 +03:00
2018-05-27 12:40:27 +03:00
2018-10-05 17:36:39 +02:00
2018-10-03 13:26:51 +01:00
2017-05-10 19:54:42 +02:00
2018-05-27 12:40:27 +03:00
2018-05-27 12:40:27 +03:00
2018-08-28 11:34:11 +03:00
2018-04-23 14:08:04 +01:00
2018-05-27 12:40:27 +03:00
2018-05-27 12:40:27 +03:00