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
29.92k stars 3.78k forks source link

sql: syntax error when updating individual subfield of composite type #102984

Open michae2 opened 1 year ago

michae2 commented 1 year ago

According to Postgres documentation it should be possible to update individual subfields of composite types using a dot syntax, but this gives a syntax error on v23.1.0-beta.3:

CREATE TYPE p AS (x INT, y INT);
CREATE TABLE ab (a INT PRIMARY KEY, b p);
INSERT INTO ab VALUES (0, (1, 2));
-- we can update the entire composite type
UPDATE ab SET b = (2, 3) WHERE a = 0;
-- but not an individual subfield
UPDATE ab SET b.y = 4 WHERE a = 0;

The error references #27792 which is now closed:

demo@127.0.0.1:26257/demoapp/defaultdb> UPDATE ab SET b.y = 4 WHERE a = 0;
invalid syntax: statement ignored: at or near "y": syntax error: unimplemented: this syntax
SQLSTATE: 0A000
DETAIL: source SQL:
UPDATE ab SET b.y = 4 WHERE a = 0
                ^
HINT: You have attempted to use a feature that is not yet implemented.
See: https://go.crdb.dev/issue-v/27792/v23.1

At the very least we should update this error message.

Jira issue: CRDB-27770

cucaroach commented 1 year ago

CC @taroface for known limitation