PostgreSQL Source Code git master
tcopprot.h File Reference
#include "nodes/params.h"
#include "nodes/plannodes.h"
#include "storage/procsignal.h"
#include "utils/guc.h"
#include "utils/queryenvironment.h"
Include dependency graph for tcopprot.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define RESTRICT_RELKIND_VIEW   0x01
 
#define RESTRICT_RELKIND_FOREIGN_TABLE   0x02
 

Enumerations

enum  LogStmtLevel { LOGSTMT_NONE , LOGSTMT_DDL , LOGSTMT_MOD , LOGSTMT_ALL }
 

Functions

Listpg_parse_query (const char *query_string)
 
Listpg_rewrite_query (Query *query)
 
Listpg_analyze_and_rewrite_fixedparams (RawStmt *parsetree, const char *query_string, const Oid *paramTypes, int numParams, QueryEnvironment *queryEnv)
 
Listpg_analyze_and_rewrite_varparams (RawStmt *parsetree, const char *query_string, Oid **paramTypes, int *numParams, QueryEnvironment *queryEnv)
 
Listpg_analyze_and_rewrite_withcb (RawStmt *parsetree, const char *query_string, ParserSetupHook parserSetup, void *parserSetupArg, QueryEnvironment *queryEnv)
 
PlannedStmtpg_plan_query (Query *querytree, const char *query_string, int cursorOptions, ParamListInfo boundParams)
 
Listpg_plan_queries (List *querytrees, const char *query_string, int cursorOptions, ParamListInfo boundParams)
 
void die (SIGNAL_ARGS)
 
pg_noreturn void quickdie (SIGNAL_ARGS)
 
void StatementCancelHandler (SIGNAL_ARGS)
 
pg_noreturn void FloatExceptionHandler (SIGNAL_ARGS)
 
void HandleRecoveryConflictInterrupt (ProcSignalReason reason)
 
void ProcessClientReadInterrupt (bool blocked)
 
void ProcessClientWriteInterrupt (bool blocked)
 
void process_postgres_switches (int argc, char *argv[], GucContext ctx, const char **dbname)
 
pg_noreturn void PostgresSingleUserMain (int argc, char *argv[], const char *username)
 
pg_noreturn void PostgresMain (const char *dbname, const char *username)
 
void ResetUsage (void)
 
void ShowUsage (const char *title)
 
int check_log_duration (char *msec_str, bool was_logged)
 
void set_debug_options (int debug_flag, GucContext context, GucSource source)
 
bool set_plan_disabling_options (const char *arg, GucContext context, GucSource source)
 
const char * get_stats_option_name (const char *arg)
 

Variables

PGDLLIMPORT CommandDest whereToSendOutput
 
PGDLLIMPORT const char * debug_query_string
 
PGDLLIMPORT int PostAuthDelay
 
PGDLLIMPORT int client_connection_check_interval
 
PGDLLIMPORT bool Log_disconnections
 
PGDLLIMPORT int log_statement
 
PGDLLIMPORT int restrict_nonsystem_relation_kind
 

Macro Definition Documentation

◆ RESTRICT_RELKIND_FOREIGN_TABLE

#define RESTRICT_RELKIND_FOREIGN_TABLE   0x02

Definition at line 44 of file tcopprot.h.

◆ RESTRICT_RELKIND_VIEW

#define RESTRICT_RELKIND_VIEW   0x01

Definition at line 43 of file tcopprot.h.

Enumeration Type Documentation

◆ LogStmtLevel

Enumerator
LOGSTMT_NONE 
LOGSTMT_DDL 
LOGSTMT_MOD 
LOGSTMT_ALL 

Definition at line 31 of file tcopprot.h.

32{
33 LOGSTMT_NONE, /* log no statements */
34 LOGSTMT_DDL, /* log data definition statements */
35 LOGSTMT_MOD, /* log modification statements, plus DDL */
36 LOGSTMT_ALL, /* log all statements */
LogStmtLevel
Definition: tcopprot.h:32
@ LOGSTMT_NONE
Definition: tcopprot.h:33
@ LOGSTMT_MOD
Definition: tcopprot.h:35
@ LOGSTMT_DDL
Definition: tcopprot.h:34
@ LOGSTMT_ALL
Definition: tcopprot.h:36

Function Documentation

◆ check_log_duration()

int check_log_duration ( char *  msec_str,
bool  was_logged 
)

Definition at line 2401 of file postgres.c.

2402{
2405 {
2406 long secs;
2407 int usecs;
2408 int msecs;
2409 bool exceeded_duration;
2410 bool exceeded_sample_duration;
2411 bool in_sample = false;
2412
2415 &secs, &usecs);
2416 msecs = usecs / 1000;
2417
2418 /*
2419 * This odd-looking test for log_min_duration_* being exceeded is
2420 * designed to avoid integer overflow with very long durations: don't
2421 * compute secs * 1000 until we've verified it will fit in int.
2422 */
2423 exceeded_duration = (log_min_duration_statement == 0 ||
2425 (secs > log_min_duration_statement / 1000 ||
2426 secs * 1000 + msecs >= log_min_duration_statement)));
2427
2428 exceeded_sample_duration = (log_min_duration_sample == 0 ||
2430 (secs > log_min_duration_sample / 1000 ||
2431 secs * 1000 + msecs >= log_min_duration_sample)));
2432
2433 /*
2434 * Do not log if log_statement_sample_rate = 0. Log a sample if
2435 * log_statement_sample_rate <= 1 and avoid unnecessary PRNG call if
2436 * log_statement_sample_rate = 1.
2437 */
2438 if (exceeded_sample_duration)
2439 in_sample = log_statement_sample_rate != 0 &&
2442
2443 if (exceeded_duration || in_sample || log_duration || xact_is_sampled)
2444 {
2445 snprintf(msec_str, 32, "%ld.%03d",
2446 secs * 1000 + msecs, usecs % 1000);
2447 if ((exceeded_duration || in_sample || xact_is_sampled) && !was_logged)
2448 return 2;
2449 else
2450 return 1;
2451 }
2452 }
2453
2454 return 0;
2455}
void TimestampDifference(TimestampTz start_time, TimestampTz stop_time, long *secs, int *microsecs)
Definition: timestamp.c:1720
TimestampTz GetCurrentTimestamp(void)
Definition: timestamp.c:1644
int log_min_duration_statement
Definition: guc_tables.c:530
int log_min_duration_sample
Definition: guc_tables.c:529
double log_statement_sample_rate
Definition: guc_tables.c:534
bool log_duration
Definition: guc_tables.c:495
double pg_prng_double(pg_prng_state *state)
Definition: pg_prng.c:268
pg_prng_state pg_global_prng_state
Definition: pg_prng.c:34
#define snprintf
Definition: port.h:239
TimestampTz GetCurrentStatementStartTimestamp(void)
Definition: xact.c:879
bool xact_is_sampled
Definition: xact.c:296

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().

◆ die()

void die ( SIGNAL_ARGS  )

Definition at line 3004 of file postgres.c.

3005{
3006 /* Don't joggle the elbow of proc_exit */
3008 {
3009 InterruptPending = true;
3010 ProcDiePending = true;
3011 }
3012
3013 /* for the cumulative stats system */
3015
3016 /* If we're still here, waken anything waiting on the process latch */
3018
3019 /*
3020 * If we're in single user mode, we want to quit immediately - we can't
3021 * rely on latches as they wouldn't work when stdin/stdout is a file.
3022 * Rather ugly, but it's unlikely to be worthwhile to invest much more
3023 * effort just for the benefit of single user mode.
3024 */
3027}
@ DestRemote
Definition: dest.h:89
volatile sig_atomic_t InterruptPending
Definition: globals.c:31
struct Latch * MyLatch
Definition: globals.c:62
volatile sig_atomic_t ProcDiePending
Definition: globals.c:33
bool proc_exit_inprogress
Definition: ipc.c:40
void SetLatch(Latch *latch)
Definition: latch.c:288
@ DISCONNECT_KILLED
Definition: pgstat.h:58
SessionEndType pgStatSessionEndCause
CommandDest whereToSendOutput
Definition: postgres.c:91
static bool DoingCommandRead
Definition: postgres.c:136
void ProcessInterrupts(void)
Definition: postgres.c:3276

References DestRemote, DISCONNECT_KILLED, DoingCommandRead, InterruptPending, MyLatch, pgStatSessionEndCause, proc_exit_inprogress, ProcDiePending, ProcessInterrupts(), SetLatch(), and whereToSendOutput.

Referenced by PostgresMain().

◆ FloatExceptionHandler()

pg_noreturn void FloatExceptionHandler ( SIGNAL_ARGS  )

Definition at line 3051 of file postgres.c.

3052{
3053 /* We're not returning, so no need to save errno */
3054 ereport(ERROR,
3055 (errcode(ERRCODE_FLOATING_POINT_EXCEPTION),
3056 errmsg("floating-point exception"),
3057 errdetail("An invalid floating-point operation was signaled. "
3058 "This probably means an out-of-range result or an "
3059 "invalid operation, such as division by zero.")));
3060}
int errdetail(const char *fmt,...)
Definition: elog.c:1203
int errcode(int sqlerrcode)
Definition: elog.c:853
int errmsg(const char *fmt,...)
Definition: elog.c:1070
#define ERROR
Definition: elog.h:39
#define ereport(elevel,...)
Definition: elog.h:149

References ereport, errcode(), errdetail(), errmsg(), and ERROR.

Referenced by AutoVacLauncherMain(), AutoVacWorkerMain(), BackgroundWorkerMain(), plperl_init_interp(), PostgresMain(), and ReplSlotSyncWorkerMain().

◆ get_stats_option_name()

const char * get_stats_option_name ( const char *  arg)

Definition at line 3722 of file postgres.c.

3723{
3724 switch (arg[0])
3725 {
3726 case 'p':
3727 if (optarg[1] == 'a') /* "parser" */
3728 return "log_parser_stats";
3729 else if (optarg[1] == 'l') /* "planner" */
3730 return "log_planner_stats";
3731 break;
3732
3733 case 'e': /* "executor" */
3734 return "log_executor_stats";
3735 break;
3736 }
3737
3738 return NULL;
3739}
void * arg
PGDLLIMPORT char * optarg
Definition: getopt.c:53

References arg, and optarg.

Referenced by PostmasterMain(), and process_postgres_switches().

◆ HandleRecoveryConflictInterrupt()

void HandleRecoveryConflictInterrupt ( ProcSignalReason  reason)

Definition at line 3067 of file postgres.c.

3068{
3069 RecoveryConflictPendingReasons[reason] = true;
3071 InterruptPending = true;
3072 /* latch will be set by procsignal_sigusr1_handler */
3073}
static volatile sig_atomic_t RecoveryConflictPendingReasons[NUM_PROCSIGNALS]
Definition: postgres.c:159
static volatile sig_atomic_t RecoveryConflictPending
Definition: postgres.c:158

References InterruptPending, RecoveryConflictPending, and RecoveryConflictPendingReasons.

Referenced by procsignal_sigusr1_handler().

◆ pg_analyze_and_rewrite_fixedparams()

List * pg_analyze_and_rewrite_fixedparams ( RawStmt parsetree,
const char *  query_string,
const Oid paramTypes,
int  numParams,
QueryEnvironment queryEnv 
)

Definition at line 665 of file postgres.c.

