Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parser,ddl: Support ENGINE_ATTRIBUTE option for future use #59201

Merged
merged 6 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions errors.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1341,6 +1341,11 @@ error = '''
Check constraint '%s' uses column '%s', hence column cannot be dropped or renamed.
'''

["ddl:3981"]
error = '''
Storage engine does not support ENGINE_ATTRIBUTE.
'''

["ddl:4135"]
error = '''
Sequence '%-.64s.%-.64s' has run out
Expand Down Expand Up @@ -1586,6 +1591,16 @@ error = '''
Auto analyze is not effective for index '%-.192s', need analyze manually
'''

["ddl:8270"]
error = '''
Invalid engine attribute format: %s
'''

["ddl:8271"]
error = '''
Invalid storage class: %s
'''

["ddl:9014"]
error = '''
TiFlash backfill index failed: %s
Expand Down
2 changes: 2 additions & 0 deletions pkg/ddl/create_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,8 @@ func handleTableOptions(options []*ast.TableOption, tbInfo *model.TableInfo) err

tbInfo.TTLInfo = ttlInfo
ttlOptionsHandled = true
case ast.TableOptionEngineAttribute:
return errors.Trace(dbterror.ErrUnsupportedEngineAttribute)
}
}
shardingBits := shardingBits(tbInfo)
Expand Down
2 changes: 2 additions & 0 deletions pkg/ddl/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -1874,6 +1874,8 @@ func (e *executor) AlterTable(ctx context.Context, sctx sessionctx.Context, stmt
Name: ast.NewCIStr(opt.StrValue),
}
case ast.TableOptionEngine:
case ast.TableOptionEngineAttribute:
err = dbterror.ErrUnsupportedEngineAttribute
case ast.TableOptionRowFormat:
case ast.TableOptionTTL, ast.TableOptionTTLEnable, ast.TableOptionTTLJobInterval:
var ttlInfo *model.TTLInfo
Expand Down
5 changes: 5 additions & 0 deletions pkg/errno/errcode.go
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,7 @@ const (
ErrConstraintNotFound = 3940
ErUserAccessDeniedForUserAccountBlockedByPasswordLock = 3955
ErrDependentByCheckConstraint = 3959
ErrEngineAttributeNotSupported = 3981
ErrJSONInBooleanContext = 3986
ErrTableWithoutPrimaryKey = 3750
// MariaDB errors.
Expand Down Expand Up @@ -1157,6 +1158,10 @@ const (
ErrResourceGroupInvalidBackgroundTaskName = 8255
ErrResourceGroupInvalidForRole = 8257

// Reserved for future use.
ErrEngineAttributeInvalidFormat = 8270
ErrStorageClassInvalidSpec = 8271

// TiKV/PD/TiFlash errors.
ErrPDServerTimeout = 9001
ErrTiKVServerTimeout = 9002
Expand Down
4 changes: 4 additions & 0 deletions pkg/errno/errname.go
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,7 @@ var MySQLErrName = map[uint16]*mysql.ErrMessage{
ErrTableWithoutPrimaryKey: mysql.Message("Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Add a primary key to the table or unset this variable to avoid this message. Note that tables without a primary key can cause performance problems in row-based replication, so please consult your DBA before changing this setting.", nil),
ErrConstraintNotFound: mysql.Message("Constraint '%s' does not exist.", nil),
ErrDependentByCheckConstraint: mysql.Message("Check constraint '%s' uses column '%s', hence column cannot be dropped or renamed.", nil),
ErrEngineAttributeNotSupported: mysql.Message("Storage engine does not support ENGINE_ATTRIBUTE.", nil),
ErrJSONInBooleanContext: mysql.Message("Evaluating a JSON value in SQL boolean context does an implicit comparison against JSON integer 0; if this is not what you want, consider converting JSON to a SQL numeric type with JSON_VALUE RETURNING", nil),
// MariaDB errors.
ErrOnlyOneDefaultPartionAllowed: mysql.Message("Only one DEFAULT partition allowed", nil),
Expand Down Expand Up @@ -1155,6 +1156,9 @@ var MySQLErrName = map[uint16]*mysql.ErrMessage{
ErrResourceGroupQueryRunawayQuarantine: mysql.Message("Quarantined and interrupted because of being in runaway watch list", nil),
ErrResourceGroupInvalidBackgroundTaskName: mysql.Message("Unknown background task name '%-.192s'", nil),

ErrEngineAttributeInvalidFormat: mysql.Message("Invalid engine attribute format: %s", nil),
ErrStorageClassInvalidSpec: mysql.Message("Invalid storage class: %s", nil),

// TiKV/PD errors.
ErrPDServerTimeout: mysql.Message("PD server timeout: %s", nil),
ErrTiKVServerTimeout: mysql.Message("TiKV server timeout", nil),
Expand Down
1 change: 1 addition & 0 deletions pkg/meta/model/bdr.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ var BDRActionMap = map[DDLBDRType][]ActionType{
ActionAlterTablePartitioning,
ActionRemovePartitioning,
ActionAddVectorIndex,
ActionModifyEngineAttribute,
},
UnmanagementDDL: {
ActionCreatePlacementPolicy,
Expand Down
2 changes: 2 additions & 0 deletions pkg/meta/model/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ const (
ActionAlterTablePartitioning ActionType = 71
ActionRemovePartitioning ActionType = 72
ActionAddVectorIndex ActionType = 73
ActionModifyEngineAttribute ActionType = 74
)

// ActionMap is the map of DDL ActionType to string.
Expand Down Expand Up @@ -184,6 +185,7 @@ var ActionMap = map[ActionType]string{
ActionAlterTablePartitioning: "alter table partition by",
ActionRemovePartitioning: "alter table remove partitioning",
ActionAddVectorIndex: "add vector index",
ActionModifyEngineAttribute: "modify engine attribute",

// `ActionAlterTableAlterPartition` is removed and will never be used.
// Just left a tombstone here for compatibility.
Expand Down
1 change: 1 addition & 0 deletions pkg/parser/ast/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -2541,6 +2541,7 @@ const (
TableOptionTTL
TableOptionTTLEnable
TableOptionTTLJobInterval
TableOptionEngineAttribute
TableOptionPlacementPolicy = TableOptionType(PlacementOptionPolicy)
TableOptionStatsBuckets = TableOptionType(StatsOptionBuckets)
TableOptionStatsTopN = TableOptionType(StatsOptionTopN)
Expand Down
1 change: 1 addition & 0 deletions pkg/parser/keywords.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/parser/keywords_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestKeywords(t *testing.T) {
}

func TestKeywordsLength(t *testing.T) {
require.Equal(t, 654, len(parser.Keywords))
require.Equal(t, 655, len(parser.Keywords))

reservedNr := 0
for _, kw := range parser.Keywords {
Expand Down
1 change: 1 addition & 0 deletions pkg/parser/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ var tokenMap = map[string]int{
"ENFORCED": enforced,
"ENGINE": engine,
"ENGINES": engines,
"ENGINE_ATTRIBUTE": engine_attribute,
"ENUM": enum,
"ERROR": errorKwd,
"ERRORS": identSQLErrors,
Expand Down
Loading