Consistently use "superuser" instead of "super user"
[pgsql.git] / src / include / access / parallel.h
blob93d88ac60e1920121ac6952ef21bd6853fb05f0f
1 /*-------------------------------------------------------------------------
3 * parallel.h
4 * Infrastructure for launching parallel workers
6 * Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
9 * src/include/access/parallel.h
11 *-------------------------------------------------------------------------
14 #ifndef PARALLEL_H
15 #define PARALLEL_H
17 #include "access/xlogdefs.h"
18 #include "lib/ilist.h"
19 #include "postmaster/bgworker.h"
20 #include "storage/shm_mq.h"
21 #include "storage/shm_toc.h"
23 typedef void (*parallel_worker_main_type) (dsm_segment *seg, shm_toc *toc);
25 typedef struct ParallelWorkerInfo
27 BackgroundWorkerHandle *bgwhandle;
28 shm_mq_handle *error_mqh;
29 int32 pid;
30 } ParallelWorkerInfo;
32 typedef struct ParallelContext
34 dlist_node node;
35 SubTransactionId subid;
36 int nworkers; /* Maximum number of workers to launch */
37 int nworkers_to_launch; /* Actual number of workers to launch */
38 int nworkers_launched;
39 char *library_name;
40 char *function_name;
41 ErrorContextCallback *error_context_stack;
42 shm_toc_estimator estimator;
43 dsm_segment *seg;
44 void *private_memory;
45 shm_toc *toc;
46 ParallelWorkerInfo *worker;
47 int nknown_attached_workers;
48 bool *known_attached_workers;
49 } ParallelContext;
51 typedef struct ParallelWorkerContext
53 dsm_segment *seg;
54 shm_toc *toc;
55 } ParallelWorkerContext;
57 extern volatile bool ParallelMessagePending;
58 extern PGDLLIMPORT int ParallelWorkerNumber;
59 extern PGDLLIMPORT bool InitializingParallelWorker;
61 #define IsParallelWorker() (ParallelWorkerNumber >= 0)
63 extern ParallelContext *CreateParallelContext(const char *library_name,
64 const char *function_name, int nworkers);
65 extern void InitializeParallelDSM(ParallelContext *pcxt);
66 extern void ReinitializeParallelDSM(ParallelContext *pcxt);
67 extern void ReinitializeParallelWorkers(ParallelContext *pcxt, int nworkers_to_launch);
68 extern void LaunchParallelWorkers(ParallelContext *pcxt);
69 extern void WaitForParallelWorkersToAttach(ParallelContext *pcxt);
70 extern void WaitForParallelWorkersToFinish(ParallelContext *pcxt);
71 extern void DestroyParallelContext(ParallelContext *pcxt);
72 extern bool ParallelContextActive(void);
74 extern void HandleParallelMessageInterrupt(void);
75 extern void HandleParallelMessages(void);
76 extern void AtEOXact_Parallel(bool isCommit);
77 extern void AtEOSubXact_Parallel(bool isCommit, SubTransactionId mySubId);
78 extern void ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end);
80 extern void ParallelWorkerMain(Datum main_arg);
82 #endif /* PARALLEL_H */