PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <math.h>
#include <sys/stat.h>
#include <unistd.h>
#include "access/parallel.h"
#include "catalog/pg_authid.h"
#include "common/hashfn.h"
#include "common/int.h"
#include "executor/instrument.h"
#include "funcapi.h"
#include "jit/jit.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "nodes/queryjumble.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/lwlock.h"
#include "storage/shmem.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 |
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 | PGSS_NUMKIND (PGSS_EXEC + 1) |
#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_V1_9 33 |
#define | PG_STAT_STATEMENTS_COLS_V1_10 43 |
#define | PG_STAT_STATEMENTS_COLS_V1_11 49 |
#define | PG_STAT_STATEMENTS_COLS 49 /* maximum of above */ |
#define | PG_STAT_STATEMENTS_INFO_COLS 2 |
#define | SINGLE_ENTRY_RESET(e) |
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 |
Enumerations | |
enum | pgssVersion { PGSS_V1_0 = 0 , PGSS_V1_1 , PGSS_V1_2 , PGSS_V1_3 , PGSS_V1_8 , PGSS_V1_9 , PGSS_V1_10 , PGSS_V1_11 } |
enum | pgssStoreKind { PGSS_INVALID = -1 , PGSS_PLAN = 0 , PGSS_EXEC } |
enum | PGSSTrackLevel { PGSS_TRACK_NONE , PGSS_TRACK_TOP , PGSS_TRACK_ALL } |
Variables | |
PG_MODULE_MAGIC | |
static const uint32 | PGSS_FILE_HEADER = 0x20220408 |
static const uint32 | PGSS_PG_MAJOR_VERSION = PG_VERSION_NUM / 100 |
static int | nesting_level = 0 |
static shmem_request_hook_type | prev_shmem_request_hook = NULL |
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 = 5000 |
static int | pgss_track = PGSS_TRACK_TOP |
static bool | pgss_track_utility = true |
static bool | pgss_track_planning = false |
static bool | pgss_save = true |
#define ASSUMED_LENGTH_INIT 1024 /* initial assumed mean query length */ |
Definition at line 97 of file pg_stat_statements.c.
#define ASSUMED_MEDIAN_INIT (10.0) /* initial assumed median usage */ |
Definition at line 96 of file pg_stat_statements.c.
Definition at line 101 of file pg_stat_statements.c.
#define PG_STAT_STATEMENTS_COLS 49 /* maximum of above */ |
Definition at line 1542 of file pg_stat_statements.c.
#define PG_STAT_STATEMENTS_COLS_V1_0 14 |
Definition at line 1534 of file pg_stat_statements.c.
#define PG_STAT_STATEMENTS_COLS_V1_1 18 |
Definition at line 1535 of file pg_stat_statements.c.
#define PG_STAT_STATEMENTS_COLS_V1_10 43 |
Definition at line 1540 of file pg_stat_statements.c.
#define PG_STAT_STATEMENTS_COLS_V1_11 49 |
Definition at line 1541 of file pg_stat_statements.c.
#define PG_STAT_STATEMENTS_COLS_V1_2 19 |
Definition at line 1536 of file pg_stat_statements.c.
#define PG_STAT_STATEMENTS_COLS_V1_3 23 |
Definition at line 1537 of file pg_stat_statements.c.
#define PG_STAT_STATEMENTS_COLS_V1_8 32 |
Definition at line 1538 of file pg_stat_statements.c.
#define PG_STAT_STATEMENTS_COLS_V1_9 33 |
Definition at line 1539 of file pg_stat_statements.c.
#define PG_STAT_STATEMENTS_INFO_COLS 2 |
Definition at line 1958 of file pg_stat_statements.c.
#define PGSS_DUMP_FILE PGSTAT_STAT_PERMANENT_DIRECTORY "/pg_stat_statements.stat" |
Definition at line 80 of file pg_stat_statements.c.
#define pgss_enabled | ( | level | ) |
Definition at line 297 of file pg_stat_statements.c.
#define PGSS_NUMKIND (PGSS_EXEC + 1) |
Definition at line 131 of file pg_stat_statements.c.
#define PGSS_TEXT_FILE PG_STAT_TMP_DIR "/pgss_query_texts.stat" |
Definition at line 85 of file pg_stat_statements.c.
#define record_gc_qtexts | ( | ) |
Definition at line 302 of file pg_stat_statements.c.
#define SINGLE_ENTRY_RESET | ( | e | ) |
Definition at line 2596 of file pg_stat_statements.c.
#define STICKY_DECREASE_FACTOR (0.50) /* factor for sticky entries */ |
Definition at line 99 of file pg_stat_statements.c.
#define USAGE_DEALLOC_PERCENT 5 /* free this % of entries at once */ |
Definition at line 100 of file pg_stat_statements.c.
#define USAGE_DECREASE_FACTOR (0.99) /* decreased every entry_dealloc */ |
Definition at line 98 of file pg_stat_statements.c.
#define USAGE_EXEC | ( | duration | ) | (1.0) |
Definition at line 94 of file pg_stat_statements.c.
#define USAGE_INIT (1.0) /* including initial planning */ |
Definition at line 95 of file pg_stat_statements.c.
typedef struct pgssGlobalStats pgssGlobalStats |
typedef struct pgssHashKey pgssHashKey |
typedef struct pgssSharedState pgssSharedState |
typedef enum pgssStoreKind pgssStoreKind |
typedef enum pgssVersion pgssVersion |
enum pgssStoreKind |
enum PGSSTrackLevel |
Enumerator | |
---|---|
PGSS_TRACK_NONE | |
PGSS_TRACK_TOP | |
PGSS_TRACK_ALL |
Definition at line 274 of file pg_stat_statements.c.
enum pgssVersion |
Enumerator | |
---|---|
PGSS_V1_0 | |
PGSS_V1_1 | |
PGSS_V1_2 | |
PGSS_V1_3 | |
PGSS_V1_8 | |
PGSS_V1_9 | |
PGSS_V1_10 | |
PGSS_V1_11 |
Definition at line 106 of file pg_stat_statements.c.
void _PG_init | ( | void | ) |
Definition at line 377 of file pg_stat_statements.c.
References DefineCustomBoolVariable(), DefineCustomEnumVariable(), DefineCustomIntVariable(), EnableQueryId(), ExecutorEnd_hook, ExecutorFinish_hook, ExecutorRun_hook, ExecutorStart_hook, MarkGUCPrefixReserved(), PGC_POSTMASTER, PGC_SIGHUP, PGC_SUSET, pgss_ExecutorEnd(), pgss_ExecutorFinish(), pgss_ExecutorRun(), pgss_ExecutorStart(), pgss_max, pgss_planner(), pgss_post_parse_analyze(), pgss_ProcessUtility(), pgss_save, pgss_shmem_request(), 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_request_hook, prev_shmem_startup_hook, process_shared_preload_libraries_in_progress, ProcessUtility_hook, shmem_request_hook, shmem_startup_hook, and track_options.
|
static |
Definition at line 2960 of file pg_stat_statements.c.
References a, b, and pg_cmp_s32().
Referenced by fill_in_constant_lengths().
|
static |
Definition at line 2023 of file pg_stat_statements.c.
References Assert, pgssEntry::counters, pgssSharedState::cur_median_usage, pgssEntry::encoding, encoding, entry_dealloc(), GetCurrentTimestamp(), HASH_ENTER, hash_get_num_entries(), hash_search(), sort-test::key, pgssEntry::minmax_stats_since, pgssEntry::mutex, pgss, pgss_hash, pgss_max, pgssEntry::query_len, pgssEntry::query_offset, SpinLockInit, pgssEntry::stats_since, Counters::usage, and USAGE_INIT.
Referenced by pgss_shmem_startup(), and pgss_store().
|
static |
|
static |
Definition at line 2081 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(), pgss, pgss_hash, qsort, pgssEntry::query_len, SpinLockAcquire, SpinLockRelease, pgssSharedState::stats, STICKY_DECREASE_FACTOR, Counters::usage, USAGE_DEALLOC_PERCENT, and USAGE_DECREASE_FACTOR.
Referenced by entry_alloc().
|
static |
Definition at line 2619 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_FIND, hash_get_num_entries(), hash_search(), hash_seq_init(), hash_seq_search(), pgssEntry::key, sort-test::key, pgssSharedState::lock, LOG, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), pgssSharedState::mutex, PG_BINARY_W, pgss, pgss_hash, PGSS_TEXT_FILE, pgssHashKey::queryid, record_gc_qtexts, SINGLE_ENTRY_RESET, SpinLockAcquire, SpinLockRelease, pgssSharedState::stats, pgssGlobalStats::stats_reset, and pgssHashKey::userid.
Referenced by pg_stat_statements_reset(), pg_stat_statements_reset_1_11(), and pg_stat_statements_reset_1_7().
|
static |
Definition at line 2860 of file pg_stat_statements.c.
References Assert, JumbleState::clocations, JumbleState::clocations_count, comp_location(), core_yylex(), core_yy_extra_type::escape_string_warning, i, LocationLen::length, LocationLen::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 2417 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, pgss_hash, 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 2753 of file pg_stat_statements.c.
References Assert, JumbleState::clocations, JumbleState::clocations_count, fill_in_constant_lengths(), JumbleState::highest_extern_param_id, i, LocationLen::length, LocationLen::location, palloc(), and sprintf.
Referenced by pgss_store().
|
static |
Definition at line 2368 of file pg_stat_statements.c.
References pgssSharedState::extent, pgssSharedState::mean_query_len, pgssSharedState::mutex, pgss, pgss_max, SpinLockAcquire, and SpinLockRelease.
Referenced by gc_qtexts(), and pgss_store().
PG_FUNCTION_INFO_V1 | ( | pg_stat_statements | ) |
PG_FUNCTION_INFO_V1 | ( | pg_stat_statements_1_10 | ) |
PG_FUNCTION_INFO_V1 | ( | pg_stat_statements_1_11 | ) |
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_1_9 | ) |
PG_FUNCTION_INFO_V1 | ( | pg_stat_statements_info | ) |
PG_FUNCTION_INFO_V1 | ( | pg_stat_statements_reset | ) |
PG_FUNCTION_INFO_V1 | ( | pg_stat_statements_reset_1_11 | ) |
PG_FUNCTION_INFO_V1 | ( | pg_stat_statements_reset_1_7 | ) |
Datum pg_stat_statements | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1619 of file pg_stat_statements.c.
References pg_stat_statements_internal(), and PGSS_V1_0.
Datum pg_stat_statements_1_10 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1565 of file pg_stat_statements.c.
References PG_GETARG_BOOL, pg_stat_statements_internal(), and PGSS_V1_10.
Datum pg_stat_statements_1_11 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1555 of file pg_stat_statements.c.
References PG_GETARG_BOOL, pg_stat_statements_internal(), and PGSS_V1_11.
Datum pg_stat_statements_1_2 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1605 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 1595 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 1585 of file pg_stat_statements.c.
References PG_GETARG_BOOL, pg_stat_statements_internal(), and PGSS_V1_8.
Datum pg_stat_statements_1_9 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1575 of file pg_stat_statements.c.
References PG_GETARG_BOOL, pg_stat_statements_internal(), and PGSS_V1_9.
Datum pg_stat_statements_info | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1964 of file pg_stat_statements.c.
References pgssGlobalStats::dealloc, elog, ereport, errcode(), errmsg(), ERROR, get_call_result_type(), heap_form_tuple(), HeapTupleGetDatum(), Int64GetDatum(), pgssSharedState::mutex, PG_RETURN_DATUM, PG_STAT_STATEMENTS_INFO_COLS, pgss, pgss_hash, SpinLockAcquire, SpinLockRelease, pgssSharedState::stats, pgssGlobalStats::stats_reset, TimestampTzGetDatum(), TYPEFUNC_COMPOSITE, and values.
|
static |
Definition at line 1629 of file pg_stat_statements.c.
References Assert, BoolGetDatum(), buf, Counters::calls, pgssEntry::counters, CStringGetDatum(), CStringGetTextDatum, pgssHashKey::dbid, DirectFunctionCall3, elog, enc, pgssEntry::encoding, ereport, errcode(), errmsg(), ERROR, pgssSharedState::extent, Float8GetDatumFast, free, pgssSharedState::gc_count, GetUserId(), has_privs_of_role(), hash_seq_init(), hash_seq_search(), i, InitMaterializedSRF(), Int32GetDatum(), Int64GetDatumFast, IS_STICKY, Counters::jit_deform_count, Counters::jit_deform_time, Counters::jit_emission_count, Counters::jit_emission_time, Counters::jit_functions, Counters::jit_generation_time, Counters::jit_inlining_count, Counters::jit_inlining_time, Counters::jit_optimization_count, Counters::jit_optimization_time, pgssEntry::key, Counters::local_blk_read_time, Counters::local_blk_write_time, 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, Counters::min_time, pgssEntry::minmax_stats_since, pgssEntry::mutex, pgssSharedState::mutex, pgssSharedState::n_writers, TupleDescData::natts, 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_10, PG_STAT_STATEMENTS_COLS_V1_11, PG_STAT_STATEMENTS_COLS_V1_2, PG_STAT_STATEMENTS_COLS_V1_3, PG_STAT_STATEMENTS_COLS_V1_8, PG_STAT_STATEMENTS_COLS_V1_9, pgss, PGSS_EXEC, pgss_hash, PGSS_NUMKIND, PGSS_V1_0, PGSS_V1_1, PGSS_V1_10, PGSS_V1_11, PGSS_V1_2, PGSS_V1_3, PGSS_V1_8, PGSS_V1_9, qtext_fetch(), qtext_load_file(), pgssEntry::query_len, pgssEntry::query_offset, pgssHashKey::queryid, FunctionCallInfoBaseData::resultinfo, Counters::rows, ReturnSetInfo::setDesc, ReturnSetInfo::setResult, Counters::shared_blk_read_time, Counters::shared_blk_write_time, Counters::shared_blks_dirtied, Counters::shared_blks_hit, Counters::shared_blks_read, Counters::shared_blks_written, snprintf, SpinLockAcquire, SpinLockRelease, pgssEntry::stats_since, Counters::sum_var_time, Counters::temp_blk_read_time, Counters::temp_blk_write_time, Counters::temp_blks_read, Counters::temp_blks_written, TimestampTzGetDatum(), pgssHashKey::toplevel, Counters::total_time, tuplestore_putvalues(), UINT64_FORMAT, pgssHashKey::userid, values, Counters::wal_bytes, Counters::wal_fpi, and Counters::wal_records.
Referenced by pg_stat_statements(), pg_stat_statements_1_10(), pg_stat_statements_1_11(), pg_stat_statements_1_2(), pg_stat_statements_1_3(), pg_stat_statements_1_8(), and pg_stat_statements_1_9().
Datum pg_stat_statements_reset | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1526 of file pg_stat_statements.c.
References entry_reset(), and PG_RETURN_VOID.
Datum pg_stat_statements_reset_1_11 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1507 of file pg_stat_statements.c.
References entry_reset(), PG_GETARG_BOOL, PG_GETARG_INT64, PG_GETARG_OID, and PG_RETURN_TIMESTAMPTZ.
Datum pg_stat_statements_reset_1_7 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1491 of file pg_stat_statements.c.
References entry_reset(), PG_GETARG_INT64, PG_GETARG_OID, and PG_RETURN_VOID.
|
static |
Definition at line 1058 of file pg_stat_statements.c.
References Instrumentation::bufusage, EState::es_jit, EState::es_total_processed, QueryDesc::estate, JitContext::instr, InstrEndLoop(), nesting_level, 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 1037 of file pg_stat_statements.c.
References nesting_level, PG_END_TRY, PG_FINALLY, PG_TRY, prev_ExecutorFinish, and standard_ExecutorFinish().
Referenced by _PG_init().
|
static |
Definition at line 1015 of file pg_stat_statements.c.
References nesting_level, PG_END_TRY, PG_FINALLY, PG_TRY, prev_ExecutorRun, and standard_ExecutorRun().
Referenced by _PG_init().
|
static |
Definition at line 981 of file pg_stat_statements.c.
References EState::es_query_cxt, QueryDesc::estate, InstrAlloc(), INSTRUMENT_ALL, MemoryContextSwitchTo(), nesting_level, pgss_enabled, QueryDesc::plannedstmt, prev_ExecutorStart, PlannedStmt::queryId, standard_ExecutorStart(), and QueryDesc::totaltime.
Referenced by _PG_init().
|
static |
Definition at line 1995 of file pg_stat_statements.c.
References add_size(), hash_estimate_size(), MAXALIGN, pgss_max, and size.
Referenced by pgss_shmem_request().
|
static |
Definition at line 878 of file pg_stat_statements.c.
References BufferUsageAccumDiff(), duration, INSTR_TIME_GET_MILLISEC, INSTR_TIME_SET_CURRENT, INSTR_TIME_SUBTRACT, nesting_level, parse(), PG_END_TRY, PG_FINALLY, PG_TRY, pgBufferUsage, pgss_enabled, PGSS_PLAN, pgss_store(), pgss_track_planning, pgWalUsage, prev_planner_hook, standard_planner(), start, and WalUsageAccumDiff().
Referenced by _PG_init().
|
static |
Definition at line 828 of file pg_stat_statements.c.
References JumbleState::clocations_count, IsA, nesting_level, ParseState::p_sourcetext, pgss, pgss_enabled, pgss_hash, PGSS_INVALID, pgss_store(), pgss_track_utility, prev_post_parse_analyze_hook, Query::stmt_location, and Query::utilityStmt.
Referenced by _PG_init().
|
static |
Definition at line 1094 of file pg_stat_statements.c.
References BufferUsageAccumDiff(), QueryCompletion::commandTag, context, generate_unaccent_rules::dest, duration, INSTR_TIME_GET_MILLISEC, INSTR_TIME_SET_CURRENT, INSTR_TIME_SUBTRACT, IsA, nesting_level, QueryCompletion::nprocessed, PG_END_TRY, PG_FINALLY, PG_TRY, pgBufferUsage, pgss_enabled, PGSS_EXEC, pgss_store(), pgss_track_utility, pgWalUsage, prev_ProcessUtility, PlannedStmt::queryId, standard_ProcessUtility(), start, PlannedStmt::stmt_len, PlannedStmt::stmt_location, PlannedStmt::utilityStmt, and WalUsageAccumDiff().
Referenced by _PG_init().
|
static |
Definition at line 487 of file pg_stat_statements.c.
References pgss_memsize(), prev_shmem_request_hook, RequestAddinShmemSpace(), and RequestNamedLWLockTranche().
Referenced by _PG_init().
|
static |
Definition at line 729 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(), len, LOG, PG_BINARY_W, pgss, PGSS_DUMP_FILE, PGSS_FILE_HEADER, pgss_hash, 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 503 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, i, IS_STICKY, IsUnderPostmaster, pgssEntry::key, HASHCTL::keysize, pgssSharedState::lock, LOG, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), Max, pgssSharedState::mean_query_len, pgssEntry::minmax_stats_since, pgssSharedState::mutex, pgssSharedState::n_writers, on_shmem_exit(), palloc(), pfree(), PG_BINARY_R, PG_BINARY_W, PG_VALID_BE_ENCODING, pgss, PGSS_DUMP_FILE, PGSS_FILE_HEADER, pgss_hash, 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, pgssGlobalStats::stats_reset, and pgssEntry::stats_since.
Referenced by _PG_init().
|
static |
Definition at line 1266 of file pg_stat_statements.c.
References Assert, Counters::calls, CleanQuerytext(), pgssEntry::counters, JitInstrumentation::created_functions, JitInstrumentation::deform_counter, JitInstrumentation::emission_counter, encoding, entry_alloc(), pgssSharedState::gc_count, gc_qtexts(), generate_normalized_query(), JitInstrumentation::generation_counter, GetDatabaseEncoding(), GetUserId(), HASH_FIND, hash_search(), JitInstrumentation::inlining_counter, INSTR_TIME_GET_MILLISEC, IS_STICKY, Counters::jit_deform_count, Counters::jit_deform_time, Counters::jit_emission_count, Counters::jit_emission_time, Counters::jit_functions, Counters::jit_generation_time, Counters::jit_inlining_count, Counters::jit_inlining_time, Counters::jit_optimization_count, Counters::jit_optimization_time, sort-test::key, Counters::local_blk_read_time, BufferUsage::local_blk_read_time, Counters::local_blk_write_time, BufferUsage::local_blk_write_time, Counters::local_blks_dirtied, BufferUsage::local_blks_dirtied, Counters::local_blks_hit, BufferUsage::local_blks_hit, Counters::local_blks_read, BufferUsage::local_blks_read, Counters::local_blks_written, BufferUsage::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(), nesting_level, JitInstrumentation::optimization_counter, pfree(), pgss, PGSS_EXEC, pgss_hash, PGSS_PLAN, qtext_store(), Counters::rows, Counters::shared_blk_read_time, BufferUsage::shared_blk_read_time, Counters::shared_blk_write_time, BufferUsage::shared_blk_write_time, Counters::shared_blks_dirtied, BufferUsage::shared_blks_dirtied, Counters::shared_blks_hit, BufferUsage::shared_blks_hit, Counters::shared_blks_read, BufferUsage::shared_blks_read, Counters::shared_blks_written, BufferUsage::shared_blks_written, SpinLockAcquire, SpinLockRelease, Counters::sum_var_time, Counters::temp_blk_read_time, BufferUsage::temp_blk_read_time, Counters::temp_blk_write_time, BufferUsage::temp_blk_write_time, Counters::temp_blks_read, BufferUsage::temp_blks_read, Counters::temp_blks_written, BufferUsage::temp_blks_written, Counters::total_time, Counters::usage, USAGE_EXEC, USAGE_INIT, Counters::wal_bytes, WalUsage::wal_bytes, Counters::wal_fpi, WalUsage::wal_fpi, Counters::wal_records, and WalUsage::wal_records.
Referenced by pgss_ExecutorEnd(), pgss_planner(), pgss_post_parse_analyze(), and pgss_ProcessUtility().
|
static |
Definition at line 2345 of file pg_stat_statements.c.
Referenced by gc_qtexts(), pg_stat_statements_internal(), and pgss_shmem_shutdown().
|
static |
Definition at line 2252 of file pg_stat_statements.c.
References buf, CloseTransientFile(), ereport, errcode(), errcode_for_file_access(), errdetail(), errmsg(), fd(), free, fstat, LOG, malloc, MaxAllocHugeSize, Min, OpenTransientFile(), PG_BINARY, PGSS_TEXT_FILE, read, and stat::st_size.
Referenced by gc_qtexts(), pg_stat_statements_internal(), and pgss_shmem_shutdown().
|
static |
Definition at line 2172 of file pg_stat_statements.c.
References CloseTransientFile(), ereport, errcode_for_file_access(), errmsg(), error(), pgssSharedState::extent, fd(), pgssSharedState::gc_count, LOG, MaxAllocHugeSize, pgssSharedState::mutex, pgssSharedState::n_writers, OpenTransientFile(), PG_BINARY, pg_pwrite, pgss, PGSS_TEXT_FILE, SpinLockAcquire, SpinLockRelease, and unlikely.
Referenced by pgss_store().
|
static |
Definition at line 255 of file pg_stat_statements.c.
Referenced by pgss_ExecutorEnd(), pgss_ExecutorFinish(), pgss_ExecutorRun(), pgss_ExecutorStart(), pgss_planner(), pgss_post_parse_analyze(), pgss_ProcessUtility(), and pgss_store().
PG_MODULE_MAGIC |
Definition at line 77 of file pg_stat_statements.c.
|
static |
Definition at line 269 of file pg_stat_statements.c.
Referenced by entry_alloc(), entry_dealloc(), entry_reset(), gc_qtexts(), need_gc_qtexts(), pg_stat_statements_info(), pg_stat_statements_internal(), pgss_post_parse_analyze(), pgss_shmem_shutdown(), pgss_shmem_startup(), pgss_store(), and qtext_store().
|
static |
Definition at line 88 of file pg_stat_statements.c.
Referenced by pgss_shmem_shutdown(), and pgss_shmem_startup().
|
static |
Definition at line 270 of file pg_stat_statements.c.
Referenced by entry_alloc(), entry_dealloc(), entry_reset(), gc_qtexts(), pg_stat_statements_info(), pg_stat_statements_internal(), pgss_post_parse_analyze(), pgss_shmem_shutdown(), pgss_shmem_startup(), and pgss_store().
|
static |
Definition at line 289 of file pg_stat_statements.c.
Referenced by _PG_init(), entry_alloc(), need_gc_qtexts(), pgss_memsize(), and pgss_shmem_startup().
|
static |
Definition at line 91 of file pg_stat_statements.c.
Referenced by pgss_shmem_shutdown(), and pgss_shmem_startup().
Definition at line 294 of file pg_stat_statements.c.
Referenced by _PG_init(), pgss_shmem_shutdown(), and pgss_shmem_startup().
|
static |
Definition at line 290 of file pg_stat_statements.c.
Referenced by _PG_init().
Definition at line 292 of file pg_stat_statements.c.
Referenced by _PG_init(), and pgss_planner().
Definition at line 291 of file pg_stat_statements.c.
Referenced by _PG_init(), pgss_post_parse_analyze(), and pgss_ProcessUtility().
|
static |
Definition at line 265 of file pg_stat_statements.c.
Referenced by _PG_init(), and pgss_ExecutorEnd().
|
static |
Definition at line 264 of file pg_stat_statements.c.
Referenced by _PG_init(), and pgss_ExecutorFinish().
|
static |
Definition at line 263 of file pg_stat_statements.c.
Referenced by _PG_init(), and pgss_ExecutorRun().
|
static |
Definition at line 262 of file pg_stat_statements.c.
Referenced by _PG_init(), and pgss_ExecutorStart().
|
static |
Definition at line 261 of file pg_stat_statements.c.
Referenced by _PG_init(), and pgss_planner().
|
static |
Definition at line 260 of file pg_stat_statements.c.
Referenced by _PG_init(), and pgss_post_parse_analyze().
|
static |
Definition at line 266 of file pg_stat_statements.c.
Referenced by _PG_init(), and pgss_ProcessUtility().
|
static |
Definition at line 258 of file pg_stat_statements.c.
Referenced by _PG_init(), and pgss_shmem_request().
|
static |
Definition at line 259 of file pg_stat_statements.c.
Referenced by _PG_init(), and pgss_shmem_startup().
|
static |
Definition at line 270 of file pg_stat_statements.c.
Referenced by _PG_init().