Skip to content

Commit dd52aa4

Browse files
committed
sql/schemachanger: properly discard zone configs for sequences
Discarding zone configs via the declarative schema changer was a no-op for sequences, leaving stale configs. This was due to not loading scpb.TableZoneConfig elements for sequences. This change ensures those elements are loaded, so configs are properly removed. Fixes #150252 Epic: none Release note (bug fix): Fixes an issue where discarding zone configs on sequences did not remove the actual configuration.
1 parent 8f667c4 commit dd52aa4

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

pkg/sql/logictest/testdata/logic_test/zone_config

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,3 +678,49 @@ ORDER BY 1
678678
/3
679679

680680
subtest end
681+
682+
subtest discard_seq
683+
684+
statement ok
685+
CREATE SEQUENCE seq1;
686+
687+
statement ok
688+
ALTER TABLE seq1 CONFIGURE ZONE USING num_replicas=7;
689+
690+
query I
691+
WITH config_lines AS (
692+
SELECT
693+
regexp_split_to_table(raw_config_sql, E'\n') AS line
694+
FROM [SHOW ZONE CONFIGURATION FROM TABLE seq1]
695+
)
696+
SELECT
697+
CAST(
698+
regexp_replace(line, '[^0-9]', '', 'g') AS INT
699+
) AS num_replicas
700+
FROM config_lines
701+
WHERE line LIKE '%num_replicas%';
702+
----
703+
7
704+
705+
statement ok
706+
ALTER TABLE seq1 CONFIGURE ZONE DISCARD;
707+
708+
query I
709+
WITH config_lines AS (
710+
SELECT
711+
regexp_split_to_table(raw_config_sql, E'\n') AS line
712+
FROM [SHOW ZONE CONFIGURATION FROM TABLE seq1]
713+
)
714+
SELECT
715+
CAST(
716+
regexp_replace(line, '[^0-9]', '', 'g') AS INT
717+
) AS num_replicas
718+
FROM config_lines
719+
WHERE line LIKE '%num_replicas%';
720+
----
721+
3
722+
723+
statement ok
724+
DROP SEQUENCE seq1;
725+
726+
subtest end

pkg/sql/schemachanger/scdecomp/decomp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ func (w *walkCtx) walkRelation(tbl catalog.TableDescriptor) {
433433
// Add a zone config element which is a stop gap to allow us to block
434434
// operations on tables. To minimize RTT impact limit
435435
// this to only tables and materialized views.
436-
if (tbl.IsTable() && !tbl.IsVirtualTable()) || tbl.MaterializedView() {
436+
if (tbl.IsTable() && !tbl.IsVirtualTable()) || tbl.MaterializedView() || tbl.IsSequence() {
437437
zoneConfig, err := w.zoneConfigReader.GetZoneConfig(w.ctx, tbl.GetID())
438438
if err != nil {
439439
panic(err)

0 commit comments

Comments
 (0)