Closed fqazi closed 3 weeks ago
Just confirming, is this different from https://github.com/cockroachdb/cockroach/issues/127147?
Yeah, this was found while working on a fix that issue on the schema changer side. I noticed that we couldn't delete values in the first place in that example table :/
[triage] Marcus will take a look, and figure out where this issue should live.
You don't need DELETE
to hit this. SELECT
works fine:
CREATE TYPE foobar AS ENUM ('a', 'b', 'c');
CREATE TABLE t (x TEXT PRIMARY KEY, INDEX ((x::foobar)));
SELECT * FROM t where x='a';
This is somewhat related to #61298: using column names to resolve columns in "table expressions", i.e., check constraint expressions, computed column expressions, partial index predicates, etc., is fragile.
In this case, it breaks because there is an implicit CHECK
expression crdb_internal_idx_expr IN ('a', 'b', 'c')
where crdb_internal_idx_expr
is an inaccessible computed column with the expression x::foobar
.
I have a few ideas on how to solve this in the short-term that I'll explore.
Thanks for the report @fqazi! This was a nasty rough edge. #129080 fixes it.
Based on the specified backports for linked PR #129080, I applied the following new label(s) to this issue: branch-release-23.1, branch-release-23.2, branch-release-24.1, branch-release-24.2. Please adjust the labels as needed to match the branches actually affected by this issue, including adding any known older branches.
:owl: Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.
If a table exists with an index expression that will require validation via synthetic check constraints:
Then delete statement on the table can fail with:
This happens because a synthetic check constraint is inject into the statement to ensure that crdb_internal_expr is a valid enum value of "typ".
Jira issue: CRDB-40415