-
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 pg_catalog.pg_constraint's confkey column #31610
Conversation
At @knz's suggestion, I've added a guard to make sure we don't have an out of bounds error. |
Thanks for this.
Don't you want to fail with an error if the prefix Len is too large? This would suggest an inconsistency.
LGTM otherwise
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
|
pkg/sql/pg_catalog.go
Outdated
@@ -680,7 +680,11 @@ CREATE TABLE pg_catalog.pg_constraint ( | |||
confupdtype = fkActionNone | |||
confdeltype = fkActionNone | |||
confmatchtype = fkMatchTypeSimple | |||
if conkey, err = colIDArrayToDatum(con.Index.ColumnIDs); err != nil { | |||
columnIDs := con.Index.ColumnIDs | |||
if con.FK.SharedPrefixLen < int32(len(columnIDs)) { |
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.
I thought this check was usually just != 0
? In very old table descs, it might be unset, and thus zero, so < len
could get us in trouble.
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.
Can you point to an example? Having to check 0 as well is a little strange.
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.
numCols := len(idx.ColumnIDs)
if idx.ForeignKey.SharedPrefixLen > 0 {
numCols = int(idx.ForeignKey.SharedPrefixLen)
}
https://github.com/cockroachdb/cockroach/blob/master/pkg/sql/create_table.go#L585
of https://github.com/cockroachdb/cockroach/blob/master/pkg/sql/sqlbase/table.go:325
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.
Ok, I think this is ready to go. PTAL
I added a comment on structured.proto
to reflect the need to check for >0 to use the sharedprefixlen
.
Prior to this patch, all columns in the index were included instead of only the ones being used in the foreign key reference. Fixes cockroachdb#31545. Release note (bug fix): Fix pg_catalog.pg_constraint's confkey column from including columns that were not involved in the foreign key reference.
bors r+ |
31554: exec: initial commit of execgen tool r=solongordon a=solongordon Execgen will be our tool for generating templated code necessary for columnarized execution. So far it only generates the EncDatumRowsToColVec function, which is used by the columnarizer to convert a RowSource into a columnarized Operator. Release note: None 31610: sql: fix pg_catalog.pg_constraint's confkey column r=BramGruneir a=BramGruneir Prior to this patch, all columns in the index were included instead of only the ones being used in the foreign key reference. Fixes #31545. Release note (bug fix): Fix pg_catalog.pg_constraint's confkey column from including columns that were not involved in the foreign key reference. 31689: storage: pick up fix for Raft uncommitted entry size tracking r=benesch a=tschottdorf Waiting for the upstream PR etcd-io/etcd#10199 to merge, but this is going to be what the result will look like. ---- The tracking of the uncommitted portion of the log had a bug where it wasn't releasing everything as it should've. As a result, over time, all proposals would be dropped. We're hitting this way earlier in our import tests, which propose large proposals. As an intentional implementation detail, a proposal that itself exceeds the max uncommitted log size is allowed only if the uncommitted log is empty. Due to the leak, we weren't ever hitting this case and so AddSSTable commands were often dropped indefinitely. Fixes #31184. Fixes #28693. Fixes #31642. Optimistically: Fixes #31675. Fixes #31654. Fixes #31446. Release note: None Co-authored-by: Solon Gordon <[email protected]> Co-authored-by: Bram Gruneir <[email protected]> Co-authored-by: Tobias Schottdorf <[email protected]>
Build succeeded |
Prior to this patch, all columns in the index were included instead of only the
ones being used in the foreign key reference.
Fixes #31545.
Release note (bug fix): Fix pg_catalog.pg_constraint's confkey column from
including columns that were not involved in the foreign key reference.