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 STACK_DEPTH_SLOP   (512 * 1024L)
 
#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)
 
void quickdie (SIGNAL_ARGS) pg_attribute_noreturn()
 
void StatementCancelHandler (SIGNAL_ARGS)
 
void FloatExceptionHandler (SIGNAL_ARGS) pg_attribute_noreturn()
 
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)
 
void PostgresSingleUserMain (int argc, char *argv[], const char *username) pg_attribute_noreturn()
 
void PostgresMain (const char *dbname, const char *username) pg_attribute_noreturn()
 
long get_stack_depth_rlimit (void)
 
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 max_stack_depth
 
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 48 of file tcopprot.h.

◆ RESTRICT_RELKIND_VIEW

#define RESTRICT_RELKIND_VIEW   0x01

Definition at line 47 of file tcopprot.h.

◆ STACK_DEPTH_SLOP

#define STACK_DEPTH_SLOP   (512 * 1024L)

Definition at line 25 of file tcopprot.h.

Enumeration Type Documentation

◆ LogStmtLevel

Enumerator
LOGSTMT_NONE 
LOGSTMT_DDL 
LOGSTMT_MOD 
LOGSTMT_ALL 

Definition at line 35 of file tcopprot.h.

36 {
37  LOGSTMT_NONE, /* log no statements */
38  LOGSTMT_DDL, /* log data definition statements */
39  LOGSTMT_MOD, /* log modification statements, plus DDL */
40  LOGSTMT_ALL, /* log all statements */
41 } LogStmtLevel;
LogStmtLevel
Definition: tcopprot.h:36
@ LOGSTMT_NONE
Definition: tcopprot.h:37
@ LOGSTMT_MOD
Definition: tcopprot.h:39
@ LOGSTMT_DDL
Definition: tcopprot.h:38
@ LOGSTMT_ALL
Definition: tcopprot.h:40

Function Documentation

◆ check_log_duration()

int check_log_duration ( char *  msec_str,
bool  was_logged 
)

Definition at line 2389 of file postgres.c.

2390 {
2391  if (log_duration || log_min_duration_sample >= 0 ||
2393  {
2394  long secs;
2395  int usecs;
2396  int msecs;
2397  bool exceeded_duration;
2398  bool exceeded_sample_duration;
2399  bool in_sample = false;
2400 
2403  &secs, &usecs);
2404  msecs = usecs / 1000;
2405 
2406  /*
2407  * This odd-looking test for log_min_duration_* being exceeded is
2408  * designed to avoid integer overflow with very long durations: don't
2409  * compute secs * 1000 until we've verified it will fit in int.
2410  */
2411  exceeded_duration = (log_min_duration_statement == 0 ||
2413  (secs > log_min_duration_statement / 1000 ||
2414  secs * 1000 + msecs >= log_min_duration_statement)));
2415 
2416  exceeded_sample_duration = (log_min_duration_sample == 0 ||
2417  (log_min_duration_sample > 0 &&
2418  (secs > log_min_duration_sample / 1000 ||
2419  secs * 1000 + msecs >= log_min_duration_sample)));
2420 
2421  /*
2422  * Do not log if log_statement_sample_rate = 0. Log a sample if
2423  * log_statement_sample_rate <= 1 and avoid unnecessary PRNG call if
2424  * log_statement_sample_rate = 1.
2425  */
2426  if (exceeded_sample_duration)
2427  in_sample = log_statement_sample_rate != 0 &&
2428  (log_statement_sample_rate == 1 ||
2430 
2431  if (exceeded_duration || in_sample || log_duration || xact_is_sampled)
2432  {
2433  snprintf(msec_str, 32, "%ld.%03d",
2434  secs * 1000 + msecs, usecs % 1000);
2435  if ((exceeded_duration || in_sample || xact_is_sampled) && !was_logged)
2436  return 2;
2437  else
2438  return 1;
2439  }
2440  }
2441 
2442  return 0;
2443 }
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:525
int log_min_duration_sample
Definition: guc_tables.c:524
double log_statement_sample_rate
Definition: guc_tables.c:529
bool log_duration
Definition: guc_tables.c:490
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:238
TimestampTz GetCurrentStatementStartTimestamp(void)
Definition: xact.c:878
bool xact_is_sampled
Definition: xact.c:295

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 2981 of file postgres.c.

2982 {
2983  /* Don't joggle the elbow of proc_exit */
2984  if (!proc_exit_inprogress)
2985  {
2986  InterruptPending = true;
2987  ProcDiePending = true;
2988  }
2989 
2990  /* for the cumulative stats system */
2992 
2993  /* If we're still here, waken anything waiting on the process latch */
2994  SetLatch(MyLatch);
2995 
2996  /*
2997  * If we're in single user mode, we want to quit immediately - we can't
2998  * rely on latches as they wouldn't work when stdin/stdout is a file.
2999  * Rather ugly, but it's unlikely to be worthwhile to invest much more
3000  * effort just for the benefit of single user mode.
3001  */
3004 }
@ 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:632
@ DISCONNECT_KILLED
Definition: pgstat.h:113
SessionEndType pgStatSessionEndCause
CommandDest whereToSendOutput
Definition: postgres.c:91
static bool DoingCommandRead
Definition: postgres.c:148
void ProcessInterrupts(void)
Definition: postgres.c:3253

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

Referenced by PostgresMain().

◆ FloatExceptionHandler()

void FloatExceptionHandler ( SIGNAL_ARGS  )

Definition at line 3028 of file postgres.c.

3029 {
3030  /* We're not returning, so no need to save errno */
3031  ereport(ERROR,
3032  (errcode(ERRCODE_FLOATING_POINT_EXCEPTION),
3033  errmsg("floating-point exception"),
3034  errdetail("An invalid floating-point operation was signaled. "
3035  "This probably means an out-of-range result or an "
3036  "invalid operation, such as division by zero.")));
3037 }
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 AutoVacWorkerMain(), BackgroundWorkerMain(), plperl_init_interp(), PostgresMain(), and ReplSlotSyncWorkerMain().

◆ get_stack_depth_rlimit()

long get_stack_depth_rlimit ( void  )

Definition at line 5047 of file postgres.c.

5048 {
5049 #if defined(HAVE_GETRLIMIT)
5050  static long val = 0;
5051 
5052  /* This won't change after process launch, so check just once */
5053  if (val == 0)
5054  {
5055  struct rlimit rlim;
5056 
5057  if (getrlimit(RLIMIT_STACK, &rlim) < 0)
5058  val = -1;
5059  else if (rlim.rlim_cur == RLIM_INFINITY)
5060  val = LONG_MAX;
5061  /* rlim_cur is probably of an unsigned type, so check for overflow */
5062  else if (rlim.rlim_cur >= LONG_MAX)
5063  val = LONG_MAX;
5064  else
5065  val = rlim.rlim_cur;
5066  }
5067  return val;
5068 #else
5069  /* On Windows we set the backend stack size in src/backend/Makefile */
5070  return WIN32_STACK_RLIMIT;
5071 #endif
5072 }
long val
Definition: informix.c:689

References val.

Referenced by check_max_stack_depth(), and InitializeGUCOptionsFromEnvironment().

◆ get_stats_option_name()

const char* get_stats_option_name ( const char *  arg)

Definition at line 3819 of file postgres.c.

3820 {
3821  switch (arg[0])
3822  {
3823  case 'p':
3824  if (optarg[1] == 'a') /* "parser" */
3825  return "log_parser_stats";
3826  else if (optarg[1] == 'l') /* "planner" */
3827  return "log_planner_stats";
3828  break;
3829 
3830  case 'e': /* "executor" */
3831  return "log_executor_stats";
3832  break;
3833  }
3834 
3835  return NULL;
3836 }
void * arg
PGDLLIMPORT char * optarg
Definition: getopt.c:52

References arg, and optarg.

Referenced by PostmasterMain(), and process_postgres_switches().

◆ HandleRecoveryConflictInterrupt()

void HandleRecoveryConflictInterrupt ( ProcSignalReason  reason)

Definition at line 3044 of file postgres.c.

3045 {
3046  RecoveryConflictPendingReasons[reason] = true;
3047  RecoveryConflictPending = true;
3048  InterruptPending = true;
3049  /* latch will be set by procsignal_sigusr1_handler */
3050 }
static volatile sig_atomic_t RecoveryConflictPendingReasons[NUM_PROCSIGNALS]
Definition: postgres.c:171
static volatile sig_atomic_t RecoveryConflictPending
Definition: postgres.c:170

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 677 of file postgres.c.

