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

206{
207 MemoryContext oldcontext;
208
211 MemoryContextSwitchTo(oldcontext);
212}
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 143 of file pg_plan_advice.c.

144{
147 "pg_plan_advice",
149
150 return pgpa_memory_context;
151}
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 170 of file pg_plan_advice.c.

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

219{
220 MemoryContext oldcontext;
221
224 MemoryContextSwitchTo(oldcontext);
225}
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 242 of file pg_plan_advice.c.

243{
244 if (activate)
246 else
247 {
250 }
251}
#define Assert(condition)
Definition c.h:943
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 157 of file pg_plan_advice.c.

158{
159 bool *plan_advice = NULL;
160
161 if (es != NULL)
163 return plan_advice != NULL && *plan_advice;
164}
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