Skip to content

Commit

Permalink
feat: support drop index name on table
Browse files Browse the repository at this point in the history
  • Loading branch information
cyz-2023 authored and wy1433 committed Apr 18, 2024
1 parent 294d054 commit cd28db2
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/sqlparser/sql_lex.l
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,9 @@ SERIALIZABLE { un_reserved_keyword(yylval, yyscanner, parser); return SERIALIZAB
SESSION { un_reserved_keyword(yylval, yyscanner, parser); return SESSION; }
SHARE { un_reserved_keyword(yylval, yyscanner, parser); return SHARE; }
SHARED { un_reserved_keyword(yylval, yyscanner, parser); return SHARED; }
INPLACE { un_reserved_keyword(yylval, yyscanner, parser); return INPLACE; }
INSTANT { un_reserved_keyword(yylval, yyscanner, parser); return INSTANT; }
COPY { un_reserved_keyword(yylval, yyscanner, parser); return COPY; }
SHUTDOWN { un_reserved_keyword(yylval, yyscanner, parser); return SHUTDOWN; }
SIGNED { un_reserved_keyword(yylval, yyscanner, parser); return SIGNED; }
SLAVE { un_reserved_keyword(yylval, yyscanner, parser); return SLAVE; }
Expand Down
62 changes: 62 additions & 0 deletions include/sqlparser/sql_parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ extern int sql_error(YYLTYPE* yylloc, yyscan_t yyscanner, SqlParser* parser, con
COMPRESSION
CONNECTION
CONSISTENT
COPY
DAY
DATA
DATE
Expand Down Expand Up @@ -335,7 +336,9 @@ extern int sql_error(YYLTYPE* yylloc, yyscan_t yyscanner, SqlParser* parser, con
IDENTIFIED
ISOLATION
INDEXES
INPLACE
INSERT_METHOD
INSTANT
INVOKER
JSON
KEY_BLOCK_SIZE
Expand Down Expand Up @@ -595,10 +598,15 @@ extern int sql_error(YYLTYPE* yylloc, yyscan_t yyscanner, SqlParser* parser, con
ColumnDefList
IndexOptionList
IndexOption
DropIndexOpt
IndexType
TablePartitionOpt
IndexTypeOpt
RowFormatOpt
AlgorithmVal
AlgorighmOpt
IndexLockVal
IndexLockOpt
InsertMethodOpt
PartitionRange
PartitionRangeList
Expand Down Expand Up @@ -2793,6 +2801,7 @@ AllIdent:
| COMPRESSION
| CONNECTION
| CONSISTENT
| COPY
| DAY
| DATA
| DATE
Expand Down Expand Up @@ -2831,8 +2840,10 @@ AllIdent:
| IDENTIFIED
| ISOLATION
| INDEXES
| INPLACE
| INSERT_METHOD
| INVOKER
| INSTANT
| JSON
| KEY_BLOCK_SIZE
| DYNAMIC_PARTITION_ATTR
Expand Down Expand Up @@ -3724,6 +3735,31 @@ IndexOptionList:
}
;

AlgorighmOpt:
ALGORITHM EqOpt AlgorithmVal {

$$ = nullptr;
}
;

IndexLockOpt:
LOCK EqOpt IndexLockVal {
$$ = nullptr;
}
;

DropIndexOpt:
{
$$ = nullptr;
}
| AlgorighmOpt {
$$ = nullptr;
}
| IndexLockOpt {

}
;

IndexOption:
KEY_BLOCK_SIZE EqOpt INTEGER_LIT {
$$ = nullptr;
Expand All @@ -3736,6 +3772,13 @@ IndexOption:
op->comment = ((LiteralExpr*)$2)->_u.str_val;
$$ = op;
}
| AlgorighmOpt {

$$ = nullptr;
}
| IndexLockOpt {
$$ = nullptr;
}
;

IndexType:
Expand Down Expand Up @@ -4542,6 +4585,14 @@ RowFormatOpt:
DEFAULT | DYNAMIC | FIXED | COMPRESSED | REDUNDANT | COMPACT
;

AlgorithmVal:
DEFAULT | INSTANT | INPLACE | COPY
;

IndexLockVal:
DEFAULT | NONE | SHARED | EXCLUSIVE
;

IgnoreTableOption:
ROW_FORMAT EqOpt RowFormatOpt
| STATS_PERSISTENT EqOpt NumLiteral
Expand Down Expand Up @@ -5107,6 +5158,17 @@ AlterTableStmt:
stmt->alter_specs.push_back((AlterTableSpec*)spec, parser->arena);
$$ = stmt;
}
| DROP INDEX IndexName ON TableName ForceOrNot DropIndexOpt
{
AlterTableStmt* stmt = new_node(AlterTableStmt);
stmt->table_name = (TableName*)$5;
AlterTableSpec* spec = new_node(AlterTableSpec);
spec->spec_type = ALTER_SPEC_DROP_INDEX;
spec->index_name = $3;
spec->force = $6;
stmt->alter_specs.push_back((AlterTableSpec*)spec, parser->arena);
$$ = stmt;
}
;

AlterSpecList:
Expand Down

0 comments on commit cd28db2

Please sign in to comment.