670{
671 Query *query;
672 List *querytree_list;
673
674 TRACE_POSTGRESQL_QUERY_REWRITE_START(query_string);
675
676 /*
677 * (1) Perform parse analysis.
678 */
680 ResetUsage();
681
682 query = parse_analyze_fixedparams(parsetree, query_string, paramTypes, numParams,
683 queryEnv);
684
686 ShowUsage("PARSE ANALYSIS STATISTICS");
687
688 /*
689 * (2) Rewrite the queries, as necessary
690 */
691 querytree_list = pg_rewrite_query(query);
692
693 TRACE_POSTGRESQL_QUERY_REWRITE_DONE(query_string);
694
695 return querytree_list;
696}
bool log_parser_stats
Definition: guc_tables.c:507
Query * parse_analyze_fixedparams(RawStmt *parseTree, const char *sourceText, const Oid *paramTypes, int numParams, QueryEnvironment *queryEnv)
Definition: analyze.c:105
List * pg_rewrite_query(Query *query)
Definition: postgres.c:798
void ShowUsage(const char *title)
Definition: postgres.c:5026
void ResetUsage(void)
Definition: postgres.c:5019
Definition: pg_list.h:54

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().

◆ pg_analyze_and_rewrite_varparams()

List * pg_analyze_and_rewrite_varparams ( RawStmt parsetree,
const char *  query_string,
Oid **  paramTypes,
int *  numParams,
QueryEnvironment queryEnv 
)

Definition at line 704 of file postgres.c.

709{
710 Query *query;
711 List *querytree_list;
712
713 TRACE_POSTGRESQL_QUERY_REWRITE_START(query_string);
714
715 /*
716 * (1) Perform parse analysis.
717 */
719 ResetUsage();
720
721 query = parse_analyze_varparams(parsetree, query_string, paramTypes, numParams,
722 queryEnv);
723
724 /*
725 * Check all parameter types got determined.
726 */
727 for (int i = 0; i < *numParams; i++)
728 {
729 Oid ptype = (*paramTypes)[i];
730
731 if (ptype == InvalidOid || ptype == UNKNOWNOID)
733 (errcode(ERRCODE_INDETERMINATE_DATATYPE),
734 errmsg("could not determine data type of parameter $%d",
735 i + 1)));
736 }
737
739 ShowUsage("PARSE ANALYSIS STATISTICS");
740
741 /*
742 * (2) Rewrite the queries, as necessary
743 */
744 querytree_list = pg_rewrite_query(query);
745
746 TRACE_POSTGRESQL_QUERY_REWRITE_DONE(query_string);
747
748 return querytree_list;
749}
int i
Definition: isn.c:74
Query * parse_analyze_varparams(RawStmt *parseTree, const char *sourceText, Oid **paramTypes, int *numParams, QueryEnvironment *queryEnv)
Definition: analyze.c:145
#define InvalidOid
Definition: postgres_ext.h:37
unsigned int Oid
Definition: postgres_ext.h:32

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().

◆ pg_analyze_and_rewrite_withcb()

List * pg_analyze_and_rewrite_withcb ( RawStmt parsetree,
const char *  query_string,
ParserSetupHook  parserSetup,
void *  parserSetupArg,
QueryEnvironment queryEnv 
)

Definition at line 758 of file postgres.c.

763{
764 Query *query;
765 List *querytree_list;
766
767 TRACE_POSTGRESQL_QUERY_REWRITE_START(query_string);
768
769 /*
770 * (1) Perform parse analysis.
771 */
773 ResetUsage();
774
775 query = parse_analyze_withcb(parsetree, query_string, parserSetup, parserSetupArg,
776 queryEnv);
777
779 ShowUsage("PARSE ANALYSIS STATISTICS");
780
781 /*
782 * (2) Rewrite the queries, as necessary
783 */
784 querytree_list = pg_rewrite_query(query);
785
786 TRACE_POSTGRESQL_QUERY_REWRITE_DONE(query_string);
787
788 return querytree_list;
789}
Query * parse_analyze_withcb(RawStmt *parseTree, const char *sourceText, ParserSetupHook parserSetup, void *parserSetupArg, QueryEnvironment *queryEnv)
Definition: analyze.c:186

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().

◆ pg_parse_query()

List * pg_parse_query ( const char *  query_string)

Definition at line 603 of file postgres.c.

604{
605 List *raw_parsetree_list;
606
607 TRACE_POSTGRESQL_QUERY_PARSE_START(query_string);
608
610 ResetUsage();
611
612 raw_parsetree_list = raw_parser(query_string, RAW_PARSE_DEFAULT);
613
615 ShowUsage("PARSER STATISTICS");
616
617#ifdef DEBUG_NODE_TESTS_ENABLED
618
619 /* Optional debugging check: pass raw parsetrees through copyObject() */
620 if (Debug_copy_parse_plan_trees)
621 {
622 List *new_list = copyObject(raw_parsetree_list);
623
624 /* This checks both copyObject() and the equal() routines... */
625 if (!equal(new_list, raw_parsetree_list))
626 elog(WARNING, "copyObject() failed to produce an equal raw parse tree");
627 else
628 raw_parsetree_list = new_list;
629 }
630
631 /*
632 * Optional debugging check: pass raw parsetrees through
633 * outfuncs/readfuncs
634 */
635 if (Debug_write_read_parse_plan_trees)
636 {
637 char *str = nodeToStringWithLocations(raw_parsetree_list);
638 List *new_list = stringToNodeWithLocations(str);
639
640 pfree(str);
641 /* This checks both outfuncs/readfuncs and the equal() routines... */
642 if (!equal(new_list, raw_parsetree_list))
643 elog(WARNING, "outfuncs/readfuncs failed to produce an equal raw parse tree");
644 else
645 raw_parsetree_list = new_list;
646 }
647
648#endif /* DEBUG_NODE_TESTS_ENABLED */
649
650 TRACE_POSTGRESQL_QUERY_PARSE_DONE(query_string);
651
652 return raw_parsetree_list;
653}
List * raw_parser(const char *str, RawParseMode mode)
Definition: parser.c:42
#define WARNING
Definition: elog.h:36
#define elog(elevel,...)
Definition: elog.h:225
bool equal(const void *a, const void *b)
Definition: equalfuncs.c:223
const char * str
static List * new_list(NodeTag type, int min_size)
Definition: list.c:91
void pfree(void *pointer)
Definition: mcxt.c:1524
#define copyObject(obj)
Definition: nodes.h:226
char * nodeToStringWithLocations(const void *obj)
Definition: outfuncs.c:800
@ RAW_PARSE_DEFAULT
Definition: parser.h:39

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().

◆ pg_plan_queries()

List * pg_plan_queries ( List querytrees,
const char *  query_string,
int  cursorOptions,
ParamListInfo  boundParams 
)

Definition at line 970 of file postgres.c.

972{
973 List *stmt_list = NIL;
974 ListCell *query_list;
975
976 foreach(query_list, querytrees)
977 {
978 Query *query = lfirst_node(Query, query_list);
980
981 if (query->commandType == CMD_UTILITY)
982 {
983 /* Utility commands require no planning. */
985 stmt->commandType = CMD_UTILITY;
986 stmt->canSetTag = query->canSetTag;
987 stmt->utilityStmt = query->utilityStmt;
988 stmt->stmt_location = query->stmt_location;
989 stmt->stmt_len = query->stmt_len;
990 stmt->queryId = query->queryId;
991 }
992 else
993 {
994 stmt = pg_plan_query(query, query_string, cursorOptions,
995 boundParams);
996 }
997
998 stmt_list = lappend(stmt_list, stmt);
999 }
1000
1001 return stmt_list;
1002}
#define stmt
Definition: indent_codes.h:59
List * lappend(List *list, void *datum)
Definition: list.c:339
@ CMD_UTILITY
Definition: nodes.h:272
#define makeNode(_type_)
Definition: nodes.h:157
#define lfirst_node(type, lc)
Definition: pg_list.h:176
#define NIL
Definition: pg_list.h:68
PlannedStmt * pg_plan_query(Query *querytree, const char *query_string, int cursorOptions, ParamListInfo boundParams)
Definition: postgres.c:882
CmdType commandType
Definition: parsenodes.h:121
Node * utilityStmt
Definition: parsenodes.h:136
ParseLoc stmt_location
Definition: parsenodes.h:249

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(), execute_sql_string(), and UpdateCachedPlan().

◆ pg_plan_query()

PlannedStmt * pg_plan_query ( Query querytree,
const char *  query_string,
int  cursorOptions,
ParamListInfo  boundParams 
)

Definition at line 882 of file postgres.c.

884{
886
887 /* Utility commands have no plans. */
888 if (querytree->commandType == CMD_UTILITY)
889 return NULL;
890
891 /* Planner must have a snapshot in case it calls user-defined functions. */
893
894 TRACE_POSTGRESQL_QUERY_PLAN_START();
895
897 ResetUsage();
898
899 /* call the optimizer */
900 plan = planner(querytree, query_string, cursorOptions, boundParams);
901
903 ShowUsage("PLANNER STATISTICS");
904
905#ifdef DEBUG_NODE_TESTS_ENABLED
906
907 /* Optional debugging check: pass plan tree through copyObject() */
908 if (Debug_copy_parse_plan_trees)
909 {
910 PlannedStmt *new_plan = copyObject(plan);
911
912 /*
913 * equal() currently does not have routines to compare Plan nodes, so
914 * don't try to test equality here. Perhaps fix someday?
915 */
916#ifdef NOT_USED
917 /* This checks both copyObject() and the equal() routines... */
918 if (!equal(new_plan, plan))
919 elog(WARNING, "copyObject() failed to produce an equal plan tree");
920 else
921#endif
922 plan = new_plan;
923 }
924
925 /* Optional debugging check: pass plan tree through outfuncs/readfuncs */
926 if (Debug_write_read_parse_plan_trees)
927 {
928 char *str;
929 PlannedStmt *new_plan;
930
932 new_plan = stringToNodeWithLocations(str);
933 pfree(str);
934
935 /*
936 * equal() currently does not have routines to compare Plan nodes, so
937 * don't try to test equality here. Perhaps fix someday?
938 */
939#ifdef NOT_USED
940 /* This checks both outfuncs/readfuncs and the equal() routines... */
941 if (!equal(new_plan, plan))
942 elog(WARNING, "outfuncs/readfuncs failed to produce an equal plan tree");
943 else
944#endif
945 plan = new_plan;
946 }
947
948#endif /* DEBUG_NODE_TESTS_ENABLED */
949
950 /*
951 * Print plan if debugging.
952 */
955
956 TRACE_POSTGRESQL_QUERY_PLAN_DONE();
957
958 return plan;
959}
Datum querytree(PG_FUNCTION_ARGS)
Definition: _int_bool.c:665
void elog_node_display(int lev, const char *title, const void *obj, bool pretty)
Definition: print.c:72
#define LOG
Definition: elog.h:31
bool Debug_print_plan
Definition: guc_tables.c:496
bool Debug_pretty_print
Definition: guc_tables.c:499
bool log_planner_stats
Definition: guc_tables.c:508
Assert(PointerIsAligned(start, uint64))
#define plan(x)
Definition: pg_regress.c:161
PlannedStmt * planner(Query *parse, const char *query_string, int cursorOptions, ParamListInfo boundParams)
Definition: planner.c:285
bool ActiveSnapshotSet(void)
Definition: snapmgr.c:799

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().

◆ pg_rewrite_query()

List * pg_rewrite_query ( Query query)

Definition at line 798 of file postgres.c.

