PostgreSQL Source Code: src/include/fe_utils/parallel_slot.h Source File

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
15#include "fe_utils/connect_utils.h"
16#include "libpq-fe.h"
17
18 typedef bool (*ParallelSlotResultHandler) (PGresult *res, PGconn *conn,
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 */
32 ParallelSlotResultHandler handler;
33 void *handler_context;
34 } ParallelSlot;
35
36 typedef struct ParallelSlotArray
37{
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;
45
46static inline void
47 ParallelSlotSetHandler(ParallelSlot *slot, ParallelSlotResultHandler handler,
48 void *context)
49{
50 slot->handler = handler;
51 slot->handler_context = context;
52}
53
54static inline void
55 ParallelSlotClearHandler(ParallelSlot *slot)
56{
57 slot->handler = NULL;
58 slot->handler_context = NULL;
59}
60
61extern ParallelSlot *ParallelSlotsGetIdle(ParallelSlotArray *sa,
62 const char *dbname);
63
64extern ParallelSlotArray *ParallelSlotsSetup(int numslots, ConnParams *cparams,
65 const char *progname, bool echo,
66 const char *initcmd);
67
68extern void ParallelSlotsAdoptConn(ParallelSlotArray *sa, PGconn *conn);
69
70extern void ParallelSlotsTerminate(ParallelSlotArray *sa);
71
72extern bool ParallelSlotsWaitCompletion(ParallelSlotArray *sa);
73
74extern bool TableCommandResultHandler(PGresult *res, PGconn *conn,
75 void *context);
76
77#endif /* PARALLEL_SLOT_H */
#define FLEXIBLE_ARRAY_MEMBER
Definition: c.h:470
const char * progname
Definition: main.c:44
ParallelSlotArray * ParallelSlotsSetup(int numslots, ConnParams *cparams, const char *progname, bool echo, const char *initcmd)
Definition: parallel_slot.c:428
bool ParallelSlotsWaitCompletion(ParallelSlotArray *sa)
Definition: parallel_slot.c:501
bool(* ParallelSlotResultHandler)(PGresult *res, PGconn *conn, void *context)
Definition: parallel_slot.h:18
bool TableCommandResultHandler(PGresult *res, PGconn *conn, void *context)
Definition: parallel_slot.c:540
struct ParallelSlotArray ParallelSlotArray
static void ParallelSlotSetHandler(ParallelSlot *slot, ParallelSlotResultHandler handler, void *context)
Definition: parallel_slot.h:47
ParallelSlot * ParallelSlotsGetIdle(ParallelSlotArray *sa, const char *dbname)
Definition: parallel_slot.c:371
static void ParallelSlotClearHandler(ParallelSlot *slot)
Definition: parallel_slot.h:55
void ParallelSlotsTerminate(ParallelSlotArray *sa)
Definition: parallel_slot.c:479
void ParallelSlotsAdoptConn(ParallelSlotArray *sa, PGconn *conn)
Definition: parallel_slot.c:460
struct ParallelSlot ParallelSlot
char * dbname
Definition: streamutil.c:49
PGconn * conn
Definition: streamutil.c:52
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
Definition: preproc-init.c:83

AltStyle によって変換されたページ (->オリジナル) /