682 {
683  Query *query;
684  List *querytree_list;
685 
686  TRACE_POSTGRESQL_QUERY_REWRITE_START(query_string);
687 
688  /*
689  * (1) Perform parse analysis.
690  */
691  if (log_parser_stats)
692  ResetUsage();
693 
694  query = parse_analyze_fixedparams(parsetree, query_string, paramTypes, numParams,
695  queryEnv);
696 
697  if (log_parser_stats)
698  ShowUsage("PARSE ANALYSIS STATISTICS");
699 
700  /*
701  * (2) Rewrite the queries, as necessary
702  */
703  querytree_list = pg_rewrite_query(query);
704 
705  TRACE_POSTGRESQL_QUERY_REWRITE_DONE(query_string);
706 
707  return querytree_list;
708 }
bool log_parser_stats
Definition: guc_tables.c:502
Query * parse_analyze_fixedparams(RawStmt *parseTree, const char *sourceText, const Oid *paramTypes, int numParams, QueryEnvironment *queryEnv)
Definition: analyze.c:105
void ShowUsage(const char *title)
Definition: postgres.c:5086
List * pg_rewrite_query(Query *query)
Definition: postgres.c:810
void ResetUsage(void)
Definition: postgres.c:5079
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 716 of file postgres.c.

721 {
722  Query *query;
723  List *querytree_list;
724 
725  TRACE_POSTGRESQL_QUERY_REWRITE_START(query_string);
726 
727  /*
728  * (1) Perform parse analysis.
729  */
730  if (log_parser_stats)
731  ResetUsage();
732 
733  query = parse_analyze_varparams(parsetree, query_string, paramTypes, numParams,
734  queryEnv);
735 
736  /*
737  * Check all parameter types got determined.
738  */
739  for (int i = 0; i < *numParams; i++)
740  {
741  Oid ptype = (*paramTypes)[i];
742 
743  if (ptype == InvalidOid || ptype == UNKNOWNOID)
744  ereport(ERROR,
745  (errcode(ERRCODE_INDETERMINATE_DATATYPE),
746  errmsg("could not determine data type of parameter $%d",
747  i + 1)));
748  }
749 
750  if (log_parser_stats)
751  ShowUsage("PARSE ANALYSIS STATISTICS");
752 
753  /*
754  * (2) Rewrite the queries, as necessary
755  */
756  querytree_list = pg_rewrite_query(query);
757 
758  TRACE_POSTGRESQL_QUERY_REWRITE_DONE(query_string);
759 
760  return querytree_list;
761 }
int i
Definition: isn.c:73
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:36
unsigned int Oid
Definition: postgres_ext.h:31

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 770 of file postgres.c.

775 {
776  Query *query;
777  List *querytree_list;
778 
779  TRACE_POSTGRESQL_QUERY_REWRITE_START(query_string);
780 
781  /*
782  * (1) Perform parse analysis.
783  */
784  if (log_parser_stats)
785  ResetUsage();
786 
787  query = parse_analyze_withcb(parsetree, query_string, parserSetup, parserSetupArg,
788  queryEnv);
789 
790  if (log_parser_stats)
791  ShowUsage("PARSE ANALYSIS STATISTICS");
792 
793  /*
794  * (2) Rewrite the queries, as necessary
795  */
796  querytree_list = pg_rewrite_query(query);
797 
798  TRACE_POSTGRESQL_QUERY_REWRITE_DONE(query_string);
799 
800  return querytree_list;
801 }
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 615 of file postgres.c.

616 {
617  List *raw_parsetree_list;
618 
619  TRACE_POSTGRESQL_QUERY_PARSE_START(query_string);
620 
621  if (log_parser_stats)
622  ResetUsage();
623 
624  raw_parsetree_list = raw_parser(query_string, RAW_PARSE_DEFAULT);
625 
626  if (log_parser_stats)
627  ShowUsage("PARSER STATISTICS");
628 
629 #ifdef DEBUG_NODE_TESTS_ENABLED
630 
631  /* Optional debugging check: pass raw parsetrees through copyObject() */
632  if (Debug_copy_parse_plan_trees)
633  {
634  List *new_list = copyObject(raw_parsetree_list);
635 
636  /* This checks both copyObject() and the equal() routines... */
637  if (!equal(new_list, raw_parsetree_list))
638  elog(WARNING, "copyObject() failed to produce an equal raw parse tree");
639  else
640  raw_parsetree_list = new_list;
641  }
642 
643  /*
644  * Optional debugging check: pass raw parsetrees through
645  * outfuncs/readfuncs
646  */
647  if (Debug_write_read_parse_plan_trees)
648  {
649  char *str = nodeToStringWithLocations(raw_parsetree_list);
650  List *new_list = stringToNodeWithLocations(str);
651 
652  pfree(str);
653  /* This checks both outfuncs/readfuncs and the equal() routines... */
654  if (!equal(new_list, raw_parsetree_list))
655  elog(WARNING, "outfuncs/readfuncs failed to produce an equal raw parse tree");
656  else
657  raw_parsetree_list = new_list;
658  }
659 
660 #endif /* DEBUG_NODE_TESTS_ENABLED */
661 
662  TRACE_POSTGRESQL_QUERY_PARSE_DONE(query_string);
663 
664  return raw_parsetree_list;
665 }
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:1521
#define copyObject(obj)
Definition: nodes.h:224
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 982 of file postgres.c.

984 {
985  List *stmt_list = NIL;
986  ListCell *query_list;
987 
988  foreach(query_list, querytrees)
989  {
990  Query *query = lfirst_node(Query, query_list);
991  PlannedStmt *stmt;
992 
993  if (query->commandType == CMD_UTILITY)
994  {
995  /* Utility commands require no planning. */
997  stmt->commandType = CMD_UTILITY;
998  stmt->canSetTag = query->canSetTag;
999  stmt->utilityStmt = query->utilityStmt;
1000  stmt->stmt_location = query->stmt_location;
1001  stmt->stmt_len = query->stmt_len;
1002  stmt->queryId = query->queryId;
1003  }
1004  else
1005  {
1006  stmt = pg_plan_query(query, query_string, cursorOptions,
1007  boundParams);
1008  }
1009 
1010  stmt_list = lappend(stmt_list, stmt);
1011  }
1012 
1013  return stmt_list;
1014 }
#define stmt
Definition: indent_codes.h:59
List * lappend(List *list, void *datum)
Definition: list.c:339
@ CMD_UTILITY
Definition: nodes.h:270
#define makeNode(_type_)
Definition: nodes.h:155
#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:894
CmdType commandType
Definition: parsenodes.h:121
Node * utilityStmt
Definition: parsenodes.h:136
ParseLoc stmt_location
Definition: parsenodes.h:240

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

◆ pg_plan_query()

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

Definition at line 894 of file postgres.c.

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

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 810 of file postgres.c.

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

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

Definition at line 4221 of file postgres.c.