799{
800 List *querytree_list;
801
803 elog_node_display(LOG, "parse tree", query,
805
807 ResetUsage();
808
809 if (query->commandType == CMD_UTILITY)
810 {
811 /* don't rewrite utilities, just dump 'em into result list */
812 querytree_list = list_make1(query);
813 }
814 else
815 {
816 /* rewrite regular queries */
817 querytree_list = QueryRewrite(query);
818 }
819
821 ShowUsage("REWRITER STATISTICS");
822
823#ifdef DEBUG_NODE_TESTS_ENABLED
824
825 /* Optional debugging check: pass querytree through copyObject() */
826 if (Debug_copy_parse_plan_trees)
827 {
828 List *new_list;
829
830 new_list = copyObject(querytree_list);
831 /* This checks both copyObject() and the equal() routines... */
832 if (!equal(new_list, querytree_list))
833 elog(WARNING, "copyObject() failed to produce an equal rewritten parse tree");
834 else
835 querytree_list = new_list;
836 }
837
838 /* Optional debugging check: pass querytree through outfuncs/readfuncs */
839 if (Debug_write_read_parse_plan_trees)
840 {
841 List *new_list = NIL;
842 ListCell *lc;
843
844 foreach(lc, querytree_list)
845 {
846 Query *curr_query = lfirst_node(Query, lc);
847 char *str = nodeToStringWithLocations(curr_query);
848 Query *new_query = stringToNodeWithLocations(str);
849
850 /*
851 * queryId is not saved in stored rules, but we must preserve it
852 * here to avoid breaking pg_stat_statements.
853 */
854 new_query->queryId = curr_query->queryId;
855
856 new_list = lappend(new_list, new_query);
857 pfree(str);
858 }
859
860 /* This checks both outfuncs/readfuncs and the equal() routines... */
861 if (!equal(new_list, querytree_list))
862 elog(WARNING, "outfuncs/readfuncs failed to produce an equal rewritten parse tree");
863 else
864 querytree_list = new_list;
865 }
866
867#endif /* DEBUG_NODE_TESTS_ENABLED */
868
870 elog_node_display(LOG, "rewritten parse tree", querytree_list,
872
873 return querytree_list;
874}
bool Debug_print_rewritten
Definition: guc_tables.c:498
bool Debug_print_parse
Definition: guc_tables.c:497
#define list_make1(x1)
Definition: pg_list.h:212
List * QueryRewrite(Query *parsetree)

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().

◆ PostgresMain()

pg_noreturn void PostgresMain ( const char *  dbname,
const char *  username 
)

Definition at line 4156 of file postgres.c.

4157{
4158 sigjmp_buf local_sigjmp_buf;
4159
4160 /* these must be volatile to ensure state is preserved across longjmp: */
4161 volatile bool send_ready_for_query = true;
4162 volatile bool idle_in_transaction_timeout_enabled = false;
4163 volatile bool idle_session_timeout_enabled = false;
4164
4165 Assert(dbname != NULL);
4166 Assert(username != NULL);
4167
4169
4170 /*
4171 * Set up signal handlers. (InitPostmasterChild or InitStandaloneProcess
4172 * has already set up BlockSig and made that the active signal mask.)
4173 *
4174 * Note that postmaster blocked all signals before forking child process,
4175 * so there is no race condition whereby we might receive a signal before
4176 * we have set up the handler.
4177 *
4178 * Also note: it's best not to use any signals that are SIG_IGNored in the
4179 * postmaster. If such a signal arrives before we are able to change the
4180 * handler to non-SIG_IGN, it'll get dropped. Instead, make a dummy
4181 * handler in the postmaster to reserve the signal. (Of course, this isn't
4182 * an issue for signals that are locally generated, such as SIGALRM and
4183 * SIGPIPE.)
4184 */
4185 if (am_walsender)
4186 WalSndSignals();
4187 else
4188 {
4190 pqsignal(SIGINT, StatementCancelHandler); /* cancel current query */
4191 pqsignal(SIGTERM, die); /* cancel current query and exit */
4192
4193 /*
4194 * In a postmaster child backend, replace SignalHandlerForCrashExit
4195 * with quickdie, so we can tell the client we're dying.
4196 *
4197 * In a standalone backend, SIGQUIT can be generated from the keyboard
4198 * easily, while SIGTERM cannot, so we make both signals do die()
4199 * rather than quickdie().
4200 */
4202 pqsignal(SIGQUIT, quickdie); /* hard crash time */
4203 else
4204 pqsignal(SIGQUIT, die); /* cancel current query and exit */
4205 InitializeTimeouts(); /* establishes SIGALRM handler */
4206
4207 /*
4208 * Ignore failure to write to frontend. Note: if frontend closes
4209 * connection, we will notice it and exit cleanly when control next
4210 * returns to outer loop. This seems safer than forcing exit in the
4211 * midst of output during who-knows-what operation...
4212 */
4213 pqsignal(SIGPIPE, SIG_IGN);
4215 pqsignal(SIGUSR2, SIG_IGN);
4217
4218 /*
4219 * Reset some signals that are accepted by postmaster but not by
4220 * backend
4221 */
4222 pqsignal(SIGCHLD, SIG_DFL); /* system() requires this on some
4223 * platforms */
4224 }
4225
4226 /* Early initialization */
4227 BaseInit();
4228
4229 /* We need to allow SIGINT, etc during the initial transaction */
4230 sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
4231
4232 /*
4233 * Generate a random cancel key, if this is a backend serving a
4234 * connection. InitPostgres() will advertise it in shared memory.
4235 */
4238 {
4239 if (!pg_strong_random(&MyCancelKey, sizeof(int32)))
4240 {
4241 ereport(ERROR,
4242 (errcode(ERRCODE_INTERNAL_ERROR),
4243 errmsg("could not generate random cancel key")));
4244 }
4245 MyCancelKeyValid = true;
4246 }
4247
4248 /*
4249 * General initialization.
4250 *
4251 * NOTE: if you are tempted to add code in this vicinity, consider putting
4252 * it inside InitPostgres() instead. In particular, anything that
4253 * involves database access should be there, not here.
4254 *
4255 * Honor session_preload_libraries if not dealing with a WAL sender.
4256 */
4257 InitPostgres(dbname, InvalidOid, /* database to connect to */
4258 username, InvalidOid, /* role to connect as */
4260 NULL); /* no out_dbname */
4261
4262 /*
4263 * If the PostmasterContext is still around, recycle the space; we don't
4264 * need it anymore after InitPostgres completes.
4265 */
4267 {
4269 PostmasterContext = NULL;
4270 }
4271
4273
4274 /*
4275 * Now all GUC states are fully set up. Report them to client if
4276 * appropriate.
4277 */
4279
4280 /*
4281 * Also set up handler to log session end; we have to wait till now to be
4282 * sure Log_disconnections has its final value.
4283 */
4286
4288
4289 /* Perform initialization specific to a WAL sender process. */
4290 if (am_walsender)
4291 InitWalSender();
4292
4293 /*
4294 * Send this backend's cancellation info to the frontend.
4295 */
4297 {
4299
4305 /* Need not flush since ReadyForQuery will do it. */
4306 }
4307
4308 /* Welcome banner for standalone case */
4310 printf("\nPostgreSQL stand-alone backend %s\n", PG_VERSION);
4311
4312 /*
4313 * Create the memory context we will use in the main loop.
4314 *
4315 * MessageContext is reset once per iteration of the main loop, ie, upon
4316 * completion of processing of each command message from the client.
4317 */
4319 "MessageContext",
4321
4322 /*
4323 * Create memory context and buffer used for RowDescription messages. As
4324 * SendRowDescriptionMessage(), via exec_describe_statement_message(), is
4325 * frequently executed for ever single statement, we don't want to
4326 * allocate a separate buffer every time.
4327 */
4329 "RowDescriptionContext",
4334
4335 /* Fire any defined login event triggers, if appropriate */
4337
4338 /*
4339 * POSTGRES main processing loop begins here
4340 *
4341 * If an exception is encountered, processing resumes here so we abort the
4342 * current transaction and start a new one.
4343 *
4344 * You might wonder why this isn't coded as an infinite loop around a
4345 * PG_TRY construct. The reason is that this is the bottom of the
4346 * exception stack, and so with PG_TRY there would be no exception handler
4347 * in force at all during the CATCH part. By leaving the outermost setjmp
4348 * always active, we have at least some chance of recovering from an error
4349 * during error recovery. (If we get into an infinite loop thereby, it
4350 * will soon be stopped by overflow of elog.c's internal state stack.)
4351 *
4352 * Note that we use sigsetjmp(..., 1), so that this function's signal mask
4353 * (to wit, UnBlockSig) will be restored when longjmp'ing to here. This
4354 * is essential in case we longjmp'd out of a signal handler on a platform
4355 * where that leaves the signal blocked. It's not redundant with the
4356 * unblock in AbortTransaction() because the latter is only called if we
4357 * were inside a transaction.
4358 */
4359
4360 if (sigsetjmp(local_sigjmp_buf, 1) != 0)
4361 {
4362 /*
4363 * NOTE: if you are tempted to add more code in this if-block,
4364 * consider the high probability that it should be in
4365 * AbortTransaction() instead. The only stuff done directly here
4366 * should be stuff that is guaranteed to apply *only* for outer-level
4367 * error recovery, such as adjusting the FE/BE protocol status.
4368 */
4369
4370 /* Since not using PG_TRY, must reset error stack by hand */
4371 error_context_stack = NULL;
4372
4373 /* Prevent interrupts while cleaning up */
4375
4376 /*
4377 * Forget any pending QueryCancel request, since we're returning to
4378 * the idle loop anyway, and cancel any active timeout requests. (In
4379 * future we might want to allow some timeout requests to survive, but
4380 * at minimum it'd be necessary to do reschedule_timeouts(), in case
4381 * we got here because of a query cancel interrupting the SIGALRM
4382 * interrupt handler.) Note in particular that we must clear the
4383 * statement and lock timeout indicators, to prevent any future plain
4384 * query cancels from being misreported as timeouts in case we're
4385 * forgetting a timeout cancel.
4386 */
4387 disable_all_timeouts(false); /* do first to avoid race condition */
4388 QueryCancelPending = false;
4389 idle_in_transaction_timeout_enabled = false;
4390 idle_session_timeout_enabled = false;
4391
4392 /* Not reading from the client anymore. */
4393 DoingCommandRead = false;
4394
4395 /* Make sure libpq is in a good state */
4396 pq_comm_reset();
4397
4398 /* Report the error to the client and/or server log */
4400
4401 /*
4402 * If Valgrind noticed something during the erroneous query, print the
4403 * query string, assuming we have one.
4404 */
4406
4407 /*
4408 * Make sure debug_query_string gets reset before we possibly clobber
4409 * the storage it points at.
4410 */
4411 debug_query_string = NULL;
4412
4413 /*
4414 * Abort the current transaction in order to recover.
4415 */
4417
4418 if (am_walsender)
4420
4422
4423 /*
4424 * We can't release replication slots inside AbortTransaction() as we
4425 * need to be able to start and abort transactions while having a slot
4426 * acquired. But we never need to hold them across top level errors,
4427 * so releasing here is fine. There also is a before_shmem_exit()
4428 * callback ensuring correct cleanup on FATAL errors.
4429 */
4430 if (MyReplicationSlot != NULL)
4432
4433 /* We also want to cleanup temporary slots on error. */
4435
4437
4438 /*
4439 * Now return to normal top-level context and clear ErrorContext for
4440 * next time.
4441 */
4444
4445 /*
4446 * If we were handling an extended-query-protocol message, initiate
4447 * skip till next Sync. This also causes us not to issue
4448 * ReadyForQuery (until we get Sync).
4449 */
4451 ignore_till_sync = true;
4452
4453 /* We don't have a transaction command open anymore */
4454 xact_started = false;
4455
4456 /*
4457 * If an error occurred while we were reading a message from the
4458 * client, we have potentially lost track of where the previous
4459 * message ends and the next one begins. Even though we have
4460 * otherwise recovered from the error, we cannot safely read any more
4461 * messages from the client, so there isn't much we can do with the
4462 * connection anymore.
4463 */
4464 if (pq_is_reading_msg())
4465 ereport(FATAL,
4466 (errcode(ERRCODE_PROTOCOL_VIOLATION),
4467 errmsg("terminating connection because protocol synchronization was lost")));
4468
4469 /* Now we can allow interrupts again */
4471 }
4472
4473 /* We can now handle ereport(ERROR) */
4474 PG_exception_stack = &local_sigjmp_buf;
4475
4476 if (!ignore_till_sync)
4477 send_ready_for_query = true; /* initially, or after error */
4478
4479 /*
4480 * Non-error queries loop here.
4481 */
4482
4483 for (;;)
4484 {
4485 int firstchar;
4486 StringInfoData input_message;
4487
4488 /*
4489 * At top of loop, reset extended-query-message flag, so that any
4490 * errors encountered in "idle" state don't provoke skip.
4491 */
4493
4494 /*
4495 * For valgrind reporting purposes, the "current query" begins here.
4496 */
4497#ifdef USE_VALGRIND
4498 old_valgrind_error_count = VALGRIND_COUNT_ERRORS;
4499#endif
4500
4501 /*
4502 * Release storage left over from prior query cycle, and create a new
4503 * query input buffer in the cleared MessageContext.
4504 */
4507
4508 initStringInfo(&input_message);
4509
4510 /*
4511 * Also consider releasing our catalog snapshot if any, so that it's
4512 * not preventing advance of global xmin while we wait for the client.
4513 */
4515
4516 /*
4517 * (1) If we've reached idle state, tell the frontend we're ready for
4518 * a new query.
4519 *
4520 * Note: this includes fflush()'ing the last of the prior output.
4521 *
4522 * This is also a good time to flush out collected statistics to the
4523 * cumulative stats system, and to update the PS stats display. We
4524 * avoid doing those every time through the message loop because it'd
4525 * slow down processing of batched messages, and because we don't want
4526 * to report uncommitted updates (that confuses autovacuum). The
4527 * notification processor wants a call too, if we are not in a
4528 * transaction block.
4529 *
4530 * Also, if an idle timeout is enabled, start the timer for that.
4531 */
4532 if (send_ready_for_query)
4533 {
4535 {
4536 set_ps_display("idle in transaction (aborted)");
4538
4539 /* Start the idle-in-transaction timer */
4542 {
4543 idle_in_transaction_timeout_enabled = true;
4546 }
4547 }
4549 {
4550 set_ps_display("idle in transaction");
4552
4553 /* Start the idle-in-transaction timer */
4556 {
4557 idle_in_transaction_timeout_enabled = true;
4560 }
4561 }
4562 else
4563 {
4564 long stats_timeout;
4565
4566 /*
4567 * Process incoming notifies (including self-notifies), if
4568 * any, and send relevant messages to the client. Doing it
4569 * here helps ensure stable behavior in tests: if any notifies
4570 * were received during the just-finished transaction, they'll
4571 * be seen by the client before ReadyForQuery is.
4572 */
4575
4576 /*
4577 * Check if we need to report stats. If pgstat_report_stat()
4578 * decides it's too soon to flush out pending stats / lock
4579 * contention prevented reporting, it'll tell us when we
4580 * should try to report stats again (so that stats updates
4581 * aren't unduly delayed if the connection goes idle for a
4582 * long time). We only enable the timeout if we don't already
4583 * have a timeout in progress, because we don't disable the
4584 * timeout below. enable_timeout_after() needs to determine
4585 * the current timestamp, which can have a negative
4586 * performance impact. That's OK because pgstat_report_stat()
4587 * won't have us wake up sooner than a prior call.
4588 */
4589 stats_timeout = pgstat_report_stat(false);
4590 if (stats_timeout > 0)
4591 {
4594 stats_timeout);
4595 }
4596 else
4597 {
4598 /* all stats flushed, no need for the timeout */
4601 }
4602
4603 set_ps_display("idle");
4605
4606 /* Start the idle-session timer */
4607 if (IdleSessionTimeout > 0)
4608 {
4609 idle_session_timeout_enabled = true;
4612 }
4613 }
4614
4615 /* Report any recently-changed GUC options */
4617
4618 /*
4619 * The first time this backend is ready for query, log the
4620 * durations of the different components of connection
4621 * establishment and setup.
4622 */
4626 {
4627 uint64 total_duration,
4628 fork_duration,
4629 auth_duration;
4630
4632
4633 total_duration =
4636 fork_duration =
4639 auth_duration =
4642
4643 ereport(LOG,
4644 errmsg("connection ready: setup total=%.3f ms, fork=%.3f ms, authentication=%.3f ms",
4645 (double) total_duration / NS_PER_US,
4646 (double) fork_duration / NS_PER_US,
4647 (double) auth_duration / NS_PER_US));
4648 }
4649
4651 send_ready_for_query = false;
4652 }
4653
4654 /*
4655 * (2) Allow asynchronous signals to be executed immediately if they
4656 * come in while we are waiting for client input. (This must be
4657 * conditional since we don't want, say, reads on behalf of COPY FROM
4658 * STDIN doing the same thing.)
4659 */
4660 DoingCommandRead = true;
4661
4662 /*
4663 * (3) read a command (loop blocks here)
4664 */
4665 firstchar = ReadCommand(&input_message);
4666
4667 /*
4668 * (4) turn off the idle-in-transaction and idle-session timeouts if
4669 * active. We do this before step (5) so that any last-moment timeout
4670 * is certain to be detected in step (5).
4671 *
4672 * At most one of these timeouts will be active, so there's no need to
4673 * worry about combining the timeout.c calls into one.
4674 */
4675 if (idle_in_transaction_timeout_enabled)
4676 {
4678 idle_in_transaction_timeout_enabled = false;
4679 }
4680 if (idle_session_timeout_enabled)
4681 {
4683 idle_session_timeout_enabled = false;
4684 }
4685
4686 /*
4687 * (5) disable async signal conditions again.
4688 *
4689 * Query cancel is supposed to be a no-op when there is no query in
4690 * progress, so if a query cancel arrived while we were idle, just
4691 * reset QueryCancelPending. ProcessInterrupts() has that effect when
4692 * it's called when DoingCommandRead is set, so check for interrupts
4693 * before resetting DoingCommandRead.
4694 */
4696 DoingCommandRead = false;
4697
4698 /*
4699 * (6) check for any other interesting events that happened while we
4700 * slept.
4701 */
4703 {
4704 ConfigReloadPending = false;
4706 }
4707
4708 /*
4709 * (7) process the command. But ignore it if we're skipping till
4710 * Sync.
4711 */
4712 if (ignore_till_sync && firstchar != EOF)
4713 continue;
4714
4715 switch (firstchar)
4716 {
4717 case PqMsg_Query:
4718 {
4719 const char *query_string;
4720
4721 /* Set statement_timestamp() */
4723
4724 query_string = pq_getmsgstring(&input_message);
4725 pq_getmsgend(&input_message);
4726
4727 if (am_walsender)
4728 {
4729 if (!exec_replication_command(query_string))
4730 exec_simple_query(query_string);
4731 }
4732 else
4733 exec_simple_query(query_string);
4734
4735 valgrind_report_error_query(query_string);
4736
4737 send_ready_for_query = true;
4738 }
4739 break;
4740
4741 case PqMsg_Parse:
4742 {
4743 const char *stmt_name;
4744 const char *query_string;
4745 int numParams;
4746 Oid *paramTypes = NULL;
4747
4748 forbidden_in_wal_sender(firstchar);
4749
4750 /* Set statement_timestamp() */
4752
4753 stmt_name = pq_getmsgstring(&input_message);
4754 query_string = pq_getmsgstring(&input_message);
4755 numParams = pq_getmsgint(&input_message, 2);
4756 if (numParams > 0)
4757 {
4758 paramTypes = palloc_array(Oid, numParams);
4759 for (int i = 0; i < numParams; i++)
4760 paramTypes[i] = pq_getmsgint(&input_message, 4);
4761 }
4762 pq_getmsgend(&input_message);
4763
4764 exec_parse_message(query_string, stmt_name,
4765 paramTypes, numParams);
4766
4767 valgrind_report_error_query(query_string);
4768 }
4769 break;
4770
4771 case PqMsg_Bind:
4772 forbidden_in_wal_sender(firstchar);
4773
4774 /* Set statement_timestamp() */
4776
4777 /*
4778 * this message is complex enough that it seems best to put
4779 * the field extraction out-of-line
4780 */
4781 exec_bind_message(&input_message);
4782
4783 /* exec_bind_message does valgrind_report_error_query */
4784 break;
4785
4786 case PqMsg_Execute:
4787 {
4788 const char *portal_name;
4789 int max_rows;
4790
4791 forbidden_in_wal_sender(firstchar);
4792
4793 /* Set statement_timestamp() */
4795
4796 portal_name = pq_getmsgstring(&input_message);
4797 max_rows = pq_getmsgint(&input_message, 4);
4798 pq_getmsgend(&input_message);
4799
4800 exec_execute_message(portal_name, max_rows);
4801
4802 /* exec_execute_message does valgrind_report_error_query */
4803 }
4804 break;
4805
4806 case PqMsg_FunctionCall:
4807 forbidden_in_wal_sender(firstchar);
4808
4809 /* Set statement_timestamp() */
4811
4812 /* Report query to various monitoring facilities. */
4814 set_ps_display("<FASTPATH>");
4815
4816 /* start an xact for this function invocation */
4818
4819 /*
4820 * Note: we may at this point be inside an aborted
4821 * transaction. We can't throw error for that until we've
4822 * finished reading the function-call message, so
4823 * HandleFunctionRequest() must check for it after doing so.
4824 * Be careful not to do anything that assumes we're inside a
4825 * valid transaction here.
4826 */
4827
4828 /* switch back to message context */
4830
4831 HandleFunctionRequest(&input_message);
4832
4833 /* commit the function-invocation transaction */
4835
4836 valgrind_report_error_query("fastpath function call");
4837
4838 send_ready_for_query = true;
4839 break;
4840
4841 case PqMsg_Close:
4842 {
4843 int close_type;
4844 const char *close_target;
4845
4846 forbidden_in_wal_sender(firstchar);
4847
4848 close_type = pq_getmsgbyte(&input_message);
4849 close_target = pq_getmsgstring(&input_message);
4850 pq_getmsgend(&input_message);
4851
4852 switch (close_type)
4853 {
4854 case 'S':
4855 if (close_target[0] != '\0')
4856 DropPreparedStatement(close_target, false);
4857 else
4858 {
4859 /* special-case the unnamed statement */
4861 }
4862 break;
4863 case 'P':
4864 {
4865 Portal portal;
4866
4867 portal = GetPortalByName(close_target);
4868 if (PortalIsValid(portal))
4869 PortalDrop(portal, false);
4870 }
4871 break;
4872 default:
4873 ereport(ERROR,
4874 (errcode(ERRCODE_PROTOCOL_VIOLATION),
4875 errmsg("invalid CLOSE message subtype %d",
4876 close_type)));
4877 break;
4878 }
4879
4882
4883 valgrind_report_error_query("CLOSE message");
4884 }
4885 break;
4886
4887 case PqMsg_Describe:
4888 {
4889 int describe_type;
4890 const char *describe_target;
4891
4892 forbidden_in_wal_sender(firstchar);
4893
4894 /* Set statement_timestamp() (needed for xact) */
4896
4897 describe_type = pq_getmsgbyte(&input_message);
4898 describe_target = pq_getmsgstring(&input_message);
4899 pq_getmsgend(&input_message);
4900
4901 switch (describe_type)
4902 {
4903 case 'S':
4904 exec_describe_statement_message(describe_target);
4905 break;
4906 case 'P':
4907 exec_describe_portal_message(describe_target);
4908 break;
4909 default:
4910 ereport(ERROR,
4911 (errcode(ERRCODE_PROTOCOL_VIOLATION),
4912 errmsg("invalid DESCRIBE message subtype %d",
4913 describe_type)));
4914 break;
4915 }
4916
4917 valgrind_report_error_query("DESCRIBE message");
4918 }
4919 break;
4920
4921 case PqMsg_Flush:
4922 pq_getmsgend(&input_message);
4924 pq_flush();
4925 break;
4926
4927 case PqMsg_Sync:
4928 pq_getmsgend(&input_message);
4929
4930 /*
4931 * If pipelining was used, we may be in an implicit
4932 * transaction block. Close it before calling
4933 * finish_xact_command.
4934 */
4937 valgrind_report_error_query("SYNC message");
4938 send_ready_for_query = true;
4939 break;
4940
4941 /*
4942 * PqMsg_Terminate means that the frontend is closing down the
4943 * socket. EOF means unexpected loss of frontend connection.
4944 * Either way, perform normal shutdown.
4945 */
4946 case EOF:
4947
4948 /* for the cumulative statistics system */
4950
4951 /* FALLTHROUGH */
4952
4953 case PqMsg_Terminate:
4954
4955 /*
4956 * Reset whereToSendOutput to prevent ereport from attempting
4957 * to send any more messages to client.
4958 */
4961
4962 /*
4963 * NOTE: if you are tempted to add more code here, DON'T!
4964 * Whatever you had in mind to do should be set up as an
4965 * on_proc_exit or on_shmem_exit callback, instead. Otherwise
4966 * it will fail to be called during other backend-shutdown
4967 * scenarios.
4968 */
4969 proc_exit(0);
4970
4971 case PqMsg_CopyData:
4972 case PqMsg_CopyDone:
4973 case PqMsg_CopyFail:
4974
4975 /*
4976 * Accept but ignore these messages, per protocol spec; we
4977 * probably got here because a COPY failed, and the frontend
4978 * is still sending data.
4979 */
4980 break;
4981
4982 default:
4983 ereport(FATAL,
4984 (errcode(ERRCODE_PROTOCOL_VIOLATION),
4985 errmsg("invalid frontend message type %d",
4986 firstchar)));
4987 }
4988 } /* end of input-reading loop */
4989}
void ProcessNotifyInterrupt(bool flush)
Definition: async.c:1834
volatile sig_atomic_t notifyInterruptPending
Definition: async.c:413
void DropPreparedStatement(const char *stmt_name, bool showError)
Definition: prepare.c:520
sigset_t UnBlockSig
Definition: pqsignal.c:22
uint32 log_connections
ConnectionTiming conn_timing
@ LOG_CONNECTION_SETUP_DURATIONS
void pgstat_report_activity(BackendState state, const char *cmd_str)
@ STATE_IDLEINTRANSACTION_ABORTED
@ STATE_IDLE
@ STATE_IDLEINTRANSACTION
@ STATE_FASTPATH
int32_t int32
Definition: c.h:498
uint64_t uint64
Definition: c.h:503
#define TIMESTAMP_MINUS_INFINITY
Definition: timestamp.h:150
void ReadyForQuery(CommandDest dest)
Definition: dest.c:256
@ DestDebug
Definition: dest.h:88
@ DestNone
Definition: dest.h:87
void EmitErrorReport(void)
Definition: elog.c:1687
ErrorContextCallback * error_context_stack
Definition: elog.c:94
void FlushErrorState(void)
Definition: elog.c:1867
sigjmp_buf * PG_exception_stack
Definition: elog.c:96
#define FATAL
Definition: elog.h:41
void EventTriggerOnLogin(void)
void HandleFunctionRequest(StringInfo msgBuf)
Definition: fastpath.c:188
#define palloc_array(type, count)
Definition: fe_memutils.h:76
int32 MyCancelKey
Definition: globals.c:52
int MyProcPid
Definition: globals.c:46
bool IsUnderPostmaster
Definition: globals.c:119
volatile sig_atomic_t QueryCancelPending
Definition: globals.c:32
bool MyCancelKeyValid
Definition: globals.c:51
Oid MyDatabaseId
Definition: globals.c:93
void ProcessConfigFile(GucContext context)
Definition: guc-file.l:120
void BeginReportingGUCOptions(void)
Definition: guc.c:2546
void ReportChangedGUCOptions(void)
Definition: guc.c:2596
@ PGC_SIGHUP
Definition: guc.h:75
static char * username
Definition: initdb.c:153
volatile sig_atomic_t ConfigReloadPending
Definition: interrupt.c:27
void SignalHandlerForConfigReload(SIGNAL_ARGS)
Definition: interrupt.c:61
void on_proc_exit(pg_on_exit_callback function, Datum arg)
Definition: ipc.c:309
void proc_exit(int code)
Definition: ipc.c:104
void jit_reset_after_error(void)
Definition: jit.c:127
#define pq_flush()
Definition: libpq.h:46
#define pq_comm_reset()
Definition: libpq.h:45
MemoryContext MessageContext
Definition: mcxt.c:153
void MemoryContextReset(MemoryContext context)
Definition: mcxt.c:383
MemoryContext TopMemoryContext
Definition: mcxt.c:149
MemoryContext PostmasterContext
Definition: mcxt.c:151
void MemoryContextDelete(MemoryContext context)
Definition: mcxt.c:454
#define AllocSetContextCreate
Definition: memutils.h:129
#define ALLOCSET_DEFAULT_SIZES
Definition: memutils.h:160
#define RESUME_INTERRUPTS()
Definition: miscadmin.h:135
@ NormalProcessing
Definition: miscadmin.h:471
@ InitProcessing
Definition: miscadmin.h:470
#define IsExternalConnectionBackend(backend_type)
Definition: miscadmin.h:404
#define GetProcessingMode()
Definition: miscadmin.h:480
#define INIT_PG_LOAD_SESSION_LIBS
Definition: miscadmin.h:498
#define CHECK_FOR_INTERRUPTS()
Definition: miscadmin.h:122
#define HOLD_INTERRUPTS()
Definition: miscadmin.h:133
#define SetProcessingMode(mode)
Definition: miscadmin.h:482
BackendType MyBackendType
Definition: miscinit.c:64
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:124
static char * buf
Definition: pg_test_fsync.c:72
long pgstat_report_stat(bool force)
Definition: pgstat.c:691
@ DISCONNECT_CLIENT_EOF
Definition: pgstat.h:56
void pgstat_report_connect(Oid dboid)
#define pqsignal
Definition: port.h:521
bool pg_strong_random(void *buf, size_t len)
#define printf(...)
Definition: port.h:245
#define PortalIsValid(p)
Definition: portal.h:212
void PortalDrop(Portal portal, bool isTopCommit)
Definition: portalmem.c:470
Portal GetPortalByName(const char *name)
Definition: portalmem.c:130
void PortalErrorCleanup(void)
Definition: portalmem.c:919
static void exec_describe_statement_message(const char *stmt_name)
Definition: postgres.c:2619
void quickdie(SIGNAL_ARGS)
Definition: postgres.c:2907
static void log_disconnections(int code, Datum arg)
Definition: postgres.c:5135
static void forbidden_in_wal_sender(char firstchar)
Definition: postgres.c:4999
static void exec_execute_message(const char *portal_name, long max_rows)
Definition: postgres.c:2096
void FloatExceptionHandler(SIGNAL_ARGS)
Definition: postgres.c:3051
void StatementCancelHandler(SIGNAL_ARGS)
Definition: postgres.c:3034
static bool ignore_till_sync
Definition: postgres.c:143
static void finish_xact_command(void)
Definition: postgres.c:2803
const char * debug_query_string
Definition: postgres.c:88
static void exec_simple_query(const char *query_string)
Definition: postgres.c:1011
static void exec_parse_message(const char *query_string, const char *stmt_name, Oid *paramTypes, int numParams)
Definition: postgres.c:1389
static void exec_bind_message(StringInfo input_message)
Definition: postgres.c:1624
void die(SIGNAL_ARGS)
Definition: postgres.c:3004
static bool xact_started
Definition: postgres.c:129
static MemoryContext row_description_context
Definition: postgres.c:162
static StringInfoData row_description_buf
Definition: postgres.c:163
static bool doing_extended_query_message
Definition: postgres.c:142
static void start_xact_command(void)
Definition: postgres.c:2764
static void exec_describe_portal_message(const char *portal_name)
Definition: postgres.c:2712
bool Log_disconnections
Definition: postgres.c:94
static void drop_unnamed_stmt(void)
Definition: postgres.c:2882
#define valgrind_report_error_query(query)
Definition: postgres.c:216
static int ReadCommand(StringInfo inBuf)
Definition: postgres.c:480
void BaseInit(void)
Definition: postinit.c:616
void InitPostgres(const char *in_dbname, Oid dboid, const char *username, Oid useroid, bits32 flags, char *out_dbname)
Definition: postinit.c:716
bool pq_is_reading_msg(void)
Definition: pqcomm.c:1182
unsigned int pq_getmsgint(StringInfo msg, int b)
Definition: pqformat.c:415
void pq_getmsgend(StringInfo msg)
Definition: pqformat.c:635
const char * pq_getmsgstring(StringInfo msg)
Definition: pqformat.c:579
void pq_putemptymessage(char msgtype)
Definition: pqformat.c:388
void pq_endmessage(StringInfo buf)
Definition: pqformat.c:296
int pq_getmsgbyte(StringInfo msg)
Definition: pqformat.c:399
void pq_beginmessage(StringInfo buf, char msgtype)
Definition: pqformat.c:88
static void pq_sendint32(StringInfo buf, uint32 i)
Definition: pqformat.h:144
void procsignal_sigusr1_handler(SIGNAL_ARGS)
Definition: procsignal.c:673
#define PqMsg_CloseComplete
Definition: protocol.h:40
#define PqMsg_CopyDone
Definition: protocol.h:64
#define PqMsg_CopyData
Definition: protocol.h:65
#define PqMsg_FunctionCall
Definition: protocol.h:23
#define PqMsg_Describe
Definition: protocol.h:21
#define PqMsg_Parse
Definition: protocol.h:25
#define PqMsg_Bind
Definition: protocol.h:19
#define PqMsg_Sync
Definition: protocol.h:27
#define PqMsg_CopyFail
Definition: protocol.h:29
#define PqMsg_Flush
Definition: protocol.h:24
#define PqMsg_BackendKeyData
Definition: protocol.h:48
#define PqMsg_Query
Definition: protocol.h:26
#define PqMsg_Terminate
Definition: protocol.h:28
#define PqMsg_Execute
Definition: protocol.h:22
#define PqMsg_Close
Definition: protocol.h:20
static void set_ps_display(const char *activity)
Definition: ps_status.h:40
ReplicationSlot * MyReplicationSlot
Definition: slot.c:147
void ReplicationSlotRelease(void)
Definition: slot.c:686
void ReplicationSlotCleanup(bool synced_only)
Definition: slot.c:775
void InvalidateCatalogSnapshotConditionally(void)
Definition: snapmgr.c:464
int IdleSessionTimeout
Definition: proc.c:62
int IdleInTransactionSessionTimeout
Definition: proc.c:60
int TransactionTimeout
Definition: proc.c:61
char * dbname
Definition: streamutil.c:49
void initStringInfo(StringInfo str)
Definition: stringinfo.c:97
TimestampTz ready_for_use
TimestampTz auth_start
TimestampTz socket_create
TimestampTz fork_start
TimestampTz auth_end
TimestampTz fork_end
void enable_timeout_after(TimeoutId id, int delay_ms)
Definition: timeout.c:560
bool get_timeout_active(TimeoutId id)
Definition: timeout.c:780
void disable_all_timeouts(bool keep_indicators)
Definition: timeout.c:751
void InitializeTimeouts(void)
Definition: timeout.c:470
void disable_timeout(TimeoutId id, bool keep_indicator)
Definition: timeout.c:685
@ IDLE_SESSION_TIMEOUT
Definition: timeout.h:35
@ IDLE_IN_TRANSACTION_SESSION_TIMEOUT
Definition: timeout.h:33
@ IDLE_STATS_UPDATE_TIMEOUT
Definition: timeout.h:36
static uint64 TimestampDifferenceMicroseconds(TimestampTz start_time, TimestampTz stop_time)
Definition: timestamp.h:90
#define NS_PER_US
Definition: uuid.c:31
void WalSndErrorCleanup(void)
Definition: walsender.c:326
bool am_walsender
Definition: walsender.c:116
bool exec_replication_command(const char *cmd_string)
Definition: walsender.c:1954
void InitWalSender(void)
Definition: walsender.c:279
void WalSndSignals(void)
Definition: walsender.c:3563
#define SIGCHLD
Definition: win32_port.h:168
#define SIGHUP
Definition: win32_port.h:158
#define SIGPIPE
Definition: win32_port.h:163
#define SIGQUIT
Definition: win32_port.h:159
#define SIGUSR1
Definition: win32_port.h:170
#define SIGUSR2
Definition: win32_port.h:171
bool IsTransactionOrTransactionBlock(void)
Definition: xact.c:4989
bool IsAbortedTransactionBlockState(void)
Definition: xact.c:407
void EndImplicitTransactionBlock(void)
Definition: xact.c:4351
void SetCurrentStatementStartTimestamp(void)
Definition: xact.c:914
void AbortCurrentTransaction(void)
Definition: xact.c:3451

References AbortCurrentTransaction(), ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, am_walsender, Assert(), ConnectionTiming::auth_end, ConnectionTiming::auth_start, BaseInit(), BeginReportingGUCOptions(), buf, CHECK_FOR_INTERRUPTS, ConfigReloadPending, conn_timing, 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(), EndImplicitTransactionBlock(), 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(), ConnectionTiming::fork_end, ConnectionTiming::fork_start, get_timeout_active(), GetCurrentTimestamp(), GetPortalByName(), GetProcessingMode, 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(), IsExternalConnectionBackend, IsTransactionOrTransactionBlock(), IsUnderPostmaster, jit_reset_after_error(), LOG, LOG_CONNECTION_SETUP_DURATIONS, log_connections, Log_disconnections, log_disconnections(), MemoryContextDelete(), MemoryContextReset(), MemoryContextSwitchTo(), MessageContext, MyBackendType, MyCancelKey, MyCancelKeyValid, MyDatabaseId, MyProcPid, MyReplicationSlot, NormalProcessing, notifyInterruptPending, NS_PER_US, on_proc_exit(), palloc_array, PG_exception_stack, pg_strong_random(), 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(), ConnectionTiming::ready_for_use, ReadyForQuery(), ReplicationSlotCleanup(), ReplicationSlotRelease(), ReportChangedGUCOptions(), RESUME_INTERRUPTS, row_description_buf, row_description_context, set_ps_display(), SetCurrentStatementStartTimestamp(), SetProcessingMode, SIGCHLD, SIGHUP, SignalHandlerForConfigReload(), SIGPIPE, SIGQUIT, SIGUSR1, SIGUSR2, ConnectionTiming::socket_create, start_xact_command(), STATE_FASTPATH, STATE_IDLE, STATE_IDLEINTRANSACTION, STATE_IDLEINTRANSACTION_ABORTED, StatementCancelHandler(), TIMESTAMP_MINUS_INFINITY, TimestampDifferenceMicroseconds(), TopMemoryContext, TransactionTimeout, UnBlockSig, username, valgrind_report_error_query, WalSndErrorCleanup(), WalSndSignals(), whereToSendOutput, and xact_started.

Referenced by BackendMain(), and PostgresSingleUserMain().

◆ PostgresSingleUserMain()

pg_noreturn void PostgresSingleUserMain ( int  argc,
char *  argv[],
const char *  username 
)

Definition at line 4027 of file postgres.c.

4029{
4030 const char *dbname = NULL;
4031
4033
4034 /* Initialize startup process environment. */
4035 InitStandaloneProcess(argv[0]);
4036
4037 /*
4038 * Set default values for command-line options.
4039 */
4041
4042 /*
4043 * Parse command-line options.
4044 */
4046
4047 /* Must have gotten a database name, or have a default (the username) */
4048 if (dbname == NULL)
4049 {
4050 dbname = username;
4051 if (dbname == NULL)
4052 ereport(FATAL,
4053 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4054 errmsg("%s: no database nor user name specified",
4055 progname)));
4056 }
4057
4058 /* Acquire configuration parameters */
4060 proc_exit(1);
4061
4062 /*
4063 * Validate we have been given a reasonable-looking DataDir and change
4064 * into it.
4065 */
4066 checkDataDir();
4068
4069 /*
4070 * Create lockfile for data directory.
4071 */
4072 CreateDataDirLockFile(false);
4073
4074 /* read control file (error checking and contains config ) */
4076
4077 /*
4078 * process any libraries that should be preloaded at postmaster start
4079 */
4081
4082 /* Initialize MaxBackends */
4084
4085 /*
4086 * We don't need postmaster child slots in single-user mode, but
4087 * initialize them anyway to avoid having special handling.
4088 */
4090
4091 /* Initialize size of fast-path lock cache. */
4093
4094 /*
4095 * Give preloaded libraries a chance to request additional shared memory.
4096 */
4098
4099 /*
4100 * Now that loadable modules have had their chance to request additional
4101 * shared memory, determine the value of any runtime-computed GUCs that
4102 * depend on the amount of shared memory required.
4103 */
4105
4106 /*
4107 * Now that modules have been loaded, we can process any custom resource
4108 * managers specified in the wal_consistency_checking GUC.
4109 */
4111
4112 /*
4113 * Create shared memory etc. (Nothing's really "shared" in single-user
4114 * mode, but we must have these data structures anyway.)
4115 */
4117
4118 /*
4119 * Estimate number of openable files. This must happen after setting up
4120 * semaphores, because on some platforms semaphores count as open files.
4121 */
4123
4124 /*
4125 * Remember stand-alone backend startup time,roughly at the same point
4126 * during startup that postmaster does so.
4127 */
4129
4130 /*
4131 * Create a per-backend PGPROC struct in shared memory. We must do this
4132 * before we can use LWLocks.
4133 */
4134 InitProcess();
4135
4136 /*
4137 * Now that sufficient infrastructure has been initialized, PostgresMain()
4138 * can do the rest.
4139 */
4141}
TimestampTz PgStartTime
Definition: timestamp.c:53
void set_max_safe_fds(void)
Definition: fd.c:1043
bool SelectConfigFiles(const char *userDoption, const char *progname)
Definition: guc.c:1784
void InitializeGUCOptions(void)
Definition: guc.c:1530
@ PGC_POSTMASTER
Definition: guc.h:74
void InitializeShmemGUCs(void)
Definition: ipci.c:355
void CreateSharedMemoryAndSemaphores(void)
Definition: ipci.c:200
const char * progname
Definition: main.c:44
void ChangeToDataDir(void)
Definition: miscinit.c:460
void process_shmem_requests(void)
Definition: miscinit.c:1930
void InitStandaloneProcess(const char *argv0)
Definition: miscinit.c:175
void process_shared_preload_libraries(void)
Definition: miscinit.c:1902
void checkDataDir(void)
Definition: miscinit.c:347
void CreateDataDirLockFile(bool amPostmaster)
Definition: miscinit.c:1514
void InitPostmasterChildSlots(void)
Definition: pmchild.c:86
void process_postgres_switches(int argc, char *argv[], GucContext ctx, const char **dbname)
Definition: postgres.c:3762
static const char * userDoption
Definition: postgres.c:153
void PostgresMain(const char *dbname, const char *username)
Definition: postgres.c:4156
void InitializeMaxBackends(void)
Definition: postinit.c:555
void InitializeFastPathLocks(void)
Definition: postinit.c:587
void InitProcess(void)
Definition: proc.c:341
void InitializeWalConsistencyChecking(void)
Definition: xlog.c:4830
void LocalProcessControlFile(bool reset)
Definition: xlog.c:4892

