Only attempt to set synchronous transaction mode with valid connection

This commit is contained in:
Ian Barwick
2017-03-17 20:32:36 +09:00
parent 0c82278fd4
commit 976a61005e

View File

@@ -90,9 +90,8 @@ _establish_db_connection(const char *conninfo, const bool exit_on_error, const b
* set "synchronous_commit" to "local" in case synchronous replication is in use
*/
if (set_config(conn, "synchronous_commit", "local") == false)
else if (set_config(conn, "synchronous_commit", "local") == false)
{
if (exit_on_error)
{
PQfinish(conn);
@@ -157,8 +156,8 @@ establish_db_connection_by_params(const char *keywords[], const char *values[],
exit(ERR_DB_CON);
}
}
else
{
/*
* set "synchronous_commit" to "local" in case synchronous replication is in
* use (provided this is not a replication connection)
@@ -178,6 +177,7 @@ establish_db_connection_by_params(const char *keywords[], const char *values[],
exit(ERR_DB_CON);
}
}
}
return conn;
}