I met a strange PostgreSQL (v.13.8) on a Windows server 2019 machine today when trying to restore a custom dump file.
The following command worked:
pg_restore -d postgres://postgres@localhost:5432/postgres --no-owner --no-privileges --create --clean --role=<myuser> --if-exists inputfile.backup 2> inputfile.log
but by simply adding the --single-transaction
option to the command line, it raised an error:
pg_restore -d postgres://postgres@localhost:5432/postgres --no-owner --no-privileges --single-transaction --create --clean --role=<myuser> --if-exists inputfile.backup 2> inputfile.log
But I can read this in the log file:
pg_restore: error : options « -c/--clean » and « -a/--data-only » cannot be used together.
I didn't even use the -a
flag... This is strange, isn't it?
I've read through the pg_restore doc, especially the paragraph about the --single-transaction
option but it doesn't say much about it, (for example about an underlying implicit -a
flag):
--single-transaction
Execute the restore as a single transaction (that is, wrap the emitted commands in BEGIN/COMMIT). This ensures that either all the commands complete successfully, or no changes are applied. This option implies --exit-on-error.
Anyone can tell me what exactly is happening when using this option?
CMD
in Windows. I updated the main post.