Skip to content

Commit

Permalink
[parser] parser: add auto_random table option support (pingcap#823)
Browse files Browse the repository at this point in the history
* add auto_random table option support

* .

* .
  • Loading branch information
AilinKid authored and ti-chi-bot committed Oct 9, 2021
1 parent 34c18a6 commit 97e61ae
Show file tree
Hide file tree
Showing 6 changed files with 3,359 additions and 3,332 deletions.
5 changes: 5 additions & 0 deletions parser/ast/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -1731,6 +1731,7 @@ const (
TableOptionCollate
TableOptionAutoIdCache
TableOptionAutoIncrement
TableOptionAutoRandom
TableOptionComment
TableOptionAvgRowLength
TableOptionCheckSum
Expand Down Expand Up @@ -1842,6 +1843,10 @@ func (n *TableOption) Restore(ctx *format.RestoreCtx) error {
ctx.WriteKeyWord("AUTO_ID_CACHE ")
ctx.WritePlain("= ")
ctx.WritePlainf("%d", n.UintValue)
case TableOptionAutoRandom:
ctx.WriteKeyWord("AUTO_RANDOM ")
ctx.WritePlain("= ")
ctx.WritePlainf("%d", n.UintValue)
case TableOptionComment:
ctx.WriteKeyWord("COMMENT ")
ctx.WritePlain("= ")
Expand Down
2 changes: 2 additions & 0 deletions parser/model/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const (
ActionAddColumns ActionType = 37
ActionDropColumns ActionType = 38
ActionModifyTableAutoIdCache ActionType = 39
ActionRebaseAutoRandom ActionType = 40
)

const (
Expand Down Expand Up @@ -117,6 +118,7 @@ var actionMap = map[ActionType]string{
ActionAddColumns: "add multi-columns",
ActionDropColumns: "drop multi-columns",
ActionModifyTableAutoIdCache: "modify auto id cache",
ActionRebaseAutoRandom: "rebase auto_random ID",
}

// String return current ddl action in string
Expand Down
1 change: 1 addition & 0 deletions parser/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ type TableInfo struct {
Comment string `json:"comment"`
AutoIncID int64 `json:"auto_inc_id"`
AutoIdCache int64 `json:"auto_id_cache"`
AutoRandID int64 `json:"auto_rand_id"`
MaxColumnID int64 `json:"max_col_id"`
MaxIndexID int64 `json:"max_idx_id"`
// UpdateTS is used to record the timestamp of updating the table's schema information.
Expand Down
Loading

0 comments on commit 97e61ae

Please sign in to comment.