Skip to content
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
4 changes: 2 additions & 2 deletions sql/rowexec/show_iters.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,9 +531,9 @@ func getForeignKeyTable(t sql.Table) (sql.ForeignKeyTable, error) {
}
}

func getAutoIncrementTable(t sql.Table) sql.AutoIncrementTable {
func getAutoIncrementTable(t sql.Table) sql.AutoIncrementGetter {
switch t := t.(type) {
case sql.AutoIncrementTable:
case sql.AutoIncrementGetter:
return t
case sql.TableWrapper:
return getAutoIncrementTable(t.Underlying())
Expand Down
13 changes: 10 additions & 3 deletions sql/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,7 @@ type TruncateableTable interface {
// AUTO_INCREMENT sequence. These methods should only be used for tables with and AUTO_INCREMENT column in their schema.
type AutoIncrementTable interface {
Table
// PeekNextAutoIncrementValue returns the next AUTO_INCREMENT value without incrementing the current
// auto_increment counter.
PeekNextAutoIncrementValue(ctx *Context) (uint64, error)
AutoIncrementGetter
// GetNextAutoIncrementValue gets the next AUTO_INCREMENT value. In the case that a table with an autoincrement
// column is passed in a row with the autoinc column failed, the next auto increment value must
// update its internal state accordingly and use the insert val at runtime.
Expand All @@ -342,6 +340,15 @@ type AutoIncrementTable interface {
AutoIncrementSetter(*Context) AutoIncrementSetter
}

// AutoIncrementGetter provides support for reading a table's AUTO_INCREMENT value.
// This can include tables that don't implement AutoIncrementTable if the table is a read-only snapshot
// of an auto-incremented table.
type AutoIncrementGetter interface {
Copy link
Member

Choose a reason for hiding this comment

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

Please embed this in the AutoIncrementTable interface to make the relationship clearer

// PeekNextAutoIncrementValue returns the next AUTO_INCREMENT value without incrementing the current
// auto_increment counter.
PeekNextAutoIncrementValue(ctx *Context) (uint64, error)
Copy link
Member

Choose a reason for hiding this comment

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

Also move the method doc from AutoIncrementTable.Peek to here

}

// AutoIncrementSetter provides support for altering a table's
// AUTO_INCREMENT sequence, eg 'ALTER TABLE t AUTO_INCREMENT = 10;'
type AutoIncrementSetter interface {
Expand Down