Skip to content
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

Merged
merged 1 commit into from
Oct 22, 2018

Conversation

BramGruneir
Copy link
Member

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.

@BramGruneir BramGruneir requested review from dt and a team October 18, 2018 21:05
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@BramGruneir
Copy link
Member Author

At @knz's suggestion, I've added a guard to make sure we don't have an out of bounds error.

@knz
Copy link
Contributor

knz commented Oct 19, 2018 via email

@@ -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)) {
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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

Copy link
Member Author

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.
@BramGruneir
Copy link
Member Author

bors r+

craig bot pushed a commit that referenced this pull request Oct 22, 2018
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 <solon@cockroachlabs.com>
Co-authored-by: Bram Gruneir <bram@cockroachlabs.com>
Co-authored-by: Tobias Schottdorf <tobias.schottdorf@gmail.com>
@craig
Copy link
Contributor

craig bot commented Oct 22, 2018

Build succeeded

@craig craig bot merged commit 0fd79ec into cockroachdb:master Oct 22, 2018
@BramGruneir BramGruneir deleted the 31545 branch October 23, 2018 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SQL: Conkey and confkey values in pg_constraints have different number of elements
4 participants