Re: TR: Issue: --exclude-schema flag not working with pgrestore

From: Julien Rouhaud <rjuju123(at)gmail(dot)com>
To: ROCHER Julien <julien(dot)rocher(at)emeria(dot)eu>
Cc: "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: TR: Issue: --exclude-schema flag not working with pgrestore
Date: 2023-01-11 09:40:26
Message-ID: 20230111094026.6jajog43mb42rwvv@jrouhaud
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2023-01-11 11:22:39 BUG #17745: RETURNING after INSERT does not return the same structure of response
Previous Message ROCHER Julien 2023-01-11 09:07:08 TR: Issue: --exclude-schema flag not working with pgrestore