diff --git a/src/backend/distributed/connection/remote_commands.c b/src/backend/distributed/connection/remote_commands.c index 2e1de8452..e342c4403 100644 --- a/src/backend/distributed/connection/remote_commands.c +++ b/src/backend/distributed/connection/remote_commands.c @@ -223,7 +223,9 @@ ExecuteCriticalRemoteCommand(MultiConnection *connection, const char *command) * an additional memory allocation). */ 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; bool wasNonblocking = PQisnonblocking(pgConn); @@ -237,7 +239,8 @@ SendRemoteCommand(MultiConnection *connection, const char *command) PQsetnonblocking(pgConn, true); } - rc = PQsendQuery(pgConn, command); + rc = PQsendQueryParams(pgConn, command, parameterCount, parameterTypes, + parameterValues, NULL, NULL, 0); /* reset nonblocking connection to its original state */ 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. * diff --git a/src/include/distributed/remote_commands.h b/src/include/distributed/remote_commands.h index 52cf255d2..e4b9ee78c 100644 --- a/src/include/distributed/remote_commands.h +++ b/src/include/distributed/remote_commands.h @@ -35,6 +35,9 @@ extern void LogRemoteCommand(MultiConnection *connection, const char *command); extern void ExecuteCriticalRemoteCommand(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, bool raiseInterrupts);