@@ -5347,6 +5347,24 @@ impl<'a> Parser<'a> {
53475347 })
53485348 }
53495349
5350+ /// Parse statements of the DropIndex type such as:
5351+ ///
5352+ /// ```sql
5353+ /// DROP Index idx_name ON table_name
5354+ /// ```
5355+ pub fn parse_drop_index(&mut self) -> Result<Statement, ParserError> {
5356+ let index_name = self.parse_object_name(false)?;
5357+ let table_name = if self.parse_keyword(Keyword::ON) {
5358+ Some(self.parse_object_name(false)?)
5359+ } else {
5360+ None
5361+ };
5362+ Ok(Statement::DropIndex {
5363+ index_name,
5364+ table_name,
5365+ })
5366+ }
5367+
53505368 /// Parse statements of the DropTrigger type such as:
53515369 ///
53525370 /// ```sql
@@ -6196,7 +6214,11 @@ impl<'a> Parser<'a> {
61966214 } else if self.parse_keywords(&[Keyword::MATERIALIZED, Keyword::VIEW]) {
61976215 ObjectType::MaterializedView
61986216 } else if self.parse_keyword(Keyword::INDEX) {
6199- ObjectType::Index
6217+ if dialect_of!(self is MySqlDialect){
6218+ return self.parse_drop_index();
6219+ }else {
6220+ ObjectType::Index
6221+ }
62006222 } else if self.parse_keyword(Keyword::ROLE) {
62016223 ObjectType::Role
62026224 } else if self.parse_keyword(Keyword::SCHEMA) {
@@ -8599,6 +8621,9 @@ impl<'a> Parser<'a> {
85998621 } else if self.parse_keywords(&[Keyword::FOREIGN, Keyword::KEY]) {
86008622 let name = self.parse_identifier()?;
86018623 AlterTableOperation::DropForeignKey { name }
8624+ } else if self.parse_keyword(Keyword::INDEX) {
8625+ let name = self.parse_identifier()?;
8626+ AlterTableOperation::DropIndex { name }
86028627 } else if self.parse_keyword(Keyword::PROJECTION)
86038628 && dialect_of!(self is ClickHouseDialect|GenericDialect)
86048629 {
0 commit comments