PostgreSQL Source Code git master
Loading...
Searching...
No Matches
pg_stash_advice.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * pg_stash_advice.h
4 * main header for pg_stash_advice contrib module
5 *
6 * This module allows plan advice strings (as used and generated by
7 * pg_plan_advice) to be "stashed" in dynamic shared memory and, from
8 * there, automatically be applied to queries as they are planned.
9 * You can create any number of advice stashes, each of which is
10 * identified by a human-readable, ASCII identifier, and each of them is
11 * essentially a query ID -> advice_string mapping.
12 *
13 * Copyright (c) 2016-2026, PostgreSQL Global Development Group
14 *
15 * contrib/pg_stash_advice/pg_stash_advice.h
16 *
17 *-------------------------------------------------------------------------
18 */
19#ifndef PG_STASH_ADVICE_H
20#define PG_STASH_ADVICE_H
21
22#include "lib/dshash.h"
23#include "storage/lwlock.h"
24
25/*
26 * The key that we use to find a particular stash entry.
27 */
33
34/*
35 * A single stash entry.
36 */
42
43/*
44 * The stash itself is just a mapping from a name to a stash ID.
45 */
51
52/*
53 * Top-level shared state object for pg_stash_advice.
54 */
66
67/* For stash ID -> stash name hash table */
74
75/* Declare stash ID -> stash name hash table */
76#define SH_PREFIX pgsa_stash_name_table
77#define SH_ELEMENT_TYPE pgsa_stash_name
78#define SH_KEY_TYPE uint64
79#define SH_SCOPE extern
80#define SH_DECLARE
81#include "lib/simplehash.h"
82
83/* Shared memory pointers */
88
89/* Function prototypes */
90extern void pgsa_attach(void);
91extern void pgsa_check_stash_name(char *stash_name);
92extern void pgsa_clear_advice_string(char *stash_name, int64 queryId);
93extern void pgsa_create_stash(char *stash_name);
94extern void pgsa_drop_stash(char *stash_name);
96extern void pgsa_set_advice_string(char *stash_name, int64 queryId,
97 char *advice_string);
98
99#endif
int64_t int64
Definition c.h:621
uint64_t uint64
Definition c.h:625
uint32_t uint32
Definition c.h:624
uint64 dsa_pointer
Definition dsa.h:62
dsm_handle dsa_handle
Definition dsa.h:136
dsa_pointer dshash_table_handle
Definition dshash.h:24
#define NAMEDATALEN
dshash_table * pgsa_entry_dshash
dshash_table * pgsa_stash_dshash
void pgsa_create_stash(char *stash_name)
void pgsa_drop_stash(char *stash_name)
void pgsa_set_advice_string(char *stash_name, int64 queryId, char *advice_string)
dsa_area * pgsa_dsa_area
uint64 pgsa_lookup_stash_id(char *stash_name)
void pgsa_attach(void)
void pgsa_check_stash_name(char *stash_name)
pgsa_shared_state * pgsa_state
void pgsa_clear_advice_string(char *stash_name, int64 queryId)
static int fb(int x)
int64 queryId
uint64 pgsa_stash_id
pgsa_entry_key key
dsa_pointer advice_string
dshash_table_handle entry_hash
dshash_table_handle stash_hash
char name[NAMEDATALEN]
uint64 pgsa_stash_id