BUG #16514: pg_dump v12 puts CREATE SCHEMA public statement into the backup file

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: kravtsov(dot)k(at)gmail(dot)com
Subject: BUG #16514: pg_dump v12 puts CREATE SCHEMA public statement into the backup file
Date: 2020-06-26 18:40:59
Message-ID: 16514-3f214ab4550eb8fd@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 16514
Logged by: Kirill Kravtsov
Email address: kravtsov(dot)k(at)gmail(dot)com
PostgreSQL version: 12.3
Operating system: CentOS 7
Description:

I’m experiencing some weird behaviour of pg_dump: based on this thread
https://www.postgresql.org/message-id/flat/20849.1541638465%40sss.pgh.pa.us#744c293b37793dea0f6e60676c3f3210
, starting from v11 pg_dump should not include CREATE SCHEMA public
statements to the dump. However, if I run pg_dump v12 with --schema public ,
it still adds that line to the backup file, which breaks the ability to
restore from it

$ /usr/pgsql-12/bin/pg_dump -d db --schema public --schema-only | grep
'CREATE SCHEMA'
CREATE SCHEMA public;

Without specifying a schema it works as expected:
$ /usr/pgsql-12/bin/pg_dump -d db --schema-only | grep 'CREATE SCHEMA'
CREATE SCHEMA admin;
CREATE SCHEMA stats;

When attempting to restore from such a backup, the following error occurs:

pg_restore: while PROCESSING TOC:
pg_restore: from TOC entry 12; 2615 2200 SCHEMA public postgres
pg_restore: error: could not execute query: ERROR: schema "public" already
exists
Command was: CREATE SCHEMA public;

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Jose Alcantara 2020-06-26 18:43:22 Problem with pgadm4
Previous Message PG Bug reporting form 2020-06-26 14:10:47 BUG #16513: Postgresql HA Cluster