1 /*-------------------------------------------------------------------------
4 * Parallel support for bin/scripts/
6 * Copyright (c) 2003-2024, PostgreSQL Global Development Group
8 * src/include/fe_utils/parallel_slot.h
10 *-------------------------------------------------------------------------
12 #ifndef PARALLEL_SLOT_H
13 #define PARALLEL_SLOT_H
15 #include "fe_utils/connect_utils.h"
18 typedef bool (*ParallelSlotResultHandler
) (PGresult
*res
, PGconn
*conn
,
21 typedef struct ParallelSlot
23 PGconn
*connection
; /* One connection */
24 bool inUse
; /* Is the slot being used? */
27 * Prior to issuing a command or query on 'connection', a handler callback
28 * function may optionally be registered to be invoked to process the
29 * results, and context information may optionally be registered for use
30 * by the handler. If unset, these fields should be NULL.
32 ParallelSlotResultHandler handler
;
33 void *handler_context
;
36 typedef struct ParallelSlotArray
43 ParallelSlot slots
[FLEXIBLE_ARRAY_MEMBER
];
47 ParallelSlotSetHandler(ParallelSlot
*slot
, ParallelSlotResultHandler handler
,
50 slot
->handler
= handler
;
51 slot
->handler_context
= context
;
55 ParallelSlotClearHandler(ParallelSlot
*slot
)
58 slot
->handler_context
= NULL
;
61 extern ParallelSlot
*ParallelSlotsGetIdle(ParallelSlotArray
*sa
,
64 extern ParallelSlotArray
*ParallelSlotsSetup(int numslots
, ConnParams
*cparams
,
65 const char *progname
, bool echo
,
68 extern void ParallelSlotsAdoptConn(ParallelSlotArray
*sa
, PGconn
*conn
);
70 extern void ParallelSlotsTerminate(ParallelSlotArray
*sa
);
72 extern bool ParallelSlotsWaitCompletion(ParallelSlotArray
*sa
);
74 extern bool TableCommandResultHandler(PGresult
*res
, PGconn
*conn
,
77 #endif /* PARALLEL_SLOT_H */