PostgreSQL Source Code git master
Loading...
Searching...
No Matches
extendplan.h File Reference
#include "nodes/pathnodes.h"
Include dependency graph for extendplan.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int GetPlannerExtensionId (const char *extension_name)
 
static voidGetPlannerGlobalExtensionState (PlannerGlobal *glob, int extension_id)
 
static voidGetPlannerInfoExtensionState (PlannerInfo *root, int extension_id)
 
static voidGetRelOptInfoExtensionState (RelOptInfo *rel, int extension_id)
 
void SetPlannerGlobalExtensionState (PlannerGlobal *glob, int extension_id, void *opaque)
 
void SetPlannerInfoExtensionState (PlannerInfo *root, int extension_id, void *opaque)
 
void SetRelOptInfoExtensionState (RelOptInfo *rel, int extension_id, void *opaque)
 

Function Documentation

◆ GetPlannerExtensionId()

int GetPlannerExtensionId ( const char extension_name)
extern

Definition at line 41 of file extendplan.c.

42{
43 /* Search for an existing extension by this name; if found, return ID. */
44 for (int i = 0; i < PlannerExtensionNamesAssigned; ++i)
46 return i;
47
48 /* If there is no array yet, create one. */
50 {
52 PlannerExtensionNameArray = (const char **)
55 * sizeof(char *));
56 }
57
58 /* If there's an array but it's currently full, expand it. */
60 {
62
63 PlannerExtensionNameArray = (const char **)
64 repalloc(PlannerExtensionNameArray, i * sizeof(char *));
66 }
67
68 /* Assign and return new ID. */
71}
static const char ** PlannerExtensionNameArray
Definition extendplan.c:28
static int PlannerExtensionNamesAssigned
Definition extendplan.c:29
static int PlannerExtensionNamesAllocated
Definition extendplan.c:30
int i
Definition isn.c:77
void * MemoryContextAlloc(MemoryContext context, Size size)
Definition mcxt.c:1232
void * repalloc(void *pointer, Size size)
Definition mcxt.c:1632
MemoryContext TopMemoryContext
Definition mcxt.c:166
static uint32 pg_nextpower2_32(uint32 num)
static int fb(int x)

References fb(), i, MemoryContextAlloc(), pg_nextpower2_32(), PlannerExtensionNameArray, PlannerExtensionNamesAllocated, PlannerExtensionNamesAssigned, repalloc(), and TopMemoryContext.

Referenced by geqo().

◆ GetPlannerGlobalExtensionState()

static void * GetPlannerGlobalExtensionState ( PlannerGlobal glob,
int  extension_id 
)
inlinestatic

Definition at line 25 of file extendplan.h.

26{
27 Assert(extension_id >= 0);
28
30 return NULL;
31
32 return glob->extension_state[extension_id];
33}
#define Assert(condition)
Definition c.h:873
int extension_state_allocated
Definition pathnodes.h:267

References Assert, PlannerGlobal::extension_state_allocated, and fb().

◆ GetPlannerInfoExtensionState()

static void * GetPlannerInfoExtensionState ( PlannerInfo root,
int  extension_id 
)
inlinestatic

Definition at line 39 of file extendplan.h.

40{
41 Assert(extension_id >= 0);
42
43 if (extension_id >= root->extension_state_allocated)
44 return NULL;
45
46 return root->extension_state[extension_id];
47}
tree ctl root
Definition radixtree.h:1857

References Assert, fb(), and root.

Referenced by GetGeqoPrivateData().

◆ GetRelOptInfoExtensionState()

static void * GetRelOptInfoExtensionState ( RelOptInfo rel,
int  extension_id 
)
inlinestatic

Definition at line 53 of file extendplan.h.

54{
55 Assert(extension_id >= 0);
56
58 return NULL;
59
60 return rel->extension_state[extension_id];
61}
int extension_state_allocated
Definition pathnodes.h:1202

References Assert, RelOptInfo::extension_state_allocated, and fb().

◆ SetPlannerGlobalExtensionState()

void SetPlannerGlobalExtensionState ( PlannerGlobal glob,
int  extension_id,
void opaque 
)
extern

Definition at line 77 of file extendplan.c.

79{
80 Assert(extension_id >= 0);
81
82 /* If there is no array yet, create one. */
83 if (glob->extension_state == NULL)
84 {
86 Size sz;
87
91 sz = glob->extension_state_allocated * sizeof(void *);
92 glob->extension_state = MemoryContextAllocZero(planner_cxt, sz);
93 }
94
95 /* If there's an array but it's currently full, expand it. */
97 {
98 int i;
99
101 glob->extension_state = repalloc0_array(glob->extension_state, void *,
104 }
105
106 glob->extension_state[extension_id] = opaque;
107}
#define Max(x, y)
Definition c.h:991
size_t Size
Definition c.h:619
void * MemoryContextAllocZero(MemoryContext context, Size size)
Definition mcxt.c:1266
MemoryContext GetMemoryChunkContext(void *pointer)
Definition mcxt.c:756
#define repalloc0_array(pointer, type, oldcount, count)
Definition palloc.h:109

References Assert, PlannerGlobal::extension_state_allocated, fb(), GetMemoryChunkContext(), i, Max, MemoryContextAllocZero(), pg_nextpower2_32(), and repalloc0_array.

◆ SetPlannerInfoExtensionState()

void SetPlannerInfoExtensionState ( PlannerInfo root,
int  extension_id,
void opaque 
)
extern

Definition at line 113 of file extendplan.c.

115{
116 Assert(extension_id >= 0);
117
118 /* If there is no array yet, create one. */
119 if (root->extension_state == NULL)
120 {
121 Size sz;
122
123 root->extension_state_allocated =
125 sz = root->extension_state_allocated * sizeof(void *);
126 root->extension_state = MemoryContextAllocZero(root->planner_cxt, sz);
127 }
128
129 /* If there's an array but it's currently full, expand it. */
130 if (extension_id >= root->extension_state_allocated)
131 {
132 int i;
133
135 root->extension_state = repalloc0_array(root->extension_state, void *,
136 root->extension_state_allocated, i);
137 root->extension_state_allocated = i;
138 }
139
140 root->extension_state[extension_id] = opaque;
141}

References Assert, fb(), i, Max, MemoryContextAllocZero(), pg_nextpower2_32(), repalloc0_array, and root.

Referenced by geqo().

◆ SetRelOptInfoExtensionState()

void SetRelOptInfoExtensionState ( RelOptInfo rel,
int  extension_id,
void opaque 
)
extern

Definition at line 147 of file extendplan.c.

149{
150 Assert(extension_id >= 0);
151
152 /* If there is no array yet, create one. */
153 if (rel->extension_state == NULL)
154 {
156 Size sz;
157
161 sz = rel->extension_state_allocated * sizeof(void *);
162 rel->extension_state = MemoryContextAllocZero(planner_cxt, sz);
163 }
164
165 /* If there's an array but it's currently full, expand it. */
167 {
168 int i;
169
171 rel->extension_state = repalloc0_array(rel->extension_state, void *,
174 }
175
176 rel->extension_state[extension_id] = opaque;
177}

References Assert, RelOptInfo::extension_state_allocated, fb(), GetMemoryChunkContext(), i, Max, MemoryContextAllocZero(), pg_nextpower2_32(), and repalloc0_array.