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@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@1a1c15437e7c bin]$ ./pg_dump  --no-tablespace -Ft -f tp.tar postgres

Now, try to restore to another cluster

[edb@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@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,

Reply via email to