31 #include <valgrind/valgrind.h>
208 static unsigned int old_valgrind_error_count;
218 unsigned int valgrind_error_count = VALGRIND_COUNT_ERRORS;
220 if (
unlikely(valgrind_error_count != old_valgrind_error_count) &&
222 VALGRIND_PRINTF(
"Valgrind detected %u error(s) during execution of \"%s\"\n",
223 valgrind_error_count - old_valgrind_error_count,
228 #define valgrind_report_error_query(query) ((void) 0)
273 if (inBuf->
len > 1 &&
274 inBuf->
data[inBuf->
len - 1] ==
'\n' &&
275 inBuf->
data[inBuf->
len - 2] ==
';')
287 if (inBuf->
len > 0 &&
288 inBuf->
data[inBuf->
len - 1] ==
'\\')
291 inBuf->
data[--inBuf->
len] =
'\0';
309 if (
c == EOF && inBuf->
len == 0)
380 (
errcode(ERRCODE_CONNECTION_FAILURE),
381 errmsg(
"unexpected EOF on client connection with an open transaction")));
391 (
errcode(ERRCODE_CONNECTION_DOES_NOT_EXIST),
466 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
467 errmsg(
"invalid frontend message type %d", qtype)));
515 int save_errno = errno;
561 int save_errno = errno;
617 List *raw_parsetree_list;
619 TRACE_POSTGRESQL_QUERY_PARSE_START(query_string);
629 #ifdef DEBUG_NODE_TESTS_ENABLED
632 if (Debug_copy_parse_plan_trees)
638 elog(
WARNING,
"copyObject() failed to produce an equal raw parse tree");
647 if (Debug_write_read_parse_plan_trees)
655 elog(
WARNING,
"outfuncs/readfuncs failed to produce an equal raw parse tree");
662 TRACE_POSTGRESQL_QUERY_PARSE_DONE(query_string);
664 return raw_parsetree_list;
678 const char *query_string,
679 const Oid *paramTypes,
684 List *querytree_list;
686 TRACE_POSTGRESQL_QUERY_REWRITE_START(query_string);
705 TRACE_POSTGRESQL_QUERY_REWRITE_DONE(query_string);
707 return querytree_list;
717 const char *query_string,
723 List *querytree_list;
725 TRACE_POSTGRESQL_QUERY_REWRITE_START(query_string);
739 for (
int i = 0;
i < *numParams;
i++)
741 Oid ptype = (*paramTypes)[
i];
743 if (ptype ==
InvalidOid || ptype == UNKNOWNOID)
745 (
errcode(ERRCODE_INDETERMINATE_DATATYPE),
746 errmsg(
"could not determine data type of parameter $%d",
758 TRACE_POSTGRESQL_QUERY_REWRITE_DONE(query_string);
760 return querytree_list;
771 const char *query_string,
773 void *parserSetupArg,
777 List *querytree_list;
779 TRACE_POSTGRESQL_QUERY_REWRITE_START(query_string);
798 TRACE_POSTGRESQL_QUERY_REWRITE_DONE(query_string);
800 return querytree_list;
812 List *querytree_list;
835 #ifdef DEBUG_NODE_TESTS_ENABLED
838 if (Debug_copy_parse_plan_trees)
845 elog(
WARNING,
"copyObject() failed to produce an equal rewritten parse tree");
851 if (Debug_write_read_parse_plan_trees)
856 foreach(lc, querytree_list)
860 Query *new_query = stringToNodeWithLocations(
str);
866 new_query->queryId = curr_query->queryId;
874 elog(
WARNING,
"outfuncs/readfuncs failed to produce an equal rewritten parse tree");
885 return querytree_list;
906 TRACE_POSTGRESQL_QUERY_PLAN_START();
917 #ifdef DEBUG_NODE_TESTS_ENABLED
920 if (Debug_copy_parse_plan_trees)
931 elog(
WARNING,
"copyObject() failed to produce an equal plan tree");
938 if (Debug_write_read_parse_plan_trees)
944 new_plan = stringToNodeWithLocations(
str);
954 elog(
WARNING,
"outfuncs/readfuncs failed to produce an equal plan tree");
968 TRACE_POSTGRESQL_QUERY_PLAN_DONE();
988 foreach(query_list, querytrees)
998 stmt->canSetTag = query->canSetTag;
1001 stmt->stmt_len = query->stmt_len;
1002 stmt->queryId = query->queryId;
1027 List *parsetree_list;
1030 bool was_logged =
false;
1031 bool use_implicit_block;
1041 TRACE_POSTGRESQL_QUERY_START(query_string);
1047 if (save_log_statement_stats)
1082 (
errmsg(
"statement: %s", query_string),
1101 use_implicit_block = (
list_length(parsetree_list) > 1);
1106 foreach(parsetree_item, parsetree_list)
1109 bool snapshot_set =
false;
1113 List *querytree_list,
1118 const char *cmdtagname;
1147 (
errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
1148 errmsg(
"current transaction is aborted, "
1149 "commands ignored until end of transaction block"),
1162 if (use_implicit_block)
1174 snapshot_set =
true;
1189 if (
lnext(parsetree_list, parsetree_item) != NULL)
1191 per_parsetree_context =
1193 "per-parsetree message context",
1296 if (
lnext(parsetree_list, parsetree_item) == NULL)
1307 if (use_implicit_block)
1351 if (per_parsetree_context)
1365 if (!parsetree_list)
1375 (
errmsg(
"duration: %s ms", msec_str),
1380 (
errmsg(
"duration: %s ms statement: %s",
1381 msec_str, query_string),
1387 if (save_log_statement_stats)
1390 TRACE_POSTGRESQL_QUERY_DONE(query_string);
1402 const char *stmt_name,
1408 List *parsetree_list;
1410 List *querytree_list;
1425 if (save_log_statement_stats)
1430 *stmt_name ? stmt_name :
"<unnamed>",
1454 is_named = (stmt_name[0] !=
'\0');
1465 unnamed_stmt_context =
1467 "unnamed prepared statement",
1485 (
errcode(ERRCODE_SYNTAX_ERROR),
1486 errmsg(
"cannot insert multiple commands into a prepared statement")));
1488 if (parsetree_list !=
NIL)
1490 bool snapshot_set =
false;
1505 (
errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
1506 errmsg(
"current transaction is aborted, "
1507 "commands ignored until end of transaction block"),
1523 snapshot_set =
true;
1544 raw_parse_tree = NULL;
1547 querytree_list =
NIL;
1556 if (unnamed_stmt_context)
1562 unnamed_stmt_context,
1611 (
errmsg(
"duration: %s ms", msec_str),
1616 (
errmsg(
"duration: %s ms parse %s: %s",
1618 *stmt_name ? stmt_name :
"<unnamed>",
1624 if (save_log_statement_stats)
1638 const char *portal_name;
1639 const char *stmt_name;
1641 int16 *pformats = NULL;
1644 int16 *rformats = NULL;
1649 char *saved_stmt_name;
1653 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")));
1694 if (save_log_statement_stats)
1710 if (numPFormats > 0)
1713 for (
int i = 0;
i < numPFormats;
i++)
1720 if (numPFormats > 1 && numPFormats != numParams)
1722 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
1723 errmsg(
"bind message has %d parameter formats but %d parameters",
1724 numPFormats, numParams)));
1728 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
1729 errmsg(
"bind message supplies %d parameters, but prepared statement \"%s\" requires %d",
1745 (
errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
1746 errmsg(
"current transaction is aborted, "
1747 "commands ignored until end of transaction block"),
1754 if (portal_name[0] ==
'\0')
1772 saved_stmt_name =
pstrdup(stmt_name);
1774 saved_stmt_name = NULL;
1783 if (numParams > 0 ||
1788 snapshot_set =
true;
1796 char **knownTextValues = NULL;
1808 params_errcxt.
arg = (
void *) &one_param_data;
1813 for (
int paramno = 0; paramno < numParams; paramno++)
1823 one_param_data.
paramno = paramno;
1827 isNull = (plength == -1);
1841 csave = pvalue[plength];
1842 pvalue[plength] =
'\0';
1851 if (numPFormats > 1)
1852 pformat = pformats[paramno];
1853 else if (numPFormats > 0)
1854 pformat = pformats[0];
1895 if (knownTextValues == NULL)
1899 knownTextValues[paramno] =
pstrdup(pstring);
1909 knownTextValues[paramno] =
1917 if (pstring != pbuf.
data)
1921 else if (pformat == 1)
1942 (
errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
1943 errmsg(
"incorrect binary data format in bind parameter %d",
1949 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1950 errmsg(
"unsupported format code: %d",
1957 pbuf.
data[plength] = csave;
1995 params_data.
params = params;
1998 params_errcxt.
arg = (
void *) ¶ms_data;
2003 if (numRFormats > 0)
2006 for (
int i = 0;
i < numRFormats;
i++)
2065 (
errmsg(
"duration: %s ms", msec_str),
2070 (
errmsg(
"duration: %s ms bind %s%s%s: %s",
2072 *stmt_name ? stmt_name :
"<unnamed>",
2073 *portal_name ?
"/" :
"",
2074 *portal_name ? portal_name :
"",
2081 if (save_log_statement_stats)
2102 const char *sourceText;
2103 const char *prepStmtName;
2106 bool is_xact_command;
2107 bool execute_is_fetch;
2108 bool was_logged =
false;
2112 const char *cmdtagname;
2123 (
errcode(ERRCODE_UNDEFINED_CURSOR),
2124 errmsg(
"portal \"%s\" does not exist", portal_name)));
2150 prepStmtName =
"<unnamed>";
2164 if (save_log_statement_stats)
2189 execute_is_fetch = !portal->
atStart;
2197 _(
"execute fetch from") :
2200 *portal_name ?
"/" :
"",
2201 *portal_name ? portal_name :
"",
2215 (
errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
2216 errmsg(
"current transaction is aborted, "
2217 "commands ignored until end of transaction block"),
2228 params_data.
params = portalParams;
2231 params_errcxt.
arg = (
void *) ¶ms_data;
2240 !execute_is_fetch && max_rows ==
FETCH_ALL,
2269 portalParams = NULL;
2315 (
errmsg(
"duration: %s ms", msec_str),
2320 (
errmsg(
"duration: %s ms %s %s%s%s: %s",
2323 _(
"execute fetch from") :
2326 *portal_name ?
"/" :
"",
2327 *portal_name ? portal_name :
"",
2334 if (save_log_statement_stats)
2335 ShowUsage(
"EXECUTE MESSAGE STATISTICS");
2360 foreach(stmt_item, stmt_list)
2397 bool exceeded_duration;
2398 bool exceeded_sample_duration;
2399 bool in_sample =
false;
2404 msecs = usecs / 1000;
2426 if (exceeded_sample_duration)
2434 secs * 1000 + msecs, usecs % 1000);
2435 if ((exceeded_duration || in_sample ||
xact_is_sampled) && !was_logged)
2456 foreach(parsetree_item, raw_parsetree_list)
2468 errdetail(
"prepare: %s", pstmt->plansource->query_string);
2492 if (
str &&
str[0] !=
'\0')
2508 errdetail(
"Abort reason: recovery conflict");
2524 errdetail(
"User was holding shared buffer pin for too long.");
2527 errdetail(
"User was holding a relation lock for too long.");
2530 errdetail(
"User was or might have been using tablespace that must be dropped.");
2533 errdetail(
"User query might have needed to see row versions that must be removed.");
2536 errdetail(
"User was using a logical replication slot that must be invalidated.");
2539 errdetail(
"User transaction caused buffer deadlock with recovery.");
2542 errdetail(
"User was connected to a database that must be dropped.");
2564 if (
data->paramno < 0)
2573 quotedval =
buf.data;
2578 if (
data->portalName &&
data->portalName[0] !=
'\0')
2581 errcontext(
"portal \"%s\" parameter $%d = %s",
2582 data->portalName,
data->paramno + 1, quotedval);
2585 data->portalName,
data->paramno + 1);
2590 errcontext(
"unnamed portal parameter $%d = %s",
2591 data->paramno + 1, quotedval);
2621 if (stmt_name[0] !=
'\0')
2634 (
errcode(ERRCODE_UNDEFINED_PSTATEMENT),
2635 errmsg(
"unnamed prepared statement does not exist")));
2653 (
errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
2654 errmsg(
"current transaction is aborted, "
2655 "commands ignored until end of transaction block"),
2716 (
errcode(ERRCODE_UNDEFINED_CURSOR),
2717 errmsg(
"portal \"%s\" does not exist", portal_name)));
2730 (
errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
2731 errmsg(
"current transaction is aborted, "
2732 "commands ignored until end of transaction block"),
2789 #ifdef MEMORY_CONTEXT_CHECKING
2795 #ifdef SHOW_MEMORY_STATS
2887 sigprocmask(SIG_SETMASK, &
BlockSig, NULL);
2936 (
errcode(ERRCODE_ADMIN_SHUTDOWN),
2937 errmsg(
"terminating connection because of unexpected SIGQUIT signal")));
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"
2948 errhint(
"In a moment you should be able to reconnect to the"
2949 " database and repeat your command.")));
2954 (
errcode(ERRCODE_ADMIN_SHUTDOWN),
2955 errmsg(
"terminating connection due to immediate shutdown command")));
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.")));
3178 errmsg(
"canceling statement due to conflict with recovery"),
3197 ERRCODE_DATABASE_DROPPED :
3199 errmsg(
"terminating connection due to conflict with recovery"),
3201 errhint(
"In a moment you should be able to reconnect to the"
3202 " database and repeat your command.")));
3206 elog(
FATAL,
"unrecognized conflict mode: %d", (
int) reason);
3270 (
errcode(ERRCODE_QUERY_CANCELED),
3271 errmsg(
"canceling authentication due to timeout")));
3274 (
errcode(ERRCODE_ADMIN_SHUTDOWN),
3275 errmsg(
"terminating autovacuum process due to administrator command")));
3278 (
errcode(ERRCODE_ADMIN_SHUTDOWN),
3279 errmsg(
"terminating logical replication worker due to administrator command")));
3293 (
errcode(ERRCODE_ADMIN_SHUTDOWN),
3294 errmsg(
"terminating background worker \"%s\" due to administrator command",
3298 (
errcode(ERRCODE_ADMIN_SHUTDOWN),
3299 errmsg(
"terminating connection due to administrator command")));
3329 (
errcode(ERRCODE_CONNECTION_FAILURE),
3330 errmsg(
"connection to client lost")));
3355 bool lock_timeout_occurred;
3356 bool stmt_timeout_occurred;
3373 if (lock_timeout_occurred && stmt_timeout_occurred &&
3375 lock_timeout_occurred =
false;
3377 if (lock_timeout_occurred)
3381 (
errcode(ERRCODE_LOCK_NOT_AVAILABLE),
3382 errmsg(
"canceling statement due to lock timeout")));
3384 if (stmt_timeout_occurred)
3388 (
errcode(ERRCODE_QUERY_CANCELED),
3389 errmsg(
"canceling statement due to statement timeout")));
3395 (
errcode(ERRCODE_QUERY_CANCELED),
3396 errmsg(
"canceling autovacuum task")));
3408 (
errcode(ERRCODE_QUERY_CANCELED),
3409 errmsg(
"canceling statement due to user request")));
3429 (
errcode(ERRCODE_IDLE_IN_TRANSACTION_SESSION_TIMEOUT),
3430 errmsg(
"terminating connection due to idle-in-transaction timeout")));
3442 (
errcode(ERRCODE_TRANSACTION_TIMEOUT),
3443 errmsg(
"terminating connection due to transaction timeout")));
3455 (
errcode(ERRCODE_IDLE_SESSION_TIMEOUT),
3456 errmsg(
"terminating connection due to idle-session timeout")));
3492 #ifndef HAVE__BUILTIN_FRAME_ADDRESS
3504 #ifdef HAVE__BUILTIN_FRAME_ADDRESS
3545 (
errcode(ERRCODE_STATEMENT_TOO_COMPLEX),
3546 errmsg(
"stack depth limit exceeded"),
3547 errhint(
"Increase the configuration parameter \"max_stack_depth\" (currently %dkB), "
3548 "after ensuring the platform's stack depth limit is adequate.",
3567 if (stack_depth < 0)
3568 stack_depth = -stack_depth;
3589 long newval_bytes = *
newval * 1024L;
3596 GUC_check_errhint(
"Increase the platform's stack depth limit via \"ulimit -s\" or local equivalent.");
3606 long newval_bytes =
newval * 1024L;
3619 GUC_check_errdetail(
"\"client_connection_check_interval\" must be set to 0 on this platform.");
3656 "\"log_parser_stats\", \"log_planner_stats\", "
3657 "or \"log_executor_stats\" is true.");
3703 foreach(l, elemlist)
3705 char *tok = (
char *)
lfirst(l);
3725 *((
int *) *extra) = flags;
3736 int *flags = (
int *) extra;
3754 sprintf(debugstr,
"debug%d", debug_flag);
3765 if (debug_flag >= 2)
3767 if (debug_flag >= 3)
3769 if (debug_flag >= 4)
3771 if (debug_flag >= 5)
3779 const char *tmp = NULL;
3784 tmp =
"enable_seqscan";
3787 tmp =
"enable_indexscan";
3790 tmp =
"enable_indexonlyscan";
3793 tmp =
"enable_bitmapscan";
3796 tmp =
"enable_tidscan";
3799 tmp =
"enable_nestloop";
3802 tmp =
"enable_mergejoin";
3805 tmp =
"enable_hashjoin";
3825 return "log_parser_stats";
3826 else if (
optarg[1] ==
'l')
3827 return "log_planner_stats";
3831 return "log_executor_stats";
3872 if (argc > 1 && strcmp(argv[1],
"--single") == 0)
3883 #ifdef HAVE_INT_OPTERR
3898 while ((
flag =
getopt(argc, argv,
"B:bC:c:D:d:EeFf:h:ijk:lN:nOPp:r:S:sTt:v:W:-:")) != -1)
3927 (
errcode(ERRCODE_SYNTAX_ERROR),
3928 errmsg(
"--%s requires a value",
3932 (
errcode(ERRCODE_SYNTAX_ERROR),
3933 errmsg(
"-c %s requires a value",
4071 if (errs || argc !=
optind)
4079 errcode(ERRCODE_SYNTAX_ERROR),
4080 errmsg(
"invalid command-line argument for server process: %s", argv[
optind]),
4084 errcode(ERRCODE_SYNTAX_ERROR),
4085 errmsg(
"%s: invalid command-line argument: %s",
4095 #ifdef HAVE_INT_OPTRESET
4114 const char *
dbname = NULL;
4137 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4138 errmsg(
"%s: no database nor user name specified",
4223 sigjmp_buf local_sigjmp_buf;
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;
4307 (
errcode(ERRCODE_INTERNAL_ERROR),
4308 errmsg(
"could not generate random cancel key")));
4375 printf(
"\nPostgreSQL stand-alone backend %s\n", PG_VERSION);
4394 "RowDescriptionContext",
4425 if (sigsetjmp(local_sigjmp_buf, 1) != 0)
4454 idle_in_transaction_timeout_enabled =
false;
4455 idle_session_timeout_enabled =
false;
4531 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
4532 errmsg(
"terminating connection because protocol synchronization was lost")));
4542 send_ready_for_query =
true;
4563 old_valgrind_error_count = VALGRIND_COUNT_ERRORS;
4597 if (send_ready_for_query)
4608 idle_in_transaction_timeout_enabled =
true;
4622 idle_in_transaction_timeout_enabled =
true;
4655 if (stats_timeout > 0)
4674 idle_session_timeout_enabled =
true;
4684 send_ready_for_query =
false;
4708 if (idle_in_transaction_timeout_enabled)
4711 idle_in_transaction_timeout_enabled =
false;
4713 if (idle_session_timeout_enabled)
4716 idle_session_timeout_enabled =
false;
4752 const char *query_string;
4770 send_ready_for_query =
true;
4776 const char *stmt_name;
4777 const char *query_string;
4779 Oid *paramTypes = NULL;
4792 for (
int i = 0;
i < numParams;
i++)
4798 paramTypes, numParams);
4821 const char *portal_name;
4871 send_ready_for_query =
true;
4877 const char *close_target;
4888 if (close_target[0] !=
'\0')
4907 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
4908 errmsg(
"invalid CLOSE message subtype %d",
4923 const char *describe_target;
4934 switch (describe_type)
4944 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
4945 errmsg(
"invalid DESCRIBE message subtype %d",
4964 send_ready_for_query =
true;
5010 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
5011 errmsg(
"invalid frontend message type %d",
5031 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
5032 errmsg(
"fastpath function calls not supported in a replication connection")));
5035 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
5036 errmsg(
"extended query protocol not supported in a replication connection")));
5049 #if defined(HAVE_GETRLIMIT)
5050 static long val = 0;
5057 if (getrlimit(RLIMIT_STACK, &rlim) < 0)
5059 else if (rlim.rlim_cur == RLIM_INFINITY)
5062 else if (rlim.rlim_cur >= LONG_MAX)
5065 val = rlim.rlim_cur;
5070 return WIN32_STACK_RLIMIT;
5076 static struct timeval
Save_t;
5089 struct timeval
user,
5091 struct timeval elapse_t;
5097 memcpy((
char *) &sys, (
char *) &r.
ru_stime,
sizeof(sys));
5098 if (elapse_t.tv_usec <
Save_t.tv_usec)
5101 elapse_t.tv_usec += 1000000;
5122 "!\t%ld.%06ld s user, %ld.%06ld s system, %ld.%06ld s elapsed\n",
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",
5132 (
long)
user.tv_usec,
5134 (
long) sys.tv_usec);
5144 "!\t%ld kB max resident size\n",
5154 "!\t%ld/%ld [%ld/%ld] filesystem blocks in/out\n",
5155 r.ru_inblock -
Save_r.ru_inblock,
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,
5167 "!\t%ld [%ld] signals rcvd, %ld/%ld [%ld/%ld] messages rcvd/sent\n",
5168 r.ru_nsignals -
Save_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);
5181 if (
str.data[
str.len - 1] ==
'\n')
5182 str.data[--
str.len] =
'\0';
5208 msecs = usecs / 1000;
5216 (
errmsg(
"disconnection: session time: %d:%02d:%02d.%03d "
5217 "user=%s database=%s host=%s%s%s",
5218 hours, minutes, seconds, msecs,
5219 port->user_name,
port->database_name,
port->remote_host,
5220 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)
void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
void getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typIOParam)
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)
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)
static int interactive_getc(void)
bool stack_is_too_deep(void)
static int errdetail_params(ParamListInfo params)
static void ProcessRecoveryConflictInterrupts(void)
static int SocketBackend(StringInfo inBuf)
void ProcessClientReadInterrupt(bool blocked)
void assign_max_stack_depth(int newval, void *extra)
void ProcessInterrupts(void)
static void bind_param_error_callback(void *arg)
static bool IsTransactionExitStmt(Node *parsetree)
PlannedStmt * pg_plan_query(Query *querytree, const char *query_string, int cursorOptions, ParamListInfo boundParams)
void PostgresMain(const char *dbname, const char *username)
static MemoryContext row_description_context
static int InteractiveBackend(StringInfo inBuf)
static void ProcessRecoveryConflictInterrupt(ProcSignalReason reason)
static char * stack_base_ptr
static struct rusage Save_r
bool check_client_connection_check_interval(int *newval, void **extra, GucSource source)
static StringInfoData row_description_buf
void ProcessClientWriteInterrupt(bool blocked)
static bool doing_extended_query_message
static void start_xact_command(void)
List * pg_plan_queries(List *querytrees, const char *query_string, int cursorOptions, ParamListInfo boundParams)
bool check_restrict_nonsystem_relation_kind(char **newval, void **extra, GucSource source)
static void exec_describe_portal_message(const char *portal_name)
void check_stack_depth(void)
pg_stack_base_t set_stack_base(void)
static void drop_unnamed_stmt(void)