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

Go to the source code of this file.

Typedefs

typedef char *(* pg_plan_advice_advisor_hook) (PlannerGlobal *glob, Query *parse, const char *query_string, int cursorOptions, ExplainState *es)
 

Functions

MemoryContext pg_plan_advice_get_mcxt (void)
 
bool pg_plan_advice_should_explain (ExplainState *es)
 
charpg_plan_advice_get_supplied_query_advice (PlannerGlobal *glob, Query *parse, const char *query_string, int cursorOptions, ExplainState *es)
 
PGDLLEXPORT void pg_plan_advice_add_advisor (pg_plan_advice_advisor_hook hook)
 
PGDLLEXPORT void pg_plan_advice_remove_advisor (pg_plan_advice_advisor_hook hook)
 
PGDLLEXPORT void pg_plan_advice_request_advice_generation (bool activate)
 

Variables

charpg_plan_advice_advice
 
bool pg_plan_advice_always_store_advice_details
 
bool pg_plan_advice_feedback_warnings
 
bool pg_plan_advice_trace_mask
 

Typedef Documentation

◆ pg_plan_advice_advisor_hook

typedef char *(* pg_plan_advice_advisor_hook) (PlannerGlobal *glob, Query *parse, const char *query_string, int cursorOptions, ExplainState *es)

Definition at line 19 of file pg_plan_advice.h.

Function Documentation

◆ pg_plan_advice_add_advisor()

PGDLLEXPORT void pg_plan_advice_add_advisor ( pg_plan_advice_advisor_hook  hook)
extern

Definition at line 204 of file pg_plan_advice.c.

205{
206 MemoryContext oldcontext;
207
210 MemoryContextSwitchTo(oldcontext);
211}
List * lappend(List *list, void *datum)
Definition list.c:339
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition palloc.h:124
MemoryContext pg_plan_advice_get_mcxt(void)
static List * advisor_hook_list

References advisor_hook_list, lappend(), MemoryContextSwitchTo(), and pg_plan_advice_get_mcxt().

◆ pg_plan_advice_get_mcxt()

MemoryContext pg_plan_advice_get_mcxt ( void  )
extern

Definition at line 142 of file pg_plan_advice.c.

143{
146 "pg_plan_advice",
148
149 return pgpa_memory_context;
150}
MemoryContext TopMemoryContext
Definition mcxt.c:166
#define AllocSetContextCreate
Definition memutils.h:129
#define ALLOCSET_DEFAULT_SIZES
Definition memutils.h:160
static MemoryContext pgpa_memory_context
static int fb(int x)

References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, fb(), pgpa_memory_context, and TopMemoryContext.

Referenced by pg_plan_advice_add_advisor(), and pg_plan_advice_remove_advisor().

◆ pg_plan_advice_get_supplied_query_advice()

char * pg_plan_advice_get_supplied_query_advice ( PlannerGlobal glob,
Query parse,
const char query_string,
int  cursorOptions,
ExplainState es 
)
extern

Definition at line 169 of file pg_plan_advice.c.

174{
175 ListCell *lc;
176
177 /*
178 * If any advisors are loaded, consult them. The first one that produces a
179 * non-NULL string wins.
180 */
181 foreach(lc, advisor_hook_list)
182 {
184 char *advice_string;
185
186 advice_string = (*hook) (glob, parse, query_string, cursorOptions, es);
187 if (advice_string != NULL)
188 return advice_string;
189 }
190
191 /* Otherwise, just use the value of the GUC. */
193}
void parse(int)
Definition parse.c:49
#define lfirst(lc)
Definition pg_list.h:172
char * pg_plan_advice_advice
char *(* pg_plan_advice_advisor_hook)(PlannerGlobal *glob, Query *parse, const char *query_string, int cursorOptions, ExplainState *es)

References advisor_hook_list, fb(), lfirst, parse(), and pg_plan_advice_advice.

Referenced by pgpa_planner_setup().

◆ pg_plan_advice_remove_advisor()

PGDLLEXPORT void pg_plan_advice_remove_advisor ( pg_plan_advice_advisor_hook  hook)
extern

Definition at line 217 of file pg_plan_advice.c.

218{
219 MemoryContext oldcontext;
220
223 MemoryContextSwitchTo(oldcontext);
224}
List * list_delete_ptr(List *list, void *datum)
Definition list.c:872

References advisor_hook_list, list_delete_ptr(), MemoryContextSwitchTo(), and pg_plan_advice_get_mcxt().

◆ pg_plan_advice_request_advice_generation()

PGDLLEXPORT void pg_plan_advice_request_advice_generation ( bool  activate)
extern

Definition at line 241 of file pg_plan_advice.c.

242{
243 if (activate)
245 else
246 {
249 }
250}
#define Assert(condition)
Definition c.h:927
int pgpa_planner_generate_advice

References Assert, fb(), and pgpa_planner_generate_advice.

◆ pg_plan_advice_should_explain()

bool pg_plan_advice_should_explain ( ExplainState es)
extern

Definition at line 156 of file pg_plan_advice.c.

157{
158 bool *plan_advice = NULL;
159
160 if (es != NULL)
162 return plan_advice != NULL && *plan_advice;
163}
void * GetExplainExtensionState(ExplainState *es, int extension_id)
static int es_extension_id

References es_extension_id, fb(), and GetExplainExtensionState().

Referenced by pg_plan_advice_explain_per_plan_hook(), and pgpa_planner_setup().

Variable Documentation

◆ pg_plan_advice_advice

char* pg_plan_advice_advice
extern

Definition at line 34 of file pg_plan_advice.c.

Referenced by _PG_init(), and pg_plan_advice_get_supplied_query_advice().

◆ pg_plan_advice_always_store_advice_details

bool pg_plan_advice_always_store_advice_details
extern

Definition at line 35 of file pg_plan_advice.c.

Referenced by _PG_init(), and pgpa_planner_setup().

◆ pg_plan_advice_feedback_warnings

bool pg_plan_advice_feedback_warnings
extern

Definition at line 37 of file pg_plan_advice.c.

Referenced by _PG_init(), pgpa_planner_setup(), and pgpa_planner_shutdown().

◆ pg_plan_advice_trace_mask

bool pg_plan_advice_trace_mask
extern