1 /*------------------------------------------------------------------------- 2 * 3 * remote_commands.h 4 * Helpers to execute commands on remote nodes, over libpq. 5 * 6 * Copyright (c) Citus Data, Inc. 7 * 8 *------------------------------------------------------------------------- 9 */ 10 11 #ifndef REMOTE_COMMAND_H 12 #define REMOTE_COMMAND_H 13 14 #include "distributed/connection_management.h" 15 16 /* errors which ExecuteRemoteCommand might return */ 17 #define RESPONSE_OKAY 0 18 #define QUERY_SEND_FAILED 1 19 #define RESPONSE_NOT_OKAY 2 20 21 /* GUC, determining whether statements sent to remote nodes are logged */ 22 extern bool LogRemoteCommands; 23 24 /* GUC that determines the number of bytes after which remote COPY is flushed */ 25 extern int RemoteCopyFlushThreshold; 26 27 28 /* simple helpers */ 29 extern bool IsResponseOK(PGresult *result); 30 extern void ForgetResults(MultiConnection *connection); 31 extern bool ClearResults(MultiConnection *connection, bool raiseErrors); 32 extern bool ClearResultsDiscardWarnings(MultiConnection *connection, bool raiseErrors); 33 extern bool ClearResultsIfReady(MultiConnection *connection); 34 35 /* report errors & warnings */ 36 extern void ReportConnectionError(MultiConnection *connection, int elevel); 37 extern void ReportResultError(MultiConnection *connection, PGresult *result, 38 int elevel); 39 extern char * pchomp(const char *in); 40 extern void LogRemoteCommand(MultiConnection *connection, const char *command); 41 42 /* wrappers around libpq functions, with command logging support */ 43 extern void ExecuteCriticalRemoteCommandList(MultiConnection *connection, 44 List *commandList); 45 extern void ExecuteCriticalRemoteCommand(MultiConnection *connection, 46 const char *command); 47 extern int ExecuteOptionalRemoteCommand(MultiConnection *connection, 48 const char *command, 49 PGresult **result); 50 extern int SendRemoteCommand(MultiConnection *connection, const char *command); 51 extern int SendRemoteCommandParams(MultiConnection *connection, const char *command, 52 int parameterCount, const Oid *parameterTypes, 53 const char *const *parameterValues, 54 bool binaryResults); 55 extern List * ReadFirstColumnAsText(PGresult *queryResult); 56 extern PGresult * GetRemoteCommandResult(MultiConnection *connection, 57 bool raiseInterrupts); 58 extern bool PutRemoteCopyData(MultiConnection *connection, const char *buffer, 59 int nbytes); 60 extern bool PutRemoteCopyEnd(MultiConnection *connection, const char *errormsg); 61 62 /* waiting for multiple command results */ 63 extern void WaitForAllConnections(List *connectionList, bool raiseInterrupts); 64 65 extern bool SendCancelationRequest(MultiConnection *connection); 66 67 #endif /* REMOTE_COMMAND_H */ 68