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: Conkey and confkey values in pg_constraints have different number of elements #31545

Closed
awoods187 opened this issue Oct 17, 2018 · 1 comment · Fixed by #31610
Closed
Assignees
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.

Comments

@awoods187
Copy link
Contributor

awoods187 commented Oct 17, 2018

Dbeaver identified a potential CRDB bug in dbeaver/dbeaver#4386 (comment):

This happens because conkey and confkey values in pg_constraints have different number of elements.
In standard PG they always have equal size.

Looks like a bug in CC - the value in conkey seems to be equal to the number of columns in table's primary key. This happens only if foreign key columns are also part of primary key (like in stock or order_line tables).
@BramGruneir
Copy link
Member

In postgres, after using the schema posted to the dbeaver issue:

bram=# select oid, conname, conkey, confkey from pg_catalog.pg_constraint where conname like '%fkey';
  oid  |      conname       | conkey  | confkey
-------+--------------------+---------+---------
 25286 | test_parent_fkey   | {2}     | {1}
 33487 | example_b_fkey     | {2}     | {1}
 33508 | b_x_fkey           | {1,2}   | {1,2}
 33529 | d_warehouse_fkey   | {1}     | {1}
 16970 | self_other_id_fkey | {2}     | {1}
 16983 | self_x2_y_fkey     | {2}     | {1}
 16988 | self_x2_z_fkey     | {3}     | {2}
 17008 | weird_id_fkey      | {1}     | {1}
 33542 | c_district_fkey    | {1,2}   | {1,2}
 33556 | h_customer_fkey    | {3,2,1} | {1,2,3}
 33561 | h_district_fkey    | {5,4}   | {1,2}
 33571 | o_customer_fkey    | {1,2,4} | {1,2,3}
 33582 | no_order_fkey      | {1,2,3} | {1,2,3}
 33597 | s_warehouse_fkey   | {1}     | {1}
 33602 | s_item_fkey        | {2}     | {1}
 33612 | ol_order_fkey      | {1,2,3} | {1,2,3}
 33617 | ol_stock_fkey      | {8,5}   | {1,2}
(17 rows)

In cockroach:

root@:26257/defaultdb> select oid, conname, conkey, confkey from pg_catalog.pg_constraint where conname like '%fkey';
     oid     |     conname      |  conkey   | confkey
+------------+------------------+-----------+---------+
  1879483418 | d_warehouse_fkey | {1,2}     | {1}
  2947212382 | c_district_fkey  | {1,2,3}   | {1,2}
  1524765624 | h_district_fkey  | {5,4}     | {1,2}
  3257882111 | h_customer_fkey  | {3,2,1}   | {1,2,3}
  3472271204 | o_customer_fkey  | {1,2,4}   | {1,2,3}
   993267767 | no_order_fkey    | {1,2,3}   | {1,2,3}
  3657084363 | s_warehouse_fkey | {1,2}     | {1}
  4156347737 | s_item_fkey      | {2}       | {1}
  4271105516 | ol_order_fkey    | {1,2,3,4} | {1,2,3}
  3999149087 | ol_stock_fkey    | {8,5}     | {1,2}
(10 rows)

BramGruneir added a commit to BramGruneir/cockroach that referenced this issue Oct 19, 2018
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.
@petermattis petermattis added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Oct 19, 2018
BramGruneir added a commit to BramGruneir/cockroach that referenced this issue Oct 22, 2018
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.
craig bot pushed a commit that referenced this issue 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 craig bot closed this as completed in #31610 Oct 22, 2018
BramGruneir added a commit to BramGruneir/cockroach that referenced this issue Oct 25, 2018
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants