-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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: null-value constraint is not enforced in CREATE TABLE ... AS (values) #69867
Comments
In addition, no jobs are created:
|
Thanks for the report @sajjadrizvi! I was able to reproduce this. However, I can only reproduce this when running the root@127.0.0.1:26257/movr> CREATE TABLE foo (x PRIMARY KEY) AS VALUES (1), (NULL);
ERROR: generate insert row: null value in column "x" violates not-null constraint
SQLSTATE: 23502
root@127.0.0.1:26257/movr> BEGIN; CREATE TABLE foo (x PRIMARY KEY) AS VALUES (1), (NULL); END;
COMMIT |
Yes, I have also noticed that. |
This is a @cockroachdb/sql-schema bug I think as we own the initial schema change. It's funny that these two are different cases. |
70439: sql: fix username parsing for CURRENT_USER/SESSION_USER r=rafiss a=RichardJCai Release note (sql change): Fix bug where previously CURRENT_USER and SESSION_USER were parsed incorrectly. Fixes #54696 70507: rowenc: error when encoding NULLs for PK columns r=postamar a=postamar This commit adds a validation check to rowenc.EncodeIndexKey to have it return an error when it encodes a NULL value for a primary key column. Fixes #69867. Release note: None Co-authored-by: richardjcai <[email protected]> Co-authored-by: Marius Posta <[email protected]>
This commit adds a validation check to rowenc.EncodeIndexKey to have it return an error when it encodes a NULL value for a primary key column. Fixes cockroachdb#69867. Release note: None
This commit adds a validation check to rowenc.EncodeIndexKey to have it return an error when it encodes a NULL value for a primary key column. Fixes cockroachdb#69867. Release justification: Low risk addition of a correctness check. Release note: None
This commit adds a validation check to rowenc.EncodeIndexKey to have it return an error when it encodes a NULL value for a primary key column. Fixes cockroachdb#69867. Release justification: Low risk addition of a correctness check. Release note: None
This commit adds a validation check to rowenc.EncodeIndexKey to have it return an error when it encodes a NULL value for a primary key column. Fixes cockroachdb#69867. Release justification: Low risk addition of a correctness check. Release note: None
The problem
A PK column can have a null value when a table is created using
CREATE TABLE ... AS (values)
.To Reproduce
BEGIN; CREATE TABLE foo (x PRIMARY KEY) AS VALUES (1), (NULL); END;
SELECT * FROM foo
results in:I tested this using current master branch.
Expected behavior
The query should not succeed.
The text was updated successfully, but these errors were encountered: