-
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: fix CREATE TABLE LIKE with implicit pk #82555
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @ajwerner)
That solution is not sufficient. See my additional comment in #82401. |
4067171
to
2cd587f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @ajwerner and @jasonmchan)
pkg/sql/create_table.go
line 2894 at r2 (raw file):
return false, err } if td.IsShardColumn(col) {
Could you also add logic tests where the source table has hash sharded index
and expression index
?
Previously, chengxiong-ruan (Chengxiong Ruan) wrote…
oops, there is already test coverage for |
I'm going to omit a fix for REGIONAL BY ROW because #82672 causes problems with this solution. Will put up a new revision for the broken CI tests. |
Previously, `CREATE TABLE LIKE` copied implicitly created columns (e.g. for the rowid default primary key and hash sharded index). Defaults for some of these columns were not properly copied over in some cases, causing unexpected constraint violations to surface. This commit fixes this by skipping copying such columns; instead, they will be freshly created. Followup work is needed for REGIONAL BY ROW. Fixes cockroachdb#82401 Release note: None
2cd587f
to
19ce4ec
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @ajwerner and @jasonmchan)
TFTR! I'm leaving out the expression index test for now because this PR doesn't change how they are handled. bors r+ |
Build succeeded: |
Previously,
CREATE TABLE LIKE
copied implicitly created columns (e.g.for the rowid default primary key and hash sharded index). Defaults for
some of these columns were not properly copied over in some cases,
causing unexpected constraint violations to surface.
This commit fixes this by skipping copying such columns; instead, they
will be freshly created. Followup work is needed for REGIONAL BY ROW.
Fixes #82401
Release note: None