-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sql: CBO fails to run CHECK constraint on input row to UPSERT/INSERT ON CONFLICT #35370
Comments
I think the CHECK constraint also needs to be run on the output, regardless; this should fail too given the example above: > insert into t(x,y) values (0,30) on conflict(x) do update set y= 10; |
Discussed offline, @rmloveland this should be documented as a known limitation / difference with postgres, and we'll hope that users are OK with that. We can leave the issue open (low priority) and perhaps label it with a new label "deliberate choice" so we can provide a better support experience when people ask. |
As another data point, @knz and I discovered that PG is inconsistent with applying CHECK constraint:
Notice that PG does not check the constraint on I think the important thing for check constraints is to verify that bad data does not get inserted/updated into table. It doesn't seem too important for input that never makes it into the table to be checked. The fact that PG is sometimes checking input and sometimes not suggests their current behavior is just an implementation accident. The CBO is consistent, in that it always checks the output values, and never checks the input values. |
@knz, can you help me with a blurb on this for the known limitations page? |
|
Documented in cockroachdb/docs#5785. |
We have marked this issue as stale because it has been inactive for |
This bug still exists in v21.1. |
We have marked this issue as stale because it has been inactive for |
The CBO runs CHECK only on the result of conflict resolution; it must run it on the input as well.
This is a regression (
set optimizer=off
provides the proper behavior)Related (but distinct from) #35364
cc @andy-kimball
Jira issue: CRDB-4590
The text was updated successfully, but these errors were encountered: