On Sat, Oct 10, 2026 at 10:20 AM lin teletele <[email protected]> wrote:
>
> Hi,
>
> I found that pg_restore --clean still reports errors when restoring a
> partitioned table with a PRIMARY KEY or UNIQUE constraint.
>
> While testing this change, I also found a related failure involving a
> local constraint whose backing index is attached to a partitioned index
> without a corresponding parent constraint. In that case, dropping the
> parent index fails because of the child constraint's dependency. This
> failure also occurs without the proposed patch.
>
> I plan to report that case in a separate thread, where we can discuss
> its cleanup behavior and a follow-up fix.
>

Since these issues all involve pg_dump and constraints, maybe one thread
is enough for all of them.

For example, while looking at your thread, I found another bug related
to pg_dump --clean and constraints.
----------------------
drop table if exists p1, p1_c1;
create table p1(f1 int constraint inh_check_constraint check (f1 > 0)
not enforced);
create table p1_c1(f1 int);
alter table p1_c1 add constraint inh_check_constraint check (f1 > 0) not valid;
alter table p1_c1 inherit p1;

pg_dump --table-and-children=p1 --no-owner --no-acl --clean
--if-exists --no-data
will produce:
-------------------------
ALTER TABLE IF EXISTS public.p1_c1 DROP CONSTRAINT IF EXISTS
inh_check_constraint;
ALTER TABLE IF EXISTS public.p1 DROP CONSTRAINT IF EXISTS inh_check_constraint;
DROP TABLE IF EXISTS public.p1_c1;
DROP TABLE IF EXISTS public.p1;
-------------------------
ALTER TABLE IF EXISTS public.p1_c1 DROP CONSTRAINT IF EXISTS
inh_check_constraint;
would error out if we run it again on an existing cluster.



--
jian
https://www.enterprisedb.com/


Reply via email to