4222 {
4223  sigjmp_buf local_sigjmp_buf;
4224 
4225  /* these must be volatile to ensure state is preserved across longjmp: */
4226  volatile bool send_ready_for_query = true;
4227  volatile bool idle_in_transaction_timeout_enabled = false;
4228  volatile bool idle_session_timeout_enabled = false;
4229 
4230  Assert(dbname != NULL);
4231  Assert(username != NULL);
4232 
4234 
4235  /*
4236  * Set up signal handlers. (InitPostmasterChild or InitStandaloneProcess
4237  * has already set up BlockSig and made that the active signal mask.)
4238  *
4239  * Note that postmaster blocked all signals before forking child process,
4240  * so there is no race condition whereby we might receive a signal before
4241  * we have set up the handler.
4242  *
4243  * Also note: it's best not to use any signals that are SIG_IGNored in the
4244  * postmaster. If such a signal arrives before we are able to change the
4245  * handler to non-SIG_IGN, it'll get dropped. Instead, make a dummy
4246  * handler in the postmaster to reserve the signal. (Of course, this isn't
4247  * an issue for signals that are locally generated, such as SIGALRM and
4248  * SIGPIPE.)
4249  */
4250  if (am_walsender)
4251  WalSndSignals();
4252  else
4253  {
4255  pqsignal(SIGINT, StatementCancelHandler); /* cancel current query */
4256  pqsignal(SIGTERM, die); /* cancel current query and exit */
4257 
4258  /*
4259  * In a postmaster child backend, replace SignalHandlerForCrashExit
4260  * with quickdie, so we can tell the client we're dying.
4261  *
4262  * In a standalone backend, SIGQUIT can be generated from the keyboard
4263  * easily, while SIGTERM cannot, so we make both signals do die()
4264  * rather than quickdie().
4265  */
4266  if (IsUnderPostmaster)
4267  pqsignal(SIGQUIT, quickdie); /* hard crash time */
4268  else
4269  pqsignal(SIGQUIT, die); /* cancel current query and exit */
4270  InitializeTimeouts(); /* establishes SIGALRM handler */
4271 
4272  /*
4273  * Ignore failure to write to frontend. Note: if frontend closes
4274  * connection, we will notice it and exit cleanly when control next
4275  * returns to outer loop. This seems safer than forcing exit in the
4276  * midst of output during who-knows-what operation...
4277  */
4282 
4283  /*
4284  * Reset some signals that are accepted by postmaster but not by
4285  * backend
4286  */
4287  pqsignal(SIGCHLD, SIG_DFL); /* system() requires this on some
4288  * platforms */
4289  }
4290 
4291  /* Early initialization */
4292  BaseInit();
4293 
4294  /* We need to allow SIGINT, etc during the initial transaction */
4295  sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
4296 
4297  /*
4298  * Generate a random cancel key, if this is a backend serving a
4299  * connection. InitPostgres() will advertise it in shared memory.
4300  */
4303  {
4304  if (!pg_strong_random(&MyCancelKey, sizeof(int32)))
4305  {
4306  ereport(ERROR,
4307  (errcode(ERRCODE_INTERNAL_ERROR),
4308  errmsg("could not generate random cancel key")));
4309  }
4310  MyCancelKeyValid = true;
4311  }
4312 
4313  /*
4314  * General initialization.
4315  *
4316  * NOTE: if you are tempted to add code in this vicinity, consider putting
4317  * it inside InitPostgres() instead. In particular, anything that
4318  * involves database access should be there, not here.
4319  *
4320  * Honor session_preload_libraries if not dealing with a WAL sender.
4321  */
4322  InitPostgres(dbname, InvalidOid, /* database to connect to */
4323  username, InvalidOid, /* role to connect as */
4325  NULL); /* no out_dbname */
4326 
4327  /*
4328  * If the PostmasterContext is still around, recycle the space; we don't
4329  * need it anymore after InitPostgres completes.
4330  */
4331  if (PostmasterContext)
4332  {
4334  PostmasterContext = NULL;
4335  }
4336 
4338 
4339  /*
4340  * Now all GUC states are fully set up. Report them to client if
4341  * appropriate.
4342  */
4344 
4345  /*
4346  * Also set up handler to log session end; we have to wait till now to be
4347  * sure Log_disconnections has its final value.
4348  */
4351 
4353 
4354  /* Perform initialization specific to a WAL sender process. */
4355  if (am_walsender)
4356  InitWalSender();
4357 
4358  /*
4359  * Send this backend's cancellation info to the frontend.
4360  */
4362  {
4364 
4369  pq_endmessage(&buf);
4370  /* Need not flush since ReadyForQuery will do it. */
4371  }
4372 
4373  /* Welcome banner for standalone case */
4375  printf("\nPostgreSQL stand-alone backend %s\n", PG_VERSION);
4376 
4377  /*
4378  * Create the memory context we will use in the main loop.
4379  *
4380  * MessageContext is reset once per iteration of the main loop, ie, upon
4381  * completion of processing of each command message from the client.
4382  */
4384  "MessageContext",
4386 
4387  /*
4388  * Create memory context and buffer used for RowDescription messages. As
4389  * SendRowDescriptionMessage(), via exec_describe_statement_message(), is
4390  * frequently executed for ever single statement, we don't want to
4391  * allocate a separate buffer every time.
4392  */
4394  "RowDescriptionContext",
4399 
4400  /* Fire any defined login event triggers, if appropriate */
4402 
4403  /*
4404  * POSTGRES main processing loop begins here
4405  *
4406  * If an exception is encountered, processing resumes here so we abort the
4407  * current transaction and start a new one.
4408  *
4409  * You might wonder why this isn't coded as an infinite loop around a
4410  * PG_TRY construct. The reason is that this is the bottom of the
4411  * exception stack, and so with PG_TRY there would be no exception handler
4412  * in force at all during the CATCH part. By leaving the outermost setjmp
4413  * always active, we have at least some chance of recovering from an error
4414  * during error recovery. (If we get into an infinite loop thereby, it
4415  * will soon be stopped by overflow of elog.c's internal state stack.)
4416  *
4417  * Note that we use sigsetjmp(..., 1), so that this function's signal mask
4418  * (to wit, UnBlockSig) will be restored when longjmp'ing to here. This
4419  * is essential in case we longjmp'd out of a signal handler on a platform
4420  * where that leaves the signal blocked. It's not redundant with the
4421  * unblock in AbortTransaction() because the latter is only called if we
4422  * were inside a transaction.
4423  */
4424 
4425  if (sigsetjmp(local_sigjmp_buf, 1) != 0)
4426  {
4427  /*
4428  * NOTE: if you are tempted to add more code in this if-block,
4429  * consider the high probability that it should be in
4430  * AbortTransaction() instead. The only stuff done directly here
4431  * should be stuff that is guaranteed to apply *only* for outer-level
4432  * error recovery, such as adjusting the FE/BE protocol status.
4433  */
4434 
4435  /* Since not using PG_TRY, must reset error stack by hand */
4436  error_context_stack = NULL;
4437 
4438  /* Prevent interrupts while cleaning up */
4439  HOLD_INTERRUPTS();
4440 
4441  /*
4442  * Forget any pending QueryCancel request, since we're returning to
4443  * the idle loop anyway, and cancel any active timeout requests. (In
4444  * future we might want to allow some timeout requests to survive, but
4445  * at minimum it'd be necessary to do reschedule_timeouts(), in case
4446  * we got here because of a query cancel interrupting the SIGALRM
4447  * interrupt handler.) Note in particular that we must clear the
4448  * statement and lock timeout indicators, to prevent any future plain
4449  * query cancels from being misreported as timeouts in case we're
4450  * forgetting a timeout cancel.
4451  */
4452  disable_all_timeouts(false); /* do first to avoid race condition */
4453  QueryCancelPending = false;
4454  idle_in_transaction_timeout_enabled = false;
4455  idle_session_timeout_enabled = false;
4456 
4457  /* Not reading from the client anymore. */
4458  DoingCommandRead = false;
4459 
4460  /* Make sure libpq is in a good state */
4461  pq_comm_reset();
4462 
4463  /* Report the error to the client and/or server log */
4464  EmitErrorReport();
4465 
4466  /*
4467  * If Valgrind noticed something during the erroneous query, print the
4468  * query string, assuming we have one.
4469  */
4471 
4472  /*
4473  * Make sure debug_query_string gets reset before we possibly clobber
4474  * the storage it points at.
4475  */
4476  debug_query_string = NULL;
4477 
4478  /*
4479  * Abort the current transaction in order to recover.
4480  */
4482 
4483  if (am_walsender)
4485 
4487 
4488  /*
4489  * We can't release replication slots inside AbortTransaction() as we
4490  * need to be able to start and abort transactions while having a slot
4491  * acquired. But we never need to hold them across top level errors,
4492  * so releasing here is fine. There also is a before_shmem_exit()
4493  * callback ensuring correct cleanup on FATAL errors.
4494  */
4495  if (MyReplicationSlot != NULL)
4497 
4498  /* We also want to cleanup temporary slots on error. */
4499  ReplicationSlotCleanup(false);
4500 
4502 
4503  /*
4504  * Now return to normal top-level context and clear ErrorContext for
4505  * next time.
4506  */
4508  FlushErrorState();
4509 
4510  /*
4511  * If we were handling an extended-query-protocol message, initiate
4512  * skip till next Sync. This also causes us not to issue
4513  * ReadyForQuery (until we get Sync).
4514  */
4516  ignore_till_sync = true;
4517 
4518  /* We don't have a transaction command open anymore */
4519  xact_started = false;
4520 
4521  /*
4522  * If an error occurred while we were reading a message from the
4523  * client, we have potentially lost track of where the previous
4524  * message ends and the next one begins. Even though we have
4525  * otherwise recovered from the error, we cannot safely read any more
4526  * messages from the client, so there isn't much we can do with the
4527  * connection anymore.
4528  */
4529  if (pq_is_reading_msg())
4530  ereport(FATAL,
4531  (errcode(ERRCODE_PROTOCOL_VIOLATION),
4532  errmsg("terminating connection because protocol synchronization was lost")));
4533 
4534  /* Now we can allow interrupts again */
4536  }
4537 
4538  /* We can now handle ereport(ERROR) */
4539  PG_exception_stack = &local_sigjmp_buf;
4540 
4541  if (!ignore_till_sync)
4542  send_ready_for_query = true; /* initially, or after error */
4543 
4544  /*
4545  * Non-error queries loop here.
4546  */
4547 
4548  for (;;)
4549  {
4550  int firstchar;
4551  StringInfoData input_message;
4552 
4553  /*
4554  * At top of loop, reset extended-query-message flag, so that any
4555  * errors encountered in "idle" state don't provoke skip.
4556  */
4558 
4559  /*
4560  * For valgrind reporting purposes, the "current query" begins here.
4561  */
4562 #ifdef USE_VALGRIND
4563  old_valgrind_error_count = VALGRIND_COUNT_ERRORS;
4564 #endif
4565 
4566  /*
4567  * Release storage left over from prior query cycle, and create a new
4568  * query input buffer in the cleared MessageContext.
4569  */
4572 
4573  initStringInfo(&input_message);
4574 
4575  /*
4576  * Also consider releasing our catalog snapshot if any, so that it's
4577  * not preventing advance of global xmin while we wait for the client.
4578  */
4580 
4581  /*
4582  * (1) If we've reached idle state, tell the frontend we're ready for
4583  * a new query.
4584  *
4585  * Note: this includes fflush()'ing the last of the prior output.
4586  *
4587  * This is also a good time to flush out collected statistics to the
4588  * cumulative stats system, and to update the PS stats display. We
4589  * avoid doing those every time through the message loop because it'd
4590  * slow down processing of batched messages, and because we don't want
4591  * to report uncommitted updates (that confuses autovacuum). The
4592  * notification processor wants a call too, if we are not in a
4593  * transaction block.
4594  *
4595  * Also, if an idle timeout is enabled, start the timer for that.
4596  */
4597  if (send_ready_for_query)
4598  {
4600  {
4601  set_ps_display("idle in transaction (aborted)");
4603 
4604  /* Start the idle-in-transaction timer */
4607  {
4608  idle_in_transaction_timeout_enabled = true;
4611  }
4612  }
4614  {
4615  set_ps_display("idle in transaction");
4617 
4618  /* Start the idle-in-transaction timer */
4621  {
4622  idle_in_transaction_timeout_enabled = true;
4625  }
4626  }
4627  else
4628  {
4629  long stats_timeout;
4630 
4631  /*
4632  * Process incoming notifies (including self-notifies), if
4633  * any, and send relevant messages to the client. Doing it
4634  * here helps ensure stable behavior in tests: if any notifies
4635  * were received during the just-finished transaction, they'll
4636  * be seen by the client before ReadyForQuery is.
4637  */
4639  ProcessNotifyInterrupt(false);
4640 
4641  /*
4642  * Check if we need to report stats. If pgstat_report_stat()
4643  * decides it's too soon to flush out pending stats / lock
4644  * contention prevented reporting, it'll tell us when we
4645  * should try to report stats again (so that stats updates
4646  * aren't unduly delayed if the connection goes idle for a
4647  * long time). We only enable the timeout if we don't already
4648  * have a timeout in progress, because we don't disable the
4649  * timeout below. enable_timeout_after() needs to determine
4650  * the current timestamp, which can have a negative
4651  * performance impact. That's OK because pgstat_report_stat()
4652  * won't have us wake up sooner than a prior call.
4653  */
4654  stats_timeout = pgstat_report_stat(false);
4655  if (stats_timeout > 0)
4656  {
4659  stats_timeout);
4660  }
4661  else
4662  {
4663  /* all stats flushed, no need for the timeout */
4666  }
4667 
4668  set_ps_display("idle");
4670 
4671  /* Start the idle-session timer */
4672  if (IdleSessionTimeout > 0)
4673  {
4674  idle_session_timeout_enabled = true;
4677  }
4678  }
4679 
4680  /* Report any recently-changed GUC options */
4682 
4684  send_ready_for_query = false;
4685  }
4686 
4687  /*
4688  * (2) Allow asynchronous signals to be executed immediately if they
4689  * come in while we are waiting for client input. (This must be
4690  * conditional since we don't want, say, reads on behalf of COPY FROM
4691  * STDIN doing the same thing.)
4692  */
4693  DoingCommandRead = true;
4694 
4695  /*
4696  * (3) read a command (loop blocks here)
4697  */
4698  firstchar = ReadCommand(&input_message);
4699 
4700  /*
4701  * (4) turn off the idle-in-transaction and idle-session timeouts if
4702  * active. We do this before step (5) so that any last-moment timeout
4703  * is certain to be detected in step (5).
4704  *
4705  * At most one of these timeouts will be active, so there's no need to
4706  * worry about combining the timeout.c calls into one.
4707  */
4708  if (idle_in_transaction_timeout_enabled)
4709  {
4711  idle_in_transaction_timeout_enabled = false;
4712  }
4713  if (idle_session_timeout_enabled)
4714  {
4716  idle_session_timeout_enabled = false;
4717  }
4718 
4719  /*
4720  * (5) disable async signal conditions again.
4721  *
4722  * Query cancel is supposed to be a no-op when there is no query in
4723  * progress, so if a query cancel arrived while we were idle, just
4724  * reset QueryCancelPending. ProcessInterrupts() has that effect when
4725  * it's called when DoingCommandRead is set, so check for interrupts
4726  * before resetting DoingCommandRead.
4727  */
4729  DoingCommandRead = false;
4730 
4731  /*
4732  * (6) check for any other interesting events that happened while we
4733  * slept.
4734  */
4735  if (ConfigReloadPending)
4736  {
4737  ConfigReloadPending = false;
4739  }
4740 
4741  /*
4742  * (7) process the command. But ignore it if we're skipping till
4743  * Sync.
4744  */
4745  if (ignore_till_sync && firstchar != EOF)
4746  continue;
4747 
4748  switch (firstchar)
4749  {
4750  case PqMsg_Query:
4751  {
4752  const char *query_string;
4753 
4754  /* Set statement_timestamp() */
4756 
4757  query_string = pq_getmsgstring(&input_message);
4758  pq_getmsgend(&input_message);
4759 
4760  if (am_walsender)
4761  {
4762  if (!exec_replication_command(query_string))
4763  exec_simple_query(query_string);
4764  }
4765  else
4766  exec_simple_query(query_string);
4767 
4768  valgrind_report_error_query(query_string);
4769 
4770  send_ready_for_query = true;
4771  }
4772  break;
4773 
4774  case PqMsg_Parse:
4775  {
4776  const char *stmt_name;
4777  const char *query_string;
4778  int numParams;
4779  Oid *paramTypes = NULL;
4780 
4781  forbidden_in_wal_sender(firstchar);
4782 
4783  /* Set statement_timestamp() */
4785 
4786  stmt_name = pq_getmsgstring(&input_message);
4787  query_string = pq_getmsgstring(&input_message);
4788  numParams = pq_getmsgint(&input_message, 2);
4789  if (numParams > 0)
4790  {
4791  paramTypes = palloc_array(Oid, numParams);
4792  for (int i = 0; i < numParams; i++)
4793  paramTypes[i] = pq_getmsgint(&input_message, 4);
4794  }
4795  pq_getmsgend(&input_message);
4796 
4797  exec_parse_message(query_string, stmt_name,
4798  paramTypes, numParams);
4799 
4800  valgrind_report_error_query(query_string);
4801  }
4802  break;
4803 
4804  case PqMsg_Bind:
4805  forbidden_in_wal_sender(firstchar);
4806 
4807  /* Set statement_timestamp() */
4809 
4810  /*
4811  * this message is complex enough that it seems best to put
4812  * the field extraction out-of-line
4813  */
4814  exec_bind_message(&input_message);
4815 
4816  /* exec_bind_message does valgrind_report_error_query */
4817  break;
4818 
4819  case PqMsg_Execute:
4820  {
4821  const char *portal_name;
4822  int max_rows;
4823 
4824  forbidden_in_wal_sender(firstchar);
4825 
4826  /* Set statement_timestamp() */
4828 
4829  portal_name = pq_getmsgstring(&input_message);
4830  max_rows = pq_getmsgint(&input_message, 4);
4831  pq_getmsgend(&input_message);
4832 
4833  exec_execute_message(portal_name, max_rows);
4834 
4835  /* exec_execute_message does valgrind_report_error_query */
4836  }
4837  break;
4838 
4839  case PqMsg_FunctionCall:
4840  forbidden_in_wal_sender(firstchar);
4841 
4842  /* Set statement_timestamp() */
4844 
4845  /* Report query to various monitoring facilities. */
4847  set_ps_display("<FASTPATH>");
4848 
4849  /* start an xact for this function invocation */
4851 
4852  /*
4853  * Note: we may at this point be inside an aborted
4854  * transaction. We can't throw error for that until we've
4855  * finished reading the function-call message, so
4856  * HandleFunctionRequest() must check for it after doing so.
4857  * Be careful not to do anything that assumes we're inside a
4858  * valid transaction here.
4859  */
4860 
4861  /* switch back to message context */
4863 
4864  HandleFunctionRequest(&input_message);
4865 
4866  /* commit the function-invocation transaction */
4868 
4869  valgrind_report_error_query("fastpath function call");
4870 
4871  send_ready_for_query = true;
4872  break;
4873 
4874  case PqMsg_Close:
4875  {
4876  int close_type;
4877  const char *close_target;
4878 
4879  forbidden_in_wal_sender(firstchar);
4880 
4881  close_type = pq_getmsgbyte(&input_message);
4882  close_target = pq_getmsgstring(&input_message);
4883  pq_getmsgend(&input_message);
4884 
4885  switch (close_type)
4886  {
4887  case 'S':
4888  if (close_target[0] != '\0')
4889  DropPreparedStatement(close_target, false);
4890  else
4891  {
4892  /* special-case the unnamed statement */
4894  }
4895  break;
4896  case 'P':
4897  {
4898  Portal portal;
4899 
4900  portal = GetPortalByName(close_target);
4901  if (PortalIsValid(portal))
4902  PortalDrop(portal, false);
4903  }
4904  break;
4905  default:
4906  ereport(ERROR,
4907  (errcode(ERRCODE_PROTOCOL_VIOLATION),
4908  errmsg("invalid CLOSE message subtype %d",
4909  close_type)));
4910  break;
4911  }
4912 
4915 
4916  valgrind_report_error_query("CLOSE message");
4917  }
4918  break;
4919 
4920  case PqMsg_Describe:
4921  {
4922  int describe_type;
4923  const char *describe_target;
4924 
4925  forbidden_in_wal_sender(firstchar);
4926 
4927  /* Set statement_timestamp() (needed for xact) */
4929 
4930  describe_type = pq_getmsgbyte(&input_message);
4931  describe_target = pq_getmsgstring(&input_message);
4932  pq_getmsgend(&input_message);
4933 
4934  switch (describe_type)
4935  {
4936  case 'S':
4937  exec_describe_statement_message(describe_target);
4938  break;
4939  case 'P':
4940  exec_describe_portal_message(describe_target);
4941  break;
4942  default:
4943  ereport(ERROR,
4944  (errcode(ERRCODE_PROTOCOL_VIOLATION),
4945  errmsg("invalid DESCRIBE message subtype %d",
4946  describe_type)));
4947  break;
4948  }
4949 
4950  valgrind_report_error_query("DESCRIBE message");
4951  }
4952  break;
4953 
4954  case PqMsg_Flush:
4955  pq_getmsgend(&input_message);
4957  pq_flush();
4958  break;
4959 
4960  case PqMsg_Sync:
4961  pq_getmsgend(&input_message);
4963  valgrind_report_error_query("SYNC message");
4964  send_ready_for_query = true;
4965  break;
4966 
4967  /*
4968  * 'X' means that the frontend is closing down the socket. EOF
4969  * means unexpected loss of frontend connection. Either way,
4970  * perform normal shutdown.
4971  */
4972  case EOF:
4973 
4974  /* for the cumulative statistics system */
4976 
4977  /* FALLTHROUGH */
4978 
4979  case PqMsg_Terminate:
4980 
4981  /*
4982  * Reset whereToSendOutput to prevent ereport from attempting
4983  * to send any more messages to client.
4984  */
4987 
4988  /*
4989  * NOTE: if you are tempted to add more code here, DON'T!
4990  * Whatever you had in mind to do should be set up as an
4991  * on_proc_exit or on_shmem_exit callback, instead. Otherwise
4992  * it will fail to be called during other backend-shutdown
4993  * scenarios.
4994  */
4995  proc_exit(0);
4996 
4997  case PqMsg_CopyData:
4998  case PqMsg_CopyDone:
4999  case PqMsg_CopyFail:
5000 
5001  /*
5002  * Accept but ignore these messages, per protocol spec; we
5003  * probably got here because a COPY failed, and the frontend
5004  * is still sending data.
5005  */
5006  break;
5007 
5008  default:
5009  ereport(FATAL,
5010  (errcode(ERRCODE_PROTOCOL_VIOLATION),
5011  errmsg("invalid frontend message type %d",
5012  firstchar)));
5013  }
5014  } /* end of input-reading loop */
5015 }
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:516
sigset_t UnBlockSig
Definition: pqsignal.c:22
void pgstat_report_activity(BackendState state, const char *cmd_str)
@ STATE_IDLEINTRANSACTION_ABORTED
@ STATE_IDLE
@ STATE_IDLEINTRANSACTION
@ STATE_FASTPATH
signed int int32
Definition: c.h:494
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:189
#define palloc_array(type, count)
Definition: fe_memutils.h:64
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 BeginReportingGUCOptions(void)
Definition: guc.c:2545
void ReportChangedGUCOptions(void)
Definition: guc.c:2595
@ PGC_SIGHUP
Definition: guc.h:71
void ProcessConfigFile(GucContext context)
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:446
@ InitProcessing
Definition: miscadmin.h:445
#define GetProcessingMode()
Definition: miscadmin.h:455
#define INIT_PG_LOAD_SESSION_LIBS
Definition: miscadmin.h:473
#define CHECK_FOR_INTERRUPTS()
Definition: miscadmin.h:122
#define HOLD_INTERRUPTS()
Definition: miscadmin.h:133
#define SetProcessingMode(mode)
Definition: miscadmin.h:457
static char * buf
Definition: pg_test_fsync.c:73
long pgstat_report_stat(bool force)
Definition: pgstat.c:660
@ DISCONNECT_CLIENT_EOF
Definition: pgstat.h:111
void pgstat_report_connect(Oid dboid)
bool pg_strong_random(void *buf, size_t len)
pqsigfunc pqsignal(int signo, pqsigfunc func)
#define printf(...)
Definition: port.h:244
#define PortalIsValid(p)
Definition: portal.h:212
void PortalDrop(Portal portal, bool isTopCommit)
Definition: portalmem.c:468
Portal GetPortalByName(const char *name)
Definition: portalmem.c:130
void PortalErrorCleanup(void)
Definition: portalmem.c:917
static void exec_describe_statement_message(const char *stmt_name)
Definition: postgres.c:2607
void quickdie(SIGNAL_ARGS)
Definition: postgres.c:2884
static void log_disconnections(int code, Datum arg)
Definition: postgres.c:5195
static void forbidden_in_wal_sender(char firstchar)
Definition: postgres.c:5025
static void exec_execute_message(const char *portal_name, long max_rows)
Definition: postgres.c:2095
void FloatExceptionHandler(SIGNAL_ARGS)
Definition: postgres.c:3028
void StatementCancelHandler(SIGNAL_ARGS)
Definition: postgres.c:3011
static bool ignore_till_sync
Definition: postgres.c:155
static void finish_xact_command(void)
Definition: postgres.c:2780
const char * debug_query_string
Definition: postgres.c:88
static void exec_simple_query(const char *query_string)
Definition: postgres.c:1023
static void exec_parse_message(const char *query_string, const char *stmt_name, Oid *paramTypes, int numParams)
Definition: postgres.c:1401
static void exec_bind_message(StringInfo input_message)
Definition: postgres.c:1636
void die(SIGNAL_ARGS)
Definition: postgres.c:2981
static bool xact_started
Definition: postgres.c:141
static MemoryContext row_description_context
Definition: postgres.c:174
static StringInfoData row_description_buf
Definition: postgres.c:175
static bool doing_extended_query_message
Definition: postgres.c:154
static void start_xact_command(void)
Definition: postgres.c:2752
static void exec_describe_portal_message(const char *portal_name)
Definition: postgres.c:2700
bool Log_disconnections
Definition: postgres.c:94
static void drop_unnamed_stmt(void)
Definition: postgres.c:2859
#define valgrind_report_error_query(query)
Definition: postgres.c:228
static int ReadCommand(StringInfo inBuf)
Definition: postgres.c:492
void BaseInit(void)
Definition: postinit.c:569
void InitPostgres(const char *in_dbname, Oid dboid, const char *username, Oid useroid, bits32 flags, char *out_dbname)
Definition: postinit.c:663
bool pq_is_reading_msg(void)
Definition: pqcomm.c:1181
unsigned int pq_getmsgint(StringInfo msg, int b)
Definition: pqformat.c:415
const char * pq_getmsgstring(StringInfo msg)
Definition: pqformat.c:579
void pq_getmsgend(StringInfo msg)
Definition: pqformat.c:635
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:671
#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
MemoryContextSwitchTo(old_ctx)
ReplicationSlot * MyReplicationSlot
Definition: slot.c:138
void ReplicationSlotRelease(void)
Definition: slot.c:652
void ReplicationSlotCleanup(bool synced_only)
Definition: slot.c:745
void InvalidateCatalogSnapshotConditionally(void)
Definition: snapmgr.c:443
int IdleSessionTimeout
Definition: proc.c:63
int IdleInTransactionSessionTimeout
Definition: proc.c:61
int TransactionTimeout
Definition: proc.c:62
char * dbname
Definition: streamutil.c:52
void initStringInfo(StringInfo str)
Definition: stringinfo.c:59
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
void WalSndErrorCleanup(void)
Definition: walsender.c:327
bool am_walsender
Definition: walsender.c:115
bool exec_replication_command(const char *cmd_string)
Definition: walsender.c:1980
void WalSndSignals(void)
Definition: walsender.c:3593
void InitWalSender(void)
#define SIGCHLD
Definition: win32_port.h:178
#define SIGHUP
Definition: win32_port.h:168
#define SIG_DFL
Definition: win32_port.h:163
#define SIGPIPE
Definition: win32_port.h:173
#define SIGQUIT
Definition: win32_port.h:169
#define SIGUSR1
Definition: win32_port.h:180
#define SIGUSR2
Definition: win32_port.h:181
#define SIG_IGN
Definition: win32_port.h:165
bool IsTransactionOrTransactionBlock(void)
Definition: xact.c:4982
bool IsAbortedTransactionBlockState(void)
Definition: xact.c:406
void SetCurrentStatementStartTimestamp(void)
Definition: xact.c:913
void AbortCurrentTransaction(void)
Definition: xact.c:3431

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(), 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(), IsTransactionOrTransactionBlock(), IsUnderPostmaster, jit_reset_after_error(), Log_disconnections, log_disconnections(), MemoryContextDelete(), MemoryContextReset(), MemoryContextSwitchTo(), MessageContext, MyCancelKey, MyCancelKeyValid, MyDatabaseId, MyProcPid, MyReplicationSlot, NormalProcessing, notifyInterruptPending, 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(), 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().

