cockroachdb / cockroach

CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement.
https://www.cockroachlabs.com
Other
30.09k stars 3.8k forks source link

sql: `SHOW ZONE CONFIGURATION FROM TABLE` returns database zone configs #93794

Closed e-mbrown closed 1 year ago

e-mbrown commented 1 year ago

The following commands should return table zone configs, but instead show zone configs for the database.

demo@127.0.0.1:26257/movr> create database db primary region "us-west1" regions "europe-west1", "us-east1" ;

demo@127.0.0.1:26257/movr> CREATE TABLE db.rbt(x INT) LOCALITY REGIONAL BY TABLE;  

demo@127.0.0.1:26257/movr> SHOW ZONE CONFIGURATION FROM TABLE db.rbt;                                                                                                                   
    target    |                                      raw_config_sql
--------------+-------------------------------------------------------------------------------------------
  DATABASE db | ALTER DATABASE db CONFIGURE ZONE USING
              |     range_min_bytes = 134217728,
              |     range_max_bytes = 536870912,
              |     gc.ttlseconds = 90000,
              |     num_replicas = 5,
              |     num_voters = 3,
              |     constraints = '{+region=europe-west1: 1, +region=us-east1: 1, +region=us-west1: 1}',
              |     voter_constraints = '[+region=us-west1]',
              |     lease_preferences = '[[+region=us-west1]]'
(1 row)

Jira issue: CRDB-22531

rafiss commented 1 year ago

After poking through the code history and double checking with @otan, this behavior seems to be expected. If an object itself doesn't have a zone config, then the command just shows the inherited zone config.

We should document this behavior better. I couldn't find it in the docs myself, but I'll double check again.