Hello,
I noticed pg_dump failed to not dump creation or comment commands for public
schema when we explicitly ask it to dump public schema.
Shorter example: pg_dump -n public dump will give:
--
-- Name: public; Type: SCHEMA; Schema: -; Owner: postgres
--
CREATE SCHEMA public;
ALTER SCHEMA public OWNER TO postgres;
--
-- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres
--
COMMENT ON SCHEMA public IS 'standard public schema';
Obviously, it trigger errors when we try to restore it as public schema already
exists.
Git bisect blame this commit (since pg11):
commit 5955d934194c3888f30318209ade71b53d29777f (refs/bisect/bad)
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: Thu Jan 25 13:54:42 2018 -0500
Improve pg_dump's handling of "special" built-in objects.
I first tried to add an only_dump_public_schema test. I am not used to how
pg_dump tests works but I do not think it is the best approach due to how many
test I had to disable for only_dump_public_schema.
Then I tried to change selectDumpableNamespace in order to apply the same
treatment to public schema when we explicitly ask pg_dump to dump public schema.
Unfortunately this broke other tests, all related to how we handle COLLATION.
For example:
# Failed test 'only_dump_test_schema: should not dump ALTER COLLATION test0
OWNER TO'
# Failed test 'only_dump_test_schema: should not dump COMMENT ON COLLATION test0'
# Failed test 'only_dump_test_schema: should not dump CREATE COLLATION test0
FROM "C"'
# Failed test 'only_dump_test_schema: should not dump REVOKE CREATE ON SCHEMA
public FROM public'
Regards,