◆ PostgresSingleUserMain()

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

Definition at line 4111 of file postgres.c.

4113 {
4114  const char *dbname = NULL;
4115 
4117 
4118  /* Initialize startup process environment. */
4119  InitStandaloneProcess(argv[0]);
4120 
4121  /*
4122  * Set default values for command-line options.
4123  */
4125 
4126  /*
4127  * Parse command-line options.
4128  */
4130 
4131  /* Must have gotten a database name, or have a default (the username) */
4132  if (dbname == NULL)
4133  {
4134  dbname = username;
4135  if (dbname == NULL)
4136  ereport(FATAL,
4137  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4138  errmsg("%s: no database nor user name specified",
4139  progname)));
4140  }
4141 
4142  /* Acquire configuration parameters */
4144  proc_exit(1);
4145 
4146  /*
4147  * Validate we have been given a reasonable-looking DataDir and change
4148  * into it.
4149  */
4150  checkDataDir();
4151  ChangeToDataDir();
4152 
4153  /*
4154  * Create lockfile for data directory.
4155  */
4156  CreateDataDirLockFile(false);
4157 
4158  /* read control file (error checking and contains config ) */
4159  LocalProcessControlFile(false);
4160 
4161  /*
4162  * process any libraries that should be preloaded at postmaster start
4163  */
4165 
4166  /* Initialize MaxBackends */
4168 
4169  /*
4170  * Give preloaded libraries a chance to request additional shared memory.
4171  */
4173 
4174  /*
4175  * Now that loadable modules have had their chance to request additional
4176  * shared memory, determine the value of any runtime-computed GUCs that
4177  * depend on the amount of shared memory required.
4178  */
4180 
4181  /*
4182  * Now that modules have been loaded, we can process any custom resource
4183  * managers specified in the wal_consistency_checking GUC.
4184  */
4186 
4188 
4189  /*
4190  * Remember stand-alone backend startup time,roughly at the same point
4191  * during startup that postmaster does so.
4192  */
4194 
4195  /*
4196  * Create a per-backend PGPROC struct in shared memory. We must do this
4197  * before we can use LWLocks.
4198  */
4199  InitProcess();
4200 
4201  /*
4202  * Now that sufficient infrastructure has been initialized, PostgresMain()
4203  * can do the rest.
4204  */
4206 }
TimestampTz PgStartTime
Definition: timestamp.c:53
bool SelectConfigFiles(const char *userDoption, const char *progname)
Definition: guc.c:1783
void InitializeGUCOptions(void)
Definition: guc.c:1529
@ PGC_POSTMASTER
Definition: guc.h:70
void InitializeShmemGUCs(void)
Definition: ipci.c:351
void CreateSharedMemoryAndSemaphores(void)
Definition: ipci.c:196
const char * progname
Definition: main.c:44
void ChangeToDataDir(void)
Definition: miscinit.c:454
void process_shmem_requests(void)
Definition: miscinit.c:1871
void InitStandaloneProcess(const char *argv0)
Definition: miscinit.c:181
void process_shared_preload_libraries(void)
Definition: miscinit.c:1843
void checkDataDir(void)
Definition: miscinit.c:341
void CreateDataDirLockFile(bool amPostmaster)
Definition: miscinit.c:1455
void process_postgres_switches(int argc, char *argv[], GucContext ctx, const char **dbname)
Definition: postgres.c:3859
static const char * userDoption
Definition: postgres.c:165
void PostgresMain(const char *dbname, const char *username)
Definition: postgres.c:4221
void InitializeMaxBackends(void)
Definition: postinit.c:542
void InitProcess(void)
Definition: proc.c:297
void InitializeWalConsistencyChecking(void)
Definition: xlog.c:4777
void LocalProcessControlFile(bool reset)
Definition: xlog.c:4839

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

