PostgreSQL Source Code git master
Loading...
Searching...
No Matches
pg_plan_advice.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * pg_plan_advice.h
4 * main header file for pg_plan_advice contrib module
5 *
6 * Copyright (c) 2016-2026, PostgreSQL Global Development Group
7 *
8 * contrib/pg_plan_advice/pg_plan_advice.h
9 *
10 *-------------------------------------------------------------------------
11 */
12#ifndef PG_PLAN_ADVICE_H
13#define PG_PLAN_ADVICE_H
14
16#include "nodes/pathnodes.h"
17
18/*
19 * Flags used in plan advice feedback.
20 *
21 * PGPA_FB_MATCH_PARTIAL means that we found some part of the query that at
22 * least partially matched the target; e.g. given JOIN_ORDER(a b), this would
23 * be set if we ever saw any joinrel including either "a" or "b".
24 *
25 * PGPA_FB_MATCH_FULL means that we found an exact match for the target; e.g.
26 * given JOIN_ORDER(a b), this would be set if we saw a joinrel containing
27 * exactly "a" and "b" and nothing else.
28 *
29 * PGPA_FB_INAPPLICABLE means that the advice doesn't properly apply to the
30 * target; e.g. INDEX_SCAN(foo bar_idx) would be so marked if bar_idx does not
31 * exist on foo. The fact that this bit has been set does not mean that the
32 * advice had no effect.
33 *
34 * PGPA_FB_CONFLICTING means that a conflict was detected between what this
35 * advice wants and what some other plan advice wants; e.g. JOIN_ORDER(a b)
36 * would conflict with HASH_JOIN(a), because the former requires "a" to be the
37 * outer table while the latter requires it to be the inner table.
38 *
39 * PGPA_FB_FAILED means that the resulting plan did not conform to the advice.
40 */
41#define PGPA_FB_MATCH_PARTIAL 0x0001
42#define PGPA_FB_MATCH_FULL 0x0002
43#define PGPA_FB_INAPPLICABLE 0x0004
44#define PGPA_FB_CONFLICTING 0x0008
45#define PGPA_FB_FAILED 0x0010
46
47/* Hook for other plugins to supply advice strings */
48typedef char *(*pg_plan_advice_advisor_hook) (PlannerGlobal *glob,
49 Query *parse,
50 const char *query_string,
51 int cursorOptions,
52 ExplainState *es);
53
54/* GUC variables */
55extern char *pg_plan_advice_advice;
59
60/* Function prototypes (for use by pg_plan_advice itself) */
64 Query *parse,
65 const char *query_string,
66 int cursorOptions,
67 ExplainState *es);
68
69/* Function prototypes (for use by other plugins) */
73
74#endif
#define PGDLLEXPORT
Definition c.h:1436
void parse(int)
Definition parse.c:49
PGDLLEXPORT void pg_plan_advice_request_advice_generation(bool activate)
PGDLLEXPORT void pg_plan_advice_remove_advisor(pg_plan_advice_advisor_hook hook)
char * pg_plan_advice_advice
MemoryContext pg_plan_advice_get_mcxt(void)
bool pg_plan_advice_trace_mask
bool pg_plan_advice_always_store_advice_details
bool pg_plan_advice_should_explain(ExplainState *es)
char * pg_plan_advice_get_supplied_query_advice(PlannerGlobal *glob, Query *parse, const char *query_string, int cursorOptions, ExplainState *es)
char *(* pg_plan_advice_advisor_hook)(PlannerGlobal *glob, Query *parse, const char *query_string, int cursorOptions, ExplainState *es)
bool pg_plan_advice_feedback_warnings
PGDLLEXPORT void pg_plan_advice_add_advisor(pg_plan_advice_advisor_hook hook)
static int fb(int x)