Skip to content

Commit f8da474

Browse files
committed
Allow SHOW CREATE to display auto increment for tables that store AutoIncrement but don't support writing it.
1 parent b9d44c4 commit f8da474

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

sql/rowexec/show_iters.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,9 +531,9 @@ func getForeignKeyTable(t sql.Table) (sql.ForeignKeyTable, error) {
531531
}
532532
}
533533

534-
func getAutoIncrementTable(t sql.Table) sql.AutoIncrementTable {
534+
func getAutoIncrementTable(t sql.Table) sql.AutoIncrementGetter {
535535
switch t := t.(type) {
536-
case sql.AutoIncrementTable:
536+
case sql.AutoIncrementGetter:
537537
return t
538538
case sql.TableWrapper:
539539
return getAutoIncrementTable(t.Underlying())

sql/tables.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,13 @@ type AutoIncrementTable interface {
342342
AutoIncrementSetter(*Context) AutoIncrementSetter
343343
}
344344

345+
// AutoIncrementGetter provides support for reading a table's AUTO_INCREMENT value.
346+
// This can include tables that don't implement AutoIncrementTable if the table is a read-only snapshot
347+
// of an auto-incremented table.
348+
type AutoIncrementGetter interface {
349+
PeekNextAutoIncrementValue(ctx *Context) (uint64, error)
350+
}
351+
345352
// AutoIncrementSetter provides support for altering a table's
346353
// AUTO_INCREMENT sequence, eg 'ALTER TABLE t AUTO_INCREMENT = 10;'
347354
type AutoIncrementSetter interface {

0 commit comments

Comments
 (0)