◆ process_postgres_switches()

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

Definition at line 3859 of file postgres.c.

3861 {
3862  bool secure = (ctx == PGC_POSTMASTER);
3863  int errs = 0;
3864  GucSource gucsource;
3865  int flag;
3866 
3867  if (secure)
3868  {
3869  gucsource = PGC_S_ARGV; /* switches came from command line */
3870 
3871  /* Ignore the initial --single argument, if present */
3872  if (argc > 1 && strcmp(argv[1], "--single") == 0)
3873  {
3874  argv++;
3875  argc--;
3876  }
3877  }
3878  else
3879  {
3880  gucsource = PGC_S_CLIENT; /* switches came from client */
3881  }
3882 
3883 #ifdef HAVE_INT_OPTERR
3884 
3885  /*
3886  * Turn this off because it's either printed to stderr and not the log
3887  * where we'd want it, or argv[0] is now "--single", which would make for
3888  * a weird error message. We print our own error message below.
3889  */
3890  opterr = 0;
3891 #endif
3892 
3893  /*
3894  * Parse command-line options. CAUTION: keep this in sync with
3895  * postmaster/postmaster.c (the option sets should not conflict) and with
3896  * the common help() function in main/main.c.
3897  */
3898  while ((flag = getopt(argc, argv, "B:bC:c:D:d:EeFf:h:ijk:lN:nOPp:r:S:sTt:v:W:-:")) != -1)
3899  {
3900  switch (flag)
3901  {
3902  case 'B':
3903  SetConfigOption("shared_buffers", optarg, ctx, gucsource);
3904  break;
3905 
3906  case 'b':
3907  /* Undocumented flag used for binary upgrades */
3908  if (secure)
3909  IsBinaryUpgrade = true;
3910  break;
3911 
3912  case 'C':
3913  /* ignored for consistency with the postmaster */
3914  break;
3915 
3916  case 'c':
3917  case '-':
3918  {
3919  char *name,
3920  *value;
3921 
3923  if (!value)
3924  {
3925  if (flag == '-')
3926  ereport(ERROR,
3927  (errcode(ERRCODE_SYNTAX_ERROR),
3928  errmsg("--%s requires a value",
3929  optarg)));
3930  else
3931  ereport(ERROR,
3932  (errcode(ERRCODE_SYNTAX_ERROR),
3933  errmsg("-c %s requires a value",
3934  optarg)));
3935  }
3936  SetConfigOption(name, value, ctx, gucsource);
3937  pfree(name);
3938  pfree(value);
3939  break;
3940  }
3941 
3942  case 'D':
3943  if (secure)
3944  userDoption = strdup(optarg);
3945  break;
3946 
3947  case 'd':
3948  set_debug_options(atoi(optarg), ctx, gucsource);
3949  break;
3950 
3951  case 'E':
3952  if (secure)
3953  EchoQuery = true;
3954  break;
3955 
3956  case 'e':
3957  SetConfigOption("datestyle", "euro", ctx, gucsource);
3958  break;
3959 
3960  case 'F':
3961  SetConfigOption("fsync", "false", ctx, gucsource);
3962  break;
3963 
3964  case 'f':
3965  if (!set_plan_disabling_options(optarg, ctx, gucsource))
3966  errs++;
3967  break;
3968 
3969  case 'h':
3970  SetConfigOption("listen_addresses", optarg, ctx, gucsource);
3971  break;
3972 
3973  case 'i':
3974  SetConfigOption("listen_addresses", "*", ctx, gucsource);
3975  break;
3976 
3977  case 'j':
3978  if (secure)
3979  UseSemiNewlineNewline = true;
3980  break;
3981 
3982  case 'k':
3983  SetConfigOption("unix_socket_directories", optarg, ctx, gucsource);
3984  break;
3985 
3986  case 'l':
3987  SetConfigOption("ssl", "true", ctx, gucsource);
3988  break;
3989 
3990  case 'N':
3991  SetConfigOption("max_connections", optarg, ctx, gucsource);
3992  break;
3993 
3994  case 'n':
3995  /* ignored for consistency with postmaster */
3996  break;
3997 
3998  case 'O':
3999  SetConfigOption("allow_system_table_mods", "true", ctx, gucsource);
4000  break;
4001 
4002  case 'P':
4003  SetConfigOption("ignore_system_indexes", "true", ctx, gucsource);
4004  break;
4005 
4006  case 'p':
4007  SetConfigOption("port", optarg, ctx, gucsource);
4008  break;
4009 
4010  case 'r':
4011  /* send output (stdout and stderr) to the given file */
4012  if (secure)
4014  break;
4015 
4016  case 'S':
4017  SetConfigOption("work_mem", optarg, ctx, gucsource);
4018  break;
4019 
4020  case 's':
4021  SetConfigOption("log_statement_stats", "true", ctx, gucsource);
4022  break;
4023 
4024  case 'T':
4025  /* ignored for consistency with the postmaster */
4026  break;
4027 
4028  case 't':
4029  {
4030  const char *tmp = get_stats_option_name(optarg);
4031 
4032  if (tmp)
4033  SetConfigOption(tmp, "true", ctx, gucsource);
4034  else
4035  errs++;
4036  break;
4037  }
4038 
4039  case 'v':
4040 
4041  /*
4042  * -v is no longer used in normal operation, since
4043  * FrontendProtocol is already set before we get here. We keep
4044  * the switch only for possible use in standalone operation,
4045  * in case we ever support using normal FE/BE protocol with a
4046  * standalone backend.
4047  */
4048  if (secure)
4050  break;
4051 
4052  case 'W':
4053  SetConfigOption("post_auth_delay", optarg, ctx, gucsource);
4054  break;
4055 
4056  default:
4057  errs++;
4058  break;
4059  }
4060 
4061  if (errs)
4062  break;
4063  }
4064 
4065  /*
4066  * Optional database name should be there only if *dbname is NULL.
4067  */
4068  if (!errs && dbname && *dbname == NULL && argc - optind >= 1)
4069  *dbname = strdup(argv[optind++]);
4070 
4071  if (errs || argc != optind)
4072  {
4073  if (errs)
4074  optind--; /* complain about the previous argument */
4075 
4076  /* spell the error message a bit differently depending on context */
4077  if (IsUnderPostmaster)
4078  ereport(FATAL,
4079  errcode(ERRCODE_SYNTAX_ERROR),
4080  errmsg("invalid command-line argument for server process: %s", argv[optind]),
4081  errhint("Try \"%s --help\" for more information.", progname));
4082  else
4083  ereport(FATAL,
4084  errcode(ERRCODE_SYNTAX_ERROR),
4085  errmsg("%s: invalid command-line argument: %s",
4086  progname, argv[optind]),
4087  errhint("Try \"%s --help\" for more information.", progname));
4088  }
4089 
4090  /*
4091  * Reset getopt(3) library so that it will work correctly in subprocesses
4092  * or when this function is called a second time with another array.
4093  */
4094  optind = 1;
4095 #ifdef HAVE_INT_OPTRESET
4096  optreset = 1; /* some systems need this too */
4097 #endif
4098 }
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:4291
void ParseLongOption(const char *string, char **name, char **value)
Definition: guc.c:6327
GucSource
Definition: guc.h:108
@ PGC_S_ARGV
Definition: guc.h:113
@ PGC_S_CLIENT
Definition: guc.h:118
static struct @157 value
#define MAXPGPATH
PGDLLIMPORT int optind
Definition: getopt.c:50
PGDLLIMPORT int opterr
Definition: getopt.c:49
int getopt(int nargc, char *const *nargv, const char *ostr)
Definition: getopt.c:71
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:3748
static bool UseSemiNewlineNewline
Definition: postgres.c:167
static bool EchoQuery
Definition: postgres.c:166
bool set_plan_disabling_options(const char *arg, GucContext context, GucSource source)
Definition: postgres.c:3777
const char * get_stats_option_name(const char *arg)
Definition: postgres.c:3819
uint32 ProtocolVersion
Definition: pqcomm.h:100
char * flag(int b)
Definition: test-ctype.c:33
const char * name

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

