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.

Macros

#define PGPA_FB_MATCH_PARTIAL   0x0001
 
#define PGPA_FB_MATCH_FULL   0x0002
 
#define PGPA_FB_INAPPLICABLE   0x0004
 
#define PGPA_FB_CONFLICTING   0x0008
 
#define PGPA_FB_FAILED   0x0010
 

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
 

Macro Definition Documentation

◆ PGPA_FB_CONFLICTING

#define PGPA_FB_CONFLICTING   0x0008

Definition at line 44 of file pg_plan_advice.h.

◆ PGPA_FB_FAILED

#define PGPA_FB_FAILED   0x0010

Definition at line 45 of file pg_plan_advice.h.

◆ PGPA_FB_INAPPLICABLE

#define PGPA_FB_INAPPLICABLE   0x0004

Definition at line 43 of file pg_plan_advice.h.

◆ PGPA_FB_MATCH_FULL

#define PGPA_FB_MATCH_FULL   0x0002

Definition at line 42 of file pg_plan_advice.h.

◆ PGPA_FB_MATCH_PARTIAL

#define PGPA_FB_MATCH_PARTIAL   0x0001

Definition at line 41 of file pg_plan_advice.h.

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 48 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 208 of file pg_plan_advice.c.

209{
210 MemoryContext oldcontext;
211
214 MemoryContextSwitchTo(oldcontext);
215}
List * lappend(List *list, void *datum)
Definition list.c:339
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition palloc.h:138
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 146 of file pg_plan_advice.c.

147{
150 "pg_plan_advice",
152
153 return pgpa_memory_context;
154}
MemoryContext TopMemoryContext
Definition mcxt.c:167
#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 173 of file pg_plan_advice.c.

178{
179 ListCell *lc;
180
181 /*
182 * If any advisors are loaded, consult them. The first one that produces a
183 * non-NULL string wins.
184 */
185 foreach(lc, advisor_hook_list)
186 {
188 char *advice_string;
189
190 advice_string = (*hook) (glob, parse, query_string, cursorOptions, es);
191 if (advice_string != NULL)
192 return advice_string;
193 }
194
195 /* Otherwise, just use the value of the GUC. */
197}
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 221 of file pg_plan_advice.c.

222{
223 MemoryContext oldcontext;
224
227 MemoryContextSwitchTo(oldcontext);
228}
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 245 of file pg_plan_advice.c.

246{
247 if (activate)
249 else
250 {
253 }
254}
#define Assert(condition)
Definition c.h:1002
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 160 of file pg_plan_advice.c.

161{
162 bool *plan_advice = NULL;
163
164 if (es != NULL)
166 return plan_advice != NULL && *plan_advice;
167}
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 37 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 38 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 40 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