Skip to content
Closed
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
11 changes: 11 additions & 0 deletions ast/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -1968,6 +1968,7 @@ const (
TableOptionAutoIdCache
TableOptionAutoIncrement
TableOptionAutoRandomBase
TableOptionRowID
TableOptionComment
TableOptionAvgRowLength
TableOptionCheckSum
Expand Down Expand Up @@ -2084,6 +2085,16 @@ func (n *TableOption) Restore(ctx *format.RestoreCtx) error {
ctx.WriteKeyWord("DEFAULT COLLATE ")
ctx.WritePlain("= ")
ctx.WriteKeyWord(n.StrValue)
case TableOptionRowID:
if n.BoolValue {
ctx.WriteWithSpecialComments(tidb.FeatureIDRowID, func() {
ctx.WriteKeyWord("FORCE")
})
ctx.WritePlain(" ")
}
ctx.WriteKeyWord("ROW_ID ")
ctx.WritePlain("= ")
ctx.WritePlainf("%d", n.UintValue)
case TableOptionAutoIncrement:
if n.BoolValue {
ctx.WriteWithSpecialComments(tidb.FeatureIDForceAutoInc, func() {
Expand Down
1 change: 1 addition & 0 deletions misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,7 @@ var tokenMap = map[string]int{
"ROW_COUNT": rowCount,
"ROW_FORMAT": rowFormat,
"ROW": row,
"ROW_ID": rowID,
"ROWS": rows,
"RTREE": rtree,
"RESUME": resume,
Expand Down
2 changes: 2 additions & 0 deletions model/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ const (
ActionDropPlacementPolicy ActionType = 53
ActionAlterTablePartitionPolicy ActionType = 54
ActionModifySchemaDefaultPlacement ActionType = 55
ActionRebaseRowID ActionType = 56
)

var actionMap = map[ActionType]string{
Expand Down Expand Up @@ -142,6 +143,7 @@ var actionMap = map[ActionType]string{
ActionAlterPlacementPolicy: "alter placement policy",
ActionDropPlacementPolicy: "drop placement policy",
ActionModifySchemaDefaultPlacement: "modify schema default placement",
ActionRebaseRowID: "rebase _tidb_row_id",
}

// String return current ddl action in string
Expand Down
15 changes: 11 additions & 4 deletions model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,16 +249,22 @@ const (
// However, the convert is missed in some scenarios before v2.1.9, so for all those tables prior to TableInfoVersion3, their
// charsets / collations will be converted to lower-case while loading from the storage.
TableInfoVersion3 = uint16(3)
// TableInfoVersion4 indicates that the auto_increment allocator in TiDB has been separated from
// TableInfoVersion5 indicates that the auto_increment allocator in TiDB has been separated from
// _tidb_rowid allocator. This version is introduced to preserve the compatibility of old tables:
// the tables with version < TableInfoVersion4 still use a single allocator for auto_increment and _tidb_rowid.
// the tables with version < TableInfoVersion5 still use a single allocator for auto_increment and _tidb_rowid.
// Also see https://github.com/pingcap/tidb/issues/982.
TableInfoVersion4 = uint16(4)
TableInfoVersion5 = uint16(5)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?? what happened to version 4

Copy link
Copy Markdown
Contributor Author

@tangenta tangenta Sep 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version 4 is introduced in #1170... but the TiDB part is not merged.

It is released to v5.0, so we need another version to identify that the auto IDs are separated.


// CurrLatestTableInfoVersion means the latest table info in the current TiDB.
CurrLatestTableInfoVersion = TableInfoVersion4
CurrLatestTableInfoVersion = TableInfoVersion5
)

// AutoIncrementIDIsSeparated indicates whether auto_increment ID of is separated from _tidb_row_id.
// For details, see https://github.com/pingcap/tidb/issues/982.
func AutoIncrementIDIsSeparated(ver uint16) bool {
return ver >= TableInfoVersion5
}

// ExtraHandleName is the name of ExtraHandle Column.
var ExtraHandleName = NewCIStr("_tidb_rowid")

Expand Down Expand Up @@ -289,6 +295,7 @@ type TableInfo struct {

Comment string `json:"comment"`
AutoIncID int64 `json:"auto_inc_id"`
AutoRowID int64 `json:"auto_row_id"`
AutoIdCache int64 `json:"auto_id_cache"`
AutoRandID int64 `json:"auto_rand_id"`
MaxColumnID int64 `json:"max_col_id"`
Expand Down
Loading