cockroachdb / cockroachdb/cockroach

sql: syntax error when updating individual subfield of composite type

Open
#102,984 2 comments 0 reactions 0 assignees View on GitHub
A-sql-datatypes A-sql-pgcompat C-enhancement docs-done docs-known-limitation O-qa T-sql-queries X-anchored-telemetry
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.