diff --git a/sql/rowexec/show_iters.go b/sql/rowexec/show_iters.go index c75e099bc9..cf618c3b42 100644 --- a/sql/rowexec/show_iters.go +++ b/sql/rowexec/show_iters.go @@ -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()) diff --git a/sql/tables.go b/sql/tables.go index 7b203aab25..4c43b8d467 100644 --- a/sql/tables.go +++ b/sql/tables.go @@ -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. @@ -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 { + // PeekNextAutoIncrementValue returns the next AUTO_INCREMENT value without incrementing the current + // auto_increment counter. + PeekNextAutoIncrementValue(ctx *Context) (uint64, error) +} + // AutoIncrementSetter provides support for altering a table's // AUTO_INCREMENT sequence, eg 'ALTER TABLE t AUTO_INCREMENT = 10;' type AutoIncrementSetter interface {