References Assert(), ChangeToDataDir(), checkDataDir(), CreateDataDirLockFile(), CreateSharedMemoryAndSemaphores(), dbname, ereport, errcode(), errmsg(), FATAL, GetCurrentTimestamp(), InitializeFastPathLocks(), InitializeGUCOptions(), InitializeMaxBackends(), InitializeShmemGUCs(), InitializeWalConsistencyChecking(), InitPostmasterChildSlots(), InitProcess(), InitStandaloneProcess(), IsUnderPostmaster, LocalProcessControlFile(), PGC_POSTMASTER, PgStartTime, PostgresMain(), proc_exit(), process_postgres_switches(), process_shared_preload_libraries(), process_shmem_requests(), progname, SelectConfigFiles(), set_max_safe_fds(), userDoption, and username.

Referenced by main().

◆ process_postgres_switches()

void process_postgres_switches ( int  argc,
char *  argv[],
GucContext  ctx,
const char **  dbname 
)

Definition at line 3762 of file postgres.c.

3764{
3765 bool secure = (ctx == PGC_POSTMASTER);
3766 int errs = 0;
3767 GucSource gucsource;
3768 int flag;
3769
3770 if (secure)
3771 {
3772 gucsource = PGC_S_ARGV; /* switches came from command line */
3773
3774 /* Ignore the initial --single argument, if present */
3775 if (argc > 1 && strcmp(argv[1], "--single") == 0)
3776 {
3777 argv++;
3778 argc--;
3779 }
3780 }
3781 else
3782 {
3783 gucsource = PGC_S_CLIENT; /* switches came from client */
3784 }
3785
3786#ifdef HAVE_INT_OPTERR
3787
3788 /*
3789 * Turn this off because it's either printed to stderr and not the log
3790 * where we'd want it, or argv[0] is now "--single", which would make for
3791 * a weird error message. We print our own error message below.
3792 */
3793 opterr = 0;
3794#endif
3795
3796 /*
3797 * Parse command-line options. CAUTION: keep this in sync with
3798 * postmaster/postmaster.c (the option sets should not conflict) and with
3799 * the common help() function in main/main.c.
3800 */
3801 while ((flag = getopt(argc, argv, "B:bC:c:D:d:EeFf:h:ijk:lN:nOPp:r:S:sTt:v:W:-:")) != -1)
3802 {
3803 switch (flag)
3804 {
3805 case 'B':
3806 SetConfigOption("shared_buffers", optarg, ctx, gucsource);
3807 break;
3808
3809 case 'b':
3810 /* Undocumented flag used for binary upgrades */
3811 if (secure)
3812 IsBinaryUpgrade = true;
3813 break;
3814
3815 case 'C':
3816 /* ignored for consistency with the postmaster */
3817 break;
3818
3819 case '-':
3820
3821 /*
3822 * Error if the user misplaced a special must-be-first option
3823 * for dispatching to a subprogram. parse_dispatch_option()
3824 * returns DISPATCH_POSTMASTER if it doesn't find a match, so
3825 * error for anything else.
3826 */
3828 ereport(ERROR,
3829 (errcode(ERRCODE_SYNTAX_ERROR),
3830 errmsg("--%s must be first argument", optarg)));
3831
3832 /* FALLTHROUGH */
3833 case 'c':
3834 {
3835 char *name,
3836 *value;
3837
3839 if (!value)
3840 {
3841 if (flag == '-')
3842 ereport(ERROR,
3843 (errcode(ERRCODE_SYNTAX_ERROR),
3844 errmsg("--%s requires a value",
3845 optarg)));
3846 else
3847 ereport(ERROR,
3848 (errcode(ERRCODE_SYNTAX_ERROR),
3849 errmsg("-c %s requires a value",
3850 optarg)));
3851 }
3852 SetConfigOption(name, value, ctx, gucsource);
3853 pfree(name);
3854 pfree(value);
3855 break;
3856 }
3857
3858 case 'D':
3859 if (secure)
3860 userDoption = strdup(optarg);
3861 break;
3862
3863 case 'd':
3864 set_debug_options(atoi(optarg), ctx, gucsource);
3865 break;
3866
3867 case 'E':
3868 if (secure)
3869 EchoQuery = true;
3870 break;
3871
3872 case 'e':
3873 SetConfigOption("datestyle", "euro", ctx, gucsource);
3874 break;
3875
3876 case 'F':
3877 SetConfigOption("fsync", "false", ctx, gucsource);
3878 break;
3879
3880 case 'f':
3881 if (!set_plan_disabling_options(optarg, ctx, gucsource))
3882 errs++;
3883 break;
3884
3885 case 'h':
3886 SetConfigOption("listen_addresses", optarg, ctx, gucsource);
3887 break;
3888
3889 case 'i':
3890 SetConfigOption("listen_addresses", "*", ctx, gucsource);
3891 break;
3892
3893 case 'j':
3894 if (secure)
3895 UseSemiNewlineNewline = true;
3896 break;
3897
3898 case 'k':
3899 SetConfigOption("unix_socket_directories", optarg, ctx, gucsource);
3900 break;
3901
3902 case 'l':
3903 SetConfigOption("ssl", "true", ctx, gucsource);
3904 break;
3905
3906 case 'N':
3907 SetConfigOption("max_connections", optarg, ctx, gucsource);
3908 break;
3909
3910 case 'n':
3911 /* ignored for consistency with postmaster */
3912 break;
3913
3914 case 'O':
3915 SetConfigOption("allow_system_table_mods", "true", ctx, gucsource);
3916 break;
3917
3918 case 'P':
3919 SetConfigOption("ignore_system_indexes", "true", ctx, gucsource);
3920 break;
3921
3922 case 'p':
3923 SetConfigOption("port", optarg, ctx, gucsource);
3924 break;
3925
3926 case 'r':
3927 /* send output (stdout and stderr) to the given file */
3928 if (secure)
3930 break;
3931
3932 case 'S':
3933 SetConfigOption("work_mem", optarg, ctx, gucsource);
3934 break;
3935
3936 case 's':
3937 SetConfigOption("log_statement_stats", "true", ctx, gucsource);
3938 break;
3939
3940 case 'T':
3941 /* ignored for consistency with the postmaster */
3942 break;
3943
3944 case 't':
3945 {
3946 const char *tmp = get_stats_option_name(optarg);
3947
3948 if (tmp)
3949 SetConfigOption(tmp, "true", ctx, gucsource);
3950 else
3951 errs++;
3952 break;
3953 }
3954
3955 case 'v':
3956
3957 /*
3958 * -v is no longer used in normal operation, since
3959 * FrontendProtocol is already set before we get here. We keep
3960 * the switch only for possible use in standalone operation,
3961 * in case we ever support using normal FE/BE protocol with a
3962 * standalone backend.
3963 */
3964 if (secure)
3966 break;
3967
3968 case 'W':
3969 SetConfigOption("post_auth_delay", optarg, ctx, gucsource);
3970 break;
3971
3972 default:
3973 errs++;
3974 break;
3975 }
3976
3977 if (errs)
3978 break;
3979 }
3980
3981 /*
3982 * Optional database name should be there only if *dbname is NULL.
3983 */
3984 if (!errs && dbname && *dbname == NULL && argc - optind >= 1)
3985 *dbname = strdup(argv[optind++]);
3986
3987 if (errs || argc != optind)
3988 {
3989 if (errs)
3990 optind--; /* complain about the previous argument */
3991
3992 /* spell the error message a bit differently depending on context */
3994 ereport(FATAL,
3995 errcode(ERRCODE_SYNTAX_ERROR),
3996 errmsg("invalid command-line argument for server process: %s", argv[optind]),
3997 errhint("Try \"%s --help\" for more information.", progname));
3998 else
3999 ereport(FATAL,
4000 errcode(ERRCODE_SYNTAX_ERROR),
4001 errmsg("%s: invalid command-line argument: %s",
4002 progname, argv[optind]),
4003 errhint("Try \"%s --help\" for more information.", progname));
4004 }
4005
4006 /*
4007 * Reset getopt(3) library so that it will work correctly in subprocesses
4008 * or when this function is called a second time with another array.
4009 */
4010 optind = 1;
4011#ifdef HAVE_INT_OPTRESET
4012 optreset = 1; /* some systems need this too */
4013#endif
4014}
int errhint(const char *fmt,...)
Definition: elog.c:1317
bool IsBinaryUpgrade
Definition: globals.c:120
ProtocolVersion FrontendProtocol
Definition: globals.c:29
char OutputFileName[MAXPGPATH]
Definition: globals.c:78
void SetConfigOption(const char *name, const char *value, GucContext context, GucSource source)
Definition: guc.c:4332
void ParseLongOption(const char *string, char **name, char **value)
Definition: guc.c:6362
GucSource
Definition: guc.h:112
@ PGC_S_ARGV
Definition: guc.h:117
@ PGC_S_CLIENT
Definition: guc.h:122
static struct @165 value
DispatchOption parse_dispatch_option(const char *name)
Definition: main.c:243
#define MAXPGPATH
PGDLLIMPORT int optind
Definition: getopt.c:51
PGDLLIMPORT int opterr
Definition: getopt.c:50
int getopt(int nargc, char *const *nargv, const char *ostr)
Definition: getopt.c:72
size_t strlcpy(char *dst, const char *src, size_t siz)
Definition: strlcpy.c:45
void set_debug_options(int debug_flag, GucContext context, GucSource source)
Definition: postgres.c:3651
static bool UseSemiNewlineNewline
Definition: postgres.c:155
static bool EchoQuery
Definition: postgres.c:154
bool set_plan_disabling_options(const char *arg, GucContext context, GucSource source)
Definition: postgres.c:3680
const char * get_stats_option_name(const char *arg)
Definition: postgres.c:3722
@ DISPATCH_POSTMASTER
Definition: postmaster.h:139
uint32 ProtocolVersion
Definition: pqcomm.h:100
char * flag(int b)
Definition: test-ctype.c:33
const char * name

