Re: Set AUTOCOMMIT to on in script output by pg_dump

Yugo Nagata <nagata@sraoss.co.jp>

From: Yugo Nagata <nagata@sraoss.co.jp>
To: Shinya Kato <Shinya11.Kato@oss.nttdata.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-10-09T03:03:14Z
Lists: pgsql-hackers
On Wed, 09 Oct 2024 11:10:37 +0900
Shinya Kato <Shinya11.Kato@oss.nttdata.com> wrote:

> 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?

I am not sure if it is good to include psql's meta-command in pg_dump/pg_dumpall
results. Can we assume users will always use psql to restore the pg_dump results?

Regards,
Yugo Nagata

-- 
Yugo Nagata <nagata@sraoss.co.jp>



Commits

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