◆ ProcessClientReadInterrupt()

void ProcessClientReadInterrupt ( bool  blocked)

Definition at line 513 of file postgres.c.

514 {
515  int save_errno = errno;
516 
517  if (DoingCommandRead)
518  {
519  /* Check for general interrupts that arrived before/while reading */
521 
522  /* Process sinval catchup interrupts, if any */
525 
526  /* Process notify interrupts, if any */
529  }
530  else if (ProcDiePending)
531  {
532  /*
533  * We're dying. If there is no data available to read, then it's safe
534  * (and sane) to handle that now. If we haven't tried to read yet,
535  * make sure the process latch is set, so that if there is no data
536  * then we'll come back here and die. If we're done reading, also
537  * make sure the process latch is set, as we might've undesirably
538  * cleared it while reading.
539  */
540  if (blocked)
542  else
543  SetLatch(MyLatch);
544  }
545 
546  errno = save_errno;
547 }
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 559 of file postgres.c.

560 {
561  int save_errno = errno;
562 
563  if (ProcDiePending)
564  {
565  /*
566  * We're dying. If it's not possible to write, then we should handle
567  * that immediately, else a stuck client could indefinitely delay our
568  * response to the signal. If we haven't tried to write yet, make
569  * sure the process latch is set, so that if the write would block
570  * then we'll come back here and die. If we're done writing, also
571  * make sure the process latch is set, as we might've undesirably
572  * cleared it while writing.
573  */
574  if (blocked)
575  {
576  /*
577  * Don't mess with whereToSendOutput if ProcessInterrupts wouldn't
578  * service ProcDiePending.
579  */
580  if (InterruptHoldoffCount == 0 && CritSectionCount == 0)
581  {
582  /*
583  * We don't want to send the client the error message, as a)
584  * that would possibly block again, and b) it would likely
585  * lead to loss of protocol sync because we may have already
586  * sent a partial protocol message.
587  */
590 
592  }
593  }
594  else
595  SetLatch(MyLatch);
596  }
597 
598  errno = save_errno;
599 }
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()