References dbname, DISPATCH_POSTMASTER, EchoQuery, ereport, errcode(), errhint(), errmsg(), ERROR, FATAL, flag(), FrontendProtocol, get_stats_option_name(), getopt(), IsBinaryUpgrade, IsUnderPostmaster, MAXPGPATH, name, optarg, opterr, optind, OutputFileName, parse_dispatch_option(), 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().

◆ ProcessClientReadInterrupt()

void ProcessClientReadInterrupt ( bool  blocked)

Definition at line 501 of file postgres.c.

502{
503 int save_errno = errno;
504
506 {
507 /* Check for general interrupts that arrived before/while reading */
509
510 /* Process sinval catchup interrupts, if any */
513
514 /* Process notify interrupts, if any */
517 }
518 else if (ProcDiePending)
519 {
520 /*
521 * We're dying. If there is no data available to read, then it's safe
522 * (and sane) to handle that now. If we haven't tried to read yet,
523 * make sure the process latch is set, so that if there is no data
524 * then we'll come back here and die. If we're done reading, also
525 * make sure the process latch is set, as we might've undesirably
526 * cleared it while reading.
527 */
528 if (blocked)
530 else
532 }
533
534 errno = save_errno;
535}
void ProcessCatchupInterrupt(void)
Definition: sinval.c:174
volatile sig_atomic_t catchupInterruptPending
Definition: sinval.c:39

