Re: TR: Issue: --exclude-schema flag not working with pgrestore - Mailing list pgsql-bugs

From Julien Rouhaud
Subject Re: TR: Issue: --exclude-schema flag not working with pgrestore
Date
Msg-id 20230111094026.6jajog43mb42rwvv@jrouhaud
Whole thread Raw
In response to TR: Issue: --exclude-schema flag not working with pgrestore  (ROCHER Julien <julien.rocher@emeria.eu>)
List pgsql-bugs
Hi,

On Wed, Jan 11, 2023 at 09:07:08AM +0000, ROCHER Julien wrote:
> 
> I don’t expect the --exclude-schema flag (-N) to restore chosen schema with
> pgrestore<https://docs.postgresql.fr/11/app-pgrestore.html> tool, but it
> actually tries to create the schema then its table.  I deliberately keep the
> same db name in the below example because this is actually what I’m trying to
> do (restore a dump from a similar db but excluding some already existing
> schemas on it), but I guess you don’t need to deal with this detail.  Did I
> misunderstand this command ?

You didn't, but made an error in how SQL object names work:

> ➜  ~ psql -U julien -W -p 5432 -d postgres  -c "create schema schemaA; create schema schemaB;"

this creates schemaa and schemab, not schemaA and schemaB.  If you want objects
to be case sensitive at the SQL level, you need to double quote identifiers,
like "schemaB".

> ➜  ~ pg_restore -p 5432 -W -d postgres --verbose  -N schemaB dump.sql

this on the other hand is a command line utility, and will use the given case
(and properly quote identifers at the SQL leve), so it means "schemaB" which
isn't found and thus not filtered.



pgsql-bugs by date:

Previous
From: ROCHER Julien
Date:
Subject: TR: Issue: --exclude-schema flag not working with pgrestore
Next
From: PG Bug reporting form
Date:
Subject: BUG #17745: RETURNING after INSERT does not return the same structure of response