void quickdie ( SIGNAL_ARGS  )

Definition at line 2884 of file postgres.c.

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

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 3748 of file postgres.c.

3749 {
3750  if (debug_flag > 0)
3751  {
3752  char debugstr[64];
3753 
3754  sprintf(debugstr, "debug%d", debug_flag);
3755  SetConfigOption("log_min_messages", debugstr, context, source);
3756  }
3757  else
3758  SetConfigOption("log_min_messages", "notice", context, source);
3759 
3760  if (debug_flag >= 1 && context == PGC_POSTMASTER)
3761  {
3762  SetConfigOption("log_connections", "true", context, source);
3763  SetConfigOption("log_disconnections", "true", context, source);
3764  }
3765  if (debug_flag >= 2)
3766  SetConfigOption("log_statement", "all", context, source);
3767  if (debug_flag >= 3)
3768  SetConfigOption("debug_print_parse", "true", context, source);
3769  if (debug_flag >= 4)
3770  SetConfigOption("debug_print_plan", "true", context, source);
3771  if (debug_flag >= 5)
3772  SetConfigOption("debug_print_rewritten", "true", context, source);
3773 }
static rewind_source * source
Definition: pg_rewind.c:89
#define sprintf
Definition: port.h:240
tree context
Definition: radixtree.h:1835

