|
PostgreSQL Source Code git master
|
#include "postgres.h"#include "common/hashfn.h"#include "common/string.h"#include "nodes/queryjumble.h"#include "pg_plan_advice.h"#include "pg_stash_advice.h"#include "storage/dsm_registry.h"#include "utils/guc.h"#include "utils/memutils.h"#include "lib/simplehash.h"
Go to the source code of this file.
Macros | |
| #define | SH_PREFIX pgsa_stash_name_table |
| #define | SH_ELEMENT_TYPE pgsa_stash_name |
| #define | SH_KEY_TYPE uint64 |
| #define | SH_KEY pgsa_stash_id |
| #define | SH_HASH_KEY(tb, key) hash_bytes((const unsigned char *) &(key), sizeof(uint64)) |
| #define | SH_EQUAL(tb, a, b) (a == b) |
| #define | SH_SCOPE extern |
| #define | SH_DEFINE |
Functions | |
| static char * | pgsa_advisor (PlannerGlobal *glob, Query *parse, const char *query_string, int cursorOptions, ExplainState *es) |
| static bool | pgsa_check_stash_name_guc (char **newval, void **extra, GucSource source) |
| static void | pgsa_init_shared_state (void *ptr, void *arg) |
| static bool | pgsa_is_identifier (char *str) |
| void | _PG_init (void) |
| void | pgsa_attach (void) |
| void | pgsa_check_stash_name (char *stash_name) |
| void | pgsa_create_stash (char *stash_name) |
| void | pgsa_clear_advice_string (char *stash_name, int64 queryId) |
| void | pgsa_drop_stash (char *stash_name) |
| uint64 | pgsa_lookup_stash_id (char *stash_name) |
| void | pgsa_set_advice_string (char *stash_name, int64 queryId, char *advice_string) |
| #define SH_DEFINE |
Definition at line 75 of file pg_stash_advice.c.
| #define SH_ELEMENT_TYPE pgsa_stash_name |
Definition at line 69 of file pg_stash_advice.c.
Definition at line 72 of file pg_stash_advice.c.
| #define SH_KEY pgsa_stash_id |
Definition at line 71 of file pg_stash_advice.c.
Definition at line 70 of file pg_stash_advice.c.
| #define SH_PREFIX pgsa_stash_name_table |
Definition at line 68 of file pg_stash_advice.c.
Definition at line 74 of file pg_stash_advice.c.
Definition at line 82 of file pg_stash_advice.c.
References DefineCustomStringVariable(), EnableQueryId(), fb(), load_external_function(), MarkGUCPrefixReserved(), pg_stash_advice_stash_name, PGC_USERSET, pgsa_advisor(), and pgsa_check_stash_name_guc().
|
static |
Definition at line 115 of file pg_stash_advice.c.
References pgsa_entry::advice_string, DEBUG2, dsa_get_address(), dshash_find(), dshash_release_lock(), elog, fb(), InvalidDsaPointer, parse(), pg_stash_advice_stash_name, pgsa_attach(), pgsa_dsa_area, pgsa_entry_dshash, pgsa_lookup_stash_id(), pstrdup(), and unlikely.
Referenced by _PG_init().
Definition at line 182 of file pg_stash_advice.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, pgsa_shared_state::area, dsa_attach(), dsa_create, dsa_get_handle(), DSA_HANDLE_INVALID, dsa_pin(), dsa_pin_mapping(), pgsa_shared_state::dsa_tranche, dshash_attach(), dshash_create(), dshash_get_hash_table_handle(), DSHASH_HANDLE_INVALID, pgsa_shared_state::entry_hash, pgsa_shared_state::entry_tranche, fb(), GetNamedDSMSegment(), pgsa_shared_state::lock, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MemoryContextSwitchTo(), pg_stash_advice_mcxt, pgsa_dsa_area, pgsa_entry_dshash, pgsa_entry_dshash_parameters, pgsa_init_shared_state(), pgsa_stash_dshash, pgsa_stash_dshash_parameters, pgsa_state, pgsa_shared_state::stash_hash, pgsa_shared_state::stash_tranche, TopMemoryContext, and dshash_parameters::tranche_id.
Referenced by pg_create_advice_stash(), pg_drop_advice_stash(), pg_get_advice_stash_contents(), pg_get_advice_stashes(), pg_set_stashed_advice(), and pgsa_advisor().
Definition at line 288 of file pg_stash_advice.c.
References ereport, errcode(), errmsg, ERROR, fb(), NAMEDATALEN, pg_is_ascii(), and pgsa_is_identifier().
Referenced by pg_create_advice_stash(), pg_drop_advice_stash(), pg_get_advice_stash_contents(), and pg_set_stashed_advice().
Definition at line 328 of file pg_stash_advice.c.
References fb(), GUC_check_errcode(), GUC_check_errdetail, NAMEDATALEN, newval, pg_is_ascii(), and pgsa_is_identifier().
Referenced by _PG_init().
Definition at line 392 of file pg_stash_advice.c.
References pgsa_entry::advice_string, Assert, dsa_free(), dshash_delete_entry(), dshash_find(), ereport, errcode(), errmsg, ERROR, fb(), InvalidDsaPointer, pgsa_shared_state::lock, LWLockHeldByMe(), pgsa_dsa_area, pgsa_entry_dshash, pgsa_lookup_stash_id(), and pgsa_state.
Referenced by pg_set_stashed_advice().
Definition at line 371 of file pg_stash_advice.c.
References Assert, dshash_find_or_insert, dshash_release_lock(), ereport, errcode(), errmsg, ERROR, fb(), pgsa_shared_state::lock, LW_EXCLUSIVE, LWLockHeldByMeInMode(), pgsa_shared_state::next_stash_id, pgsa_stash_dshash, and pgsa_state.
Referenced by pg_create_advice_stash().
Definition at line 432 of file pg_stash_advice.c.
References pgsa_entry::advice_string, Assert, dsa_free(), dshash_delete_current(), dshash_delete_entry(), dshash_find(), dshash_seq_init(), dshash_seq_next(), dshash_seq_term(), ereport, errcode(), errmsg, ERROR, fb(), InvalidDsaPointer, pgsa_entry::key, pgsa_shared_state::lock, LW_EXCLUSIVE, LWLockHeldByMeInMode(), pgsa_dsa_area, pgsa_entry_dshash, pgsa_stash_dshash, pgsa_entry_key::pgsa_stash_id, and pgsa_state.
Referenced by pg_drop_advice_stash().
Definition at line 473 of file pg_stash_advice.c.
References DSA_HANDLE_INVALID, DSHASH_HANDLE_INVALID, LWLockInitialize(), LWLockNewTrancheId(), and UINT64CONST.
Referenced by pgsa_attach().
Definition at line 493 of file pg_stash_advice.c.
References str.
Referenced by pgsa_check_stash_name(), and pgsa_check_stash_name_guc().
Definition at line 516 of file pg_stash_advice.c.
References dshash_find(), dshash_release_lock(), fb(), and pgsa_stash_dshash.
Referenced by pg_get_advice_stash_contents(), pgsa_advisor(), pgsa_clear_advice_string(), and pgsa_set_advice_string().
Definition at line 535 of file pg_stash_advice.c.
References pgsa_entry::advice_string, Assert, dsa_allocate, dsa_free(), dsa_get_address(), DsaPointerIsValid, dshash_find_or_insert_extended(), DSHASH_INSERT_NO_OOM, dshash_release_lock(), ereport, errcode(), errdetail(), errmsg, ERROR, fb(), InvalidDsaPointer, pgsa_shared_state::lock, LWLockHeldByMe(), pgsa_dsa_area, pgsa_entry_dshash, pgsa_lookup_stash_id(), and pgsa_state.
Referenced by pg_set_stashed_advice().
| PG_MODULE_MAGIC |
Definition at line 23 of file pg_stash_advice.c.
|
static |
Definition at line 54 of file pg_stash_advice.c.
Referenced by pgsa_attach().
|
static |
Definition at line 45 of file pg_stash_advice.c.
Referenced by _PG_init(), and pgsa_advisor().
| dsa_area* pgsa_dsa_area |
Definition at line 49 of file pg_stash_advice.c.
Referenced by pg_get_advice_stash_contents(), pgsa_advisor(), pgsa_attach(), pgsa_clear_advice_string(), pgsa_drop_stash(), and pgsa_set_advice_string().
| dshash_table* pgsa_entry_dshash |
Definition at line 51 of file pg_stash_advice.c.
Referenced by pg_create_advice_stash(), pg_drop_advice_stash(), pg_get_advice_stash_contents(), pg_get_advice_stashes(), pg_set_stashed_advice(), pgsa_advisor(), pgsa_attach(), pgsa_clear_advice_string(), pgsa_drop_stash(), and pgsa_set_advice_string().
|
static |
Definition at line 35 of file pg_stash_advice.c.
Referenced by pgsa_attach().
| dshash_table* pgsa_stash_dshash |
Definition at line 50 of file pg_stash_advice.c.
Referenced by pg_get_advice_stash_contents(), pg_get_advice_stashes(), pgsa_attach(), pgsa_create_stash(), pgsa_drop_stash(), and pgsa_lookup_stash_id().
|
static |
Definition at line 26 of file pg_stash_advice.c.
Referenced by pgsa_attach().
| pgsa_shared_state* pgsa_state |
Definition at line 48 of file pg_stash_advice.c.
Referenced by pg_create_advice_stash(), pg_drop_advice_stash(), pg_set_stashed_advice(), pgsa_attach(), pgsa_clear_advice_string(), pgsa_create_stash(), pgsa_drop_stash(), and pgsa_set_advice_string().