Re: Non-text mode for pg_dumpall - Mailing list pgsql-hackers

From tushar
Subject Re: Non-text mode for pg_dumpall
Date
Msg-id CAC6VRoZHZWzHZ0Oh++WW=9Q83co4AyG6u4+7HVi1gJiuv1CZ2g@mail.gmail.com
Whole thread Raw
In response to Re: Non-text mode for pg_dumpall  (tushar <tushar.ahuja@enterprisedb.com>)
List pgsql-hackers


On Mon, Dec 1, 2025 at 6:36 PM tushar <tushar.ahuja@enterprisedb.com> wrote:


On Thu, Nov 27, 2025 at 2:49 PM Mahendra Singh Thalor <mahi6run@gmail.com> wrote:

Fixed. Here, I am attaching an updated patch for the review and testing.

Thanks Mahendra, please refer this scenario where restoring the dump(database contain tablespace) throwing an error 

Steps to reproduce 
initdb (./initdb -D data) , start the server ( ./pg_ctl -D data start) , connect to psql terminal ( ./psql postgres)
create a directory ( \! mkdir /tmp/abc) , create a tablespace ( create tablespace a location '/tmp/abc'); ) 
create a table ( create table t(n int) tablespace a; ) , insert data ( insert into t values ('a');  ) 
perform pg_dumpall with option -c  ( ./pg_dumpall -Fc -f my.d)
try to perform pg_restore with option --no-tablespaces  ( ./pg_restore --no-tablespaces -Fc my.d  -d postgres -C) 
Getting this error :
"
pg_restore: error: could not execute query: ERROR:  role "edb" already exists
Command was: CREATE ROLE edb;
ALTER ROLE edb WITH SUPERUSER INHERIT CREATEROLE CREATEDB LOGIN REPLICATION BYPASSRLS;

pg_restore: error: could not execute query: ERROR:  directory "/tmp/abc/PG_19_202511281" already in use as a tablespace
Command was: CREATE TABLESPACE a OWNER edb LOCATION '/tmp/abc';

pg_restore: warning: errors ignored on restore: 2
"

 
I have observed that when combining the --globals-only option with certain other switches during a pg_restore - operation fails silently.
The attempted restore does not execute, but no error message or warning is displayed unless the --verbose option is also used.

--this will just run without any message but objects also not going to create  
./pg_restore -Fc ok31. -C -d postgres  -t mytable  --globals-only 
./pg_restore -Fc ok31. -C -d postgres  -no-tablespace     --globals-only
./pg_restore -Fc ok31. -C -d postgres  -no-data  --globals-only

with --verbose
[edb@1a1c15437e7c bin]$ ./pg_restore -Fc ok31. -C -d postgres  -t myable  --globals-only -v
pg_restore: connecting to database for restore
pg_restore: executing SELECT pg_catalog.set_config('search_path', '', false);
pg_restore: implied no-schema restore
pg_restore: database restoring skipped because option -g/--globals-only was specified

we should probably add some message there. 

regards,

pgsql-hackers by date:

Previous
From: Masahiko Sawada
Date:
Subject: Re: Newly created replication slot may be invalidated by checkpoint
Next
From: Nathan Bossart
Date:
Subject: split tablecmds.c