Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delegate: fix zone configs for SHOW CREATE TABLE with no partitions #65167

Merged
merged 1 commit into from
May 14, 2021
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
9 changes: 5 additions & 4 deletions pkg/sql/delegate/show_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,17 @@ SELECT
%[3]s AS table_name,
concat(create_statement,
CASE
WHEN NOT has_partitions
THEN NULL
WHEN is_multi_region THEN
CASE
WHEN (SELECT mr FROM zone_configs) IS NULL THEN NULL
ELSE concat(e';\n', (SELECT mr FROM zone_configs))
END
WHEN (SELECT raw FROM zone_configs) IS NULL THEN
WHEN (SELECT raw FROM zone_configs) IS NOT NULL THEN
concat(e';\n', (SELECT raw FROM zone_configs))
WHEN NOT has_partitions
THEN NULL
ELSE
e'\n-- Warning: Partitioned table with no zone configurations.'
ELSE concat(e';\n', (SELECT raw FROM zone_configs))
END
) AS create_statement
FROM
Expand Down
20 changes: 19 additions & 1 deletion pkg/sql/logictest/testdata/logic_test/zone_config
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,25 @@ SELECT zone_id, raw_config_sql FROM [SHOW ZONE CONFIGURATION FOR TABLE a]
constraints = '[+region=test]',
lease_preferences = '[[+region=test]]'

# Test SHOW CREATE TABLE correctly shows the CREATE TABLE.
query TT
SHOW CREATE TABLE a
----
a CREATE TABLE public.a (
id INT8 NOT NULL,
CONSTRAINT "primary" PRIMARY KEY (id ASC),
FAMILY "primary" (id)
);
ALTER TABLE test.public.a CONFIGURE ZONE USING
range_min_bytes = 200001,
range_max_bytes = 400000,
gc.ttlseconds = 3600,
num_replicas = 1,
constraints = '[+region=test]',
lease_preferences = '[[+region=test]]';
ALTER TABLE test.test.a CONFIGURE ZONE USING
gc.ttlseconds = 1234

# Check that we can reset the configuration to defaults.

statement ok
Expand Down Expand Up @@ -196,7 +215,6 @@ ORDER BY feature_name
sql.schema.alter_range.configure_zone
sql.schema.alter_table.configure_zone


# Check that configuring num_voters separately from num_replicas behaves as
# expected, across setting them directly and through inheritance.
#
Expand Down