-
Notifications
You must be signed in to change notification settings - Fork 4.1k
sql: allow SHOW RANGE FROM TABLE foo FOR ROW to only apply for fields in PK #41421
Copy link
Copy link
Closed
Closed
Copy link
Labels
C-enhancementSolution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)S-3-ux-surpriseIssue leaves users wondering whether CRDB is behaving properly. Likely to hurt reputation/adoption.Issue leaves users wondering whether CRDB is behaving properly. Likely to hurt reputation/adoption.
Description
Using the new SQL SHOW RANGE FROM TABLE foo FOR ROW command is a bit difficult as it requires the user to input some values for all of the columns in the table and not just the PK:
Consider the vehicles table in MovR:
show create table vehicles;
table_name | create_statement
+------------+-----------------------------------------------------------------------------------------------+
vehicles | CREATE TABLE vehicles (
| id UUID NOT NULL,
| city VARCHAR NOT NULL,
| type VARCHAR NULL,
| owner_id UUID NULL,
| creation_time TIMESTAMP NULL,
| status VARCHAR NULL,
| current_location VARCHAR NULL,
| ext JSONB NULL,
| CONSTRAINT "primary" PRIMARY KEY (city ASC, id ASC),
| CONSTRAINT fk_city_ref_users FOREIGN KEY (city, owner_id) REFERENCES users(city, id),
| INDEX vehicles_auto_index_fk_city_ref_users (city ASC, owner_id ASC),
| FAMILY "primary" (id, city, type, owner_id, creation_time, status, current_location, ext)
| )
(1 row)
Time: 46.349msTo use the new command you must provide values for every entry and not just those in the PK:
show range from table vehicles for row ('acde070d-8c4c-4f0d-9d8a-162843c10333','san francisco','',Null,Null,'','',Null);
start_key | end_key | range_id | lease_holder | lease_holder_locality | replicas | replica_localities
+-----------+---------+----------+--------------+-----------------------+----------+------------------------------------------------------------------------+
NULL | NULL | 26 | 4 | region=us-east,az=1 | {3,4,8} | {"region=us-west,az=2","region=us-east,az=1","region=us-central,az=1"}
(1 row)
Time: 7.347msPK only:
root@127.0.0.1:49818/movr> show range from table vehicles for row ('acde070d-8c4c-4f0d-9d8a-162843c10333','san francisco');
pq: number of values in row must equal number of columns in the requested tableYou must provide values for everything in a secondary index which means, in effect, you must provide values for all columns in order to specify which columns apply.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C-enhancementSolution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)S-3-ux-surpriseIssue leaves users wondering whether CRDB is behaving properly. Likely to hurt reputation/adoption.Issue leaves users wondering whether CRDB is behaving properly. Likely to hurt reputation/adoption.