BUG #17753: pg_dump --if-exists bug

The Post Office <noreply@postgresql.org>

From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: justin@tonic.ai
Date: 2023-01-18T22:33:15Z
Lists: pgsql-bugs
The following bug has been logged on the website:

Bug reference:      17753
Logged by:          Justin Zhang
Email address:      justin@tonic.ai
PostgreSQL version: 15.1
Operating system:   MacOS 12.6
Description:        

Running pg_dump with the options "--section=pre-data --no-owner
--no-privileges --no-subscriptions --no-publications --clean --if-exists
--file=/Users/ju5tinz/Dev/pg_pass_test/pre_data.sql" prints the warning: 
pg_dump: warning: could not find where to insert IF EXISTS in statement "--
*not* dropping schema, since initdb creates it
"

Seems like pg_dump is trying to add the IF EXISTS operator to a comment
because of the --if-exists option. Tested this in v14 and the warning does
not appear. Also, the sql file is generated successfully.

Commits

  1. Avoid harmless warning from pg_dump --if-exists mode.