Fix multiple bugs in PostgreSQL hook #677
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch ":fix-postgres-hook"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
See commit messages.
I think there are issues open for some of these too, could you link to them in the description so it's easier to close them? Anyway, I'll try to do that in some time.
I haven’t found any in this repository.
ab91570603
toc105bea740
589d98c156
to17f122bfe5
Thank you for finding and fixing these issues! I filed a ticket with the issues you've identified (pretty much copy and pasted): #678 ... mostly so folks have a ticket to reference from the eventual changelog.
This looks great! I appreciate you diving in and fixing these issues. The only thing potentially missing is adding (or updating) a test demonstrating that the
psql_command
andpg_restore_command
options now support commands with arguments in these functions. Do you think that's something you could add? It wouldn't have to be a full end-to-end test that calls out to PostgreSQL commands or anything; a simple unit test that the right arguments get created would suffice. Thanks!@ -59,8 +60,10 @@ def database_names_to_dump(database, extra_environment, log_prefix, dry_run):
if dry_run:
return ()
psql_command = shlex.split(database.get('psql_command') or 'psql')
Nice.. I didn't know about
shlex.split()
!@ -62,2 +64,3 @@
list_command = (
('psql', '--list', '--no-password', '--csv', '--tuples-only')
tuple(psql_command)
+ ('--list', '--no-password', '--no-psqlrc', '--csv', '--tuples-only')
The addition of
--no-psqlrc
sounds more correct, but I do worry a little that someone will be relying on their~/.psqlrc
to be read. I guess we'll find out.This is not a hypothetical situation, it happened to me… borgmatic failed because I have
\pset linestyle unicode
and\pset border 2
in.psqlrc
.According to theconfiguration reference, it was already supposed to support it, but it didn't work:
I’m sorry, but I’ve already spent more time on it than I would have liked, I need to focus on other projects.
Okay, thanks anyway! I appreciate your contribution, and I'll take it from here.
FYI I ended backing out this one change:
The reason is that I couldn't get the end-to-end tests to pass with it in place, and I think those tests are probably pretty indicative of how real users will use dumps and restores. borgmatic PostgreSQL dumps are created with
--clean
--if-exists
and so they include statements likeDROP ROLE IF EXISTS postgres;
. But then when the restore is attempted viapsql --set ON_ERROR_STOP=on
, it'll abort with:ERROR: current user cannot be dropped.
I don't know of a way around this without:
--clean
/--if-exists
from the dump process.DROP ROLE IF EXISTS postgres;
... none of which I'm really excited about. I'm happy to hear about other options though. Thanks!