cockroachdb / cockroachdb/cockroach
sql: syntax error when updating individual subfield of composite type
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
According to [Postgres documentation](https://www.postgresql.org/docs/15/rowtypes.html#id-1.5.7.24.8) 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`:
```sql
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
Contributor guide
Assessment
This issue has not been assessed yet.