31 #include <valgrind/valgrind.h>
207 static unsigned int old_valgrind_error_count;
217 unsigned int valgrind_error_count = VALGRIND_COUNT_ERRORS;
219 if (
unlikely(valgrind_error_count != old_valgrind_error_count) &&
221 VALGRIND_PRINTF(
"Valgrind detected %u error(s) during execution of \"%s\"\n",
222 valgrind_error_count - old_valgrind_error_count,
227 #define valgrind_report_error_query(query) ((void) 0)
272 if (inBuf->
len > 1 &&
273 inBuf->
data[inBuf->
len - 1] ==
'\n' &&
274 inBuf->
data[inBuf->
len - 2] ==
';')
286 if (inBuf->
len > 0 &&
287 inBuf->
data[inBuf->
len - 1] ==
'\\')
290 inBuf->
data[--inBuf->
len] =
'\0';
308 if (
c == EOF && inBuf->
len == 0)
379 (
errcode(ERRCODE_CONNECTION_FAILURE),
380 errmsg(
"unexpected EOF on client connection with an open transaction")));
390 (
errcode(ERRCODE_CONNECTION_DOES_NOT_EXIST),
465 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
466 errmsg(
"invalid frontend message type %d", qtype)));
514 int save_errno = errno;
560 int save_errno = errno;
616 List *raw_parsetree_list;
618 TRACE_POSTGRESQL_QUERY_PARSE_START(query_string);
628 #ifdef DEBUG_NODE_TESTS_ENABLED
631 if (Debug_copy_parse_plan_trees)
637 elog(
WARNING,
"copyObject() failed to produce an equal raw parse tree");
646 if (Debug_write_read_parse_plan_trees)
654 elog(
WARNING,
"outfuncs/readfuncs failed to produce an equal raw parse tree");
661 TRACE_POSTGRESQL_QUERY_PARSE_DONE(query_string);
663 return raw_parsetree_list;
677 const char *query_string,
678 const Oid *paramTypes,
683 List *querytree_list;
685 TRACE_POSTGRESQL_QUERY_REWRITE_START(query_string);
704 TRACE_POSTGRESQL_QUERY_REWRITE_DONE(query_string);
706 return querytree_list;
716 const char *query_string,
722 List *querytree_list;
724 TRACE_POSTGRESQL_QUERY_REWRITE_START(query_string);
738 for (
int i = 0;
i < *numParams;
i++)
740 Oid ptype = (*paramTypes)[
i];
742 if (ptype ==
InvalidOid || ptype == UNKNOWNOID)
744 (
errcode(ERRCODE_INDETERMINATE_DATATYPE),
745 errmsg(
"could not determine data type of parameter $%d",
757 TRACE_POSTGRESQL_QUERY_REWRITE_DONE(query_string);
759 return querytree_list;
770 const char *query_string,
772 void *parserSetupArg,
776 List *querytree_list;
778 TRACE_POSTGRESQL_QUERY_REWRITE_START(query_string);
797 TRACE_POSTGRESQL_QUERY_REWRITE_DONE(query_string);
799 return querytree_list;
811 List *querytree_list;
834 #ifdef DEBUG_NODE_TESTS_ENABLED
837 if (Debug_copy_parse_plan_trees)
844 elog(
WARNING,
"copyObject() failed to produce an equal rewritten parse tree");
850 if (Debug_write_read_parse_plan_trees)
855 foreach(lc, querytree_list)
859 Query *new_query = stringToNodeWithLocations(
str);
865 new_query->queryId = curr_query->queryId;
873 elog(
WARNING,
"outfuncs/readfuncs failed to produce an equal rewritten parse tree");
884 return querytree_list;
905 TRACE_POSTGRESQL_QUERY_PLAN_START();
916 #ifdef DEBUG_NODE_TESTS_ENABLED
919 if (Debug_copy_parse_plan_trees)
930 elog(
WARNING,
"copyObject() failed to produce an equal plan tree");
937 if (Debug_write_read_parse_plan_trees)
943 new_plan = stringToNodeWithLocations(
str);
953 elog(
WARNING,
"outfuncs/readfuncs failed to produce an equal plan tree");
967 TRACE_POSTGRESQL_QUERY_PLAN_DONE();
987 foreach(query_list, querytrees)
997 stmt->canSetTag = query->canSetTag;
1000 stmt->stmt_len = query->stmt_len;
1001 stmt->queryId = query->queryId;
1026 List *parsetree_list;
1029 bool was_logged =
false;
1030 bool use_implicit_block;
1040 TRACE_POSTGRESQL_QUERY_START(query_string);
1046 if (save_log_statement_stats)
1081 (
errmsg(
"statement: %s", query_string),
1100 use_implicit_block = (
list_length(parsetree_list) > 1);
1105 foreach(parsetree_item, parsetree_list)
1108 bool snapshot_set =
false;
1112 List *querytree_list,
1117 const char *cmdtagname;
1146 (
errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
1147 errmsg(
"current transaction is aborted, "
1148 "commands ignored until end of transaction block"),
1161 if (use_implicit_block)
1173 snapshot_set =
true;
1188 if (
lnext(parsetree_list, parsetree_item) != NULL)
1190 per_parsetree_context =
1192 "per-parsetree message context",
1295 if (
lnext(parsetree_list, parsetree_item) == NULL)
1306 if (use_implicit_block)
1350 if (per_parsetree_context)
1364 if (!parsetree_list)
1374 (
errmsg(
"duration: %s ms", msec_str),
1379 (
errmsg(
"duration: %s ms statement: %s",
1380 msec_str, query_string),
1386 if (save_log_statement_stats)
1389 TRACE_POSTGRESQL_QUERY_DONE(query_string);
1401 const char *stmt_name,
1407 List *parsetree_list;
1409 List *querytree_list;
1424 if (save_log_statement_stats)
1429 *stmt_name ? stmt_name :
"<unnamed>",
1453 is_named = (stmt_name[0] !=
'\0');
1464 unnamed_stmt_context =
1466 "unnamed prepared statement",
1484 (
errcode(ERRCODE_SYNTAX_ERROR),
1485 errmsg(
"cannot insert multiple commands into a prepared statement")));
1487 if (parsetree_list !=
NIL)
1489 bool snapshot_set =
false;
1504 (
errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
1505 errmsg(
"current transaction is aborted, "
1506 "commands ignored until end of transaction block"),
1522 snapshot_set =
true;
1543 raw_parse_tree = NULL;
1546 querytree_list =
NIL;
1555 if (unnamed_stmt_context)
1561 unnamed_stmt_context,
1610 (
errmsg(
"duration: %s ms", msec_str),
1615 (
errmsg(
"duration: %s ms parse %s: %s",
1617 *stmt_name ? stmt_name :
"<unnamed>",
1623 if (save_log_statement_stats)
1637 const char *portal_name;
1638 const char *stmt_name;
1640 int16 *pformats = NULL;
1643 int16 *rformats = NULL;
1648 char *saved_stmt_name;
1652 bool snapshot_set =
false;
1664 *portal_name ? portal_name :
"<unnamed>",
1665 *stmt_name ? stmt_name :
"<unnamed>")));
1668 if (stmt_name[0] !=
'\0')
1681 (
errcode(ERRCODE_UNDEFINED_PSTATEMENT),
1682 errmsg(
"unnamed prepared statement does not exist")));
1705 if (save_log_statement_stats)
1721 if (numPFormats > 0)
1724 for (
int i = 0;
i < numPFormats;
i++)
1731 if (numPFormats > 1 && numPFormats != numParams)
1733 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
1734 errmsg(
"bind message has %d parameter formats but %d parameters",
1735 numPFormats, numParams)));
1739 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
1740 errmsg(
"bind message supplies %d parameters, but prepared statement \"%s\" requires %d",
1756 (
errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
1757 errmsg(
"current transaction is aborted, "
1758 "commands ignored until end of transaction block"),
1765 if (portal_name[0] ==
'\0')
1783 saved_stmt_name =
pstrdup(stmt_name);
1785 saved_stmt_name = NULL;
1794 if (numParams > 0 ||
1799 snapshot_set =
true;
1807 char **knownTextValues = NULL;
1819 params_errcxt.
arg = &one_param_data;
1824 for (
int paramno = 0; paramno < numParams; paramno++)
1834 one_param_data.
paramno = paramno;
1838 isNull = (plength == -1);
1852 csave = pvalue[plength];
1853 pvalue[plength] =
'\0';
1862 if (numPFormats > 1)
1863 pformat = pformats[paramno];
1864 else if (numPFormats > 0)
1865 pformat = pformats[0];
1906 if (knownTextValues == NULL)
1910 knownTextValues[paramno] =
pstrdup(pstring);
1920 knownTextValues[paramno] =
1928 if (pstring != pbuf.
data)
1932 else if (pformat == 1)
1953 (
errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
1954 errmsg(
"incorrect binary data format in bind parameter %d",
1960 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1961 errmsg(
"unsupported format code: %d",
1968 pbuf.
data[plength] = csave;
2006 params_data.
params = params;
2009 params_errcxt.
arg = ¶ms_data;
2014 if (numRFormats > 0)
2017 for (
int i = 0;
i < numRFormats;
i++)
2076 (
errmsg(
"duration: %s ms", msec_str),
2081 (
errmsg(
"duration: %s ms bind %s%s%s: %s",
2083 *stmt_name ? stmt_name :
"<unnamed>",
2084 *portal_name ?
"/" :
"",
2085 *portal_name ? portal_name :
"",
2092 if (save_log_statement_stats)
2113 const char *sourceText;
2114 const char *prepStmtName;
2117 bool is_xact_command;
2118 bool execute_is_fetch;
2119 bool was_logged =
false;
2123 const char *cmdtagname;
2135 (
errcode(ERRCODE_UNDEFINED_CURSOR),
2136 errmsg(
"portal \"%s\" does not exist", portal_name)));
2162 prepStmtName =
"<unnamed>";
2172 foreach(lc, portal->
stmts)
2187 if (save_log_statement_stats)
2212 execute_is_fetch = !portal->
atStart;
2220 _(
"execute fetch from") :
2223 *portal_name ?
"/" :
"",
2224 *portal_name ? portal_name :
"",
2238 (
errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
2239 errmsg(
"current transaction is aborted, "
2240 "commands ignored until end of transaction block"),
2251 params_data.
params = portalParams;
2254 params_errcxt.
arg = ¶ms_data;
2263 !execute_is_fetch && max_rows ==
FETCH_ALL,
2292 portalParams = NULL;
2338 (
errmsg(
"duration: %s ms", msec_str),
2343 (
errmsg(
"duration: %s ms %s %s%s%s: %s",
2346 _(
"execute fetch from") :
2349 *portal_name ?
"/" :
"",
2350 *portal_name ? portal_name :
"",
2357 if (save_log_statement_stats)
2358 ShowUsage(
"EXECUTE MESSAGE STATISTICS");
2383 foreach(stmt_item, stmt_list)
2420 bool exceeded_duration;
2421 bool exceeded_sample_duration;
2422 bool in_sample =
false;
2427 msecs = usecs / 1000;
2449 if (exceeded_sample_duration)
2457 secs * 1000 + msecs, usecs % 1000);
2458 if ((exceeded_duration || in_sample ||
xact_is_sampled) && !was_logged)
2479 foreach(parsetree_item, raw_parsetree_list)
2491 errdetail(
"prepare: %s", pstmt->plansource->query_string);
2515 if (
str &&
str[0] !=
'\0')
2531 errdetail(
"Abort reason: recovery conflict");
2547 errdetail(
"User was holding shared buffer pin for too long.");
2550 errdetail(
"User was holding a relation lock for too long.");
2553 errdetail(
"User was or might have been using tablespace that must be dropped.");
2556 errdetail(
"User query might have needed to see row versions that must be removed.");
2559 errdetail(
"User was using a logical replication slot that must be invalidated.");
2562 errdetail(
"User transaction caused buffer deadlock with recovery.");
2565 errdetail(
"User was connected to a database that must be dropped.");
2587 if (
data->paramno < 0)
2596 quotedval =
buf.data;
2601 if (
data->portalName &&
data->portalName[0] !=
'\0')
2604 errcontext(
"portal \"%s\" parameter $%d = %s",
2605 data->portalName,
data->paramno + 1, quotedval);
2608 data->portalName,
data->paramno + 1);
2613 errcontext(
"unnamed portal parameter $%d = %s",
2614 data->paramno + 1, quotedval);
2644 if (stmt_name[0] !=
'\0')
2657 (
errcode(ERRCODE_UNDEFINED_PSTATEMENT),
2658 errmsg(
"unnamed prepared statement does not exist")));
2676 (
errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
2677 errmsg(
"current transaction is aborted, "
2678 "commands ignored until end of transaction block"),
2739 (
errcode(ERRCODE_UNDEFINED_CURSOR),
2740 errmsg(
"portal \"%s\" does not exist", portal_name)));
2753 (
errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
2754 errmsg(
"current transaction is aborted, "
2755 "commands ignored until end of transaction block"),
2823 #ifdef MEMORY_CONTEXT_CHECKING
2829 #ifdef SHOW_MEMORY_STATS
2921 sigprocmask(SIG_SETMASK, &
BlockSig, NULL);
2970 (
errcode(ERRCODE_ADMIN_SHUTDOWN),
2971 errmsg(
"terminating connection because of unexpected SIGQUIT signal")));
2976 (
errcode(ERRCODE_CRASH_SHUTDOWN),
2977 errmsg(
"terminating connection because of crash of another server process"),
2978 errdetail(
"The postmaster has commanded this server process to roll back"
2979 " the current transaction and exit, because another"
2980 " server process exited abnormally and possibly corrupted"
2982 errhint(
"In a moment you should be able to reconnect to the"
2983 " database and repeat your command.")));
2988 (
errcode(ERRCODE_ADMIN_SHUTDOWN),
2989 errmsg(
"terminating connection due to immediate shutdown command")));
3066 (
errcode(ERRCODE_FLOATING_POINT_EXCEPTION),
3067 errmsg(
"floating-point exception"),
3068 errdetail(
"An invalid floating-point operation was signaled. "
3069 "This probably means an out-of-range result or an "
3070 "invalid operation, such as division by zero.")));
3212 errmsg(
"canceling statement due to conflict with recovery"),
3231 ERRCODE_DATABASE_DROPPED :
3233 errmsg(
"terminating connection due to conflict with recovery"),
3235 errhint(
"In a moment you should be able to reconnect to the"
3236 " database and repeat your command.")));
3240 elog(
FATAL,
"unrecognized conflict mode: %d", (
int) reason);
3304 (
errcode(ERRCODE_QUERY_CANCELED),
3305 errmsg(
"canceling authentication due to timeout")));
3308 (
errcode(ERRCODE_ADMIN_SHUTDOWN),
3309 errmsg(
"terminating autovacuum process due to administrator command")));
3312 (
errcode(ERRCODE_ADMIN_SHUTDOWN),
3313 errmsg(
"terminating logical replication worker due to administrator command")));
3327 (
errcode(ERRCODE_ADMIN_SHUTDOWN),
3328 errmsg(
"terminating background worker \"%s\" due to administrator command",
3332 (
errcode(ERRCODE_ADMIN_SHUTDOWN),
3333 errmsg(
"terminating connection due to administrator command")));
3363 (
errcode(ERRCODE_CONNECTION_FAILURE),
3364 errmsg(
"connection to client lost")));
3389 bool lock_timeout_occurred;
3390 bool stmt_timeout_occurred;
3407 if (lock_timeout_occurred && stmt_timeout_occurred &&
3409 lock_timeout_occurred =
false;
3411 if (lock_timeout_occurred)
3415 (
errcode(ERRCODE_LOCK_NOT_AVAILABLE),
3416 errmsg(
"canceling statement due to lock timeout")));
3418 if (stmt_timeout_occurred)
3422 (
errcode(ERRCODE_QUERY_CANCELED),
3423 errmsg(
"canceling statement due to statement timeout")));
3429 (
errcode(ERRCODE_QUERY_CANCELED),
3430 errmsg(
"canceling autovacuum task")));
3442 (
errcode(ERRCODE_QUERY_CANCELED),
3443 errmsg(
"canceling statement due to user request")));
3463 (
errcode(ERRCODE_IDLE_IN_TRANSACTION_SESSION_TIMEOUT),
3464 errmsg(
"terminating connection due to idle-in-transaction timeout")));
3476 (
errcode(ERRCODE_TRANSACTION_TIMEOUT),
3477 errmsg(
"terminating connection due to transaction timeout")));
3489 (
errcode(ERRCODE_IDLE_SESSION_TIMEOUT),
3490 errmsg(
"terminating connection due to idle-session timeout")));
3526 #ifndef HAVE__BUILTIN_FRAME_ADDRESS
3538 #ifdef HAVE__BUILTIN_FRAME_ADDRESS
3579 (
errcode(ERRCODE_STATEMENT_TOO_COMPLEX),
3580 errmsg(
"stack depth limit exceeded"),
3581 errhint(
"Increase the configuration parameter \"max_stack_depth\" (currently %dkB), "
3582 "after ensuring the platform's stack depth limit is adequate.",
3601 if (stack_depth < 0)
3602 stack_depth = -stack_depth;
3623 long newval_bytes = *
newval * 1024L;
3630 GUC_check_errhint(
"Increase the platform's stack depth limit via \"ulimit -s\" or local equivalent.");
3640 long newval_bytes =
newval * 1024L;
3653 GUC_check_errdetail(
"\"client_connection_check_interval\" must be set to 0 on this platform.");
3690 "\"log_parser_stats\", \"log_planner_stats\", "
3691 "or \"log_executor_stats\" is true.");
3737 foreach(l, elemlist)
3739 char *tok = (
char *)
lfirst(l);
3759 *((
int *) *extra) = flags;
3770 int *flags = (
int *) extra;
3788 sprintf(debugstr,
"debug%d", debug_flag);
3799 if (debug_flag >= 2)
3801 if (debug_flag >= 3)
3803 if (debug_flag >= 4)
3805 if (debug_flag >= 5)
3813 const char *tmp = NULL;
3818 tmp =
"enable_seqscan";
3821 tmp =
"enable_indexscan";
3824 tmp =
"enable_indexonlyscan";
3827 tmp =
"enable_bitmapscan";
3830 tmp =
"enable_tidscan";
3833 tmp =
"enable_nestloop";
3836 tmp =
"enable_mergejoin";
3839 tmp =
"enable_hashjoin";
3859 return "log_parser_stats";
3860 else if (
optarg[1] ==
'l')
3861 return "log_planner_stats";
3865 return "log_executor_stats";
3906 if (argc > 1 && strcmp(argv[1],
"--single") == 0)
3917 #ifdef HAVE_INT_OPTERR
3932 while ((
flag =
getopt(argc, argv,
"B:bC:c:D:d:EeFf:h:ijk:lN:nOPp:r:S:sTt:v:W:-:")) != -1)
3960 (
errcode(ERRCODE_SYNTAX_ERROR),
3974 (
errcode(ERRCODE_SYNTAX_ERROR),
3975 errmsg(
"--%s requires a value",
3979 (
errcode(ERRCODE_SYNTAX_ERROR),
3980 errmsg(
"-c %s requires a value",
4118 if (errs || argc !=
optind)
4126 errcode(ERRCODE_SYNTAX_ERROR),
4127 errmsg(
"invalid command-line argument for server process: %s", argv[
optind]),
4131 errcode(ERRCODE_SYNTAX_ERROR),
4132 errmsg(
"%s: invalid command-line argument: %s",
4142 #ifdef HAVE_INT_OPTRESET
4161 const char *
dbname = NULL;
4184 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4185 errmsg(
"%s: no database nor user name specified",
4279 sigjmp_buf local_sigjmp_buf;
4282 volatile bool send_ready_for_query =
true;
4283 volatile bool idle_in_transaction_timeout_enabled =
false;
4284 volatile bool idle_session_timeout_enabled =
false;
4363 (
errcode(ERRCODE_INTERNAL_ERROR),
4364 errmsg(
"could not generate random cancel key")));
4431 printf(
"\nPostgreSQL stand-alone backend %s\n", PG_VERSION);
4450 "RowDescriptionContext",
4481 if (sigsetjmp(local_sigjmp_buf, 1) != 0)
4510 idle_in_transaction_timeout_enabled =
false;
4511 idle_session_timeout_enabled =
false;
4587 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
4588 errmsg(
"terminating connection because protocol synchronization was lost")));
4598 send_ready_for_query =
true;
4619 old_valgrind_error_count = VALGRIND_COUNT_ERRORS;
4653 if (send_ready_for_query)
4664 idle_in_transaction_timeout_enabled =
true;
4678 idle_in_transaction_timeout_enabled =
true;
4711 if (stats_timeout > 0)
4730 idle_session_timeout_enabled =
true;
4740 send_ready_for_query =
false;
4764 if (idle_in_transaction_timeout_enabled)
4767 idle_in_transaction_timeout_enabled =
false;
4769 if (idle_session_timeout_enabled)
4772 idle_session_timeout_enabled =
false;
4808 const char *query_string;
4826 send_ready_for_query =
true;
4832 const char *stmt_name;
4833 const char *query_string;
4835 Oid *paramTypes = NULL;
4848 for (
int i = 0;
i < numParams;
i++)
4854 paramTypes, numParams);
4877 const char *portal_name;
4927 send_ready_for_query =
true;
4933 const char *close_target;
4944 if (close_target[0] !=
'\0')
4963 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
4964 errmsg(
"invalid CLOSE message subtype %d",
4979 const char *describe_target;
4990 switch (describe_type)
5000 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
5001 errmsg(
"invalid DESCRIBE message subtype %d",
5027 send_ready_for_query =
true;
5073 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
5074 errmsg(
"invalid frontend message type %d",
5094 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
5095 errmsg(
"fastpath function calls not supported in a replication connection")));
5098 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
5099 errmsg(
"extended query protocol not supported in a replication connection")));
5112 #if defined(HAVE_GETRLIMIT)
5113 static long val = 0;
5120 if (getrlimit(RLIMIT_STACK, &rlim) < 0)
5122 else if (rlim.rlim_cur == RLIM_INFINITY)
5125 else if (rlim.rlim_cur >= LONG_MAX)
5128 val = rlim.rlim_cur;
5133 return WIN32_STACK_RLIMIT;
5139 static struct timeval
Save_t;
5152 struct timeval
user,
5154 struct timeval elapse_t;
5160 memcpy((
char *) &sys, (
char *) &r.
ru_stime,
sizeof(sys));
5161 if (elapse_t.tv_usec <
Save_t.tv_usec)
5164 elapse_t.tv_usec += 1000000;
5185 "!\t%ld.%06ld s user, %ld.%06ld s system, %ld.%06ld s elapsed\n",
5190 (
long) (elapse_t.tv_sec -
Save_t.tv_sec),
5191 (
long) (elapse_t.tv_usec -
Save_t.tv_usec));
5193 "!\t[%ld.%06ld s user, %ld.%06ld s system total]\n",
5195 (
long)
user.tv_usec,
5197 (
long) sys.tv_usec);
5207 "!\t%ld kB max resident size\n",
5217 "!\t%ld/%ld [%ld/%ld] filesystem blocks in/out\n",
5218 r.ru_inblock -
Save_r.ru_inblock,
5220 r.ru_oublock -
Save_r.ru_oublock,
5221 r.ru_inblock, r.ru_oublock);
5223 "!\t%ld/%ld [%ld/%ld] page faults/reclaims, %ld [%ld] swaps\n",
5224 r.ru_majflt -
Save_r.ru_majflt,
5225 r.ru_minflt -
Save_r.ru_minflt,
5226 r.ru_majflt, r.ru_minflt,
5227 r.ru_nswap -
Save_r.ru_nswap,
5230 "!\t%ld [%ld] signals rcvd, %ld/%ld [%ld/%ld] messages rcvd/sent\n",
5231 r.ru_nsignals -
Save_r.ru_nsignals,
5233 r.ru_msgrcv -
Save_r.ru_msgrcv,
5234 r.ru_msgsnd -
Save_r.ru_msgsnd,
5235 r.ru_msgrcv, r.ru_msgsnd);
5237 "!\t%ld/%ld [%ld/%ld] voluntary/involuntary context switches\n",
5238 r.ru_nvcsw -
Save_r.ru_nvcsw,
5239 r.ru_nivcsw -
Save_r.ru_nivcsw,
5240 r.ru_nvcsw, r.ru_nivcsw);
5244 if (
str.data[
str.len - 1] ==
'\n')
5245 str.data[--
str.len] =
'\0';
5271 msecs = usecs / 1000;
5279 (
errmsg(
"disconnection: session time: %d:%02d:%02d.%03d "
5280 "user=%s database=%s host=%s%s%s",
5281 hours, minutes, seconds, msecs,
5282 port->user_name,
port->database_name,
port->remote_host,
5283 port->remote_port[0] ?
" port=" :
"",
port->remote_port)));
Datum querytree(PG_FUNCTION_ARGS)
volatile sig_atomic_t ParallelApplyMessagePending
void HandleParallelApplyMessages(void)
void ProcessNotifyInterrupt(bool flush)
volatile sig_atomic_t notifyInterruptPending
void HandleParallelMessages(void)
volatile sig_atomic_t ParallelMessagePending
void DropPreparedStatement(const char *stmt_name, bool showError)
PreparedStatement * FetchPreparedStatement(const char *stmt_name, bool throwError)
void StorePreparedStatement(const char *stmt_name, CachedPlanSource *plansource, bool from_sql)
void elog_node_display(int lev, const char *title, const void *obj, bool pretty)
List * raw_parser(const char *str, RawParseMode mode)
bool IsLogicalWorker(void)
void TimestampDifference(TimestampTz start_time, TimestampTz stop_time, long *secs, int *microsecs)
TimestampTz GetCurrentTimestamp(void)
void pgstat_report_query_id(uint64 query_id, bool force)
void pgstat_report_activity(BackendState state, const char *cmd_str)
@ STATE_IDLEINTRANSACTION_ABORTED
@ STATE_IDLEINTRANSACTION
bool HoldingBufferPinThatDelaysRecovery(void)
#define unconstify(underlying_type, expr)
#define Assert(condition)
const char * GetCommandTagNameAndLen(CommandTag commandTag, Size *len)
void EndCommand(const QueryCompletion *qc, CommandDest dest, bool force_undecorated_output)
void BeginCommand(CommandTag commandTag, CommandDest dest)
void ReadyForQuery(CommandDest dest)
DestReceiver * CreateDestReceiver(CommandDest dest)
void NullCommand(CommandDest dest)
int errmsg_internal(const char *fmt,...)
int errhidestmt(bool hide_stmt)
void EmitErrorReport(void)
int errdetail_internal(const char *fmt,...)
int errdetail(const char *fmt,...)
ErrorContextCallback * error_context_stack
void FlushErrorState(void)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
sigjmp_buf * PG_exception_stack
#define WARNING_CLIENT_ONLY
#define ereport(elevel,...)
bool equal(const void *a, const void *b)
void EventTriggerOnLogin(void)
void HandleFunctionRequest(StringInfo msgBuf)
#define palloc_array(type, count)
#define palloc0_array(type, count)
Datum OidReceiveFunctionCall(Oid functionId, StringInfo buf, Oid typioparam, int32 typmod)
Datum OidInputFunctionCall(Oid functionId, char *str, Oid typioparam, int32 typmod)
volatile sig_atomic_t IdleStatsUpdateTimeoutPending
volatile sig_atomic_t LogMemoryContextPending
volatile sig_atomic_t ProcSignalBarrierPending
volatile sig_atomic_t InterruptPending
volatile sig_atomic_t IdleSessionTimeoutPending
volatile uint32 QueryCancelHoldoffCount
ProtocolVersion FrontendProtocol
volatile sig_atomic_t IdleInTransactionSessionTimeoutPending
volatile uint32 InterruptHoldoffCount
volatile sig_atomic_t TransactionTimeoutPending
volatile sig_atomic_t ClientConnectionLost
volatile uint32 CritSectionCount
volatile sig_atomic_t QueryCancelPending
TimestampTz MyStartTimestamp
char OutputFileName[MAXPGPATH]
volatile sig_atomic_t ProcDiePending
volatile sig_atomic_t CheckClientConnectionPending
void BeginReportingGUCOptions(void)
void * guc_malloc(int elevel, size_t size)
void SetConfigOption(const char *name, const char *value, GucContext context, GucSource source)
bool SelectConfigFiles(const char *userDoption, const char *progname)
void ParseLongOption(const char *string, char **name, char **value)
void InitializeGUCOptions(void)
void ReportChangedGUCOptions(void)
#define GUC_check_errdetail
#define GUC_check_errhint
void ProcessConfigFile(GucContext context)
int log_parameter_max_length_on_error
int log_min_duration_statement
int log_min_duration_sample
bool Debug_print_rewritten
int log_parameter_max_length
double log_statement_sample_rate
#define INJECTION_POINT(name)
volatile sig_atomic_t ConfigReloadPending
void SignalHandlerForConfigReload(SIGNAL_ARGS)
void on_proc_exit(pg_on_exit_callback function, Datum arg)
bool proc_exit_inprogress
void InitializeShmemGUCs(void)
void CreateSharedMemoryAndSemaphores(void)
if(TABLE==NULL||TABLE_index==NULL)
void jit_reset_after_error(void)
void SetLatch(Latch *latch)
bool WaitEventSetCanReportClosed(void)
bool IsLogicalLauncher(void)
#define PQ_SMALL_MESSAGE_LIMIT
#define PQ_LARGE_MESSAGE_LIMIT
static void const char fflush(stdout)
static List * new_list(NodeTag type, int min_size)
List * lappend(List *list, void *datum)
void list_free(List *list)
LOCALLOCK * GetAwaitedLock(void)
void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
void getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typIOParam)
DispatchOption parse_dispatch_option(const char *name)
char * pg_client_to_server(const char *s, int len)
char * pnstrdup(const char *in, Size len)
MemoryContext MessageContext
void MemoryContextReset(MemoryContext context)
void MemoryContextSetParent(MemoryContext context, MemoryContext new_parent)
char * pstrdup(const char *in)
void pfree(void *pointer)
MemoryContext TopMemoryContext
void MemoryContextStats(MemoryContext context)
MemoryContext PostmasterContext
void ProcessLogMemoryContextInterrupt(void)
void MemoryContextDelete(MemoryContext context)
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
#define RESUME_INTERRUPTS()
#define GetProcessingMode()
#define HOLD_CANCEL_INTERRUPTS()
#define INIT_PG_LOAD_SESSION_LIBS
#define AmAutoVacuumWorkerProcess()
#define RESUME_CANCEL_INTERRUPTS()
#define AmBackgroundWorkerProcess()
#define CHECK_FOR_INTERRUPTS()
#define HOLD_INTERRUPTS()
#define SetProcessingMode(mode)
void ChangeToDataDir(void)
void process_shmem_requests(void)
void InitStandaloneProcess(const char *argv0)
void process_shared_preload_libraries(void)
void CreateDataDirLockFile(bool amPostmaster)
#define IsA(nodeptr, _type_)
char * nodeToStringWithLocations(const void *obj)
ParamListInfo makeParamList(int numParams)
char * BuildParamLogString(ParamListInfo params, char **knownTextValues, int maxlen)
void ParamsErrorCallback(void *arg)
void(* ParserSetupHook)(struct ParseState *pstate, void *arg)
#define CURSOR_OPT_PARALLEL_OK
#define CURSOR_OPT_BINARY
Query * parse_analyze_withcb(RawStmt *parseTree, const char *sourceText, ParserSetupHook parserSetup, void *parserSetupArg, QueryEnvironment *queryEnv)
bool analyze_requires_snapshot(RawStmt *parseTree)
Query * parse_analyze_varparams(RawStmt *parseTree, const char *sourceText, Oid **paramTypes, int *numParams, QueryEnvironment *queryEnv)
Query * parse_analyze_fixedparams(RawStmt *parseTree, const char *sourceText, const Oid *paramTypes, int numParams, QueryEnvironment *queryEnv)
int getopt(int nargc, char *const *nargv, const char *ostr)
PGDLLIMPORT char * optarg
#define lfirst_node(type, lc)
static int list_length(const List *l)
#define linitial_node(type, l)
static ListCell * lnext(const List *l, const ListCell *c)
double pg_prng_double(pg_prng_state *state)
pg_prng_state pg_global_prng_state
static rewind_source * source
#define MAX_MULTIBYTE_CHAR_LEN
#define ERRCODE_T_R_SERIALIZATION_FAILURE
long pgstat_report_stat(bool force)
void pgstat_report_connect(Oid dboid)
void pgstat_report_recovery_conflict(int reason)
SessionEndType pgStatSessionEndCause
void DropCachedPlan(CachedPlanSource *plansource)
List * CachedPlanGetTargetList(CachedPlanSource *plansource, QueryEnvironment *queryEnv)
void SaveCachedPlan(CachedPlanSource *plansource)
void CompleteCachedPlan(CachedPlanSource *plansource, List *querytree_list, MemoryContext querytree_context, Oid *param_types, int num_params, ParserSetupHook parserSetup, void *parserSetupArg, int cursor_options, bool fixed_result)
CachedPlanSource * CreateCachedPlan(RawStmt *raw_parse_tree, const char *query_string, CommandTag commandTag)
CachedPlan * GetCachedPlan(CachedPlanSource *plansource, ParamListInfo boundParams, ResourceOwner owner, QueryEnvironment *queryEnv)
PlannedStmt * planner(Query *parse, const char *query_string, int cursorOptions, ParamListInfo boundParams)
void InitPostmasterChildSlots(void)
QuitSignalReason GetQuitSignalReason(void)
bool pg_strong_random(void *buf, size_t len)
int pg_strcasecmp(const char *s1, const char *s2)
pqsigfunc pqsignal(int signo, pqsigfunc func)
size_t strlcpy(char *dst, const char *src, size_t siz)
void PortalDrop(Portal portal, bool isTopCommit)
Portal GetPortalByName(const char *name)
void PortalDefineQuery(Portal portal, const char *prepStmtName, const char *sourceText, CommandTag commandTag, List *stmts, CachedPlan *cplan)
Portal CreatePortal(const char *name, bool allowDup, bool dupSilent)
void PortalErrorCleanup(void)
static int errdetail_recovery_conflict(ProcSignalReason reason)
struct BindParamCbData BindParamCbData
static void disable_statement_timeout(void)
List * pg_parse_query(const char *query_string)
static bool IsTransactionStmtList(List *pstmts)
void assign_transaction_timeout(int newval, void *extra)
static bool check_log_statement(List *stmt_list)
static void exec_describe_statement_message(const char *stmt_name)
void assign_restrict_nonsystem_relation_kind(const char *newval, void *extra)
void process_postgres_switches(int argc, char *argv[], GucContext ctx, const char **dbname)
void restore_stack_base(pg_stack_base_t base)
void quickdie(SIGNAL_ARGS)
static bool IsTransactionExitStmtList(List *pstmts)
static void log_disconnections(int code, Datum arg)
static int errdetail_abort(void)
static void forbidden_in_wal_sender(char firstchar)
static void exec_execute_message(const char *portal_name, long max_rows)
bool check_max_stack_depth(int *newval, void **extra, GucSource source)
void PostgresSingleUserMain(int argc, char *argv[], const char *username)
void set_debug_options(int debug_flag, GucContext context, GucSource source)
static bool UseSemiNewlineNewline
static CachedPlanSource * unnamed_stmt_psrc
void FloatExceptionHandler(SIGNAL_ARGS)
int client_connection_check_interval
bool check_log_stats(bool *newval, void **extra, GucSource source)
void StatementCancelHandler(SIGNAL_ARGS)
CommandDest whereToSendOutput
long get_stack_depth_rlimit(void)
static bool ignore_till_sync
static void finish_xact_command(void)
bool set_plan_disabling_options(const char *arg, GucContext context, GucSource source)
static void enable_statement_timeout(void)
static long max_stack_depth_bytes
int check_log_duration(char *msec_str, bool was_logged)
static struct timeval Save_t
const char * debug_query_string
static void exec_simple_query(const char *query_string)
List * pg_analyze_and_rewrite_varparams(RawStmt *parsetree, const char *query_string, Oid **paramTypes, int *numParams, QueryEnvironment *queryEnv)
void HandleRecoveryConflictInterrupt(ProcSignalReason reason)
static volatile sig_atomic_t RecoveryConflictPendingReasons[NUM_PROCSIGNALS]
static int errdetail_execute(List *raw_parsetree_list)
List * pg_analyze_and_rewrite_withcb(RawStmt *parsetree, const char *query_string, ParserSetupHook parserSetup, void *parserSetupArg, QueryEnvironment *queryEnv)
void ShowUsage(const char *title)
static void exec_parse_message(const char *query_string, const char *stmt_name, Oid *paramTypes, int numParams)
List * pg_analyze_and_rewrite_fixedparams(RawStmt *parsetree, const char *query_string, const Oid *paramTypes, int numParams, QueryEnvironment *queryEnv)
int restrict_nonsystem_relation_kind
static const char * userDoption
static volatile sig_atomic_t RecoveryConflictPending
static void exec_bind_message(StringInfo input_message)
static bool DoingCommandRead
List * pg_rewrite_query(Query *query)
const char * get_stats_option_name(const char *arg)
Definition: