aboutsummaryrefslogtreecommitdiff
path: root/src/include/fe_utils/parallel_slot.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/fe_utils/parallel_slot.h')
-rw-r--r--src/include/fe_utils/parallel_slot.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/include/fe_utils/parallel_slot.h b/src/include/fe_utils/parallel_slot.h
index 99eeb3328d6..8902f8d4f48 100644
--- a/src/include/fe_utils/parallel_slot.h
+++ b/src/include/fe_utils/parallel_slot.h
@@ -15,12 +15,39 @@
#include "fe_utils/connect_utils.h"
#include "libpq-fe.h"
+typedef bool (*ParallelSlotResultHandler) (PGresult *res, PGconn *conn,
+ void *context);
+
typedef struct ParallelSlot
{
PGconn *connection; /* One connection */
bool isFree; /* Is it known to be idle? */
+
+ /*
+ * Prior to issuing a command or query on 'connection', a handler callback
+ * function may optionally be registered to be invoked to process the
+ * results, and context information may optionally be registered for use
+ * by the handler. If unset, these fields should be NULL.
+ */
+ ParallelSlotResultHandler handler;
+ void *handler_context;
} ParallelSlot;
+static inline void
+ParallelSlotSetHandler(ParallelSlot *slot, ParallelSlotResultHandler handler,
+ void *context)
+{
+ slot->handler = handler;
+ slot->handler_context = context;
+}
+
+static inline void
+ParallelSlotClearHandler(ParallelSlot *slot)
+{
+ slot->handler = NULL;
+ slot->handler_context = NULL;
+}
+
extern ParallelSlot *ParallelSlotsGetIdle(ParallelSlot *slots, int numslots);
extern ParallelSlot *ParallelSlotsSetup(const ConnParams *cparams,
@@ -31,5 +58,7 @@ extern void ParallelSlotsTerminate(ParallelSlot *slots, int numslots);
extern bool ParallelSlotsWaitCompletion(ParallelSlot *slots, int numslots);
+extern bool TableCommandResultHandler(PGresult *res, PGconn *conn,
+ void *context);
#endif /* PARALLEL_SLOT_H */