References context, 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 3777 of file postgres.c.

3778 {
3779  const char *tmp = NULL;
3780 
3781  switch (arg[0])
3782  {
3783  case 's': /* seqscan */
3784  tmp = "enable_seqscan";
3785  break;
3786  case 'i': /* indexscan */
3787  tmp = "enable_indexscan";
3788  break;
3789  case 'o': /* indexonlyscan */
3790  tmp = "enable_indexonlyscan";
3791  break;
3792  case 'b': /* bitmapscan */
3793  tmp = "enable_bitmapscan";
3794  break;
3795  case 't': /* tidscan */
3796  tmp = "enable_tidscan";
3797  break;
3798  case 'n': /* nestloop */
3799  tmp = "enable_nestloop";
3800  break;
3801  case 'm': /* mergejoin */
3802  tmp = "enable_mergejoin";
3803  break;
3804  case 'h': /* hashjoin */
3805  tmp = "enable_hashjoin";
3806  break;
3807  }
3808  if (tmp)
3809  {
3810  SetConfigOption(tmp, "false", context, source);
3811  return true;
3812  }
3813  else
3814  return false;
3815 }

References arg, context, SetConfigOption(), and source.

Referenced by PostmasterMain(), and process_postgres_switches().

◆ ShowUsage()

void ShowUsage ( const char *  title)

Definition at line 5086 of file postgres.c.

5087 {
5089  struct timeval user,
5090  sys;
5091  struct timeval elapse_t;
5092  struct rusage r;
5093 
5094  getrusage(RUSAGE_SELF, &r);
5095  gettimeofday(&elapse_t, NULL);
5096  memcpy((char *) &user, (char *) &r.ru_utime, sizeof(user));
5097  memcpy((char *) &sys, (char *) &r.ru_stime, sizeof(sys));
5098  if (elapse_t.tv_usec < Save_t.tv_usec)
5099  {
5100  elapse_t.tv_sec--;
5101  elapse_t.tv_usec += 1000000;
5102  }
5103  if (r.ru_utime.tv_usec < Save_r.ru_utime.tv_usec)
5104  {
5105  r.ru_utime.tv_sec--;
5106  r.ru_utime.tv_usec += 1000000;
5107  }
5108  if (r.ru_stime.tv_usec < Save_r.ru_stime.tv_usec)
5109  {
5110  r.ru_stime.tv_sec--;
5111  r.ru_stime.tv_usec += 1000000;
5112  }
5113 
5114  /*
5115  * The only stats we don't show here are ixrss, idrss, isrss. It takes
5116  * some work to interpret them, and most platforms don't fill them in.
5117  */
5118  initStringInfo(&str);
5119 
5120  appendStringInfoString(&str, "! system usage stats:\n");
5122  "!\t%ld.%06ld s user, %ld.%06ld s system, %ld.%06ld s elapsed\n",
5123  (long) (r.ru_utime.tv_sec - Save_r.ru_utime.tv_sec),
5124  (long) (r.ru_utime.tv_usec - Save_r.ru_utime.tv_usec),
5125  (long) (r.ru_stime.tv_sec - Save_r.ru_stime.tv_sec),
5126  (long) (r.ru_stime.tv_usec - Save_r.ru_stime.tv_usec),
5127  (long) (elapse_t.tv_sec - Save_t.tv_sec),
5128  (long) (elapse_t.tv_usec - Save_t.tv_usec));
5130  "!\t[%ld.%06ld s user, %ld.%06ld s system total]\n",
5131  (long) user.tv_sec,
5132  (long) user.tv_usec,
5133  (long) sys.tv_sec,
5134  (long) sys.tv_usec);
5135 #ifndef WIN32
5136 
5137  /*
5138  * The following rusage fields are not defined by POSIX, but they're
5139  * present on all current Unix-like systems so we use them without any
5140  * special checks. Some of these could be provided in our Windows
5141  * emulation in src/port/win32getrusage.c with more work.
5142  */
5144  "!\t%ld kB max resident size\n",
5145 #if defined(__darwin__)
5146  /* in bytes on macOS */
5147  r.ru_maxrss / 1024
5148 #else
5149  /* in kilobytes on most other platforms */
5150  r.ru_maxrss
5151 #endif
5152  );
5154  "!\t%ld/%ld [%ld/%ld] filesystem blocks in/out\n",
5155  r.ru_inblock - Save_r.ru_inblock,
5156  /* they only drink coffee at dec */
5157  r.ru_oublock - Save_r.ru_oublock,
5158  r.ru_inblock, r.ru_oublock);
5160  "!\t%ld/%ld [%ld/%ld] page faults/reclaims, %ld [%ld] swaps\n",
5161  r.ru_majflt - Save_r.ru_majflt,
5162  r.ru_minflt - Save_r.ru_minflt,
5163  r.ru_majflt, r.ru_minflt,
5164  r.ru_nswap - Save_r.ru_nswap,
5165  r.ru_nswap);
5167  "!\t%ld [%ld] signals rcvd, %ld/%ld [%ld/%ld] messages rcvd/sent\n",
5168  r.ru_nsignals - Save_r.ru_nsignals,
5169  r.ru_nsignals,
5170  r.ru_msgrcv - Save_r.ru_msgrcv,
5171  r.ru_msgsnd - Save_r.ru_msgsnd,
5172  r.ru_msgrcv, r.ru_msgsnd);
5174  "!\t%ld/%ld [%ld/%ld] voluntary/involuntary context switches\n",
5175  r.ru_nvcsw - Save_r.ru_nvcsw,
5176  r.ru_nivcsw - Save_r.ru_nivcsw,
5177  r.ru_nvcsw, r.ru_nivcsw);
5178 #endif /* !WIN32 */
5179 
5180  /* remove trailing newline */
5181  if (str.data[str.len - 1] == '\n')
5182  str.data[--str.len] = '\0';
5183 
5184  ereport(LOG,
5185  (errmsg_internal("%s", title),
5186  errdetail_internal("%s", str.data)));
5187 
5188  pfree(str.data);
5189 }
#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:120
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:97
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:182
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 3011 of file postgres.c.

3012 {
3013  /*
3014  * Don't joggle the elbow of proc_exit
3015  */
3016  if (!proc_exit_inprogress)
3017  {
3018  InterruptPending = true;
3019  QueryCancelPending = true;
3020  }
3021 
3022  /* If we're still here, waken anything waiting on the process latch */
3023  SetLatch(MyLatch);
3024 }

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

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

Variable Documentation

◆ client_connection_check_interval

PGDLLIMPORT int client_connection_check_interval
extern

Definition at line 105 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().

◆ max_stack_depth

PGDLLIMPORT int max_stack_depth
extern

Definition at line 99 of file postgres.c.

Referenced by check_stack_depth().

◆ PostAuthDelay

PGDLLIMPORT int PostAuthDelay
extern

Definition at line 102 of file postgres.c.

Referenced by AutoVacWorkerMain(), BackgroundWorkerMain(), and InitPostgres().

◆ restrict_nonsystem_relation_kind

PGDLLIMPORT int restrict_nonsystem_relation_kind
extern

◆ whereToSendOutput