If pg_dump fails to connect to Postgres, it attempts to print an error
message in ConnectDatabase():
/* check to see that the backend connection was successfully made */
if (PQstatus(AH->connection) == CONNECTION_BAD)
die_horribly(AH, modulename,
"connection to database \"%s\" failed: %s",
dbname, PQerrorMessage(AH->connection));
But if no database is explicitly specified, `dbname' is NULL, and libc
is entitled to crash if you pass a NULL pointer to it for a %s
formatting sequence (it actually does crash on Solaris, for example --
per report from Omar Kilani).
Attached is a patch that fixes this by just removing `dbname' from the
error message, as PQerrorMessage() should provide enough information.
Barring any objections, I'll apply this to HEAD and back branches within
24 hours.
-Neil
Index: src/bin/pg_dump/pg_backup_db.c
===================================================================
RCS file: /var/lib/cvs/pgsql/src/bin/pg_dump/pg_backup_db.c,v
retrieving revision 1.63
diff -c -r1.63 pg_backup_db.c
*** src/bin/pg_dump/pg_backup_db.c 1 Jul 2005 21:03:25 -0000 1.63
--- src/bin/pg_dump/pg_backup_db.c 27 Jul 2005 01:23:27 -0000
***************
*** 265,272 ****
/* check to see that the backend connection was successfully made */
if (PQstatus(AH->connection) == CONNECTION_BAD)
! die_horribly(AH, modulename, "connection to database \"%s\" failed: %s",
! dbname, PQerrorMessage(AH->connection));
/* check for version mismatch */
_check_database_version(AH, ignoreVersion);
--- 265,272 ----
/* check to see that the backend connection was successfully made */
if (PQstatus(AH->connection) == CONNECTION_BAD)
! die_horribly(AH, modulename, "connection to database failed: %s",
! PQerrorMessage(AH->connection));
/* check for version mismatch */
_check_database_version(AH, ignoreVersion);
---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?
http://archives.postgresql.org