-
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: ALTER TABLE ... ADD COLUMN ... PRIMARY KEY doesn't work correctly #81449
Comments
seems more like we want an error for the second statement right? e.g. PG
|
You're most likely correct, I didn't cross-check with postgres, sorry. |
I agree we should reject |
feels like we should definitely allow it if
that said, it is totally broken in the new schema changer:
|
Previously, the behavior of ALTER TABLE ... ADD COLUMN ... PRIMARY KEY was undefined. With the legacy schema changer, this statement would appear to succeed, but it would break the new schema changer. This commit changes this by returning an explicit error. In the future, we should support this statement if the table's primary key was originally the default rowid primary key (see cockroachdb#81449). Release note: None
Previously, the behavior of ALTER TABLE ... ADD COLUMN ... PRIMARY KEY was undefined. With the legacy schema changer, this statement would appear to succeed, but it would break the new schema changer. This commit changes this by returning an explicit error. In the future, we should support this statement if the table's primary key was originally the default rowid primary key (see cockroachdb#82735). Fixes cockroachdb#81449 Release note: None
To repro:
Expected:
the primary key isan error is returned (in pg:b
multiple primary keys for table "t" are not allowed
)Actual: success, and a subsequent
SHOW CREATE TABLE t
yieldsJira issue: CRDB-15178
The text was updated successfully, but these errors were encountered: