Discrepancy in --no-tablespaces behavior between Tar and Plain-text formats

From: tushar <tushar(dot)ahuja(at)enterprisedb(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Discrepancy in --no-tablespaces behavior between Tar and Plain-text formats
Date: 2026-02-18 10:43:11
Message-ID: CAC6VRob=TYw-__j2E1sYTymPCsy2Mgfhp67iyCbTOrWRvZ204A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I observed that pg_restore attempts to set default_tablespace from a Tar
archive even if --no-tablespaces was used during pg_dump.

Please refer to this scenario:

[edb(at)1a1c15437e7c bin]$ ./psql postgres
psql (19devel)
Type "help" for help.
postgres=# \! mkdir /tmp/tbsp
postgres=# create tablespace a location '/tmp/tbsp';
CREATE TABLESPACE
postgres=#
postgres=# create table t(n int) tablespace a;
CREATE TABLE
postgres=# insert into t values (1);
INSERT 0 1
postgres=# \q
[edb(at)1a1c15437e7c bin]$ ./pg_dump --no-tablespace -Ft -f tp.tar postgres

Now, try to restore to another cluster

[edb(at)1a1c15437e7c bin]$ ./pg_restore -Ft -C -d postgres -p 9000 tp.tar
pg_restore: error: could not execute query: ERROR: database "postgres"
already exists
Command was: CREATE DATABASE postgres WITH TEMPLATE = template0 ENCODING =
'UTF8' LOCALE_PROVIDER = libc LOCALE = 'C.UTF-8';

pg_restore: error: could not set "default_tablespace" to a: ERROR: invalid
value for parameter "default_tablespace": "a"
DETAIL: Tablespace "a" does not exist.
pg_restore: warning: errors ignored on restore: 2
[edb(at)1a1c15437e7c bin]$

If we do like this - using -Fp format, then no error
./pg_dump --no-tablespace -Fp -f tp.txt postgres
\i tp.txt

regards,

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Henson Choi 2026-02-18 10:56:53 Re: Row pattern recognition
Previous Message Fabrice Chapuis 2026-02-18 10:40:26 incremental backup issue