mirror of https://github.com/citusdata/citus.git
Add a wrapper for PQsendQuery
parent
87c62d598e
commit
00d55ad957
|
@ -223,7 +223,9 @@ ExecuteCriticalRemoteCommand(MultiConnection *connection, const char *command)
|
||||||
* an additional memory allocation).
|
* an additional memory allocation).
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
SendRemoteCommand(MultiConnection *connection, const char *command)
|
SendRemoteCommandParams(MultiConnection *connection, const char *command,
|
||||||
|
int parameterCount, const Oid *parameterTypes,
|
||||||
|
const char *const *parameterValues)
|
||||||
{
|
{
|
||||||
PGconn *pgConn = connection->pgConn;
|
PGconn *pgConn = connection->pgConn;
|
||||||
bool wasNonblocking = PQisnonblocking(pgConn);
|
bool wasNonblocking = PQisnonblocking(pgConn);
|
||||||
|
@ -237,7 +239,8 @@ SendRemoteCommand(MultiConnection *connection, const char *command)
|
||||||
PQsetnonblocking(pgConn, true);
|
PQsetnonblocking(pgConn, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = PQsendQuery(pgConn, command);
|
rc = PQsendQueryParams(pgConn, command, parameterCount, parameterTypes,
|
||||||
|
parameterValues, NULL, NULL, 0);
|
||||||
|
|
||||||
/* reset nonblocking connection to its original state */
|
/* reset nonblocking connection to its original state */
|
||||||
if (!wasNonblocking)
|
if (!wasNonblocking)
|
||||||
|
@ -249,6 +252,19 @@ SendRemoteCommand(MultiConnection *connection, const char *command)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SendRemoteCommand is a PQsendQuery wrapper that logs remote commands, and
|
||||||
|
* accepts a MultiConnection instead of a plain PGconn. It makes sure it can
|
||||||
|
* send commands asynchronously without blocking (at the potential expense of
|
||||||
|
* an additional memory allocation).
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
SendRemoteCommand(MultiConnection *connection, const char *command)
|
||||||
|
{
|
||||||
|
return SendRemoteCommandParams(connection, command, 0, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GetCommandResult is a wrapper around PQgetResult() that handles interrupts.
|
* GetCommandResult is a wrapper around PQgetResult() that handles interrupts.
|
||||||
*
|
*
|
||||||
|
|
|
@ -35,6 +35,9 @@ extern void LogRemoteCommand(MultiConnection *connection, const char *command);
|
||||||
extern void ExecuteCriticalRemoteCommand(MultiConnection *connection,
|
extern void ExecuteCriticalRemoteCommand(MultiConnection *connection,
|
||||||
const char *command);
|
const char *command);
|
||||||
extern int SendRemoteCommand(MultiConnection *connection, const char *command);
|
extern int SendRemoteCommand(MultiConnection *connection, const char *command);
|
||||||
|
extern int SendRemoteCommandParams(MultiConnection *connection, const char *command,
|
||||||
|
int parameterCount, const Oid *parameterTypes,
|
||||||
|
const char *const *parameterValues);
|
||||||
extern struct pg_result * GetRemoteCommandResult(MultiConnection *connection,
|
extern struct pg_result * GetRemoteCommandResult(MultiConnection *connection,
|
||||||
bool raiseInterrupts);
|
bool raiseInterrupts);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue