diff --git a/pkg/sql/logictest/testdata/logic_test/sequences b/pkg/sql/logictest/testdata/logic_test/sequences index 0eb708968bcd..e027bd0fbdb6 100644 --- a/pkg/sql/logictest/testdata/logic_test/sequences +++ b/pkg/sql/logictest/testdata/logic_test/sequences @@ -1485,6 +1485,11 @@ CREATE SEQUENCE cache_test CACHE 0 statement ok CREATE SEQUENCE cache_test CACHE 10 INCREMENT 1 +query TT +SHOW CREATE SEQUENCE cache_test +---- +cache_test CREATE SEQUENCE public.cache_test MINVALUE 1 MAXVALUE 9223372036854775807 INCREMENT 1 START 1 CACHE 10 + # Verify cache invalidation with schema changes. # 10 values (1,2,...,10) are cached, and the underlying sequence is incremented to 10. diff --git a/pkg/sql/show_create_clauses.go b/pkg/sql/show_create_clauses.go index 4ccb7c3af45c..49b43f6e5373 100644 --- a/pkg/sql/show_create_clauses.go +++ b/pkg/sql/show_create_clauses.go @@ -248,6 +248,9 @@ func ShowCreateSequence( if opts.Virtual { f.Printf(" VIRTUAL") } + if opts.CacheSize > 1 { + f.Printf(" CACHE %d", opts.CacheSize) + } return f.CloseAndGetString(), nil } diff --git a/pkg/sql/show_test.go b/pkg/sql/show_test.go index 12e073df4cdf..a646e4a12fce 100644 --- a/pkg/sql/show_test.go +++ b/pkg/sql/show_test.go @@ -432,6 +432,14 @@ func TestShowCreateSequence(t *testing.T) { `CREATE SEQUENCE %s INCREMENT 5 MAXVALUE 10000 START 10 MINVALUE 0`, `CREATE SEQUENCE public.%s MINVALUE 0 MAXVALUE 10000 INCREMENT 5 START 10`, }, + { + `CREATE SEQUENCE %s INCREMENT 5 MAXVALUE 10000 START 10 MINVALUE 0 CACHE 1`, + `CREATE SEQUENCE public.%s MINVALUE 0 MAXVALUE 10000 INCREMENT 5 START 10`, + }, + { + `CREATE SEQUENCE %s INCREMENT 5 MAXVALUE 10000 START 10 MINVALUE 0 CACHE 10`, + `CREATE SEQUENCE public.%s MINVALUE 0 MAXVALUE 10000 INCREMENT 5 START 10 CACHE 10`, + }, } for i, test := range tests { t.Run(fmt.Sprint(i), func(t *testing.T) {