PostgreSQL Source Code git master
parallel_slot.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * parallel_slot.h
4 * Parallel support for bin/scripts/
5 *
6 * Copyright (c) 2003-2025, PostgreSQL Global Development Group
7 *
8 * src/include/fe_utils/parallel_slot.h
9 *
10 *-------------------------------------------------------------------------
11 */
12#ifndef PARALLEL_SLOT_H
13#define PARALLEL_SLOT_H
14
16#include "libpq-fe.h"
17
19 void *context);
20
21typedef struct ParallelSlot
22{
23 PGconn *connection; /* One connection */
24 bool inUse; /* Is the slot being used? */
25
26 /*
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.
31 */
35
36typedef struct ParallelSlotArray
37{
40 const char *progname;
41 bool echo;
42 const char *initcmd;
45
46static inline void
48 void *context)
49{
50 slot->handler = handler;
51 slot->handler_context = context;
52}
53
54static inline void
56{
57 slot->handler = NULL;
58 slot->handler_context = NULL;
59}
60
62 const char *dbname);
63
64extern ParallelSlotArray *ParallelSlotsSetup(int numslots, ConnParams *cparams,
65 const char *progname, bool echo,
66 const char *initcmd);
67
69
71
73
75 void *context);
76
77#endif /* PARALLEL_SLOT_H */
#define FLEXIBLE_ARRAY_MEMBER
Definition: c.h:420
const char * progname
Definition: main.c:44
ParallelSlotArray * ParallelSlotsSetup(int numslots, ConnParams *cparams, const char *progname, bool echo, const char *initcmd)
bool ParallelSlotsWaitCompletion(ParallelSlotArray *sa)
bool(* ParallelSlotResultHandler)(PGresult *res, PGconn *conn, void *context)
Definition: parallel_slot.h:18
bool TableCommandResultHandler(PGresult *res, PGconn *conn, void *context)
struct ParallelSlotArray ParallelSlotArray
static void ParallelSlotSetHandler(ParallelSlot *slot, ParallelSlotResultHandler handler, void *context)
Definition: parallel_slot.h:47
ParallelSlot * ParallelSlotsGetIdle(ParallelSlotArray *sa, const char *dbname)
static void ParallelSlotClearHandler(ParallelSlot *slot)
Definition: parallel_slot.h:55
void ParallelSlotsTerminate(ParallelSlotArray *sa)
void ParallelSlotsAdoptConn(ParallelSlotArray *sa, PGconn *conn)
struct ParallelSlot ParallelSlot
char * dbname
Definition: streamutil.c:50
PGconn * conn
Definition: streamutil.c:53
ConnParams * cparams
Definition: parallel_slot.h:39
const char * initcmd
Definition: parallel_slot.h:42
ParallelSlot slots[FLEXIBLE_ARRAY_MEMBER]
Definition: parallel_slot.h:43
const char * progname
Definition: parallel_slot.h:40
ParallelSlotResultHandler handler
Definition: parallel_slot.h:32
PGconn * connection
Definition: parallel_slot.h:23
void * handler_context
Definition: parallel_slot.h:33