Set AUTOCOMMIT to on in script output by pg_dump

Shinya Kato <shinya11.kato@oss.nttdata.com>

From: Shinya Kato <Shinya11.Kato@oss.nttdata.com>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-10-09T02:10:37Z
Lists: pgsql-hackers

Attachments

Hi hackers!

When SQL scripts created with pg_dump/pg_dumpall/pg_restore are executed 
in psql with AUTOCOMMIT turned off, they will not succeed in many cases.
This is because the script contains SQL statements that cannot be 
executed within a transaction block.

If you simply add set AUTOCOMMIT on to the scripts created by 
pg_dump/pg_dumpall/pg_restore, they will work fine.
A patch is attached

No documentation has been added as we could not find any documentation 
on the details in the script.

Do you think?

Regards,
Shinya Kato
NTT DATA GROUP CORPORATION

Commits

  1. Doc: recommend "psql -X" for restoring pg_dump scripts.