File tree Expand file tree Collapse file tree 4 files changed +21
-0
lines changed Expand file tree Collapse file tree 4 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -187,6 +187,12 @@ pub enum AlterTableOperation {
187
187
DropForeignKey {
188
188
name : Ident ,
189
189
} ,
190
+ /// `DROP INDEX <index_name>`
191
+ ///
192
+ /// [MySQL]: https://dev.mysql.com/doc/refman/8.4/en/alter-table.html
193
+ DropIndex {
194
+ name : Ident ,
195
+ } ,
190
196
/// `ENABLE ALWAYS RULE rewrite_rule_name`
191
197
///
192
198
/// Note: this is a PostgreSQL-specific operation.
@@ -606,6 +612,7 @@ impl fmt::Display for AlterTableOperation {
606
612
}
607
613
AlterTableOperation :: DropPrimaryKey => write ! ( f, "DROP PRIMARY KEY" ) ,
608
614
AlterTableOperation :: DropForeignKey { name } => write ! ( f, "DROP FOREIGN KEY {name}" ) ,
615
+ AlterTableOperation :: DropIndex { name } => write ! ( f, "DROP INDEX {name}" ) ,
609
616
AlterTableOperation :: DropColumn {
610
617
has_column_keyword,
611
618
column_name,
Original file line number Diff line number Diff line change @@ -1115,6 +1115,7 @@ impl Spanned for AlterTableOperation {
1115
1115
. union_opt ( & with_name. as_ref ( ) . map ( |n| n. span ) ) ,
1116
1116
AlterTableOperation :: DropPrimaryKey => Span :: empty ( ) ,
1117
1117
AlterTableOperation :: DropForeignKey { name } => name. span ,
1118
+ AlterTableOperation :: DropIndex { name } => name. span ,
1118
1119
AlterTableOperation :: EnableAlwaysRule { name } => name. span ,
1119
1120
AlterTableOperation :: EnableAlwaysTrigger { name } => name. span ,
1120
1121
AlterTableOperation :: EnableReplicaRule { name } => name. span ,
Original file line number Diff line number Diff line change @@ -8636,6 +8636,9 @@ impl<'a> Parser<'a> {
8636
8636
} else if self.parse_keywords(&[Keyword::FOREIGN, Keyword::KEY]) {
8637
8637
let name = self.parse_identifier()?;
8638
8638
AlterTableOperation::DropForeignKey { name }
8639
+ } else if self.parse_keyword(Keyword::INDEX) {
8640
+ let name = self.parse_identifier()?;
8641
+ AlterTableOperation::DropIndex { name }
8639
8642
} else if self.parse_keyword(Keyword::PROJECTION)
8640
8643
&& dialect_of!(self is ClickHouseDialect|GenericDialect)
8641
8644
{
Original file line number Diff line number Diff line change @@ -4025,3 +4025,13 @@ fn parse_drop_index() {
4025
4025
_ => unreachable ! ( ) ,
4026
4026
}
4027
4027
}
4028
+
4029
+ #[ test]
4030
+ fn parse_alter_table_drop_index ( ) {
4031
+ assert_matches ! (
4032
+ alter_table_op(
4033
+ mysql_and_generic( ) . verified_stmt( "ALTER TABLE tab DROP INDEX idx_index" )
4034
+ ) ,
4035
+ AlterTableOperation :: DropIndex { name } if name. value == "idx_index"
4036
+ ) ;
4037
+ }
You can’t perform that action at this time.
0 commit comments