References catchupInterruptPending, CHECK_FOR_INTERRUPTS, DoingCommandRead, MyLatch, notifyInterruptPending, ProcDiePending, ProcessCatchupInterrupt(), ProcessNotifyInterrupt(), and SetLatch().

Referenced by interactive_getc(), and secure_read().

◆ ProcessClientWriteInterrupt()

void ProcessClientWriteInterrupt ( bool  blocked)

Definition at line 547 of file postgres.c.

548{
549 int save_errno = errno;
550
551 if (ProcDiePending)
552 {
553 /*
554 * We're dying. If it's not possible to write, then we should handle
555 * that immediately, else a stuck client could indefinitely delay our
556 * response to the signal. If we haven't tried to write yet, make
557 * sure the process latch is set, so that if the write would block
558 * then we'll come back here and die. If we're done writing, also
559 * make sure the process latch is set, as we might've undesirably
560 * cleared it while writing.
561 */
562 if (blocked)
563 {
564 /*
565 * Don't mess with whereToSendOutput if ProcessInterrupts wouldn't
566 * service ProcDiePending.
567 */
569 {
570 /*
571 * We don't want to send the client the error message, as a)
572 * that would possibly block again, and b) it would likely
573 * lead to loss of protocol sync because we may have already
574 * sent a partial protocol message.
575 */
578
580 }
581 }
582 else
584 }
585
586 errno = save_errno;
587}
volatile uint32 InterruptHoldoffCount
Definition: globals.c:42
volatile uint32 CritSectionCount
Definition: globals.c:44

