Re: BUG #18917: "Foreign key constraint drop fails with 'column is not in index' unless pg_constraint is queried

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: samfelder17(at)gmail(dot)com
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18917: "Foreign key constraint drop fails with 'column is not in index' unless pg_constraint is queried
Date: 2025-05-08 01:50:34
Message-ID: 104861.1746669034@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
> when trying to drop a foreign key constraint with an existing index that
> hasn't been used, you need to make a query against constraint table to get
> it working. see below for psql sequence of events
> ```
> mydb=> begin;
> BEGIN
> mydb=*> CREATE INDEX IF NOT EXISTS "child_table_parent_id_idx" ON
> "child_table"("parent_id");
> CREATE INDEX
> ... etc ...

This test case is incomplete on its face. (How was the table created?
Where did "child_table_parent_id_fkey" come from?) So it's hard to
tell what's going on, much less fix it. Could we have a complete
reproducer starting from an empty database?

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Richard Guo 2025-05-08 10:26:30 Re: BUG #18902: TRAP:: failed Assert("!is_sorted") in File: "createplan.c"
Previous Message PG Bug reporting form 2025-05-08 01:23:53 BUG #18917: "Foreign key constraint drop fails with 'column is not in index' unless pg_constraint is queried