| From: | Dilip Kumar <dilipbalaut(at)gmail(dot)com> |
|---|---|
| To: | shihao zhong <zhong950419(at)gmail(dot)com> |
| Cc: | 125atishprak(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Subject: | Re: BUG #19858: pg_dump --clean --if-exists fails on NOT VALID domain constraint |
| Date: | 2026-11-18 09:57:45 |
| Message-ID: | CAFiTN-vG=TXcWp8CghgmCHxjDWpJ+qUGTGN4OpacsurM0UEFdQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
On Tue, Nov 17, 2026 at 7:50 AM shihao zhong <zhong950419(at)gmail(dot)com> wrote:
>
> Thanks for the clear report. I can reproduce it on 17-master.
>
> 0001 skips the ALTER DOMAIN ... DROP CONSTRAINT when the domain itself
> is being dropped too, since DROP DOMAIN removes the constraint anyway.
Thanks for the patch Shihao,
Don't you think that skipping ALTER DOMAIN ... DROP CONSTRAINT breaks
"--clean --if-exists" restores into existing databases when the
constraint depends on objects dropped before the domain?
Check below example[1]:
[1]
createdb test_f1
psql -X -d test_f1 <<'SQL'
CREATE FUNCTION is_pos(int) RETURNS boolean
LANGUAGE sql IMMUTABLE AS $$ SELECT $1 > 0 $$;
CREATE DOMAIN pos_int AS int;
ALTER DOMAIN pos_int
ADD CONSTRAINT pos_int_chk CHECK (is_pos(VALUE)) NOT VALID;
SQL
dilipkumarb(at)dilipkumarb:~/PG/postgres$ pg_dump --clean --if-exists
test_f1 > x_dump
dilipkumarb(at)dilipkumarb:~/PG/postgres$ psql -X -v ON_ERROR_STOP=1 -d
test_f1 -f x_dump
SET
.....
SET
2026-11-18 09:54:03.565 UTC [1566167] ERROR: cannot drop function
public.is_pos(integer) because other objects depend on it
2026-11-18 09:54:03.565 UTC [1566167] DETAIL: constraint pos_int_chk
depends on function public.is_pos(integer)
2026-11-18 09:54:03.565 UTC [1566167] HINT: Use DROP ... CASCADE to
drop the dependent objects too.
2026-11-18 09:54:03.565 UTC [1566167] STATEMENT: DROP FUNCTION IF
EXISTS public.is_pos(integer);
psql:x_dump:22: ERROR: cannot drop function public.is_pos(integer)
because other objects depend on it
DETAIL: constraint pos_int_chk depends on function public.is_pos(integer)
HINT: Use DROP ... CASCADE to drop the dependent objects too.
--
Regards,
Dilip Kumar
Google
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Shlok Kyal | 2026-11-18 10:46:12 | Re: Logical replication commits duplicates in DEFERRABLE unique indexes |
| Previous Message | Amit Langote | 2026-11-18 06:08:07 | Re: BUG #19851: Adding a tautological CHECK(true) to a domain changes JSON_VALUE's result (silent NULL, value/type c |