References CHECK_FOR_INTERRUPTS, CritSectionCount, DestNone, DestRemote, InterruptHoldoffCount, MyLatch, ProcDiePending, SetLatch(), and whereToSendOutput.

Referenced by secure_write().

◆ quickdie()

pg_noreturn void quickdie ( SIGNAL_ARGS  )

Definition at line 2907 of file postgres.c.

2908{
2909 sigaddset(&BlockSig, SIGQUIT); /* prevent nested calls */
2910 sigprocmask(SIG_SETMASK, &BlockSig, NULL);
2911
2912 /*
2913 * Prevent interrupts while exiting; though we just blocked signals that
2914 * would queue new interrupts, one may have been pending. We don't want a
2915 * quickdie() downgraded to a mere query cancel.
2916 */
2918
2919 /*
2920 * If we're aborting out of client auth, don't risk trying to send
2921 * anything to the client; we will likely violate the protocol, not to
2922 * mention that we may have interrupted the guts of OpenSSL or some
2923 * authentication library.
2924 */
2927
2928 /*
2929 * Notify the client before exiting, to give a clue on what happened.
2930 *
2931 * It's dubious to call ereport() from a signal handler. It is certainly
2932 * not async-signal safe. But it seems better to try, than to disconnect
2933 * abruptly and leave the client wondering what happened. It's remotely
2934 * possible that we crash or hang while trying to send the message, but
2935 * receiving a SIGQUIT is a sign that something has already gone badly
2936 * wrong, so there's not much to lose. Assuming the postmaster is still
2937 * running, it will SIGKILL us soon if we get stuck for some reason.
2938 *
2939 * One thing we can do to make this a tad safer is to clear the error
2940 * context stack, so that context callbacks are not called. That's a lot
2941 * less code that could be reached here, and the context info is unlikely
2942 * to be very relevant to a SIGQUIT report anyway.
2943 */
2944 error_context_stack = NULL;
2945
2946 /*
2947 * When responding to a postmaster-issued signal, we send the message only
2948 * to the client; sending to the server log just creates log spam, plus
2949 * it's more code that we need to hope will work in a signal handler.
2950 *
2951 * Ideally these should be ereport(FATAL), but then we'd not get control
2952 * back to force the correct type of process exit.
2953 */
2954 switch (GetQuitSignalReason())
2955 {
2956 case PMQUIT_NOT_SENT:
2957 /* Hmm, SIGQUIT arrived out of the blue */
2959 (errcode(ERRCODE_ADMIN_SHUTDOWN),
2960 errmsg("terminating connection because of unexpected SIGQUIT signal")));
2961 break;
2962 case PMQUIT_FOR_CRASH:
2963 /* A crash-and-restart cycle is in progress */
2965 (errcode(ERRCODE_CRASH_SHUTDOWN),
2966 errmsg("terminating connection because of crash of another server process"),
2967 errdetail("The postmaster has commanded this server process to roll back"
2968 " the current transaction and exit, because another"
2969 " server process exited abnormally and possibly corrupted"
2970 " shared memory."),
2971 errhint("In a moment you should be able to reconnect to the"
2972 " database and repeat your command.")));
2973 break;
2974 case PMQUIT_FOR_STOP:
2975 /* Immediate-mode stop */
2977 (errcode(ERRCODE_ADMIN_SHUTDOWN),
2978 errmsg("terminating connection due to immediate shutdown command")));
2979 break;
2980 }
2981
2982 /*
2983 * We DO NOT want to run proc_exit() or atexit() callbacks -- we're here
2984 * because shared memory may be corrupted, so we don't want to try to
2985 * clean up our transaction. Just nail the windows shut and get out of
2986 * town. The callbacks wouldn't be safe to run from a signal handler,
2987 * anyway.
2988 *
2989 * Note we do _exit(2) not _exit(0). This is to force the postmaster into
2990 * a system reset cycle if someone sends a manual SIGQUIT to a random
2991 * backend. This is necessary precisely because we don't clean up our
2992 * shared memory state. (The "dead man switch" mechanism in pmsignal.c
2993 * should ensure the postmaster sees this as a crash, too, but no harm in
2994 * being doubly sure.)
2995 */
2996 _exit(2);
2997}
sigset_t BlockSig
Definition: pqsignal.c:23
#define WARNING_CLIENT_ONLY
Definition: elog.h:38
QuitSignalReason GetQuitSignalReason(void)
Definition: pmsignal.c:213
@ PMQUIT_FOR_STOP
Definition: pmsignal.h:55
@ PMQUIT_FOR_CRASH
Definition: pmsignal.h:54
@ PMQUIT_NOT_SENT
Definition: pmsignal.h:53
bool ClientAuthInProgress
Definition: postmaster.c:371

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().

