PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <math.h>
#include <sys/stat.h>
#include <unistd.h>
#include "catalog/pg_authid.h"
#include "common/hashfn.h"
#include "executor/instrument.h"
#include "funcapi.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "optimizer/planner.h"
#include "parser/analyze.h"
#include "parser/parsetree.h"
#include "parser/scanner.h"
#include "parser/scansup.h"
#include "pgstat.h"
#include "storage/fd.h"
#include "storage/ipc.h"
#include "storage/spin.h"
#include "tcop/utility.h"
#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/memutils.h"
#include "utils/timestamp.h"
Go to the source code of this file.
Data Structures | |
struct | pgssHashKey |
struct | Counters |
struct | pgssGlobalStats |
struct | pgssEntry |
struct | pgssSharedState |
struct | pgssLocationLen |
struct | pgssJumbleState |
Macros | |
#define | PGSS_DUMP_FILE PGSTAT_STAT_PERMANENT_DIRECTORY "/pg_stat_statements.stat" |
#define | PGSS_TEXT_FILE PG_STAT_TMP_DIR "/pgss_query_texts.stat" |
#define | USAGE_EXEC(duration) (1.0) |
#define | USAGE_INIT (1.0) /* including initial planning */ |
#define | ASSUMED_MEDIAN_INIT (10.0) /* initial assumed median usage */ |
#define | ASSUMED_LENGTH_INIT 1024 /* initial assumed mean query length */ |
#define | USAGE_DECREASE_FACTOR (0.99) /* decreased every entry_dealloc */ |
#define | STICKY_DECREASE_FACTOR (0.50) /* factor for sticky entries */ |
#define | USAGE_DEALLOC_PERCENT 5 /* free this % of entries at once */ |
#define | IS_STICKY(c) ((c.calls[PGSS_PLAN] + c.calls[PGSS_EXEC]) == 0) |
#define | JUMBLE_SIZE 1024 /* query serialization buffer size */ |
#define | pgss_enabled(level) |
#define | record_gc_qtexts() |
#define | PG_STAT_STATEMENTS_COLS_V1_0 14 |
#define | PG_STAT_STATEMENTS_COLS_V1_1 18 |
#define | PG_STAT_STATEMENTS_COLS_V1_2 19 |
#define | PG_STAT_STATEMENTS_COLS_V1_3 23 |
#define | PG_STAT_STATEMENTS_COLS_V1_8 32 |
#define | PG_STAT_STATEMENTS_COLS 32 /* maximum of above */ |
#define | PG_STAT_STATEMENTS_INFO_COLS 2 |
#define | APP_JUMB(item) AppendJumble(jstate, (const unsigned char *) &(item), sizeof(item)) |
#define | APP_JUMB_STRING(str) AppendJumble(jstate, (const unsigned char *) (str), strlen(str) + 1) |
Typedefs | |
typedef enum pgssVersion | pgssVersion |
typedef enum pgssStoreKind | pgssStoreKind |
typedef struct pgssHashKey | pgssHashKey |
typedef struct Counters | Counters |
typedef struct pgssGlobalStats | pgssGlobalStats |
typedef struct pgssEntry | pgssEntry |
typedef struct pgssSharedState | pgssSharedState |
typedef struct pgssLocationLen | pgssLocationLen |
typedef struct pgssJumbleState | pgssJumbleState |
Enumerations | |
enum | pgssVersion { PGSS_V1_0 = 0, PGSS_V1_1, PGSS_V1_2, PGSS_V1_3, PGSS_V1_8 } |
enum | pgssStoreKind { PGSS_INVALID = -1, PGSS_PLAN = 0, PGSS_EXEC, PGSS_NUMKIND } |
enum | PGSSTrackLevel { PGSS_TRACK_NONE, PGSS_TRACK_TOP, PGSS_TRACK_ALL } |
Functions | |
void | _PG_init (void) |
void | _PG_fini (void) |
PG_FUNCTION_INFO_V1 (pg_stat_statements_reset) | |
PG_FUNCTION_INFO_V1 (pg_stat_statements_reset_1_7) | |
PG_FUNCTION_INFO_V1 (pg_stat_statements_1_2) | |
PG_FUNCTION_INFO_V1 (pg_stat_statements_1_3) | |
PG_FUNCTION_INFO_V1 (pg_stat_statements_1_8) | |
PG_FUNCTION_INFO_V1 (pg_stat_statements) | |
PG_FUNCTION_INFO_V1 (pg_stat_statements_info) | |
static void | pgss_shmem_startup (void) |
static void | pgss_shmem_shutdown (int code, Datum arg) |
static void | pgss_post_parse_analyze (ParseState *pstate, Query *query) |
static PlannedStmt * | pgss_planner (Query *parse, const char *query_string, int cursorOptions, ParamListInfo boundParams) |
static void | pgss_ExecutorStart (QueryDesc *queryDesc, int eflags) |
static void | pgss_ExecutorRun (QueryDesc *queryDesc, ScanDirection direction, uint64 count, bool execute_once) |
static void | pgss_ExecutorFinish (QueryDesc *queryDesc) |
static void | pgss_ExecutorEnd (QueryDesc *queryDesc) |
static void | pgss_ProcessUtility (PlannedStmt *pstmt, const char *queryString, ProcessUtilityContext context, ParamListInfo params, QueryEnvironment *queryEnv, DestReceiver *dest, QueryCompletion *qc) |
static uint64 | pgss_hash_string (const char *str, int len) |
static void | pgss_store (const char *query, uint64 queryId, int query_location, int query_len, pgssStoreKind kind, double total_time, uint64 rows, const BufferUsage *bufusage, const WalUsage *walusage, pgssJumbleState *jstate) |
static void | pg_stat_statements_internal (FunctionCallInfo fcinfo, pgssVersion api_version, bool showtext) |
static Size | pgss_memsize (void) |
static pgssEntry * | entry_alloc (pgssHashKey *key, Size query_offset, int query_len, int encoding, bool sticky) |
static void | entry_dealloc (void) |
static bool | qtext_store (const char *query, int query_len, Size *query_offset, int *gc_count) |
static char * | qtext_load_file (Size *buffer_size) |
static char * | qtext_fetch (Size query_offset, int query_len, char *buffer, Size buffer_size) |
static bool | need_gc_qtexts (void) |
static void | gc_qtexts (void) |
static void | entry_reset (Oid userid, Oid dbid, uint64 queryid) |
static void | AppendJumble (pgssJumbleState *jstate, const unsigned char *item, Size size) |
static void | JumbleQuery (pgssJumbleState *jstate, Query *query) |
static void | JumbleRangeTable (pgssJumbleState *jstate, List *rtable) |
static void | JumbleRowMarks (pgssJumbleState *jstate, List *rowMarks) |
static void | JumbleExpr (pgssJumbleState *jstate, Node *node) |
static void | RecordConstLocation (pgssJumbleState *jstate, int location) |
static char * | generate_normalized_query (pgssJumbleState *jstate, const char *query, int query_loc, int *query_len_p) |
static void | fill_in_constant_lengths (pgssJumbleState *jstate, const char *query, int query_loc) |
static int | comp_location (const void *a, const void *b) |
Datum | pg_stat_statements_reset_1_7 (PG_FUNCTION_ARGS) |
Datum | pg_stat_statements_reset (PG_FUNCTION_ARGS) |
Datum | pg_stat_statements_1_8 (PG_FUNCTION_ARGS) |
Datum | pg_stat_statements_1_3 (PG_FUNCTION_ARGS) |
Datum | pg_stat_statements_1_2 (PG_FUNCTION_ARGS) |
Datum | pg_stat_statements (PG_FUNCTION_ARGS) |
Datum | pg_stat_statements_info (PG_FUNCTION_ARGS) |
static int | entry_cmp (const void *lhs, const void *rhs) |
Variables | |
PG_MODULE_MAGIC | |
static const uint32 | PGSS_FILE_HEADER = 0x20201218 |
static const uint32 | PGSS_PG_MAJOR_VERSION = PG_VERSION_NUM / 100 |
static int | exec_nested_level = 0 |
static int | plan_nested_level = 0 |
static shmem_startup_hook_type | prev_shmem_startup_hook = NULL |
static post_parse_analyze_hook_type | prev_post_parse_analyze_hook = NULL |
static planner_hook_type | prev_planner_hook = NULL |
static ExecutorStart_hook_type | prev_ExecutorStart = NULL |
static ExecutorRun_hook_type | prev_ExecutorRun = NULL |
static ExecutorFinish_hook_type | prev_ExecutorFinish = NULL |
static ExecutorEnd_hook_type | prev_ExecutorEnd = NULL |
static ProcessUtility_hook_type | prev_ProcessUtility = NULL |
static pgssSharedState * | pgss = NULL |
static HTAB * | pgss_hash = NULL |
static const struct config_enum_entry | track_options [] |
static int | pgss_max |
static int | pgss_track |
static bool | pgss_track_utility |
static bool | pgss_track_planning |
static bool | pgss_save |
#define APP_JUMB | ( | item | ) | AppendJumble(jstate, (const unsigned char *) &(item), sizeof(item)) |
Definition at line 2671 of file pg_stat_statements.c.
Referenced by JumbleExpr(), JumbleQuery(), JumbleRangeTable(), and JumbleRowMarks().
#define APP_JUMB_STRING | ( | str | ) | AppendJumble(jstate, (const unsigned char *) (str), strlen(str) + 1) |
Definition at line 2673 of file pg_stat_statements.c.
Referenced by JumbleExpr(), and JumbleRangeTable().
#define ASSUMED_LENGTH_INIT 1024 /* initial assumed mean query length */ |
Definition at line 111 of file pg_stat_statements.c.
Referenced by entry_dealloc(), gc_qtexts(), and pgss_shmem_startup().
#define ASSUMED_MEDIAN_INIT (10.0) /* initial assumed median usage */ |
Definition at line 110 of file pg_stat_statements.c.
Referenced by pgss_shmem_startup().
Definition at line 115 of file pg_stat_statements.c.
Referenced by entry_dealloc(), pg_stat_statements_internal(), pgss_shmem_startup(), and pgss_store().
#define JUMBLE_SIZE 1024 /* query serialization buffer size */ |
Definition at line 117 of file pg_stat_statements.c.
Referenced by AppendJumble(), and pgss_post_parse_analyze().
#define PG_STAT_STATEMENTS_COLS 32 /* maximum of above */ |
Definition at line 1514 of file pg_stat_statements.c.
Referenced by pg_stat_statements_internal().
#define PG_STAT_STATEMENTS_COLS_V1_0 14 |
Definition at line 1509 of file pg_stat_statements.c.
Referenced by pg_stat_statements_internal().
#define PG_STAT_STATEMENTS_COLS_V1_1 18 |
Definition at line 1510 of file pg_stat_statements.c.
Referenced by pg_stat_statements_internal().
#define PG_STAT_STATEMENTS_COLS_V1_2 19 |
Definition at line 1511 of file pg_stat_statements.c.
Referenced by pg_stat_statements_internal().
#define PG_STAT_STATEMENTS_COLS_V1_3 23 |
Definition at line 1512 of file pg_stat_statements.c.
Referenced by pg_stat_statements_internal().
#define PG_STAT_STATEMENTS_COLS_V1_8 32 |
Definition at line 1513 of file pg_stat_statements.c.
Referenced by pg_stat_statements_internal().
#define PG_STAT_STATEMENTS_INFO_COLS 2 |
Definition at line 1888 of file pg_stat_statements.c.
Referenced by pg_stat_statements_info().
#define PGSS_DUMP_FILE PGSTAT_STAT_PERMANENT_DIRECTORY "/pg_stat_statements.stat" |
Definition at line 89 of file pg_stat_statements.c.
Referenced by pgss_shmem_shutdown(), and pgss_shmem_startup().
#define pgss_enabled | ( | level | ) |
Definition at line 318 of file pg_stat_statements.c.
Referenced by pgss_ExecutorEnd(), pgss_ExecutorStart(), pgss_planner(), pgss_post_parse_analyze(), and pgss_ProcessUtility().
#define PGSS_TEXT_FILE PG_STAT_TMP_DIR "/pgss_query_texts.stat" |
Definition at line 99 of file pg_stat_statements.c.
Referenced by entry_reset(), gc_qtexts(), pgss_shmem_shutdown(), pgss_shmem_startup(), qtext_load_file(), and qtext_store().
#define record_gc_qtexts | ( | ) |
Definition at line 322 of file pg_stat_statements.c.
Referenced by entry_reset(), and gc_qtexts().
#define STICKY_DECREASE_FACTOR (0.50) /* factor for sticky entries */ |
Definition at line 113 of file pg_stat_statements.c.
Referenced by entry_dealloc().
#define USAGE_DEALLOC_PERCENT 5 /* free this % of entries at once */ |
Definition at line 114 of file pg_stat_statements.c.
Referenced by entry_dealloc().
#define USAGE_DECREASE_FACTOR (0.99) /* decreased every entry_dealloc */ |
Definition at line 112 of file pg_stat_statements.c.
Referenced by entry_dealloc().
#define USAGE_EXEC | ( | duration | ) | (1.0) |
Definition at line 108 of file pg_stat_statements.c.
Referenced by pgss_store().
#define USAGE_INIT (1.0) /* including initial planning */ |
Definition at line 109 of file pg_stat_statements.c.
Referenced by entry_alloc(), and pgss_store().
typedef struct pgssGlobalStats pgssGlobalStats |
typedef struct pgssHashKey pgssHashKey |
typedef struct pgssJumbleState pgssJumbleState |
typedef struct pgssLocationLen pgssLocationLen |
typedef struct pgssSharedState pgssSharedState |
typedef enum pgssStoreKind pgssStoreKind |
typedef enum pgssVersion pgssVersion |
enum pgssStoreKind |
Enumerator | |
---|---|
PGSS_INVALID | |
PGSS_PLAN | |
PGSS_EXEC | |
PGSS_NUMKIND |
Definition at line 131 of file pg_stat_statements.c.
enum PGSSTrackLevel |
Enumerator | |
---|---|
PGSS_TRACK_NONE | |
PGSS_TRACK_TOP | |
PGSS_TRACK_ALL |
Definition at line 296 of file pg_stat_statements.c.
enum pgssVersion |
Enumerator | |
---|---|
PGSS_V1_0 | |
PGSS_V1_1 | |
PGSS_V1_2 | |
PGSS_V1_3 | |
PGSS_V1_8 |
Definition at line 122 of file pg_stat_statements.c.
void _PG_fini | ( | void | ) |
Definition at line 510 of file pg_stat_statements.c.
References ExecutorEnd_hook, ExecutorFinish_hook, ExecutorRun_hook, ExecutorStart_hook, planner_hook, post_parse_analyze_hook, prev_ExecutorEnd, prev_ExecutorFinish, prev_ExecutorRun, prev_ExecutorStart, prev_planner_hook, prev_post_parse_analyze_hook, prev_ProcessUtility, prev_shmem_startup_hook, ProcessUtility_hook, and shmem_startup_hook.
void _PG_init | ( | void | ) |
Definition at line 401 of file pg_stat_statements.c.
References DefineCustomBoolVariable(), DefineCustomEnumVariable(), DefineCustomIntVariable(), EmitWarningsOnPlaceholders(), ExecutorEnd_hook, ExecutorFinish_hook, ExecutorRun_hook, ExecutorStart_hook, PGC_POSTMASTER, PGC_SIGHUP, PGC_SUSET, pgss_ExecutorEnd(), pgss_ExecutorFinish(), pgss_ExecutorRun(), pgss_ExecutorStart(), pgss_max, pgss_memsize(), pgss_planner(), pgss_post_parse_analyze(), pgss_ProcessUtility(), pgss_save, pgss_shmem_startup(), pgss_track, pgss_track_planning, PGSS_TRACK_TOP, pgss_track_utility, planner_hook, post_parse_analyze_hook, prev_ExecutorEnd, prev_ExecutorFinish, prev_ExecutorRun, prev_ExecutorStart, prev_planner_hook, prev_post_parse_analyze_hook, prev_ProcessUtility, prev_shmem_startup_hook, process_shared_preload_libraries_in_progress, ProcessUtility_hook, RequestAddinShmemSpace(), RequestNamedLWLockTranche(), and shmem_startup_hook.
|
static |
Definition at line 2635 of file pg_stat_statements.c.
References DatumGetUInt64, hash_any_extended(), pgssJumbleState::jumble, pgssJumbleState::jumble_len, JUMBLE_SIZE, and Min.
|
static |
Definition at line 3529 of file pg_stat_statements.c.
Referenced by fill_in_constant_lengths().
|
static |
Definition at line 1960 of file pg_stat_statements.c.
References Assert, pgssEntry::counters, pgssSharedState::cur_median_usage, encoding, pgssEntry::encoding, entry_dealloc(), HASH_ENTER, hash_get_num_entries(), hash_search(), pgssEntry::mutex, pgss_max, pgssEntry::query_len, pgssEntry::query_offset, SpinLockInit, Counters::usage, and USAGE_INIT.
Referenced by pgss_shmem_startup(), and pgss_store().
|
static |
Definition at line 1997 of file pg_stat_statements.c.
Referenced by entry_dealloc().
|
static |
Definition at line 2016 of file pg_stat_statements.c.
References ASSUMED_LENGTH_INIT, pgssEntry::counters, pgssSharedState::cur_median_usage, pgssGlobalStats::dealloc, entry_cmp(), hash_get_num_entries(), HASH_REMOVE, hash_search(), hash_seq_init(), hash_seq_search(), i, IS_STICKY, sort-test::key, Max, pgssSharedState::mean_query_len, Min, pgssSharedState::mutex, palloc(), pfree(), qsort, pgssEntry::query_len, SpinLockAcquire, SpinLockRelease, pgssSharedState::stats, STICKY_DECREASE_FACTOR, Counters::usage, USAGE_DEALLOC_PERCENT, and USAGE_DECREASE_FACTOR.
Referenced by entry_alloc().
Definition at line 2525 of file pg_stat_statements.c.
References AllocateFile(), pgssHashKey::dbid, pgssGlobalStats::dealloc, ereport, errcode(), errcode_for_file_access(), errmsg(), ERROR, pgssSharedState::extent, FreeFile(), ftruncate, GetCurrentTimestamp(), hash_get_num_entries(), HASH_REMOVE, hash_search(), hash_seq_init(), hash_seq_search(), sort-test::key, pgssEntry::key, pgssSharedState::lock, LOG, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), pgssSharedState::mutex, PG_BINARY_W, PGSS_TEXT_FILE, pgssHashKey::queryid, record_gc_qtexts, SpinLockAcquire, SpinLockRelease, pgssSharedState::stats, pgssGlobalStats::stats_reset, and pgssHashKey::userid.
Referenced by pg_stat_statements_reset(), and pg_stat_statements_reset_1_7().
|
static |
Definition at line 3429 of file pg_stat_statements.c.
References Assert, pgssJumbleState::clocations, pgssJumbleState::clocations_count, comp_location(), core_yylex(), core_yy_extra_type::escape_string_warning, i, pgssLocationLen::length, pgssLocationLen::location, qsort, core_yy_extra_type::scanbuf, ScanKeywords, ScanKeywordTokens, scanner_finish(), scanner_init(), YYLTYPE, and yyscanner.
Referenced by generate_normalized_query().
|
static |
Definition at line 2341 of file pg_stat_statements.c.
References AllocateFile(), ASSUMED_LENGTH_INIT, DEBUG1, elog, ereport, errcode_for_file_access(), errmsg(), pgssSharedState::extent, free, FreeFile(), ftruncate, hash_seq_init(), hash_seq_search(), hash_seq_term(), LOG, pgssSharedState::mean_query_len, need_gc_qtexts(), PG_BINARY_W, PGSS_TEXT_FILE, qtext_fetch(), qtext_load_file(), pgssEntry::query_len, pgssEntry::query_offset, and record_gc_qtexts.
Referenced by pgss_store().
|
static |
Definition at line 3322 of file pg_stat_statements.c.
References Assert, pgssJumbleState::clocations, pgssJumbleState::clocations_count, fill_in_constant_lengths(), pgssJumbleState::highest_extern_param_id, i, pgssLocationLen::length, pgssLocationLen::location, palloc(), and sprintf.
Referenced by pgss_store().
|
static |
Definition at line 2802 of file pg_stat_statements.c.
References OnConflictExpr::action, Aggref::aggdirectargs, Aggref::aggdistinct, Aggref::aggfilter, WindowFunc::aggfilter, Aggref::aggfnoid, Aggref::aggorder, SetOperationStmt::all, APP_JUMB, APP_JUMB_STRING, OnConflictExpr::arbiterElems, OnConflictExpr::arbiterWhere, NamedArgExpr::arg, FieldSelect::arg, FieldStore::arg, RelabelType::arg, CoerceViaIO::arg, ArrayCoerceExpr::arg, ConvertRowtypeExpr::arg, CollateExpr::arg, CaseExpr::arg, NullTest::arg, BooleanTest::arg, CoerceToDomain::arg, NamedArgExpr::argnumber, generate_unaccent_rules::args, Aggref::args, WindowFunc::args, FuncExpr::args, OpExpr::args, ScalarArrayOpExpr::args, BoolExpr::args, CaseExpr::args, MinMaxExpr::args, TableSampleClause::args, XmlExpr::args, BoolExpr::boolop, BooleanTest::booltesttype, castNode, check_stack_depth(), TableFunc::colexprs, CollateExpr::collOid, OnConflictExpr::constraint, Const::consttype, GroupingSet::content, CommonTableExpr::ctematerialized, CommonTableExpr::ctename, CommonTableExpr::ctequery, CurrentOfExpr::cursor_name, CurrentOfExpr::cursor_param, CurrentOfExpr::cvarno, CaseExpr::defresult, TableFunc::docexpr, ArrayCoerceExpr::elemexpr, elog, WindowClause::endOffset, SortGroupClause::eqop, OnConflictExpr::exclRelIndex, OnConflictExpr::exclRelTlist, CaseWhen::expr, InferenceElem::expr, TargetEntry::expr, FieldSelect::fieldnum, WindowClause::frameOptions, FromExpr::fromlist, RangeTblFunction::funcexpr, FuncExpr::funcid, pgssJumbleState::highest_extern_param_id, InferenceElem::infercollid, InferenceElem::inferopclass, JoinExpr::isNatural, JoinExpr::jointype, JumbleQuery(), JoinExpr::larg, SetOperationStmt::larg, RowCompareExpr::largs, lfirst, lfirst_int, lfirst_node, Const::location, XmlExpr::named_args, FieldStore::newvals, nodeTag, SortGroupClause::nulls_first, NullTest::nulltesttype, OnConflictExpr::onConflictSet, OnConflictExpr::onConflictWhere, MinMaxExpr::op, SQLValueFunction::op, XmlExpr::op, SetOperationStmt::op, OpExpr::opno, ScalarArrayOpExpr::opno, WindowClause::orderClause, PARAM_EXTERN, Param::paramid, Param::paramkind, Param::paramtype, WindowClause::partitionClause, JoinExpr::quals, FromExpr::quals, JoinExpr::rarg, SetOperationStmt::rarg, RowCompareExpr::rargs, RowCompareExpr::rctype, RecordConstLocation(), SubscriptingRef::refassgnexpr, SubscriptingRef::refexpr, SubscriptingRef::reflowerindexpr, GroupingFunc::refs, SubscriptingRef::refupperindexpr, TableSampleClause::repeatable, TargetEntry::resno, TargetEntry::ressortgroupref, CaseWhen::result, RelabelType::resulttype, CoerceViaIO::resulttype, ArrayCoerceExpr::resulttype, ConvertRowtypeExpr::resulttype, CoerceToDomain::resulttype, TableFunc::rowexpr, RangeTblRef::rtindex, JoinExpr::rtindex, NextValueExpr::seqid, SortGroupClause::sortop, WindowClause::startOffset, SubLink::subLinkId, SubLink::subLinkType, SubLink::subselect, T_Aggref, T_ArrayCoerceExpr, T_ArrayExpr, T_BooleanTest, T_BoolExpr, T_CaseExpr, T_CaseTestExpr, T_CoalesceExpr, T_CoerceToDomain, T_CoerceToDomainValue, T_CoerceViaIO, T_CollateExpr, T_CommonTableExpr, T_Const, T_ConvertRowtypeExpr, T_CurrentOfExpr, T_DistinctExpr, T_FieldSelect, T_FieldStore, T_FromExpr, T_FuncExpr, T_GroupingFunc, T_GroupingSet, T_InferenceElem, T_IntList, T_JoinExpr, T_List, T_MinMaxExpr, T_NamedArgExpr, T_NextValueExpr, T_NullIfExpr, T_NullTest, T_OnConflictExpr, T_OpExpr, T_Param, T_RangeTblFunction, T_RangeTblRef, T_RelabelType, T_RowCompareExpr, T_RowExpr, T_ScalarArrayOpExpr, T_SetOperationStmt, T_SetToDefault, T_SortGroupClause, T_SQLValueFunction, T_SubLink, T_SubscriptingRef, T_TableFunc, T_TableSampleClause, T_TargetEntry, T_Var, T_WindowClause, T_WindowFunc, T_XmlExpr, SubLink::testexpr, SortGroupClause::tleSortGroupRef, TableSampleClause::tsmhandler, Node::type, CaseTestExpr::typeId, CoerceToDomainValue::typeId, SetToDefault::typeId, NextValueExpr::typeId, SQLValueFunction::typmod, ScalarArrayOpExpr::useOr, Var::varattno, Var::varlevelsup, Var::varno, WARNING, WindowFunc::winfnoid, WindowFunc::winref, and WindowClause::winref.
Referenced by JumbleQuery(), and JumbleRangeTable().
|
static |
Definition at line 2686 of file pg_stat_statements.c.
References APP_JUMB, Assert, Query::commandType, Query::cteList, Query::distinctClause, Query::groupClause, Query::groupingSets, Query::havingQual, IsA, Query::jointree, JumbleExpr(), JumbleRangeTable(), JumbleRowMarks(), Query::limitCount, Query::limitOffset, Query::onConflict, Query::returningList, Query::rowMarks, Query::rtable, Query::setOperations, Query::sortClause, Query::targetList, Query::utilityStmt, and Query::windowClause.
Referenced by JumbleExpr(), JumbleRangeTable(), and pgss_post_parse_analyze().
|
static |
Definition at line 2715 of file pg_stat_statements.c.
References APP_JUMB, APP_JUMB_STRING, RangeTblEntry::ctelevelsup, RangeTblEntry::ctename, elog, RangeTblEntry::enrname, ERROR, RangeTblEntry::functions, RangeTblEntry::jointype, JumbleExpr(), JumbleQuery(), lfirst_node, RangeTblEntry::relid, RTE_CTE, RTE_FUNCTION, RTE_JOIN, RTE_NAMEDTUPLESTORE, RTE_RELATION, RTE_RESULT, RTE_SUBQUERY, RTE_TABLEFUNC, RTE_VALUES, RangeTblEntry::rtekind, RangeTblEntry::subquery, RangeTblEntry::tablefunc, RangeTblEntry::tablesample, and RangeTblEntry::values_lists.
Referenced by JumbleQuery().
|
static |
Definition at line 2770 of file pg_stat_statements.c.
References APP_JUMB, lfirst_node, RowMarkClause::pushedDown, RowMarkClause::rti, RowMarkClause::strength, and RowMarkClause::waitPolicy.
Referenced by JumbleQuery().
|
static |
Definition at line 2294 of file pg_stat_statements.c.
References pgssSharedState::extent, pgssSharedState::mutex, pgss_max, SpinLockAcquire, and SpinLockRelease.
Referenced by gc_qtexts(), and pgss_store().
PG_FUNCTION_INFO_V1 | ( | pg_stat_statements_reset | ) |
PG_FUNCTION_INFO_V1 | ( | pg_stat_statements_reset_1_7 | ) |
PG_FUNCTION_INFO_V1 | ( | pg_stat_statements_1_2 | ) |
PG_FUNCTION_INFO_V1 | ( | pg_stat_statements_1_3 | ) |
PG_FUNCTION_INFO_V1 | ( | pg_stat_statements_1_8 | ) |
PG_FUNCTION_INFO_V1 | ( | pg_stat_statements | ) |
PG_FUNCTION_INFO_V1 | ( | pg_stat_statements_info | ) |
Datum pg_stat_statements | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1561 of file pg_stat_statements.c.
References pg_stat_statements_internal(), and PGSS_V1_0.
Datum pg_stat_statements_1_2 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1547 of file pg_stat_statements.c.
References PG_GETARG_BOOL, pg_stat_statements_internal(), and PGSS_V1_2.
Datum pg_stat_statements_1_3 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1537 of file pg_stat_statements.c.
References PG_GETARG_BOOL, pg_stat_statements_internal(), and PGSS_V1_3.
Datum pg_stat_statements_1_8 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1527 of file pg_stat_statements.c.
References PG_GETARG_BOOL, pg_stat_statements_internal(), and PGSS_V1_8.
Datum pg_stat_statements_info | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1894 of file pg_stat_statements.c.
References pgssGlobalStats::dealloc, elog, ereport, errcode(), errmsg(), ERROR, get_call_result_type(), heap_form_tuple(), HeapTupleGetDatum, Int64GetDatum(), MemSet, pgssSharedState::mutex, PG_RETURN_DATUM, PG_STAT_STATEMENTS_INFO_COLS, SpinLockAcquire, SpinLockRelease, pgssSharedState::stats, pgssGlobalStats::stats_reset, TimestampTzGetDatum, TYPEFUNC_COMPOSITE, and values.
|
static |
Definition at line 1571 of file pg_stat_statements.c.
References ReturnSetInfo::allowedModes, Assert, Counters::blk_read_time, Counters::blk_write_time, buf, Counters::calls, pgssEntry::counters, CStringGetDatum, CStringGetTextDatum, pgssHashKey::dbid, DirectFunctionCall3, ReturnSetInfo::econtext, ExprContext::ecxt_per_query_memory, elog, enc, pgssEntry::encoding, ereport, errcode(), errmsg(), ERROR, pgssSharedState::extent, Float8GetDatumFast, free, pgssSharedState::gc_count, get_call_result_type(), GetUserId(), hash_seq_init(), hash_seq_search(), i, Int32GetDatum, Int64GetDatumFast, is_member_of_role(), IS_STICKY, IsA, pgssEntry::key, Counters::local_blks_dirtied, Counters::local_blks_hit, Counters::local_blks_read, Counters::local_blks_written, pgssSharedState::lock, LW_SHARED, LWLockAcquire(), LWLockRelease(), Counters::max_time, Counters::mean_time, MemoryContextSwitchTo(), Counters::min_time, pgssEntry::mutex, pgssSharedState::mutex, pgssSharedState::n_writers, numeric_in(), ObjectIdGetDatum, pfree(), pg_any_to_server(), PG_STAT_STATEMENTS_COLS, PG_STAT_STATEMENTS_COLS_V1_0, PG_STAT_STATEMENTS_COLS_V1_1, PG_STAT_STATEMENTS_COLS_V1_2, PG_STAT_STATEMENTS_COLS_V1_3, PG_STAT_STATEMENTS_COLS_V1_8, PGSS_EXEC, PGSS_NUMKIND, PGSS_V1_0, PGSS_V1_1, PGSS_V1_2, PGSS_V1_3, PGSS_V1_8, qtext_fetch(), qtext_load_file(), pgssEntry::query_len, pgssEntry::query_offset, pgssHashKey::queryid, FunctionCallInfoBaseData::resultinfo, ReturnSetInfo::returnMode, Counters::rows, ReturnSetInfo::setDesc, ReturnSetInfo::setResult, SFRM_Materialize, Counters::shared_blks_dirtied, Counters::shared_blks_hit, Counters::shared_blks_read, Counters::shared_blks_written, snprintf, SpinLockAcquire, SpinLockRelease, Counters::sum_var_time, Counters::temp_blks_read, Counters::temp_blks_written, Counters::total_time, tuplestore_begin_heap(), tuplestore_donestoring, tuplestore_putvalues(), TYPEFUNC_COMPOSITE, UINT64_FORMAT, pgssHashKey::userid, values, Counters::wal_bytes, Counters::wal_fpi, Counters::wal_records, and work_mem.
Referenced by pg_stat_statements(), pg_stat_statements_1_2(), pg_stat_statements_1_3(), and pg_stat_statements_1_8().
Datum pg_stat_statements_reset | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1501 of file pg_stat_statements.c.
References entry_reset(), and PG_RETURN_VOID.
Datum pg_stat_statements_reset_1_7 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1482 of file pg_stat_statements.c.
References pgssHashKey::dbid, entry_reset(), PG_GETARG_INT64, PG_GETARG_OID, PG_RETURN_VOID, pgssHashKey::queryid, and pgssHashKey::userid.
|
static |
Definition at line 1100 of file pg_stat_statements.c.
References Instrumentation::bufusage, EState::es_processed, QueryDesc::estate, exec_nested_level, InstrEndLoop(), pgss_enabled, PGSS_EXEC, pgss_store(), QueryDesc::plannedstmt, prev_ExecutorEnd, PlannedStmt::queryId, QueryDesc::sourceText, standard_ExecutorEnd(), PlannedStmt::stmt_len, PlannedStmt::stmt_location, Instrumentation::total, QueryDesc::totaltime, and Instrumentation::walusage.
Referenced by _PG_init().
|
static |
Definition at line 1079 of file pg_stat_statements.c.
References exec_nested_level, PG_END_TRY, PG_FINALLY, PG_TRY, prev_ExecutorFinish, and standard_ExecutorFinish().
Referenced by _PG_init().
|
static |
Definition at line 1057 of file pg_stat_statements.c.
References exec_nested_level, PG_END_TRY, PG_FINALLY, PG_TRY, prev_ExecutorRun, and standard_ExecutorRun().
Referenced by _PG_init().
|
static |
Definition at line 1023 of file pg_stat_statements.c.
References EState::es_query_cxt, QueryDesc::estate, exec_nested_level, InstrAlloc(), INSTRUMENT_ALL, MemoryContextSwitchTo(), pgss_enabled, QueryDesc::plannedstmt, prev_ExecutorStart, PlannedStmt::queryId, standard_ExecutorStart(), and QueryDesc::totaltime.
Referenced by _PG_init().
|
static |
Definition at line 1243 of file pg_stat_statements.c.
References DatumGetUInt64, and hash_any_extended().
Referenced by pgss_store().
|
static |
Definition at line 1932 of file pg_stat_statements.c.
References add_size(), hash_estimate_size(), MAXALIGN, and pgss_max.
Referenced by _PG_init().
|
static |
Definition at line 928 of file pg_stat_statements.c.
References BufferUsageAccumDiff(), duration, exec_nested_level, INSTR_TIME_GET_MILLISEC, INSTR_TIME_SET_CURRENT, INSTR_TIME_SUBTRACT, PG_END_TRY, PG_FINALLY, PG_TRY, pgBufferUsage, pgss_enabled, PGSS_PLAN, pgss_store(), pgss_track_planning, pgWalUsage, plan_nested_level, prev_planner_hook, Query::queryId, standard_planner(), Query::stmt_len, Query::stmt_location, and WalUsageAccumDiff().
Referenced by _PG_init().
|
static |
Definition at line 854 of file pg_stat_statements.c.
References Assert, pgssJumbleState::clocations, pgssJumbleState::clocations_buf_size, pgssJumbleState::clocations_count, DatumGetUInt64, exec_nested_level, hash_any_extended(), pgssJumbleState::highest_extern_param_id, pgssJumbleState::jumble, pgssJumbleState::jumble_len, JUMBLE_SIZE, JumbleQuery(), ParseState::p_sourcetext, palloc(), pgss_enabled, PGSS_INVALID, pgss_store(), prev_post_parse_analyze_hook, Query::queryId, Query::stmt_len, Query::stmt_location, and Query::utilityStmt.
Referenced by _PG_init().
|
static |
Definition at line 1135 of file pg_stat_statements.c.
References BufferUsageAccumDiff(), QueryCompletion::commandTag, duration, exec_nested_level, INSTR_TIME_GET_MILLISEC, INSTR_TIME_SET_CURRENT, INSTR_TIME_SUBTRACT, IsA, QueryCompletion::nprocessed, PG_END_TRY, PG_FINALLY, PG_TRY, pgBufferUsage, pgss_enabled, PGSS_EXEC, pgss_store(), pgss_track_utility, pgWalUsage, prev_ProcessUtility, standard_ProcessUtility(), PlannedStmt::stmt_len, PlannedStmt::stmt_location, PlannedStmt::utilityStmt, and WalUsageAccumDiff().
Referenced by _PG_init().
|
static |
Definition at line 754 of file pg_stat_statements.c.
References AllocateFile(), durable_rename(), ereport, errcode_for_file_access(), errmsg(), error(), free, FreeFile(), hash_get_num_entries(), hash_seq_init(), hash_seq_search(), hash_seq_term(), LOG, PG_BINARY_W, PGSS_DUMP_FILE, PGSS_FILE_HEADER, PGSS_PG_MAJOR_VERSION, pgss_save, PGSS_TEXT_FILE, qtext_fetch(), qtext_load_file(), pgssEntry::query_len, pgssEntry::query_offset, and pgssSharedState::stats.
Referenced by pgss_shmem_startup().
|
static |
Definition at line 530 of file pg_stat_statements.c.
References AllocateFile(), ASSUMED_LENGTH_INIT, ASSUMED_MEDIAN_INIT, pgssEntry::counters, pgssSharedState::cur_median_usage, pgssGlobalStats::dealloc, pgssEntry::encoding, entry_alloc(), HASHCTL::entrysize, ereport, errcode(), errcode_for_file_access(), errmsg(), pgssSharedState::extent, FreeFile(), pgssSharedState::gc_count, GetCurrentTimestamp(), GetNamedLWLockTranche(), HASH_BLOBS, HASH_ELEM, header(), i, IS_STICKY, IsUnderPostmaster, pgssEntry::key, HASHCTL::keysize, pgssSharedState::lock, LOG, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), Max, pgssSharedState::mean_query_len, pgssSharedState::mutex, pgssSharedState::n_writers, on_shmem_exit(), palloc(), pfree(), PG_BINARY_R, PG_BINARY_W, PG_VALID_BE_ENCODING, PGSS_DUMP_FILE, PGSS_FILE_HEADER, pgss_max, PGSS_PG_MAJOR_VERSION, pgss_save, pgss_shmem_shutdown(), PGSS_TEXT_FILE, prev_shmem_startup_hook, pgssEntry::query_len, repalloc(), ShmemInitHash(), ShmemInitStruct(), SpinLockInit, pgssSharedState::stats, and pgssGlobalStats::stats_reset.
Referenced by _PG_init().
|
static |
Definition at line 1264 of file pg_stat_statements.c.
References Assert, BufferUsage::blk_read_time, Counters::blk_read_time, BufferUsage::blk_write_time, Counters::blk_write_time, Counters::calls, pgssEntry::counters, pgssHashKey::dbid, encoding, entry_alloc(), pgssSharedState::gc_count, gc_qtexts(), generate_normalized_query(), GetDatabaseEncoding(), GetUserId(), HASH_FIND, hash_search(), INSTR_TIME_GET_MILLISEC, IS_STICKY, sort-test::key, BufferUsage::local_blks_dirtied, Counters::local_blks_dirtied, BufferUsage::local_blks_hit, Counters::local_blks_hit, BufferUsage::local_blks_read, Counters::local_blks_read, BufferUsage::local_blks_written, Counters::local_blks_written, pgssSharedState::lock, LW_EXCLUSIVE, LW_SHARED, LWLockAcquire(), LWLockRelease(), Counters::max_time, Counters::mean_time, Counters::min_time, pgssEntry::mutex, MyDatabaseId, need_gc_qtexts(), pfree(), PGSS_EXEC, pgss_hash_string(), PGSS_PLAN, qtext_store(), pgssHashKey::queryid, Counters::rows, scanner_isspace(), BufferUsage::shared_blks_dirtied, Counters::shared_blks_dirtied, BufferUsage::shared_blks_hit, Counters::shared_blks_hit, BufferUsage::shared_blks_read, Counters::shared_blks_read, BufferUsage::shared_blks_written, Counters::shared_blks_written, SpinLockAcquire, SpinLockRelease, Counters::sum_var_time, BufferUsage::temp_blks_read, Counters::temp_blks_read, BufferUsage::temp_blks_written, Counters::temp_blks_written, Counters::total_time, Counters::usage, USAGE_EXEC, USAGE_INIT, pgssHashKey::userid, WalUsage::wal_bytes, Counters::wal_bytes, WalUsage::wal_fpi, Counters::wal_fpi, WalUsage::wal_records, and Counters::wal_records.
Referenced by pgss_ExecutorEnd(), pgss_planner(), pgss_post_parse_analyze(), and pgss_ProcessUtility().