mirror of https://github.com/citusdata/citus.git
Fix SendRemoteCommandParams() handling of a NULL MultiConnection->pgConn. (#1271)
Previously we'd segfault in PQisnonblocking() which, contrary to other libpq calls, doesn't handle a NULL PQconn (because there'd be no appropriate return value for that). cr: @jasonmp85pull/1387/head
parent
2d6915c82a
commit
09c42481bb
|
@ -277,11 +277,22 @@ SendRemoteCommandParams(MultiConnection *connection, const char *command,
|
||||||
const char *const *parameterValues)
|
const char *const *parameterValues)
|
||||||
{
|
{
|
||||||
PGconn *pgConn = connection->pgConn;
|
PGconn *pgConn = connection->pgConn;
|
||||||
bool wasNonblocking = PQisnonblocking(pgConn);
|
bool wasNonblocking = false;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
LogRemoteCommand(connection, command);
|
LogRemoteCommand(connection, command);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Don't try to send command if connection is entirely gone
|
||||||
|
* (PQisnonblocking() would crash).
|
||||||
|
*/
|
||||||
|
if (!pgConn)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
wasNonblocking = PQisnonblocking(pgConn);
|
||||||
|
|
||||||
/* make sure not to block anywhere */
|
/* make sure not to block anywhere */
|
||||||
if (!wasNonblocking)
|
if (!wasNonblocking)
|
||||||
{
|
{
|
||||||
|
@ -340,7 +351,11 @@ GetRemoteCommandResult(MultiConnection *connection, bool raiseInterrupts)
|
||||||
PGresult *result = NULL;
|
PGresult *result = NULL;
|
||||||
bool failed = false;
|
bool failed = false;
|
||||||
|
|
||||||
/* short circuit tests around the more expensive parts of this routine */
|
/*
|
||||||
|
* Short circuit tests around the more expensive parts of this
|
||||||
|
* routine. This'd also trigger a return in the, unlikely, case of a
|
||||||
|
* failed/nonexistant connection.
|
||||||
|
*/
|
||||||
if (!PQisBusy(pgConn))
|
if (!PQisBusy(pgConn))
|
||||||
{
|
{
|
||||||
return PQgetResult(connection->pgConn);
|
return PQgetResult(connection->pgConn);
|
||||||
|
|
Loading…
Reference in New Issue