Skip to content

Commit

Permalink
Fixes #57478.
Browse files Browse the repository at this point in the history
Release note (sql change): Setting of zone configs for non physical tables is
now forbidden .
  • Loading branch information
naivcit committed Feb 15, 2021
1 parent ac0f819 commit cf24056
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
26 changes: 26 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/zone_config
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,29 @@ SELECT zone_id, raw_config_sql FROM [SHOW ZONE CONFIGURATION FOR TABLE a]
constraints = '[]',
voter_constraints = '{+region=test: 1}',
lease_preferences = '[]'

# Check entities for which we can set zone configs

subtest test_entity_validity

statement ok
CREATE TABLE zc (
a INT PRIMARY KEY,
b INT
)

statement ok
ALTER TABLE zc CONFIGURE ZONE USING gc.ttlseconds = 100000;

statement ok
CREATE MATERIALIZED VIEW vm(x,y) AS SELECT a,b FROM zc ; ALTER TABLE vm CONFIGURE ZONE USING gc.ttlseconds = 100000;

statement error pgcode 42809 "v" is not a physical table
CREATE VIEW v(x,y) AS SELECT a, b FROM zc; ALTER TABLE v CONFIGURE ZONE USING gc.ttlseconds = 100000;

user root
statement error pq: user root does not have ZONECONFIG or CREATE privilege on relation pg_type
ALTER TABLE pg_catalog.pg_type CONFIGURE ZONE USING gc.ttlseconds = 100000;

statement error pq: user root does not have ZONECONFIG or CREATE privilege on relation columns
ALTER TABLE information_schema.columns CONFIGURE ZONE USING gc.ttlseconds = 100000;
6 changes: 6 additions & 0 deletions pkg/sql/set_zone_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,12 @@ func (n *setZoneConfigNode) startExec(params runParams) error {
return err
}

// If the table descriptor is resolved but is not a
// physical table(stored in the kv layer) then return an error
if table != nil && !table.IsPhysicalTable() {
return pgerror.Newf(pgcode.WrongObjectType, `"%v" is not a physical table`, table.GetName())
}

if n.zoneSpecifier.TargetsPartition() && len(n.zoneSpecifier.TableOrIndex.Index) == 0 && !n.allIndexes {
// Backward compatibility for ALTER PARTITION ... OF TABLE. Determine which
// index has the specified partition.
Expand Down

0 comments on commit cf24056

Please sign in to comment.