Closed
Description
Jira Link: DB-15562
Description
A foreign key constraint that exists only on the parent
CREATE TABLE test_primary_constraints(id int PRIMARY KEY);
CREATE TABLE test_foreign_constraints(id1 int REFERENCES test_primary_constraints(id));
CREATE TABLE test_foreign_constraints_inh () INHERITS (test_foreign_constraints);
ALTER TABLE test_foreign_constraints DROP CONSTRAINT test_foreign_constraints_id1_fkey;
The issue also occurs with primary key constraints that exist only on the parent
create table par(id int primary key, c1 int);
create table child(ch1 int) inherits (par);
alter table par drop constraint par_pkey;
ERROR: constraint "par_pkey" for table "child" does not exist
As a workaround, use alter table only
for both these cases to drop the primary key / foreign key from just the parent.
yugabyte=# ALTER TABLE ONLY test_foreign_constraints DROP CONSTRAINT test_foreign_constraints_id1_fkey;
ALTER TABLE
yugabyte=# alter table only par drop constraint par_pkey;
NOTICE: table rewrite may lead to inconsistencies
DETAIL: Concurrent DMLs may not be reflected in the new table.
HINT: See https://github.com/yugabyte/yugabyte-db/issues/19860. Set 'ysql_suppress_unsafe_alter_notice' yb-tserver gflag to true to suppress this notice.
ALTER TABLE
Issue Type
kind/bug
Warning: Please confirm that this issue does not contain any sensitive information
- I confirm this issue does not contain any sensitive information.