PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <fcntl.h>
#include <limits.h>
#include <signal.h>
#include <unistd.h>
#include <sys/resource.h>
#include <sys/socket.h>
#include <sys/time.h>
#include "access/parallel.h"
#include "access/printtup.h"
#include "access/xact.h"
#include "catalog/pg_type.h"
#include "commands/async.h"
#include "commands/event_trigger.h"
#include "commands/prepare.h"
#include "common/pg_prng.h"
#include "jit/jit.h"
#include "libpq/libpq.h"
#include "libpq/pqformat.h"
#include "libpq/pqsignal.h"
#include "mb/pg_wchar.h"
#include "mb/stringinfo_mb.h"
#include "miscadmin.h"
#include "nodes/print.h"
#include "optimizer/optimizer.h"
#include "parser/analyze.h"
#include "parser/parser.h"
#include "pg_getopt.h"
#include "pg_trace.h"
#include "pgstat.h"
#include "postmaster/autovacuum.h"
#include "postmaster/interrupt.h"
#include "postmaster/postmaster.h"
#include "replication/logicallauncher.h"
#include "replication/logicalworker.h"
#include "replication/slot.h"
#include "replication/walsender.h"
#include "rewrite/rewriteHandler.h"
#include "storage/bufmgr.h"
#include "storage/ipc.h"
#include "storage/pmsignal.h"
#include "storage/proc.h"
#include "storage/procsignal.h"
#include "storage/sinval.h"
#include "tcop/fastpath.h"
#include "tcop/pquery.h"
#include "tcop/tcopprot.h"
#include "tcop/utility.h"
#include "utils/guc_hooks.h"
#include "utils/injection_point.h"
#include "utils/lsyscache.h"
#include "utils/memutils.h"
#include "utils/ps_status.h"
#include "utils/snapmgr.h"
#include "utils/timeout.h"
#include "utils/timestamp.h"
Go to the source code of this file.
Data Structures | |
struct | BindParamCbData |
Macros | |
#define | valgrind_report_error_query(query) ((void) 0) |
Typedefs | |
typedef struct BindParamCbData | BindParamCbData |
Variables | |
const char * | debug_query_string |
CommandDest | whereToSendOutput = DestDebug |
bool | Log_disconnections = false |
int | log_statement = LOGSTMT_NONE |
int | max_stack_depth = 100 |
int | PostAuthDelay = 0 |
int | client_connection_check_interval = 0 |
static long | max_stack_depth_bytes = 100 * 1024L |
static char * | stack_base_ptr = NULL |
static bool | xact_started = false |
static bool | DoingCommandRead = false |
static bool | doing_extended_query_message = false |
static bool | ignore_till_sync = false |
static CachedPlanSource * | unnamed_stmt_psrc = NULL |
static const char * | userDoption = NULL |
static bool | EchoQuery = false |
static bool | UseSemiNewlineNewline = false |
static volatile sig_atomic_t | RecoveryConflictPending = false |
static volatile sig_atomic_t | RecoveryConflictPendingReasons [NUM_PROCSIGNALS] |
static MemoryContext | row_description_context = NULL |
static StringInfoData | row_description_buf |
static struct rusage | Save_r |
static struct timeval | Save_t |
#define valgrind_report_error_query | ( | query | ) | ((void) 0) |
Definition at line 224 of file postgres.c.
typedef struct BindParamCbData BindParamCbData |
void assign_max_stack_depth | ( | int | newval, |
void * | extra | ||
) |
Definition at line 3595 of file postgres.c.
References max_stack_depth_bytes, and newval.
void assign_transaction_timeout | ( | int | newval, |
void * | extra | ||
) |
Definition at line 3656 of file postgres.c.
References disable_timeout(), enable_timeout_after(), get_timeout_active(), IsTransactionState(), newval, and TRANSACTION_TIMEOUT.
|
static |
Definition at line 2548 of file postgres.c.
References appendStringInfoStringQuoted(), arg, buf, data, errcontext, initStringInfo(), log_parameter_max_length_on_error, and pfree().
Referenced by exec_bind_message().
Definition at line 3606 of file postgres.c.
References GUC_check_errdetail, newval, and WaitEventSetCanReportClosed().
int check_log_duration | ( | char * | msec_str, |
bool | was_logged | ||
) |
Definition at line 2379 of file postgres.c.
References GetCurrentStatementStartTimestamp(), GetCurrentTimestamp(), log_duration, log_min_duration_sample, log_min_duration_statement, log_statement_sample_rate, pg_global_prng_state, pg_prng_double(), snprintf, TimestampDifference(), and xact_is_sampled.
Referenced by exec_bind_message(), exec_execute_message(), exec_parse_message(), exec_simple_query(), and HandleFunctionRequest().
Definition at line 2340 of file postgres.c.
References GetCommandLogLevel(), lfirst, log_statement, LOGSTMT_ALL, LOGSTMT_NONE, and stmt.
Referenced by exec_execute_message(), and exec_simple_query().
Definition at line 3641 of file postgres.c.
References GUC_check_errdetail, log_executor_stats, log_parser_stats, log_planner_stats, and newval.
Definition at line 3578 of file postgres.c.
References get_stack_depth_rlimit(), GUC_check_errdetail, GUC_check_errhint, newval, and STACK_DEPTH_SLOP.
void check_stack_depth | ( | void | ) |
Definition at line 3531 of file postgres.c.
References ereport, errcode(), errhint(), errmsg(), ERROR, max_stack_depth, and stack_is_too_deep().
Referenced by _jumbleNode(), AlterTypeRecurse(), apply_scanjoin_target_to_paths(), ATAddCheckNNConstraint(), ATExecAddColumn(), ATExecAlterConstrRecurse(), ATExecDropColumn(), ATExecSetNotNull(), CheckAttributeType(), checkCond(), clean_NOT_intree(), clean_stopword_intree(), cntsize(), contains_required_value(), convertJsonbValue(), copyObjectImpl(), Cover(), create_plan_recurse(), datum_to_json_internal(), datum_to_jsonb_internal(), dofindsubquery(), dropconstraint_internal(), emit_jsp_gin_entries(), equal(), eval_const_expressions_mutator(), EventTriggerInvoke(), ExecEndNode(), ExecEvalSubPlan(), ExecInitExprRec(), ExecInitNode(), ExecMakeFunctionResultSet(), ExecProcNodeFirst(), ExecShutdownNode_walker(), execute(), executeAnyItem(), executeBoolItem(), executeItemOptUnwrapTarget(), expand_partitioned_rtentry(), expression_tree_mutator_impl(), expression_tree_walker_impl(), extract_jsp_bool_expr(), fillQT(), find_composite_type_dependencies(), find_matching_subplans_recurse(), findDependentObjects(), findoprnd(), findoprnd_recurse(), flatten_grouping_sets(), flattenJsonPathParseItem(), FreePageManagerDumpBtree(), freetree(), generate_partition_qual(), generate_partitionwise_join_paths(), get_query_def(), get_rels_with_domain(), get_rule_expr(), get_setop_query(), get_steps_using_prefix_recurse(), gistSplit(), hash_range(), hash_range_extended(), hash_record(), hash_record_extended(), hk_depth_search(), infix(), inline_set_returning_function(), int_query_opr_selec(), is_simple_union_all_recurse(), JsonbDeepContains(), lseg_inside_poly(), ltree_execute(), makepol(), maketree(), MatchText(), MultiExecProcNode(), outNode(), p_ishost(), p_isURLPath(), parse_array(), parse_object(), parseNodeString(), plainnode(), planstate_tree_walker_impl(), plperl_hash_from_tuple(), plperl_sv_to_datum(), PLy_input_setup_func(), PLy_output_setup_func(), populate_array_dim_jsonb(), populate_record_field(), printJsonPathItem(), pull_up_sublinks_jointree_recurse(), pull_up_subqueries_recurse(), QT2QTN(), QTNBinary(), QTNClearFlags(), QTNCopy(), QTNFree(), QTNodeCompare(), QTNSort(), QTNTernary(), range_cmp(), range_in(), range_out(), range_recv(), range_send(), raw_expression_tree_walker_impl(), record_cmp(), record_eq(), record_in(), record_out(), record_recv(), record_send(), recurse_set_operations(), regex_selectivity_sub(), relation_is_updatable(), resolve_special_varno(), set_append_rel_size(), set_attnotnull(), setPath(), split_array(), SplitToVariants(), standard_ProcessUtility(), transformExprRecurse(), transformFromClauseItem(), transformSetOperationTree(), traverse_lacons(), try_partitionwise_join(), TS_execute_locations_recurse(), TS_execute_recurse(), TS_phrase_execute(), tsquery_opr_selec(), and tsquery_requires_match().
Definition at line 3627 of file postgres.c.
References GUC_check_errdetail, log_statement_stats, and newval.
void die | ( | SIGNAL_ARGS | ) |
Definition at line 2972 of file postgres.c.
References DestRemote, DISCONNECT_KILLED, DoingCommandRead, InterruptPending, MyLatch, pgStatSessionEndCause, proc_exit_inprogress, ProcDiePending, ProcessInterrupts(), SetLatch(), and whereToSendOutput.
Referenced by PostgresMain().
|
static |
Definition at line 5167 of file postgres.c.
References disable_timeout(), get_timeout_active(), and STATEMENT_TIMEOUT.
Referenced by exec_execute_message(), exec_simple_query(), and finish_xact_command().
|
static |
Definition at line 2850 of file postgres.c.
References DropCachedPlan(), and unnamed_stmt_psrc.
Referenced by exec_parse_message(), exec_simple_query(), and PostgresMain().
|
static |
Definition at line 5145 of file postgres.c.
References Assert, disable_timeout(), enable_timeout_after(), get_timeout_active(), STATEMENT_TIMEOUT, StatementTimeout, TransactionTimeout, and xact_started.
Referenced by start_xact_command().
|
static |
Definition at line 2495 of file postgres.c.
References errdetail(), MyProc, and PGPROC::recoveryConflictPending.
Referenced by exec_bind_message(), exec_describe_portal_message(), exec_describe_statement_message(), exec_execute_message(), exec_parse_message(), and exec_simple_query().
|
static |
Definition at line 2442 of file postgres.c.
References errdetail(), FetchPreparedStatement(), IsA, lfirst_node, RawStmt::stmt, and stmt.
Referenced by exec_simple_query().
|
static |
Definition at line 2475 of file postgres.c.
References BuildParamLogString(), errdetail(), log_parameter_max_length, ParamListInfoData::numParams, and str.
Referenced by exec_bind_message(), and exec_execute_message().
|
static |
Definition at line 2509 of file postgres.c.
References errdetail(), PROCSIG_RECOVERY_CONFLICT_BUFFERPIN, PROCSIG_RECOVERY_CONFLICT_DATABASE, PROCSIG_RECOVERY_CONFLICT_LOCK, PROCSIG_RECOVERY_CONFLICT_LOGICALSLOT, PROCSIG_RECOVERY_CONFLICT_SNAPSHOT, PROCSIG_RECOVERY_CONFLICT_STARTUP_DEADLOCK, and PROCSIG_RECOVERY_CONFLICT_TABLESPACE.
Referenced by ProcessRecoveryConflictInterrupt().
|
static |
Definition at line 1626 of file postgres.c.
References analyze_requires_snapshot(), ErrorContextCallback::arg, bind_param_error_callback(), BuildParamLogString(), ErrorContextCallback::callback, check_log_duration(), CachedPlanSource::commandTag, CreatePortal(), StringInfoData::cursor, StringInfoData::data, DEBUG2, debug_query_string, DestRemote, ereport, errcode(), errdetail_abort(), errdetail_params(), errhidestmt(), errmsg(), errmsg_internal(), ERROR, error_context_stack, FetchPreparedStatement(), GetCachedPlan(), GetTransactionSnapshot(), getTypeBinaryInputInfo(), getTypeInputInfo(), i, initReadOnlyStringInfo(), InvalidSnapshot, IsAbortedTransactionBlockState(), ParamExternData::isnull, IsTransactionExitStmt(), StringInfoData::len, LOG, log_parameter_max_length_on_error, log_statement_stats, makeParamList(), MAX_MULTIBYTE_CHAR_LEN, MemoryContextSwitchTo(), MessageContext, PortalData::name, CachedPlanSource::num_params, OidInputFunctionCall(), OidReceiveFunctionCall(), palloc0_array, palloc_array, PARAM_FLAG_CONST, CachedPlanSource::param_types, BindParamCbData::paramno, ParamListInfoData::params, ParamsErrorCbData::params, ParamsErrorCallback(), BindParamCbData::paramval, ParamListInfoData::paramValuesStr, ParamExternData::pflags, pfree(), pg_client_to_server(), pgstat_report_activity(), PreparedStatement::plansource, pnstrdup(), PopActiveSnapshot(), PortalData::portalContext, PortalDefineQuery(), BindParamCbData::portalName, ParamsErrorCbData::portalName, PortalSetResultFormat(), PortalStart(), pq_getmsgbytes(), pq_getmsgend(), pq_getmsgint(), pq_getmsgstring(), pq_putemptymessage(), PqMsg_BindComplete, ErrorContextCallback::previous, pstrdup(), ParamExternData::ptype, PushActiveSnapshot(), CachedPlanSource::query_string, CachedPlanSource::raw_parse_tree, ResetUsage(), set_ps_display(), ShowUsage(), start_xact_command(), STATE_RUNNING, RawStmt::stmt, CachedPlan::stmt_list, unconstify, unnamed_stmt_psrc, valgrind_report_error_query, ParamExternData::value, and whereToSendOutput.
Referenced by PostgresMain().
|
static |
Definition at line 2691 of file postgres.c.
References DestRemote, ereport, errcode(), errdetail_abort(), errmsg(), ERROR, FetchPortalTargetList(), PortalData::formats, GetPortalByName(), IsAbortedTransactionBlockState(), MemoryContextSwitchTo(), MessageContext, PortalIsValid, pq_putemptymessage(), PqMsg_NoData, row_description_buf, SendRowDescriptionMessage(), start_xact_command(), PortalData::tupDesc, and whereToSendOutput.
Referenced by PostgresMain().
|
static |
Definition at line 2597 of file postgres.c.
References Assert, CachedPlanGetTargetList(), DestRemote, ereport, errcode(), errdetail_abort(), errmsg(), ERROR, FetchPreparedStatement(), CachedPlanSource::fixed_result, i, IsAbortedTransactionBlockState(), MemoryContextSwitchTo(), MessageContext, CachedPlanSource::num_params, CachedPlanSource::param_types, PreparedStatement::plansource, pq_beginmessage_reuse(), pq_endmessage_reuse(), pq_putemptymessage(), pq_sendint16(), pq_sendint32(), PqMsg_NoData, CachedPlanSource::resultDesc, row_description_buf, SendRowDescriptionMessage(), start_xact_command(), unnamed_stmt_psrc, and whereToSendOutput.
Referenced by PostgresMain().
|
static |
Definition at line 2085 of file postgres.c.
References _, ErrorContextCallback::arg, Assert, PortalData::atStart, BeginCommand(), ErrorContextCallback::callback, CHECK_FOR_INTERRUPTS, check_log_duration(), check_log_statement(), CommandCounterIncrement(), PortalData::commandTag, CreateDestReceiver(), debug_query_string, generate_unaccent_rules::dest, DestRemote, DestRemoteExecute, disable_statement_timeout(), EndCommand(), ereport, errcode(), errdetail_abort(), errdetail_params(), errhidestmt(), errmsg(), ERROR, error_context_stack, FETCH_ALL, finish_xact_command(), GetCommandTagNameAndLen(), GetPortalByName(), IsAbortedTransactionBlockState(), IsTransactionExitStmtList(), IsTransactionStmtList(), LOG, log_statement_stats, MyXactFlags, PortalData::name, NIL, NullCommand(), ParamsErrorCbData::params, ParamsErrorCallback(), pgstat_report_activity(), PortalIsValid, ParamsErrorCbData::portalName, PortalData::portalParams, PortalRun(), pq_putemptymessage(), PqMsg_PortalSuspended, PortalData::prepStmtName, ErrorContextCallback::previous, pstrdup(), _DestReceiver::rDestroy, ResetUsage(), set_ps_display_with_len(), SetRemoteDestReceiverParams(), ShowUsage(), PortalData::sourceText, start_xact_command(), STATE_RUNNING, PortalData::stmts, valgrind_report_error_query, whereToSendOutput, XACT_FLAGS_NEEDIMMEDIATECOMMIT, and XACT_FLAGS_PIPELINING.
Referenced by PostgresMain().
|
static |
Definition at line 1391 of file postgres.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, analyze_requires_snapshot(), CHECK_FOR_INTERRUPTS, check_log_duration(), CommandCounterIncrement(), CompleteCachedPlan(), CachedPlanSource::context, CreateCachedPlan(), CreateCommandTag(), CURSOR_OPT_PARALLEL_OK, DEBUG2, debug_query_string, DestRemote, drop_unnamed_stmt(), ereport, errcode(), errdetail_abort(), errhidestmt(), errmsg(), errmsg_internal(), ERROR, GetTransactionSnapshot(), IsAbortedTransactionBlockState(), IsTransactionExitStmt(), linitial_node, list_length(), LOG, log_statement_stats, MemoryContextSetParent(), MemoryContextSwitchTo(), MessageContext, NIL, pg_analyze_and_rewrite_varparams(), pg_parse_query(), pgstat_report_activity(), PopActiveSnapshot(), pq_putemptymessage(), PqMsg_ParseComplete, PushActiveSnapshot(), ResetUsage(), SaveCachedPlan(), set_ps_display(), ShowUsage(), start_xact_command(), STATE_RUNNING, RawStmt::stmt, StorePreparedStatement(), unnamed_stmt_psrc, and whereToSendOutput.
Referenced by PostgresMain().
|
static |
Definition at line 1013 of file postgres.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, analyze_requires_snapshot(), Assert, BeginCommand(), BeginImplicitTransactionBlock(), CHECK_FOR_INTERRUPTS, check_log_duration(), check_log_statement(), CommandCounterIncrement(), CreateCommandTag(), CreateDestReceiver(), CreatePortal(), CURSOR_OPT_BINARY, CURSOR_OPT_PARALLEL_OK, PortalData::cursorOptions, debug_query_string, generate_unaccent_rules::dest, DestRemote, disable_statement_timeout(), drop_unnamed_stmt(), EndCommand(), EndImplicitTransactionBlock(), ereport, errcode(), errdetail_abort(), errdetail_execute(), errhidestmt(), errmsg(), ERROR, FETCH_ALL, finish_xact_command(), format, GetCommandTagNameAndLen(), GetPortalByName(), GetTransactionSnapshot(), if(), InvalidSnapshot, IsA, IsAbortedTransactionBlockState(), IsTransactionExitStmt(), lfirst_node, list_length(), lnext(), LOG, log_statement_stats, MemoryContextDelete(), MemoryContextSwitchTo(), MessageContext, MyXactFlags, NullCommand(), pg_analyze_and_rewrite_fixedparams(), pg_parse_query(), pg_plan_queries(), pgstat_report_activity(), pgstat_report_query_id(), PopActiveSnapshot(), PortalDefineQuery(), PortalDrop(), PortalIsValid, PortalRun(), PortalSetResultFormat(), PortalStart(), PushActiveSnapshot(), _DestReceiver::rDestroy, ResetUsage(), set_ps_display_with_len(), SetRemoteDestReceiverParams(), ShowUsage(), start_xact_command(), STATE_RUNNING, RawStmt::stmt, stmt, PortalData::visible, whereToSendOutput, and XACT_FLAGS_NEEDIMMEDIATECOMMIT.
Referenced by PostgresMain().
|
static |
Definition at line 2771 of file postgres.c.
References CommitTransactionCommand(), disable_statement_timeout(), MemoryContextStats(), TopMemoryContext, and xact_started.
Referenced by exec_execute_message(), exec_simple_query(), and PostgresMain().
void FloatExceptionHandler | ( | SIGNAL_ARGS | ) |
Definition at line 3019 of file postgres.c.
References ereport, errcode(), errdetail(), errmsg(), and ERROR.
Referenced by AutoVacWorkerMain(), BackgroundWorkerMain(), plperl_init_interp(), PostgresMain(), and ReplSlotSyncWorkerMain().
|
static |
Definition at line 4939 of file postgres.c.
References am_walsender, ereport, errcode(), errmsg(), ERROR, and PqMsg_FunctionCall.
Referenced by PostgresMain().
long get_stack_depth_rlimit | ( | void | ) |
Definition at line 4961 of file postgres.c.
References val.
Referenced by check_max_stack_depth(), and InitializeGUCOptionsFromEnvironment().
const char* get_stats_option_name | ( | const char * | arg | ) |
Definition at line 3750 of file postgres.c.
Referenced by PostmasterMain(), and process_postgres_switches().
void HandleRecoveryConflictInterrupt | ( | ProcSignalReason | reason | ) |
Definition at line 3035 of file postgres.c.
References InterruptPending, RecoveryConflictPending, and RecoveryConflictPendingReasons.
Referenced by procsignal_sigusr1_handler().
|
static |
Definition at line 332 of file postgres.c.
References CHECK_FOR_INTERRUPTS, and ProcessClientReadInterrupt().
Referenced by InteractiveBackend().
|
static |
Definition at line 244 of file postgres.c.
References appendStringInfoChar(), StringInfoData::data, EchoQuery, fflush(), interactive_getc(), StringInfoData::len, printf, resetStringInfo(), generate_unaccent_rules::stdout, and UseSemiNewlineNewline.
Referenced by ReadCommand().
Definition at line 2803 of file postgres.c.
References IsA, stmt, TRANS_STMT_COMMIT, TRANS_STMT_PREPARE, TRANS_STMT_ROLLBACK, and TRANS_STMT_ROLLBACK_TO.
Referenced by exec_bind_message(), exec_parse_message(), exec_simple_query(), and IsTransactionExitStmtList().
Definition at line 2820 of file postgres.c.
References CMD_UTILITY, PlannedStmt::commandType, IsTransactionExitStmt(), linitial_node, list_length(), and PlannedStmt::utilityStmt.
Referenced by exec_execute_message().
Definition at line 2835 of file postgres.c.
References CMD_UTILITY, PlannedStmt::commandType, IsA, linitial_node, list_length(), and PlannedStmt::utilityStmt.
Referenced by exec_execute_message().
|
static |
Definition at line 5109 of file postgres.c.
References ereport, errmsg(), GetCurrentTimestamp(), LOG, MyProcPort, MyStartTimestamp, port, SECS_PER_HOUR, SECS_PER_MINUTE, and TimestampDifference().
Referenced by PostgresMain().
List* pg_analyze_and_rewrite_fixedparams | ( | RawStmt * | parsetree, |
const char * | query_string, | ||
const Oid * | paramTypes, | ||
int | numParams, | ||
QueryEnvironment * | queryEnv | ||
) |
Definition at line 671 of file postgres.c.
References log_parser_stats, parse_analyze_fixedparams(), pg_rewrite_query(), ResetUsage(), and ShowUsage().
Referenced by _SPI_execute_plan(), _SPI_prepare_plan(), BeginCopyTo(), exec_simple_query(), execute_sql_string(), and RevalidateCachedQuery().
List* pg_analyze_and_rewrite_varparams | ( | RawStmt * | parsetree, |
const char * | query_string, | ||
Oid ** | paramTypes, | ||
int * | numParams, | ||
QueryEnvironment * | queryEnv | ||
) |
Definition at line 710 of file postgres.c.
References ereport, errcode(), errmsg(), ERROR, i, InvalidOid, log_parser_stats, parse_analyze_varparams(), pg_rewrite_query(), ResetUsage(), and ShowUsage().
Referenced by exec_parse_message(), and PrepareQuery().
List* pg_analyze_and_rewrite_withcb | ( | RawStmt * | parsetree, |
const char * | query_string, | ||
ParserSetupHook | parserSetup, | ||
void * | parserSetupArg, | ||
QueryEnvironment * | queryEnv | ||
) |
Definition at line 764 of file postgres.c.
References log_parser_stats, parse_analyze_withcb(), pg_rewrite_query(), ResetUsage(), and ShowUsage().
Referenced by _SPI_execute_plan(), _SPI_prepare_plan(), fmgr_sql_validator(), init_sql_fcache(), inline_set_returning_function(), and RevalidateCachedQuery().
List* pg_parse_query | ( | const char * | query_string | ) |
Definition at line 611 of file postgres.c.
References copyObject, elog, equal(), log_parser_stats, new_list(), nodeToStringWithLocations(), pfree(), RAW_PARSE_DEFAULT, raw_parser(), ResetUsage(), ShowUsage(), str, and WARNING.
Referenced by exec_parse_message(), exec_simple_query(), execute_sql_string(), fmgr_sql_validator(), ImportForeignSchema(), init_sql_fcache(), inline_function(), and inline_set_returning_function().
List* pg_plan_queries | ( | List * | querytrees, |
const char * | query_string, | ||
int | cursorOptions, | ||
ParamListInfo | boundParams | ||
) |
Definition at line 972 of file postgres.c.
References CMD_UTILITY, Query::commandType, lappend(), lfirst_node, makeNode, NIL, pg_plan_query(), stmt, Query::stmt_location, and Query::utilityStmt.
Referenced by BuildCachedPlan(), exec_simple_query(), and execute_sql_string().
PlannedStmt* pg_plan_query | ( | Query * | querytree, |
const char * | query_string, | ||
int | cursorOptions, | ||
ParamListInfo | boundParams | ||
) |
Definition at line 886 of file postgres.c.
References ActiveSnapshotSet(), Assert, CMD_UTILITY, copyObject, Debug_pretty_print, Debug_print_plan, elog, elog_node_display(), equal(), LOG, log_planner_stats, nodeToStringWithLocations(), pfree(), plan, planner(), querytree(), ResetUsage(), ShowUsage(), str, and WARNING.
Referenced by BeginCopyTo(), ExecCreateTableAs(), init_execution_state(), PerformCursorOpen(), pg_plan_queries(), refresh_matview_datafill(), and standard_ExplainOneQuery().
Definition at line 804 of file postgres.c.
References CMD_UTILITY, Query::commandType, copyObject, Debug_pretty_print, Debug_print_parse, Debug_print_rewritten, elog, elog_node_display(), equal(), lappend(), lfirst_node, list_make1, LOG, log_parser_stats, new_list(), NIL, nodeToStringWithLocations(), pfree(), QueryRewrite(), ResetUsage(), ShowUsage(), str, and WARNING.
Referenced by fmgr_sql_validator(), init_sql_fcache(), inline_set_returning_function(), pg_analyze_and_rewrite_fixedparams(), pg_analyze_and_rewrite_varparams(), and pg_analyze_and_rewrite_withcb().
void PostgresMain | ( | const char * | dbname, |
const char * | username | ||
) |
Definition at line 4152 of file postgres.c.
References AbortCurrentTransaction(), ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, am_walsender, Assert, BaseInit(), BeginReportingGUCOptions(), buf, CHECK_FOR_INTERRUPTS, ConfigReloadPending, dbname, debug_query_string, DestDebug, DestNone, DestRemote, die(), disable_all_timeouts(), disable_timeout(), DISCONNECT_CLIENT_EOF, doing_extended_query_message, DoingCommandRead, drop_unnamed_stmt(), DropPreparedStatement(), EmitErrorReport(), enable_timeout_after(), ereport, errcode(), errmsg(), ERROR, error_context_stack, EventTriggerOnLogin(), exec_bind_message(), exec_describe_portal_message(), exec_describe_statement_message(), exec_execute_message(), exec_parse_message(), exec_replication_command(), exec_simple_query(), FATAL, finish_xact_command(), FloatExceptionHandler(), FlushErrorState(), forbidden_in_wal_sender(), get_timeout_active(), GetPortalByName(), HandleFunctionRequest(), HOLD_INTERRUPTS, i, IDLE_IN_TRANSACTION_SESSION_TIMEOUT, IDLE_SESSION_TIMEOUT, IDLE_STATS_UPDATE_TIMEOUT, IdleInTransactionSessionTimeout, IdleSessionTimeout, ignore_till_sync, INIT_PG_LOAD_SESSION_LIBS, InitializeTimeouts(), InitPostgres(), InitProcessing, initStringInfo(), InitWalSender(), InvalidateCatalogSnapshotConditionally(), InvalidOid, IsAbortedTransactionBlockState(), IsTransactionOrTransactionBlock(), IsUnderPostmaster, jit_reset_after_error(), Log_disconnections, log_disconnections(), MemoryContextDelete(), MemoryContextReset(), MemoryContextSwitchTo(), MessageContext, MyCancelKey, MyDatabaseId, MyProcPid, MyReplicationSlot, NormalProcessing, notifyInterruptPending, on_proc_exit(), palloc_array, PG_exception_stack, PGC_SIGHUP, pgstat_report_activity(), pgstat_report_connect(), pgstat_report_stat(), pgStatSessionEndCause, PortalDrop(), PortalErrorCleanup(), PortalIsValid, PostmasterContext, pq_beginmessage(), pq_comm_reset, pq_endmessage(), pq_flush, pq_getmsgbyte(), pq_getmsgend(), pq_getmsgint(), pq_getmsgstring(), pq_is_reading_msg(), pq_putemptymessage(), pq_sendint32(), PqMsg_BackendKeyData, PqMsg_Bind, PqMsg_Close, PqMsg_CloseComplete, PqMsg_CopyData, PqMsg_CopyDone, PqMsg_CopyFail, PqMsg_Describe, PqMsg_Execute, PqMsg_Flush, PqMsg_FunctionCall, PqMsg_Parse, PqMsg_Query, PqMsg_Sync, PqMsg_Terminate, pqsignal(), printf, proc_exit(), ProcessConfigFile(), ProcessNotifyInterrupt(), procsignal_sigusr1_handler(), QueryCancelPending, quickdie(), ReadCommand(), ReadyForQuery(), ReplicationSlotCleanup(), ReplicationSlotRelease(), ReportChangedGUCOptions(), RESUME_INTERRUPTS, row_description_buf, row_description_context, set_ps_display(), SetCurrentStatementStartTimestamp(), SetProcessingMode, SIG_DFL, SIG_IGN, SIGCHLD, SIGHUP, SignalHandlerForConfigReload(), SIGPIPE, SIGQUIT, SIGUSR1, SIGUSR2, start_xact_command(), STATE_FASTPATH, STATE_IDLE, STATE_IDLEINTRANSACTION, STATE_IDLEINTRANSACTION_ABORTED, StatementCancelHandler(), TopMemoryContext, TransactionTimeout, UnBlockSig, username, valgrind_report_error_query, WalSndErrorCleanup(), WalSndSignals(), whereToSendOutput, and xact_started.
Referenced by BackendMain(), and PostgresSingleUserMain().
void PostgresSingleUserMain | ( | int | argc, |
char * | argv[], | ||
const char * | username | ||
) |
Definition at line 4042 of file postgres.c.
References Assert, ChangeToDataDir(), checkDataDir(), CreateDataDirLockFile(), CreateSharedMemoryAndSemaphores(), dbname, ereport, errcode(), errmsg(), FATAL, GetCurrentTimestamp(), InitializeGUCOptions(), InitializeMaxBackends(), InitializeShmemGUCs(), InitializeWalConsistencyChecking(), InitProcess(), InitStandaloneProcess(), IsUnderPostmaster, LocalProcessControlFile(), PGC_POSTMASTER, PgStartTime, PostgresMain(), proc_exit(), process_postgres_switches(), process_shared_preload_libraries(), process_shmem_requests(), progname, SelectConfigFiles(), userDoption, and username.
Referenced by main().
void process_postgres_switches | ( | int | argc, |
char * | argv[], | ||
GucContext | ctx, | ||
const char ** | dbname | ||
) |
Definition at line 3790 of file postgres.c.
References dbname, EchoQuery, ereport, errcode(), errhint(), errmsg(), ERROR, FATAL, flag(), FrontendProtocol, get_stats_option_name(), getopt(), IsBinaryUpgrade, IsUnderPostmaster, MAXPGPATH, name, optarg, opterr, optind, OutputFileName, ParseLongOption(), pfree(), PGC_POSTMASTER, PGC_S_ARGV, PGC_S_CLIENT, progname, set_debug_options(), set_plan_disabling_options(), SetConfigOption(), strlcpy(), userDoption, UseSemiNewlineNewline, and value.
Referenced by PostgresSingleUserMain(), and process_startup_options().
void ProcessClientReadInterrupt | ( | bool | blocked | ) |
Definition at line 509 of file postgres.c.
References catchupInterruptPending, CHECK_FOR_INTERRUPTS, DoingCommandRead, MyLatch, notifyInterruptPending, ProcDiePending, ProcessCatchupInterrupt(), ProcessNotifyInterrupt(), and SetLatch().
Referenced by interactive_getc(), and secure_read().
void ProcessClientWriteInterrupt | ( | bool | blocked | ) |
Definition at line 555 of file postgres.c.
References CHECK_FOR_INTERRUPTS, CritSectionCount, DestNone, DestRemote, InterruptHoldoffCount, MyLatch, ProcDiePending, SetLatch(), and whereToSendOutput.
Referenced by secure_write().
void ProcessInterrupts | ( | void | ) |
Definition at line 3244 of file postgres.c.
References AmAutoVacuumWorkerProcess, AmBackgroundWorkerProcess, BackgroundWorker::bgw_type, CheckClientConnectionPending, client_connection_check_interval, CLIENT_CONNECTION_CHECK_TIMEOUT, ClientAuthInProgress, ClientConnectionLost, CritSectionCount, DEBUG1, DestNone, DestRemote, DoingCommandRead, enable_timeout_after(), ereport, errcode(), errmsg(), errmsg_internal(), ERROR, FATAL, get_timeout_finish_time(), get_timeout_indicator(), HandleParallelApplyMessages(), HandleParallelMessages(), IdleInTransactionSessionTimeout, IdleInTransactionSessionTimeoutPending, IdleSessionTimeout, IdleSessionTimeoutPending, IdleStatsUpdateTimeoutPending, INJECTION_POINT, InterruptHoldoffCount, InterruptPending, IsLogicalLauncher(), IsLogicalWorker(), IsTransactionOrTransactionBlock(), LOCK_TIMEOUT, LockErrorCleanup(), LogMemoryContextPending, MyBgworkerEntry, ParallelApplyMessagePending, ParallelMessagePending, pgstat_report_stat(), pq_check_connection(), proc_exit(), ProcDiePending, ProcessLogMemoryContextInterrupt(), ProcessProcSignalBarrier(), ProcessRecoveryConflictInterrupts(), ProcSignalBarrierPending, QueryCancelHoldoffCount, QueryCancelPending, RecoveryConflictPending, STATEMENT_TIMEOUT, TransactionTimeout, TransactionTimeoutPending, and whereToSendOutput.
Referenced by die().
|
static |
Definition at line 3047 of file postgres.c.
References CheckDeadLockAlert(), DoingCommandRead, elog, ereport, errcode(), ERRCODE_T_R_SERIALIZATION_FAILURE, errdetail_recovery_conflict(), errhint(), errmsg(), ERROR, FATAL, GetStartupBufferPinWaitBufId(), HoldingBufferPinThatDelaysRecovery(), InterruptPending, IsAbortedTransactionBlockState(), IsSubTransaction(), IsTransactionOrTransactionBlock(), IsWaitingForLock(), LockErrorCleanup(), MyProc, pgstat_report_recovery_conflict(), PROCSIG_RECOVERY_CONFLICT_BUFFERPIN, PROCSIG_RECOVERY_CONFLICT_DATABASE, PROCSIG_RECOVERY_CONFLICT_LOCK, PROCSIG_RECOVERY_CONFLICT_LOGICALSLOT, PROCSIG_RECOVERY_CONFLICT_SNAPSHOT, PROCSIG_RECOVERY_CONFLICT_STARTUP_DEADLOCK, PROCSIG_RECOVERY_CONFLICT_TABLESPACE, QueryCancelHoldoffCount, RecoveryConflictPending, PGPROC::recoveryConflictPending, and RecoveryConflictPendingReasons.
Referenced by ProcessRecoveryConflictInterrupts().
|
static |
Definition at line 3205 of file postgres.c.
References Assert, InterruptHoldoffCount, proc_exit_inprogress, ProcessRecoveryConflictInterrupt(), PROCSIG_RECOVERY_CONFLICT_FIRST, PROCSIG_RECOVERY_CONFLICT_LAST, RecoveryConflictPending, and RecoveryConflictPendingReasons.
Referenced by ProcessInterrupts().
void quickdie | ( | SIGNAL_ARGS | ) |
Definition at line 2875 of file postgres.c.
References BlockSig, ClientAuthInProgress, DestNone, DestRemote, ereport, errcode(), errdetail(), errhint(), errmsg(), error_context_stack, GetQuitSignalReason(), HOLD_INTERRUPTS, PMQUIT_FOR_CRASH, PMQUIT_FOR_STOP, PMQUIT_NOT_SENT, SIGQUIT, WARNING, WARNING_CLIENT_ONLY, and whereToSendOutput.
Referenced by PostgresMain().
|
static |
Definition at line 488 of file postgres.c.
References DestRemote, InteractiveBackend(), SocketBackend(), and whereToSendOutput.
Referenced by PostgresMain().
void ResetUsage | ( | void | ) |
Definition at line 4993 of file postgres.c.
References getrusage(), gettimeofday(), RUSAGE_SELF, Save_r, and Save_t.
Referenced by _bt_leader_participate_as_worker(), _bt_leafbuild(), _bt_parallel_build_main(), _SPI_pquery(), btbuild(), exec_bind_message(), exec_execute_message(), exec_parse_message(), exec_simple_query(), pg_analyze_and_rewrite_fixedparams(), pg_analyze_and_rewrite_varparams(), pg_analyze_and_rewrite_withcb(), pg_parse_query(), pg_plan_query(), pg_rewrite_query(), PortalRun(), and PortalRunMulti().
void restore_stack_base | ( | pg_stack_base_t | base | ) |
void set_debug_options | ( | int | debug_flag, |
GucContext | context, | ||
GucSource | source | ||
) |
Definition at line 3679 of file postgres.c.
References context, PGC_POSTMASTER, SetConfigOption(), source, and sprintf.
Referenced by PostmasterMain(), and process_postgres_switches().
bool set_plan_disabling_options | ( | const char * | arg, |
GucContext | context, | ||
GucSource | source | ||
) |
Definition at line 3708 of file postgres.c.
References arg, context, SetConfigOption(), and source.
Referenced by PostmasterMain(), and process_postgres_switches().
pg_stack_base_t set_stack_base | ( | void | ) |
Definition at line 3481 of file postgres.c.
References stack_base_ptr.
Referenced by InitPostmasterChild(), and PostmasterMain().
void ShowUsage | ( | const char * | title | ) |
Definition at line 5000 of file postgres.c.
References __darwin__, appendStringInfo(), appendStringInfoString(), ereport, errdetail_internal(), errmsg_internal(), getrusage(), gettimeofday(), initStringInfo(), LOG, pfree(), rusage::ru_stime, rusage::ru_utime, RUSAGE_SELF, Save_r, Save_t, str, and user.
Referenced by _bt_leader_participate_as_worker(), _bt_leafbuild(), _bt_parallel_build_main(), _SPI_pquery(), btbuild(), exec_bind_message(), exec_execute_message(), exec_parse_message(), exec_simple_query(), pg_analyze_and_rewrite_fixedparams(), pg_analyze_and_rewrite_varparams(), pg_analyze_and_rewrite_withcb(), pg_parse_query(), pg_plan_query(), pg_rewrite_query(), PortalRun(), and PortalRunMulti().
|
static |
Definition at line 360 of file postgres.c.
References COMMERROR, DEBUG1, DestNone, doing_extended_query_message, ereport, errcode(), errmsg(), errmsg_internal(), FATAL, HOLD_CANCEL_INTERRUPTS, ignore_till_sync, IsTransactionState(), pq_getbyte(), pq_getmessage(), PQ_LARGE_MESSAGE_LIMIT, PQ_SMALL_MESSAGE_LIMIT, pq_startmsgread(), PqMsg_Bind, PqMsg_Close, PqMsg_CopyData, PqMsg_CopyDone, PqMsg_CopyFail, PqMsg_Describe, PqMsg_Execute, PqMsg_Flush, PqMsg_FunctionCall, PqMsg_Parse, PqMsg_Query, PqMsg_Sync, PqMsg_Terminate, RESUME_CANCEL_INTERRUPTS, and whereToSendOutput.
Referenced by ReadCommand().
bool stack_is_too_deep | ( | void | ) |
Definition at line 3545 of file postgres.c.
References max_stack_depth_bytes, and stack_base_ptr.
Referenced by check_stack_depth(), MemoryContextStatsInternal(), rstacktoodeep(), and ShowTransactionStateRec().
|
static |
Definition at line 2743 of file postgres.c.
References client_connection_check_interval, CLIENT_CONNECTION_CHECK_TIMEOUT, enable_statement_timeout(), enable_timeout_after(), get_timeout_active(), IsUnderPostmaster, MyProcPort, StartTransactionCommand(), and xact_started.
Referenced by exec_bind_message(), exec_describe_portal_message(), exec_describe_statement_message(), exec_execute_message(), exec_parse_message(), exec_simple_query(), and PostgresMain().
void StatementCancelHandler | ( | SIGNAL_ARGS | ) |
Definition at line 3002 of file postgres.c.
References InterruptPending, MyLatch, proc_exit_inprogress, QueryCancelPending, and SetLatch().
Referenced by AutoVacWorkerMain(), BackgroundWorkerMain(), PostgresMain(), and WalSndSignals().
int client_connection_check_interval = 0 |
Definition at line 104 of file postgres.c.
Referenced by ProcessInterrupts(), and start_xact_command().
const char* debug_query_string |
Definition at line 87 of file postgres.c.
Referenced by _brin_begin_parallel(), _brin_parallel_build_main(), _bt_begin_parallel(), _bt_parallel_build_main(), check_log_of_query(), current_query(), errstart(), exec_bind_message(), exec_execute_message(), exec_parse_message(), exec_replication_command(), exec_simple_query(), initialize_worker_spi(), parallel_vacuum_init(), parallel_vacuum_main(), ParallelQueryMain(), PostgresMain(), proc_exit_prepare(), send_message_to_server_log(), worker_spi_main(), write_csvlog(), and write_jsonlog().
Definition at line 150 of file postgres.c.
Referenced by PostgresMain(), and SocketBackend().
Definition at line 144 of file postgres.c.
Referenced by die(), PostgresMain(), ProcessClientReadInterrupt(), ProcessInterrupts(), and ProcessRecoveryConflictInterrupt().
Definition at line 162 of file postgres.c.
Referenced by InteractiveBackend(), and process_postgres_switches().
Definition at line 151 of file postgres.c.
Referenced by PostgresMain(), and SocketBackend().
Definition at line 93 of file postgres.c.
Referenced by PostgresMain().
int log_statement = LOGSTMT_NONE |
Definition at line 95 of file postgres.c.
Referenced by check_log_statement(), and HandleFunctionRequest().
int max_stack_depth = 100 |
Definition at line 98 of file postgres.c.
Referenced by check_stack_depth().
|
static |
Definition at line 125 of file postgres.c.
Referenced by assign_max_stack_depth(), and stack_is_too_deep().
int PostAuthDelay = 0 |
Definition at line 101 of file postgres.c.
Referenced by AutoVacWorkerMain(), BackgroundWorkerMain(), and InitPostgres().
|
static |
Definition at line 166 of file postgres.c.
Referenced by HandleRecoveryConflictInterrupt(), ProcessInterrupts(), ProcessRecoveryConflictInterrupt(), and ProcessRecoveryConflictInterrupts().
|
static |
Definition at line 167 of file postgres.c.
Referenced by HandleRecoveryConflictInterrupt(), ProcessRecoveryConflictInterrupt(), and ProcessRecoveryConflictInterrupts().
|
static |
Definition at line 171 of file postgres.c.
Referenced by exec_describe_portal_message(), exec_describe_statement_message(), and PostgresMain().
|
static |
Definition at line 170 of file postgres.c.
Referenced by PostgresMain().
|
static |
Definition at line 4961 of file postgres.c.
Referenced by ResetUsage(), and ShowUsage().
|
static |
Definition at line 4961 of file postgres.c.
Referenced by ResetUsage(), and ShowUsage().
|
static |
Definition at line 131 of file postgres.c.
Referenced by restore_stack_base(), set_stack_base(), and stack_is_too_deep().
|
static |
Definition at line 158 of file postgres.c.
Referenced by drop_unnamed_stmt(), exec_bind_message(), exec_describe_statement_message(), and exec_parse_message().
|
static |
Definition at line 161 of file postgres.c.
Referenced by BootstrapModeMain(), PostgresSingleUserMain(), PostmasterMain(), process_postgres_switches(), and SelectConfigFiles().
Definition at line 163 of file postgres.c.
Referenced by InteractiveBackend(), and process_postgres_switches().
CommandDest whereToSendOutput = DestDebug |
Definition at line 90 of file postgres.c.
Referenced by BackendInitialize(), BeginCopyFrom(), BeginCopyTo(), BeginReportingGUCOptions(), die(), DoCopyTo(), errfinish(), exec_bind_message(), exec_describe_portal_message(), exec_describe_statement_message(), exec_execute_message(), exec_parse_message(), exec_simple_query(), NotifyMyFrontEnd(), PostgresMain(), PostmasterMain(), pq_cleanup_redirect_to_shm_mq(), pq_redirect_to_shm_mq(), ProcessClientWriteInterrupt(), ProcessInterrupts(), quickdie(), ReadCommand(), send_message_to_server_log(), should_output_to_client(), SocketBackend(), SyncRepWaitForLSN(), and SysLoggerMain().
Definition at line 137 of file postgres.c.
Referenced by enable_statement_timeout(), finish_xact_command(), PostgresMain(), and start_xact_command().