cockroach
cockroach copied to clipboard
sql, opt: error on UPDATE with a computed column which has a check constraint
Minimal example:
> CREATE TABLE t (a INT, b INT AS (a + 1) STORED, CONSTRAINT ck CHECK (b > 0));
> UPDATE t SET a = 123 WHERE a = 456;
This fails on the UPDATE statement with the following error:
pq: column reference "b" is ambiguous (candidates: test.public.t.b, test.public.t.b)
The error only happens when the optimizer is turned on. I did some bisecting and was able to reproduce on https://github.com/cockroachdb/cockroach/commit/68bd456bf095cccb51d23387beb3a0134c5998eb but not the commit before it, so it seems like the issue was introduced with #34118.