◆ ResetUsage()

void ResetUsage ( void  )

◆ set_debug_options()

void set_debug_options ( int  debug_flag,
GucContext  context,
GucSource  source 
)

Definition at line 3651 of file postgres.c.

3652{
3653 if (debug_flag > 0)
3654 {
3655 char debugstr[64];
3656
3657 sprintf(debugstr, "debug%d", debug_flag);
3658 SetConfigOption("log_min_messages", debugstr, context, source);
3659 }
3660 else
3661 SetConfigOption("log_min_messages", "notice", context, source);
3662
3663 if (debug_flag >= 1 && context == PGC_POSTMASTER)
3664 {
3665 SetConfigOption("log_connections", "true", context, source);
3666 SetConfigOption("log_disconnections", "true", context, source);
3667 }
3668 if (debug_flag >= 2)
3669 SetConfigOption("log_statement", "all", context, source);
3670 if (debug_flag >= 3)
3671 SetConfigOption("debug_print_parse", "true", context, source);
3672 if (debug_flag >= 4)
3673 SetConfigOption("debug_print_plan", "true", context, source);
3674 if (debug_flag >= 5)
3675 SetConfigOption("debug_print_rewritten", "true", context, source);
3676}
static rewind_source * source
Definition: pg_rewind.c:89
#define sprintf
Definition: port.h:241

References PGC_POSTMASTER, SetConfigOption(), source, and sprintf.

Referenced by PostmasterMain(), and process_postgres_switches().

◆ set_plan_disabling_options()

bool set_plan_disabling_options ( const char *  arg,
GucContext  context,
GucSource  source 
)

Definition at line 3680 of file postgres.c.

3681{
3682 const char *tmp = NULL;
3683
3684 switch (arg[0])
3685 {
3686 case 's': /* seqscan */
3687 tmp = "enable_seqscan";
3688 break;
3689 case 'i': /* indexscan */
3690 tmp = "enable_indexscan";
3691 break;
3692 case 'o': /* indexonlyscan */
3693 tmp = "enable_indexonlyscan";
3694 break;
3695 case 'b': /* bitmapscan */
3696 tmp = "enable_bitmapscan";
3697 break;
3698 case 't': /* tidscan */
3699 tmp = "enable_tidscan";
3700 break;
3701 case 'n': /* nestloop */
3702 tmp = "enable_nestloop";
3703 break;
3704 case 'm': /* mergejoin */
3705 tmp = "enable_mergejoin";
3706 break;
3707 case 'h': /* hashjoin */
3708 tmp = "enable_hashjoin";
3709 break;
3710 }
3711 if (tmp)
3712 {
3713 SetConfigOption(tmp, "false", context, source);
3714 return true;
3715 }
3716 else
3717 return false;
3718}

References arg, SetConfigOption(), and source.

Referenced by PostmasterMain(), and process_postgres_switches().

◆ ShowUsage()

void ShowUsage ( const char *  title)

Definition at line 5026 of file postgres.c.

5027{
5029 struct timeval user,
5030 sys;
5031 struct timeval elapse_t;
5032 struct rusage r;
5033
5035 gettimeofday(&elapse_t, NULL);
5036 memcpy(&user, &r.ru_utime, sizeof(user));
5037 memcpy(&sys, &r.ru_stime, sizeof(sys));
5038 if (elapse_t.tv_usec < Save_t.tv_usec)
5039 {
5040 elapse_t.tv_sec--;
5041 elapse_t.tv_usec += 1000000;
5042 }
5043 if (r.ru_utime.tv_usec < Save_r.ru_utime.tv_usec)
5044 {
5045 r.ru_utime.tv_sec--;
5046 r.ru_utime.tv_usec += 1000000;
5047 }
5048 if (r.ru_stime.tv_usec < Save_r.ru_stime.tv_usec)
5049 {
5050 r.ru_stime.tv_sec--;
5051 r.ru_stime.tv_usec += 1000000;
5052 }
5053
5054 /*
5055 * The only stats we don't show here are ixrss, idrss, isrss. It takes
5056 * some work to interpret them, and most platforms don't fill them in.
5057 */
5059
5060 appendStringInfoString(&str, "! system usage stats:\n");
5062 "!\t%ld.%06ld s user, %ld.%06ld s system, %ld.%06ld s elapsed\n",
5063 (long) (r.ru_utime.tv_sec - Save_r.ru_utime.tv_sec),
5064 (long) (r.ru_utime.tv_usec - Save_r.ru_utime.tv_usec),
5065 (long) (r.ru_stime.tv_sec - Save_r.ru_stime.tv_sec),
5066 (long) (r.ru_stime.tv_usec - Save_r.ru_stime.tv_usec),
5067 (long) (elapse_t.tv_sec - Save_t.tv_sec),
5068 (long) (elapse_t.tv_usec - Save_t.tv_usec));
5070 "!\t[%ld.%06ld s user, %ld.%06ld s system total]\n",
5071 (long) user.tv_sec,
5072 (long) user.tv_usec,
5073 (long) sys.tv_sec,
5074 (long) sys.tv_usec);
5075#ifndef WIN32
5076
5077 /*
5078 * The following rusage fields are not defined by POSIX, but they're
5079 * present on all current Unix-like systems so we use them without any
5080 * special checks. Some of these could be provided in our Windows
5081 * emulation in src/port/win32getrusage.c with more work.
5082 */
5084 "!\t%ld kB max resident size\n",
5085#if defined(__darwin__)
5086 /* in bytes on macOS */
5087 r.ru_maxrss / 1024
5088#else
5089 /* in kilobytes on most other platforms */
5090 r.ru_maxrss
5091#endif
5092 );
5094 "!\t%ld/%ld [%ld/%ld] filesystem blocks in/out\n",
5095 r.ru_inblock - Save_r.ru_inblock,
5096 /* they only drink coffee at dec */
5097 r.ru_oublock - Save_r.ru_oublock,
5098 r.ru_inblock, r.ru_oublock);
5100 "!\t%ld/%ld [%ld/%ld] page faults/reclaims, %ld [%ld] swaps\n",
5101 r.ru_majflt - Save_r.ru_majflt,
5102 r.ru_minflt - Save_r.ru_minflt,
5103 r.ru_majflt, r.ru_minflt,
5104 r.ru_nswap - Save_r.ru_nswap,
5105 r.ru_nswap);
5107 "!\t%ld [%ld] signals rcvd, %ld/%ld [%ld/%ld] messages rcvd/sent\n",
5108 r.ru_nsignals - Save_r.ru_nsignals,
5109 r.ru_nsignals,
5110 r.ru_msgrcv - Save_r.ru_msgrcv,
5111 r.ru_msgsnd - Save_r.ru_msgsnd,
5112 r.ru_msgrcv, r.ru_msgsnd);
5114 "!\t%ld/%ld [%ld/%ld] voluntary/involuntary context switches\n",
5115 r.ru_nvcsw - Save_r.ru_nvcsw,
5116 r.ru_nivcsw - Save_r.ru_nivcsw,
5117 r.ru_nvcsw, r.ru_nivcsw);
5118#endif /* !WIN32 */
5119
5120 /* remove trailing newline */
5121 if (str.data[str.len - 1] == '\n')
5122 str.data[--str.len] = '\0';
5123
5124 ereport(LOG,
5125 (errmsg_internal("%s", title),
5126 errdetail_internal("%s", str.data)));
5127
5128 pfree(str.data);
5129}
#define __darwin__
Definition: darwin.h:3
int errmsg_internal(const char *fmt,...)
Definition: elog.c:1157
int errdetail_internal(const char *fmt,...)
Definition: elog.c:1230
static char * user
Definition: pg_regress.c:119
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:145
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:230
struct timeval ru_utime
Definition: resource.h:14
struct timeval ru_stime
Definition: resource.h:15

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().

◆ StatementCancelHandler()

void StatementCancelHandler ( SIGNAL_ARGS  )

Definition at line 3034 of file postgres.c.

3035{
3036 /*
3037 * Don't joggle the elbow of proc_exit
3038 */
3040 {
3041 InterruptPending = true;
3042 QueryCancelPending = true;
3043 }
3044
3045 /* If we're still here, waken anything waiting on the process latch */
3047}

References InterruptPending, MyLatch, proc_exit_inprogress, QueryCancelPending, and SetLatch().

Referenced by AutoVacLauncherMain(), AutoVacWorkerMain(), BackgroundWorkerMain(), PostgresMain(), and WalSndSignals().

Variable Documentation

◆ client_connection_check_interval

PGDLLIMPORT int client_connection_check_interval
extern

Definition at line 102 of file postgres.c.

Referenced by ProcessInterrupts(), and start_xact_command().

◆ debug_query_string

◆ Log_disconnections

PGDLLIMPORT bool Log_disconnections
extern

Definition at line 94 of file postgres.c.

Referenced by PostgresMain().

◆ log_statement

PGDLLIMPORT int log_statement
extern

Definition at line 96 of file postgres.c.

Referenced by check_log_statement(), and HandleFunctionRequest().

◆ PostAuthDelay

PGDLLIMPORT int PostAuthDelay
extern

◆ restrict_nonsystem_relation_kind

PGDLLIMPORT int restrict_nonsystem_relation_kind
extern

◆ whereToSendOutput