Unmark gen_random_uuid() function leakproof.
[pgsql.git] / src / include / fe_utils / parallel_slot.h
blob4d79030aa6caf7078be0b6071c409fa0a77001e2
1 /*-------------------------------------------------------------------------
3 * parallel_slot.h
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"
16 #include "libpq-fe.h"
18 typedef bool (*ParallelSlotResultHandler) (PGresult *res, PGconn *conn,
19 void *context);
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;
34 } ParallelSlot;
36 typedef struct ParallelSlotArray
38 int numslots;
39 ConnParams *cparams;
40 const char *progname;
41 bool echo;
42 const char *initcmd;
43 ParallelSlot slots[FLEXIBLE_ARRAY_MEMBER];
44 } ParallelSlotArray;
46 static inline void
47 ParallelSlotSetHandler(ParallelSlot *slot, ParallelSlotResultHandler handler,
48 void *context)
50 slot->handler = handler;
51 slot->handler_context = context;
54 static inline void
55 ParallelSlotClearHandler(ParallelSlot *slot)
57 slot->handler = NULL;
58 slot->handler_context = NULL;
61 extern ParallelSlot *ParallelSlotsGetIdle(ParallelSlotArray *sa,
62 const char *dbname);
64 extern ParallelSlotArray *ParallelSlotsSetup(int numslots, ConnParams *cparams,
65 const char *progname, bool echo,
66 const char *initcmd);
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,
75 void *context);
77 #endif /* PARALLEL_SLOT_H */