Branch data Line data Source code
1 : : /*-------------------------------------------------------------------------
2 : : *
3 : : * extendplan.h
4 : : * Extend core planner objects with additional private state
5 : : *
6 : : *
7 : : * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
8 : : * Portions Copyright (c) 1994, Regents of the University of California
9 : : *
10 : : * src/include/optimizer/extendplan.h
11 : : *
12 : : *-------------------------------------------------------------------------
13 : : */
14 : : #ifndef EXTENDPLAN_H
15 : : #define EXTENDPLAN_H
16 : :
17 : : #include "nodes/pathnodes.h"
18 : :
19 : : extern int GetPlannerExtensionId(const char *extension_name);
20 : :
21 : : /*
22 : : * Get extension-specific state from a PlannerGlobal.
23 : : */
24 : : static inline void *
25 : 184485 : GetPlannerGlobalExtensionState(PlannerGlobal *glob, int extension_id)
26 : : {
27 [ + - ]: 184485 : Assert(extension_id >= 0);
28 : :
29 [ + + ]: 184485 : if (extension_id >= glob->extension_state_allocated)
30 : 3571 : return NULL;
31 : :
32 : 180914 : return glob->extension_state[extension_id];
33 : 184485 : }
34 : :
35 : : /*
36 : : * Get extension-specific state from a PlannerInfo.
37 : : */
38 : : static inline void *
39 : 2481 : GetPlannerInfoExtensionState(PlannerInfo *root, int extension_id)
40 : : {
41 [ + - ]: 2481 : Assert(extension_id >= 0);
42 : :
43 [ - + ]: 2481 : if (extension_id >= root->extension_state_allocated)
44 : 0 : return NULL;
45 : :
46 : 2481 : return root->extension_state[extension_id];
47 : 2481 : }
48 : :
49 : : /*
50 : : * Get extension-specific state from a PlannerInfo.
51 : : */
52 : : static inline void *
53 : 88310 : GetRelOptInfoExtensionState(RelOptInfo *rel, int extension_id)
54 : : {
55 [ + - ]: 88310 : Assert(extension_id >= 0);
56 : :
57 [ + + ]: 88310 : if (extension_id >= rel->extension_state_allocated)
58 : 21872 : return NULL;
59 : :
60 : 66438 : return rel->extension_state[extension_id];
61 : 88310 : }
62 : :
63 : : /* Functions to store private state into various planner objects */
64 : : extern void SetPlannerGlobalExtensionState(PlannerGlobal *glob,
65 : : int extension_id,
66 : : void *opaque);
67 : : extern void SetPlannerInfoExtensionState(PlannerInfo *root, int extension_id,
68 : : void *opaque);
69 : : extern void SetRelOptInfoExtensionState(RelOptInfo *rel, int extension_id,
70 : : void *opaque);
71 : :
72 : : #endif
|