0

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?

5
  • 1
    What command line are you using? In my hands, CMD doesn't support backslash continuation lines.
    – jjanes
    Sep 29, 2022 at 0:16
  • Ah sorry about that, you are perfectly right; it was only for a better readability that I write it this way. I'm using the standard command line CMD in Windows. I updated the main post.
    – s.k
    Sep 29, 2022 at 17:18
  • Did you translate the message? I wonder if this is a bug in one of the translation files. What locale are you using? Chevrons are not used for quote marks in English, and I cannot reproduce this error in C locale (other than by actually using -a, of course)
    – jjanes
    Sep 29, 2022 at 17:57
  • Nope, again, this was to indicate that it's a user input from the terminal, as the dollar sign in Unix based system. Updated again to remove it then.
    – s.k
    Sep 29, 2022 at 18:02
  • Ah wait,... you mean the error message I got? Yes I manually translated it, the db was installed with the default locale of the OS, which was french, indeed. So it may not exactly what would have pop if it was installed with an English locale. What exactly is a C locale? Is it possible to change the locale of PostgreSQL without having to reinstall it if that was the origin of that glitch?
    – s.k
    Sep 29, 2022 at 18:04

1 Answer 1

2

I don't know how you get the different language messages to be used.

But there is an obvious copy-and-paste mistake in the French translation file src/bin/pg_dump/po/fr.po:

#: pg_restore.c:338
#, c-format
msgid "options -C/--create and -1/--single-transaction cannot be used together"
msgstr "les options « -c/--clean » et « -a/--data-only » ne peuvent pas être utilisées ensemble"

Bug reported.

1
  • Oh, indeed, thanks a lot for the reporting! I'll go to investigate the error with the true underlying error message now :)
    – s.k
    Sep 30, 2022 at 13:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.