27 #ifdef HAVE_SYS_SELECT_H
28 #include <sys/select.h>
30 #ifdef HAVE_SYS_RESOURCE_H
32 #include <sys/resource.h>
35 #ifndef HAVE_GETRUSAGE
120 #if defined(__ia64__) || defined(__ia64)
121 char *register_stack_base_ptr =
NULL;
167 #ifndef TCOP_DONTUSENEWLINE
223 bool backslashSeen =
false;
246 inBuf->
data[--inBuf->
len] =
'\0';
247 backslashSeen =
false;
258 backslashSeen =
true;
260 backslashSeen =
false;
295 printf(
"statement: %s\n", inBuf->
data);
351 (
errcode(ERRCODE_CONNECTION_FAILURE),
352 errmsg(
"unexpected EOF on client connection with an open transaction")));
362 (
errcode(ERRCODE_CONNECTION_DOES_NOT_EXIST),
363 errmsg(
"unexpected EOF on client connection")));
387 (
errcode(ERRCODE_CONNECTION_FAILURE),
388 errmsg(
"unexpected EOF on client connection with an open transaction")));
398 (
errcode(ERRCODE_CONNECTION_DOES_NOT_EXIST),
399 errmsg(
"unexpected EOF on client connection")));
414 (
errcode(ERRCODE_CONNECTION_FAILURE),
415 errmsg(
"unexpected EOF on client connection with an open transaction")));
425 (
errcode(ERRCODE_CONNECTION_DOES_NOT_EXIST),
426 errmsg(
"unexpected EOF on client connection")));
448 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
449 errmsg(
"invalid frontend message type %d", qtype)));
460 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
461 errmsg(
"invalid frontend message type %d", qtype)));
471 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
472 errmsg(
"invalid frontend message type %d", qtype)));
483 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
484 errmsg(
"invalid frontend message type %d", qtype)));
535 int save_errno = errno;
573 int save_errno = errno;
615 List *raw_parsetree_list;
617 TRACE_POSTGRESQL_QUERY_PARSE_START(query_string);
622 raw_parsetree_list =
raw_parser(query_string);
627 #ifdef COPY_PARSE_PLAN_TREES
633 if (!
equal(new_list, raw_parsetree_list))
634 elog(
WARNING,
"copyObject() failed to produce an equal raw parse tree");
640 TRACE_POSTGRESQL_QUERY_PARSE_DONE(query_string);
642 return raw_parsetree_list;
656 Oid *paramTypes,
int numParams)
659 List *querytree_list;
661 TRACE_POSTGRESQL_QUERY_REWRITE_START(query_string);
669 query =
parse_analyze(parsetree, query_string, paramTypes, numParams);
679 TRACE_POSTGRESQL_QUERY_REWRITE_DONE(query_string);
681 return querytree_list;
691 const char *query_string,
693 void *parserSetupArg)
697 List *querytree_list;
701 TRACE_POSTGRESQL_QUERY_REWRITE_START(query_string);
711 (*parserSetup) (pstate, parserSetupArg);
716 (*post_parse_analyze_hook) (pstate, query);
728 TRACE_POSTGRESQL_QUERY_REWRITE_DONE(query_string);
730 return querytree_list;
742 List *querytree_list;
765 #ifdef COPY_PARSE_PLAN_TREES
772 if (!
equal(new_list, querytree_list))
773 elog(
WARNING,
"copyObject() failed to produce equal parse tree");
783 return querytree_list;
803 TRACE_POSTGRESQL_QUERY_PLAN_START();
809 plan =
planner(querytree, cursorOptions, boundParams);
814 #ifdef COPY_PARSE_PLAN_TREES
825 if (!
equal(new_plan, plan))
826 elog(
WARNING,
"copyObject() failed to produce an equal plan tree");
839 TRACE_POSTGRESQL_QUERY_PLAN_DONE();
856 foreach(query_list, querytrees)
871 stmt_list =
lappend(stmt_list, stmt);
888 List *parsetree_list;
891 bool was_logged =
false;
903 TRACE_POSTGRESQL_QUERY_START(query_string);
909 if (save_log_statement_stats)
944 (
errmsg(
"statement: %s", query_string),
967 foreach(parsetree_item, parsetree_list)
970 bool snapshot_set =
false;
971 const char *commandTag;
973 List *querytree_list,
1002 (
errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
1003 errmsg(
"current transaction is aborted, "
1004 "commands ignored until end of transaction block"),
1019 snapshot_set =
true;
1164 if (!parsetree_list)
1174 (
errmsg(
"duration: %s ms", msec_str),
1179 (
errmsg(
"duration: %s ms statement: %s",
1180 msec_str, query_string),
1186 if (save_log_statement_stats)
1189 TRACE_POSTGRESQL_QUERY_DONE(query_string);
1201 const char *stmt_name,
1207 List *parsetree_list;
1208 Node *raw_parse_tree;
1209 const char *commandTag;
1210 List *querytree_list;
1225 if (save_log_statement_stats)
1230 *stmt_name ? stmt_name :
"<unnamed>",
1253 is_named = (stmt_name[0] !=
'\0');
1264 unnamed_stmt_context =
1266 "unnamed prepared statement",
1286 (
errcode(ERRCODE_SYNTAX_ERROR),
1287 errmsg(
"cannot insert multiple commands into a prepared statement")));
1289 if (parsetree_list !=
NIL)
1292 bool snapshot_set =
false;
1313 (
errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
1314 errmsg(
"current transaction is aborted, "
1315 "commands ignored until end of transaction block"),
1330 snapshot_set =
true;
1349 for (i = 0; i < numParams; i++)
1351 Oid ptype = paramTypes[
i];
1355 (
errcode(ERRCODE_INDETERMINATE_DATATYPE),
1356 errmsg(
"could not determine data type of parameter $%d",
1372 raw_parse_tree =
NULL;
1375 querytree_list =
NIL;
1384 if (unnamed_stmt_context)
1390 unnamed_stmt_context,
1414 unnamed_stmt_psrc = psrc;
1439 (
errmsg(
"duration: %s ms", msec_str),
1444 (
errmsg(
"duration: %s ms parse %s: %s",
1446 *stmt_name ? stmt_name :
"<unnamed>",
1452 if (save_log_statement_stats)
1466 const char *portal_name;
1467 const char *stmt_name;
1477 char *saved_stmt_name;
1481 bool snapshot_set =
false;
1490 *portal_name ? portal_name :
"<unnamed>",
1491 *stmt_name ? stmt_name :
"<unnamed>")));
1494 if (stmt_name[0] !=
'\0')
1507 (
errcode(ERRCODE_UNDEFINED_PSTATEMENT),
1508 errmsg(
"unnamed prepared statement does not exist")));
1520 if (save_log_statement_stats)
1535 if (numPFormats > 0)
1540 for (i = 0; i < numPFormats; i++)
1547 if (numPFormats > 1 && numPFormats != numParams)
1549 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
1550 errmsg(
"bind message has %d parameter formats but %d parameters",
1551 numPFormats, numParams)));
1555 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
1556 errmsg(
"bind message supplies %d parameters, but prepared statement \"%s\" requires %d",
1571 (
errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
1572 errmsg(
"current transaction is aborted, "
1573 "commands ignored until end of transaction block"),
1580 if (portal_name[0] ==
'\0')
1598 saved_stmt_name =
pstrdup(stmt_name);
1600 saved_stmt_name =
NULL;
1609 if (numParams > 0 ||
1614 snapshot_set =
true;
1633 for (paramno = 0; paramno < numParams; paramno++)
1644 isNull = (plength == -1);
1658 pbuf.
data = (
char *) pvalue;
1659 pbuf.
maxlen = plength + 1;
1663 csave = pbuf.
data[plength];
1664 pbuf.
data[plength] =
'\0';
1672 if (numPFormats > 1)
1673 pformat = pformats[paramno];
1674 else if (numPFormats > 0)
1675 pformat = pformats[0];
1699 if (pstring && pstring != pbuf.
data)
1702 else if (pformat == 1)
1723 (
errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
1724 errmsg(
"incorrect binary data format in bind parameter %d",
1730 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1731 errmsg(
"unsupported format code: %d",
1738 pbuf.
data[plength] = csave;
1759 if (numRFormats > 0)
1764 for (i = 0; i < numRFormats; i++)
1817 (
errmsg(
"duration: %s ms", msec_str),
1822 (
errmsg(
"duration: %s ms bind %s%s%s: %s",
1824 *stmt_name ? stmt_name :
"<unnamed>",
1825 *portal_name ?
"/" :
"",
1826 *portal_name ? portal_name :
"",
1833 if (save_log_statement_stats)
1852 const char *sourceText;
1853 const char *prepStmtName;
1856 bool is_xact_command;
1857 bool execute_is_fetch;
1858 bool was_logged =
false;
1869 (
errcode(ERRCODE_UNDEFINED_CURSOR),
1870 errmsg(
"portal \"%s\" does not exist", portal_name)));
1891 if (is_xact_command)
1897 prepStmtName =
"<unnamed>";
1903 portalParams =
NULL;
1911 prepStmtName =
"<unnamed>";
1924 if (save_log_statement_stats)
1949 execute_is_fetch = !portal->
atStart;
1957 _(
"execute fetch from") :
1960 *portal_name ?
"/" :
"",
1961 *portal_name ? portal_name :
"",
1975 (
errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
1976 errmsg(
"current transaction is aborted, "
1977 "commands ignored until end of transaction block"),
2000 if (is_xact_command)
2034 (
errmsg(
"duration: %s ms", msec_str),
2039 (
errmsg(
"duration: %s ms %s %s%s%s: %s",
2042 _(
"execute fetch from") :
2045 *portal_name ?
"/" :
"",
2046 *portal_name ? portal_name :
"",
2053 if (save_log_statement_stats)
2054 ShowUsage(
"EXECUTE MESSAGE STATISTICS");
2077 foreach(stmt_item, stmt_list)
2116 msecs = usecs / 1000;
2131 secs * 1000 + msecs, usecs % 1000);
2132 if (exceeded && !was_logged)
2153 foreach(parsetree_item, raw_parsetree_list)
2194 for (paramno = 0; paramno < params->
numParams; paramno++)
2203 paramno > 0 ?
", " :
"",
2217 for (p = pstring; *p; p++)
2247 errdetail(
"abort reason: recovery conflict");
2263 errdetail(
"User was holding shared buffer pin for too long.");
2266 errdetail(
"User was holding a relation lock for too long.");
2269 errdetail(
"User was or might have been using tablespace that must be dropped.");
2272 errdetail(
"User query might have needed to see row versions that must be removed.");
2275 errdetail(
"User transaction caused buffer deadlock with recovery.");
2278 errdetail(
"User was connected to a database that must be dropped.");
2310 if (stmt_name[0] !=
'\0')
2323 (
errcode(ERRCODE_UNDEFINED_PSTATEMENT),
2324 errmsg(
"unnamed prepared statement does not exist")));
2342 (
errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
2343 errmsg(
"current transaction is aborted, "
2344 "commands ignored until end of transaction block"),
2403 (
errcode(ERRCODE_UNDEFINED_CURSOR),
2404 errmsg(
"portal \"%s\" does not exist", portal_name)));
2417 (
errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
2418 errmsg(
"current transaction is aborted, "
2419 "commands ignored until end of transaction block"),
2471 #ifdef MEMORY_CONTEXT_CHECKING
2477 #ifdef SHOW_MEMORY_STATS
2558 if (unnamed_stmt_psrc)
2562 unnamed_stmt_psrc =
NULL;
2606 (
errcode(ERRCODE_CRASH_SHUTDOWN),
2607 errmsg(
"terminating connection because of crash of another server process"),
2608 errdetail(
"The postmaster has commanded this server process to roll back"
2609 " the current transaction and exit, because another"
2610 " server process exited abnormally and possibly corrupted"
2612 errhint(
"In a moment you should be able to reconnect to the"
2613 " database and repeat your command.")));
2643 int save_errno = errno;
2674 int save_errno = errno;
2697 (
errcode(ERRCODE_FLOATING_POINT_EXCEPTION),
2698 errmsg(
"floating-point exception"),
2699 errdetail(
"An invalid floating-point operation was signaled. "
2700 "This probably means an out-of-range result or an "
2701 "invalid operation, such as division by zero.")));
2708 int save_errno = errno;
2725 int save_errno = errno;
2809 elog(
FATAL,
"unrecognized conflict mode: %d",
2862 (
errcode(ERRCODE_QUERY_CANCELED),
2863 errmsg(
"canceling authentication due to timeout")));
2866 (
errcode(ERRCODE_ADMIN_SHUTDOWN),
2867 errmsg(
"terminating autovacuum process due to administrator command")));
2872 (
errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
2873 errmsg(
"terminating connection due to conflict with recovery"),
2882 (
errcode(ERRCODE_DATABASE_DROPPED),
2883 errmsg(
"terminating connection due to conflict with recovery"),
2888 (
errcode(ERRCODE_ADMIN_SHUTDOWN),
2889 errmsg(
"terminating connection due to administrator command")));
2898 (
errcode(ERRCODE_CONNECTION_FAILURE),
2899 errmsg(
"connection to client lost")));
2915 (
errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
2916 errmsg(
"terminating connection due to conflict with recovery"),
2918 errhint(
"In a moment you should be able to reconnect to the"
2919 " database and repeat your command.")));
2951 (
errcode(ERRCODE_LOCK_NOT_AVAILABLE),
2952 errmsg(
"canceling statement due to lock timeout")));
2958 (
errcode(ERRCODE_QUERY_CANCELED),
2959 errmsg(
"canceling statement due to statement timeout")));
2965 (
errcode(ERRCODE_QUERY_CANCELED),
2966 errmsg(
"canceling autovacuum task")));
2974 (
errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
2975 errmsg(
"canceling statement due to conflict with recovery"),
2988 (
errcode(ERRCODE_QUERY_CANCELED),
2989 errmsg(
"canceling statement due to user request")));
3007 #if defined(__ia64__) || defined(__ia64)
3009 #if defined(__hpux) && !defined(__GNUC__) && !defined(__INTEL_COMPILER)
3011 #include <ia64/sys/inline.h>
3012 #define ia64_get_bsp() ((char *) (_Asm_mov_from_ar(_AREG_BSP, _NO_FENCE)))
3013 #elif defined(__INTEL_COMPILER)
3015 #include <asm/ia64regs.h>
3016 #define ia64_get_bsp() ((char *) __getReg(_IA64_REG_AR_BSP))
3019 static __inline__
char *
3025 __asm__ __volatile__(
3047 #if defined(__ia64__) || defined(__ia64)
3049 old.register_stack_base_ptr = register_stack_base_ptr;
3056 #if defined(__ia64__) || defined(__ia64)
3057 register_stack_base_ptr = ia64_get_bsp();
3075 #if defined(__ia64__) || defined(__ia64)
3077 register_stack_base_ptr = base.register_stack_base_ptr;
3105 if (stack_depth < 0)
3106 stack_depth = -stack_depth;
3120 (
errcode(ERRCODE_STATEMENT_TOO_COMPLEX),
3121 errmsg(
"stack depth limit exceeded"),
3122 errhint(
"Increase the configuration parameter \"max_stack_depth\" (currently %dkB), "
3123 "after ensuring the platform's stack depth limit is adequate.",
3135 #if defined(__ia64__) || defined(__ia64)
3136 stack_depth = (long) (ia64_get_bsp() - register_stack_base_ptr);
3139 register_stack_base_ptr !=
NULL)
3142 (
errcode(ERRCODE_STATEMENT_TOO_COMPLEX),
3143 errmsg(
"stack depth limit exceeded"),
3144 errhint(
"Increase the configuration parameter \"max_stack_depth\" (currently %dkB), "
3145 "after ensuring the platform's stack depth limit is adequate.",
3155 long newval_bytes = *newval * 1024L;
3162 GUC_check_errhint(
"Increase the platform's stack depth limit via \"ulimit -s\" or local equivalent.");
3172 long newval_bytes = newval * 1024L;
3191 sprintf(debugstr,
"debug%d", debug_flag);
3202 if (debug_flag >= 2)
3204 if (debug_flag >= 3)
3206 if (debug_flag >= 4)
3208 if (debug_flag >= 5)
3216 const char *tmp =
NULL;
3221 tmp =
"enable_seqscan";
3224 tmp =
"enable_indexscan";
3227 tmp =
"enable_indexonlyscan";
3230 tmp =
"enable_bitmapscan";
3233 tmp =
"enable_tidscan";
3236 tmp =
"enable_nestloop";
3239 tmp =
"enable_mergejoin";
3242 tmp =
"enable_hashjoin";
3262 return "log_parser_stats";
3263 else if (
optarg[1] ==
'l')
3264 return "log_planner_stats";
3268 return "log_executor_stats";
3309 if (argc > 1 && strcmp(argv[1],
"--single") == 0)
3320 #ifdef HAVE_INT_OPTERR
3335 while ((flag =
getopt(argc, argv,
"B:bc:C:D:d:EeFf:h:ijk:lN:nOo:Pp:r:S:sTt:v:W:-:")) != -1)
3482 (
errcode(ERRCODE_SYNTAX_ERROR),
3483 errmsg(
"--%s requires a value",
3487 (
errcode(ERRCODE_SYNTAX_ERROR),
3488 errmsg(
"-c %s requires a value",
3510 if (!errs && dbname && *dbname ==
NULL && argc -
optind >= 1)
3511 *dbname = strdup(argv[
optind++]);
3513 if (errs || argc !=
optind)
3521 (
errcode(ERRCODE_SYNTAX_ERROR),
3522 errmsg(
"invalid command-line argument for server process: %s", argv[
optind]),
3526 (
errcode(ERRCODE_SYNTAX_ERROR),
3527 errmsg(
"%s: invalid command-line argument: %s",
3537 #ifdef HAVE_INT_OPTRESET
3561 sigjmp_buf local_sigjmp_buf;
3562 volatile bool send_ready_for_query =
true;
3587 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3588 errmsg(
"%s: no database nor user name specified",
3766 printf(
"\nPostgreSQL stand-alone backend %s\n", PG_VERSION);
3808 if (sigsetjmp(local_sigjmp_buf, 1) != 0)
3899 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
3900 errmsg(
"terminating connection because protocol sync was lost")));
3910 send_ready_for_query =
true;
3946 if (send_ready_for_query)
3968 send_ready_for_query =
false;
4017 const char *query_string;
4030 send_ready_for_query =
true;
4036 const char *stmt_name;
4037 const char *query_string;
4054 for (i = 0; i < numParams; i++)
4060 paramTypes, numParams);
4079 const char *portal_name;
4137 send_ready_for_query =
true;
4143 const char *close_target;
4154 if (close_target[0] !=
'\0')
4173 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
4174 errmsg(
"invalid CLOSE message subtype %d",
4187 const char *describe_target;
4198 switch (describe_type)
4208 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
4209 errmsg(
"invalid DESCRIBE message subtype %d",
4225 send_ready_for_query =
true;
4265 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
4266 errmsg(
"invalid frontend message type %d",
4284 if (firstchar ==
'F')
4286 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
4287 errmsg(
"fastpath function calls not supported in a replication connection")));
4290 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
4291 errmsg(
"extended query protocol not supported in a replication connection")));
4304 #if defined(HAVE_GETRLIMIT) && defined(RLIMIT_STACK)
4305 static long val = 0;
4312 if (getrlimit(RLIMIT_STACK, &rlim) < 0)
4314 else if (rlim.rlim_cur == RLIM_INFINITY)
4317 else if (rlim.rlim_cur >= LONG_MAX)
4320 val = rlim.rlim_cur;
4324 #if defined(WIN32) || defined(__CYGWIN__)
4326 return WIN32_STACK_RLIMIT;
4348 struct timeval user,
4350 struct timeval elapse_t;
4355 memcpy((
char *) &user, (
char *) &r.
ru_utime,
sizeof(user));
4356 memcpy((
char *) &sys, (
char *) &r.
ru_stime,
sizeof(sys));
4357 if (elapse_t.tv_usec <
Save_t.tv_usec)
4360 elapse_t.tv_usec += 1000000;
4384 "!\t%ld.%06ld elapsed %ld.%06ld user %ld.%06ld system sec\n",
4385 (
long) (elapse_t.tv_sec -
Save_t.tv_sec),
4386 (
long) (elapse_t.tv_usec -
Save_t.tv_usec),
4392 "!\t[%ld.%06ld user %ld.%06ld sys total]\n",
4394 (
long) user.tv_usec,
4396 (
long) sys.tv_usec);
4397 #if defined(HAVE_GETRUSAGE)
4399 "!\t%ld/%ld [%ld/%ld] filesystem blocks in/out\n",
4400 r.ru_inblock -
Save_r.ru_inblock,
4402 r.ru_oublock -
Save_r.ru_oublock,
4403 r.ru_inblock, r.ru_oublock);
4405 "!\t%ld/%ld [%ld/%ld] page faults/reclaims, %ld [%ld] swaps\n",
4406 r.ru_majflt -
Save_r.ru_majflt,
4407 r.ru_minflt -
Save_r.ru_minflt,
4408 r.ru_majflt, r.ru_minflt,
4409 r.ru_nswap -
Save_r.ru_nswap,
4412 "!\t%ld [%ld] signals rcvd, %ld/%ld [%ld/%ld] messages rcvd/sent\n",
4413 r.ru_nsignals -
Save_r.ru_nsignals,
4415 r.ru_msgrcv -
Save_r.ru_msgrcv,
4416 r.ru_msgsnd -
Save_r.ru_msgsnd,
4417 r.ru_msgrcv, r.ru_msgsnd);
4419 "!\t%ld/%ld [%ld/%ld] voluntary/involuntary context switches\n",
4420 r.ru_nvcsw -
Save_r.ru_nvcsw,
4421 r.ru_nivcsw -
Save_r.ru_nivcsw,
4422 r.ru_nvcsw, r.ru_nivcsw);
4426 if (str.
data[str.
len - 1] ==
'\n')
4453 msecs = usecs / 1000;
4461 (
errmsg(
"disconnection: session time: %d:%02d:%02d.%03d "
4462 "user=%s database=%s host=%s%s%s",
4463 hours, minutes, seconds, msecs,
pg_stack_base_t set_stack_base(void)
void ProcessCatchupInterrupt(void)
void InitializeTimeouts(void)
ParamExternData params[FLEXIBLE_ARRAY_MEMBER]
int log_min_duration_statement
void AbortCurrentTransaction(void)
volatile uint32 InterruptHoldoffCount
void SetRemoteDestReceiverParams(DestReceiver *self, Portal portal)
Portal CreatePortal(const char *name, bool allowDup, bool dupSilent)
static void exec_describe_portal_message(const char *portal_name)
void(* rDestroy)(DestReceiver *self)
#define IsA(nodeptr, _type_)
int gettimeofday(struct timeval *tp, struct timezone *tzp)
void MemoryContextDelete(MemoryContext context)
bool IsWaitingForLock(void)
void RecoveryConflictInterrupt(ProcSignalReason reason)
#define HOLD_CANCEL_INTERRUPTS()
List * QueryRewrite(Query *parsetree)
void BeginReportingGUCOptions(void)
int errhint(const char *fmt,...)
void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena)
void PortalSetResultFormat(Portal portal, int nFormats, int16 *formats)
int GetOldFunctionMessage(StringInfo buf)
List * raw_parser(const char *str)
static int ReadCommand(StringInfo inBuf)
void PortalStart(Portal portal, ParamListInfo params, int eflags, Snapshot snapshot)
void pgstat_report_recovery_conflict(int reason)
static void finish_xact_command(void)
void elog_node_display(int lev, const char *title, const void *obj, bool pretty)
void ProcessConfigFile(GucContext context)
bool equal(const void *a, const void *b)
void PortalDefineQuery(Portal portal, const char *prepStmtName, const char *sourceText, const char *commandTag, List *stmts, CachedPlan *cplan)
static volatile sig_atomic_t got_SIGHUP
TimestampTz GetCurrentTimestamp(void)
#define GUC_check_errdetail
void on_proc_exit(pg_on_exit_callback function, Datum arg)
void pgstat_report_activity(BackendState state, const char *cmd_str)
CachedPlanSource * plansource
void ShowUsage(const char *title)
void MemoryContextSetParent(MemoryContext context, MemoryContext new_parent)
Portal GetPortalByName(const char *name)
#define CURSOR_OPT_BINARY
char * pstrdup(const char *in)
void CommitTransactionCommand(void)
void InitStandaloneProcess(const char *argv0)
void ParseLongOption(const char *string, char **name, char **value)
void ValidatePgVersion(const char *path)
bool IsAbortedTransactionBlockState(void)
bool set_plan_disabling_options(const char *arg, GucContext context, GucSource source)
static struct rusage Save_r
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
volatile uint32 QueryCancelHoldoffCount
void set_ps_display(const char *activity, bool force)
static bool IsTransactionStmtList(List *parseTrees)
List * pg_analyze_and_rewrite_params(Node *parsetree, const char *query_string, ParserSetupHook parserSetup, void *parserSetupArg)
static void forbidden_in_wal_sender(char firstchar)
int errcode(int sqlerrcode)
int errhidestmt(bool hide_stmt)
bool IsTransactionOrTransactionBlock(void)
const char * get_stats_option_name(const char *arg)
static List * new_list(NodeTag type)
#define SetProcessingMode(mode)
static int errdetail_abort(void)
int snprintf(char *str, size_t count, const char *fmt,...) pg_attribute_printf(3
void PopActiveSnapshot(void)
void set_debug_options(int debug_flag, GucContext context, GucSource source)
void BeginCommand(const char *commandTag, CommandDest dest)
ParserSetupHook parserSetup
struct ParamListInfoData * ParamListInfo
int getrusage(int who, struct rusage *rusage)
#define PG_PROTOCOL_MAJOR(v)
volatile bool QueryCancelPending
void restore_stack_base(pg_stack_base_t base)
Snapshot GetTransactionSnapshot(void)
#define OidIsValid(objectId)
void SendRowDescriptionMessage(TupleDesc typeinfo, List *targetlist, int16 *formats)
List * pg_analyze_and_rewrite(Node *parsetree, const char *query_string, Oid *paramTypes, int numParams)
PlannedStmt * planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
int getopt(int nargc, char *const *nargv, const char *ostr)
void FlushErrorState(void)
void StatementCancelHandler(SIGNAL_ARGS)
#define ALLOCSET_DEFAULT_MINSIZE
static void exec_execute_message(const char *portal_name, long max_rows)
int errdetail_internal(const char *fmt,...)
static bool IsTransactionExitStmt(Node *parsetree)
static void log_disconnections(int code, Datum arg)
ParseState * make_parsestate(ParseState *parentParseState)
void * copyObject(const void *from)
#define RESUME_INTERRUPTS()
ErrorContextCallback * error_context_stack
int check_log_duration(char *msec_str, bool was_logged)
volatile bool ClientConnectionLost
static int errdetail_execute(List *raw_parsetree_list)
bool ClientAuthInProgress
bool check_max_stack_depth(int *newval, void **extra, GucSource source)
#define appendStringInfoCharMacro(str, ch)
ParamFetchHook paramFetch
void pfree(void *pointer)
ParamListInfo portalParams
char * pg_client_to_server(const char *s, int len)
void disable_all_timeouts(bool keep_indicators)
void appendStringInfo(StringInfo str, const char *fmt,...)
void EndCommand(const char *commandTag, CommandDest dest)
void CreateDataDirLockFile(bool amPostmaster)
void pq_startmsgread(void)
void ProcessNotifyInterrupt(void)
static int InteractiveBackend(StringInfo inBuf)
bool pq_is_reading_msg(void)
CachedPlan * GetCachedPlan(CachedPlanSource *plansource, ParamListInfo boundParams, bool useResOwner)
static int interactive_getc(void)
void ProcessInterrupts(void)
List * pg_parse_query(const char *query_string)
void MemoryContextStats(MemoryContext context)
static void SigHupHandler(SIGNAL_ARGS)
TimestampTz SessionStartTime
Datum OidReceiveFunctionCall(Oid functionId, StringInfo buf, Oid typioparam, int32 typmod)
void PostgresMain(int argc, char *argv[], const char *dbname, const char *username)
void HandleParallelMessages(void)
void appendStringInfoString(StringInfo str, const char *s)
char OutputFileName[MAXPGPATH]
void SetConfigOption(const char *name, const char *value, GucContext context, GucSource source)
bool analyze_requires_snapshot(Node *parseTree)
static struct timeval Save_t
void PushActiveSnapshot(Snapshot snap)
bool recoveryConflictPending
void check_stack_depth(void)
static CachedPlanSource * unnamed_stmt_psrc
DestReceiver * CreateDestReceiver(CommandDest dest)
static void exec_bind_message(StringInfo input_message)
int errdetail(const char *fmt,...)
void ChangeToDataDir(void)
void resetStringInfo(StringInfo str)
void ReplicationSlotRelease(void)
void(* ParserSetupHook)(struct ParseState *pstate, void *arg)
bool ActiveSnapshotSet(void)
static int SocketBackend(StringInfo inBuf)
const char * p_sourcetext
volatile uint32 CritSectionCount
static int errdetail_params(ParamListInfo params)
Query * parse_analyze(Node *parseTree, const char *sourceText, Oid *paramTypes, int numParams)
void getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typIOParam)
bool IsAutoVacuumWorkerProcess(void)
void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
#define ereport(elevel, rest)
void exec_replication_command(const char *cmd_string)
void LockErrorCleanup(void)
MemoryContext TopMemoryContext
const char * CreateCommandTag(Node *parsetree)
void SetLatch(volatile Latch *latch)
static ProcSignalReason RecoveryConflictReason
long get_stack_depth_rlimit(void)
struct ParamExternData ParamExternData
List * lappend(List *list, void *datum)
static bool RecoveryConflictPending
void appendStringInfoChar(StringInfo str, char ch)
void initStringInfo(StringInfo str)
const char * debug_query_string
int pq_getmessage(StringInfo s, int maxlen)
static List * pg_rewrite_query(Query *query)
#define MemoryContextResetAndDeleteChildren(ctx)
static bool check_log_statement(List *stmt_list)
static void exec_parse_message(const char *query_string, const char *stmt_name, Oid *paramTypes, int numParams)
static bool RecoveryConflictRetryable
static void start_xact_command(void)
static bool IsTransactionExitStmtList(List *parseTrees)
static bool doing_extended_query_message
void process_session_preload_libraries(void)
void WalSndErrorCleanup(void)
MemoryContext AllocSetContextCreate(MemoryContext parent, const char *name, Size minContextSize, Size initBlockSize, Size maxBlockSize)
void CommandCounterIncrement(void)
bool SelectConfigFiles(const char *userDoption, const char *progname)
void ProcessClientReadInterrupt(bool blocked)
bool get_timeout_indicator(TimeoutId id, bool reset_indicator)
static int errdetail_recovery_conflict(void)
void EmitErrorReport(void)
Query * transformTopLevelStmt(ParseState *pstate, Node *parseTree)
void StorePreparedStatement(const char *stmt_name, CachedPlanSource *plansource, bool from_sql)
void SaveCachedPlan(CachedPlanSource *plansource)
pqsigfunc pqsignal(int signum, pqsigfunc handler)
volatile bool InterruptPending
size_t strlcpy(char *dst, const char *src, size_t siz)
int errmsg_internal(const char *fmt,...)
void enable_timeout_after(TimeoutId id, int delay_ms)
ReplicationSlot * MyReplicationSlot
static long max_stack_depth_bytes
#define COMPLETION_TAG_BUFSIZE
Query * parse_analyze_varparams(Node *parseTree, const char *sourceText, Oid **paramTypes, int *numParams)
bool PortalRun(Portal portal, long count, bool isTopLevel, DestReceiver *dest, DestReceiver *altdest, char *completionTag)
#define Assert(condition)
void ProcessCompletedNotifies(void)
bool proc_exit_inprogress
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)
bool HoldingBufferPinThatDelaysRecovery(void)
void StartTransactionCommand(void)
static bool DoingCommandRead
const char * query_string
void InitializeMaxBackends(void)
bool ParallelMessagePending
static int list_length(const List *l)
#define PortalGetHeapMemory(portal)
List * CachedPlanGetTargetList(CachedPlanSource *plansource)
bool IsTransactionState(void)
MemoryContext MessageContext
Datum querytree(PG_FUNCTION_ARGS)
sigjmp_buf * PG_exception_stack
static const char * userDoption
bool IsSubTransaction(void)
volatile bool ProcDiePending
#define CURSOR_OPT_PARALLEL_OK
void SetCurrentStatementStartTimestamp(void)
void InitPostgres(const char *in_dbname, Oid dboid, const char *username, Oid useroid, char *out_dbname)
char * OidOutputFunctionCall(Oid functionId, Datum val)
#define GUC_check_errhint
int errmsg(const char *fmt,...)
void PortalDrop(Portal portal, bool isTopCommit)
void ReadyForQuery(CommandDest dest)
#define HOLD_INTERRUPTS()
#define ALLOCSET_DEFAULT_INITSIZE
void FloatExceptionHandler(SIGNAL_ARGS)
static void drop_unnamed_stmt(void)
int pq_getstring(StringInfo s)
void DropCachedPlan(CachedPlanSource *plansource)
volatile sig_atomic_t notifyInterruptPending
#define ALLOCSET_DEFAULT_MAXSIZE
bool Debug_print_rewritten
volatile sig_atomic_t catchupInterruptPending
#define CHECK_FOR_INTERRUPTS()
void process_postgres_switches(int argc, char *argv[], GucContext ctx, const char **dbname)
void disable_timeout(TimeoutId id, bool keep_indicator)
void procsignal_sigusr1_handler(SIGNAL_ARGS)
CommandDest whereToSendOutput
List * FetchPortalTargetList(Portal portal)
void TimestampDifference(TimestampTz start_time, TimestampTz stop_time, long *secs, int *microsecs)
void free_parsestate(ParseState *pstate)
static bool ignore_till_sync
void assign_max_stack_depth(int newval, void *extra)
PreparedStatement * FetchPreparedStatement(const char *stmt_name, bool throwError)
CachedPlanSource * CreateCachedPlan(Node *raw_parse_tree, const char *query_string, const char *commandTag)
Datum OidInputFunctionCall(Oid functionId, char *str, Oid typioparam, int32 typmod)
List * pg_plan_queries(List *querytrees, int cursorOptions, ParamListInfo boundParams)
void quickdie(SIGNAL_ARGS)
ProtocolVersion FrontendProtocol
MemoryContext PostmasterContext
post_parse_analyze_hook_type post_parse_analyze_hook
#define offsetof(type, field)
static void exec_simple_query(const char *query_string)
const char * prepStmtName
LogStmtLevel GetCommandLogLevel(Node *parsetree)
int HandleFunctionRequest(StringInfo msgBuf)
void NullCommand(CommandDest dest)
TimestampTz GetCurrentStatementStartTimestamp(void)
void InitializeGUCOptions(void)
#define RESUME_CANCEL_INTERRUPTS()
void ProcessClientWriteInterrupt(bool blocked)
void pgstat_report_stat(bool force)
void DropPreparedStatement(const char *stmt_name, bool showError)
static void exec_describe_statement_message(const char *stmt_name)
PlannedStmt * pg_plan_query(Query *querytree, int cursorOptions, ParamListInfo boundParams)