/* check to see that the backend connection was successfully made */
if (PQstatus(conn) == CONNECTION_BAD)
{
- pg_log_error("could not connect to database %s: %s",
- my_opts->dbname, PQerrorMessage(conn));
+ pg_log_error("%s", PQerrorMessage(conn));
PQfinish(conn);
exit(1);
}
/* check to see that the backend connection was successfully made */
if (PQstatus(conn) == CONNECTION_BAD)
{
- pg_log_error("connection to database \"%s\" failed: %s",
- database, PQerrorMessage(conn));
+ pg_log_error("%s", PQerrorMessage(conn));
PQfinish(conn);
return -1;
}
if (PQstatus(conn) != CONNECTION_OK)
{
- fprintf(stderr, "Connection to database failed: %s",
- PQerrorMessage(conn));
+ /* PQerrorMessage's result includes a trailing newline */
+ fprintf(stderr, "%s", PQerrorMessage(conn));
PQfinish(conn);
return 1;
}
/* Check to see that the backend connection was successfully made */
if (PQstatus(conn) != CONNECTION_OK)
{
- fprintf(stderr, "Connection to database failed: %s",
- PQerrorMessage(conn));
+ fprintf(stderr, "%s", PQerrorMessage(conn));
exit_nicely(conn);
}
/* Check to see that the backend connection was successfully made */
if (PQstatus(conn) != CONNECTION_OK)
{
- fprintf(stderr, "Connection to database failed: %s",
- PQerrorMessage(conn));
+ fprintf(stderr, "%s", PQerrorMessage(conn));
exit_nicely(conn);
}
/* Check to see that the backend connection was successfully made */
if (PQstatus(conn) != CONNECTION_OK)
{
- fprintf(stderr, "Connection to database failed: %s",
- PQerrorMessage(conn));
+ fprintf(stderr, "%s", PQerrorMessage(conn));
exit_nicely(conn);
}
/* check to see that the backend connection was successfully made */
if (PQstatus(conn) != CONNECTION_OK)
{
- fprintf(stderr, "Connection to database failed: %s",
- PQerrorMessage(conn));
+ fprintf(stderr, "%s", PQerrorMessage(conn));
exit_nicely(conn);
}
if (PQstatus(AH->connection) == CONNECTION_BAD)
{
if (isReconnect)
- fatal("reconnection to database \"%s\" failed: %s",
- PQdb(AH->connection) ? PQdb(AH->connection) : "",
+ fatal("reconnection failed: %s",
PQerrorMessage(AH->connection));
else
- fatal("connection to database \"%s\" failed: %s",
- PQdb(AH->connection) ? PQdb(AH->connection) : "",
+ fatal("%s",
PQerrorMessage(AH->connection));
}
{
if (fail_on_error)
{
- pg_log_error("could not connect to database \"%s\": %s",
- dbname, PQerrorMessage(conn));
+ pg_log_error("%s", PQerrorMessage(conn));
exit_nicely(1);
}
else
command_fails_like(
[ 'pg_dump', '-p', "$port", 'qqq' ],
- qr/pg_dump: error: connection to database "qqq" failed: connection to server .* failed: FATAL: database "qqq" does not exist/,
+ qr/pg_dump: error: connection to server .* failed: FATAL: database "qqq" does not exist/,
'connecting to a non-existent database');
#########################################
if (conn == NULL || PQstatus(conn) != CONNECTION_OK)
{
- pg_log(PG_REPORT, "connection to database failed: %s",
- PQerrorMessage(conn));
+ pg_log(PG_REPORT, "%s", PQerrorMessage(conn));
if (conn)
PQfinish(conn);
* get_db_conn()
*
* get database connection, using named database + standard params for cluster
+ *
+ * Caller must check for connection failure!
*/
static PGconn *
get_db_conn(ClusterInfo *cluster, const char *db_name)
if ((conn = get_db_conn(cluster, "template1")) == NULL ||
PQstatus(conn) != CONNECTION_OK)
{
- pg_log(PG_REPORT, "\nconnection to database failed: %s",
- PQerrorMessage(conn));
+ pg_log(PG_REPORT, "\n%s", PQerrorMessage(conn));
if (conn)
PQfinish(conn);
if (cluster == &old_cluster)
/* check to see that the backend connection was successfully made */
if (PQstatus(conn) == CONNECTION_BAD)
{
- pg_log_error("connection to database \"%s\" failed: %s",
- dbName, PQerrorMessage(conn));
+ pg_log_error("%s", PQerrorMessage(conn));
PQfinish(conn);
return NULL;
}
1,
[qr{^$}],
[
- qr{connection to database "no-such-database" failed},
+ qr{connection to server .* failed},
qr{FATAL: database "no-such-database" does not exist}
],
'no such database');
PQfinish(conn);
return NULL;
}
- pg_log_error("could not connect to database %s: %s",
- cparams->dbname, PQerrorMessage(conn));
+ pg_log_error("%s", PQerrorMessage(conn));
exit(1);
}
const char *errmsg = PQerrorMessage(this->connection);
const char *db = realname ? realname : ecpg_gettext("<DEFAULT>");
- ecpg_log("ECPGconnect: could not open database: %s\n", errmsg);
+ /* PQerrorMessage's result already has a trailing newline */
+ ecpg_log("ECPGconnect: %s", errmsg);
ecpg_finish(this);
#ifdef ENABLE_THREAD_SAFETY
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGconnect: opening database <DEFAULT> on <DEFAULT> port <DEFAULT> for user regress_ecpg_user2
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGconnect: could not open database: connection to server failed: FATAL: database "regress_ecpg_user2" does not exist
-
+[NO_PID]: ECPGconnect: connection to server failed: FATAL: database "regress_ecpg_user2" does not exist
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: connection main closed
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: sqlca: code: -220, state: 08003
[NO_PID]: ECPGconnect: opening database <DEFAULT> on <DEFAULT> port <DEFAULT> for user regress_ecpg_user2
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGconnect: could not open database: connection to server failed: FATAL: database "regress_ecpg_user2" does not exist
-
+[NO_PID]: ECPGconnect: connection to server failed: FATAL: database "regress_ecpg_user2" does not exist
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: connection main closed
[NO_PID]: sqlca: code: 0, state: 00000
/* Check to see that the backend connection was successfully made */
if (PQstatus(conn) != CONNECTION_OK)
{
- fprintf(stderr, "Connection to database failed: %s",
- PQerrorMessage(conn));
+ fprintf(stderr, "%s", PQerrorMessage(conn));
exit_nicely(conn);
}
/* Check to see that the backend connection was successfully made */
if (PQstatus(conn) != CONNECTION_OK)
{
- fprintf(stderr, "Connection to database failed: %s",
- PQerrorMessage(conn));
+ fprintf(stderr, "%s", PQerrorMessage(conn));
exit_nicely(conn);
}
/* Check to see that the backend connection was successfully made */
if (PQstatus(conn) != CONNECTION_OK)
{
- fprintf(stderr, "Connection to database failed: %s",
- PQerrorMessage(conn));
+ fprintf(stderr, "%s", PQerrorMessage(conn));
exit_nicely(conn);
}
/* check to see that the backend connection was successfully made */
if (PQstatus(conn) != CONNECTION_OK)
{
- fprintf(stderr, "Connection to database \"%s\" failed: %s",
- dbName, PQerrorMessage(conn));
+ fprintf(stderr, "%s", PQerrorMessage(conn));
exit(1);
}
/* check to see that the backend connection was successfully made */
if (PQstatus(conn) != CONNECTION_OK)
{
- fprintf(stderr, "Connection to database failed: %s",
- PQerrorMessage(conn));
+ fprintf(stderr, "%s", PQerrorMessage(conn));
exit_nicely(conn);
}
/* check to see that the backend connection was successfully made */
if (PQstatus(conn) != CONNECTION_OK)
{
- fprintf(stderr, "Connection to database failed: %s",
- PQerrorMessage(conn));
+ fprintf(stderr, "%s", PQerrorMessage(conn));
exit_nicely(conn);
}
conns[i] = PQconnectdb(conninfo);
if (PQstatus(conns[i]) != CONNECTION_OK)
{
- fprintf(stderr, "Connection %d to database failed: %s",
+ fprintf(stderr, "Connection %d failed: %s",
i, PQerrorMessage(conns[i]));
exit(1);
}
conn = PQconnectdb(sql.data);
if (PQstatus(conn) == CONNECTION_BAD)
{
- fprintf(stderr, "connection error: %s\n", PQerrorMessage(conn));
+ fprintf(stderr, "%s", PQerrorMessage(conn));
exit(EXIT_FAILURE);
}