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;
1163 if (!parsetree_list)
1173 (
errmsg(
"duration: %s ms", msec_str),
1178 (
errmsg(
"duration: %s ms statement: %s",
1179 msec_str, query_string),
1185 if (save_log_statement_stats)
1188 TRACE_POSTGRESQL_QUERY_DONE(query_string);
1200 const char *stmt_name,
1206 List *parsetree_list;
1207 Node *raw_parse_tree;
1208 const char *commandTag;
1209 List *querytree_list;
1224 if (save_log_statement_stats)
1229 *stmt_name ? stmt_name :
"<unnamed>",
1252 is_named = (stmt_name[0] !=
'\0');
1263 unnamed_stmt_context =
1265 "unnamed prepared statement",
1285 (
errcode(ERRCODE_SYNTAX_ERROR),
1286 errmsg(
"cannot insert multiple commands into a prepared statement")));
1288 if (parsetree_list !=
NIL)
1291 bool snapshot_set =
false;
1312 (
errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
1313 errmsg(
"current transaction is aborted, "
1314 "commands ignored until end of transaction block"),
1329 snapshot_set =
true;
1348 for (i = 0; i < numParams; i++)
1350 Oid ptype = paramTypes[
i];
1354 (
errcode(ERRCODE_INDETERMINATE_DATATYPE),
1355 errmsg(
"could not determine data type of parameter $%d",
1371 raw_parse_tree =
NULL;
1374 querytree_list =
NIL;
1383 if (unnamed_stmt_context)
1389 unnamed_stmt_context,
1413 unnamed_stmt_psrc = psrc;
1438 (
errmsg(
"duration: %s ms", msec_str),
1443 (
errmsg(
"duration: %s ms parse %s: %s",
1445 *stmt_name ? stmt_name :
"<unnamed>",
1451 if (save_log_statement_stats)
1465 const char *portal_name;
1466 const char *stmt_name;
1476 char *saved_stmt_name;
1480 bool snapshot_set =
false;
1489 *portal_name ? portal_name :
"<unnamed>",
1490 *stmt_name ? stmt_name :
"<unnamed>")));
1493 if (stmt_name[0] !=
'\0')
1506 (
errcode(ERRCODE_UNDEFINED_PSTATEMENT),
1507 errmsg(
"unnamed prepared statement does not exist")));
1519 if (save_log_statement_stats)
1534 if (numPFormats > 0)
1539 for (i = 0; i < numPFormats; i++)
1546 if (numPFormats > 1 && numPFormats != numParams)
1548 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
1549 errmsg(
"bind message has %d parameter formats but %d parameters",
1550 numPFormats, numParams)));
1554 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
1555 errmsg(
"bind message supplies %d parameters, but prepared statement \"%s\" requires %d",
1570 (
errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
1571 errmsg(
"current transaction is aborted, "
1572 "commands ignored until end of transaction block"),
1579 if (portal_name[0] ==
'\0')
1597 saved_stmt_name =
pstrdup(stmt_name);
1599 saved_stmt_name =
NULL;
1608 if (numParams > 0 ||
1613 snapshot_set =
true;
1632 for (paramno = 0; paramno < numParams; paramno++)
1643 isNull = (plength == -1);
1657 pbuf.
data = (
char *) pvalue;
1658 pbuf.
maxlen = plength + 1;
1662 csave = pbuf.
data[plength];
1663 pbuf.
data[plength] =
'\0';
1671 if (numPFormats > 1)
1672 pformat = pformats[paramno];
1673 else if (numPFormats > 0)
1674 pformat = pformats[0];
1698 if (pstring && pstring != pbuf.
data)
1701 else if (pformat == 1)
1722 (
errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
1723 errmsg(
"incorrect binary data format in bind parameter %d",
1729 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1730 errmsg(
"unsupported format code: %d",
1737 pbuf.
data[plength] = csave;
1758 if (numRFormats > 0)
1763 for (i = 0; i < numRFormats; i++)
1816 (
errmsg(
"duration: %s ms", msec_str),
1821 (
errmsg(
"duration: %s ms bind %s%s%s: %s",
1823 *stmt_name ? stmt_name :
"<unnamed>",
1824 *portal_name ?
"/" :
"",
1825 *portal_name ? portal_name :
"",
1832 if (save_log_statement_stats)
1851 const char *sourceText;
1852 const char *prepStmtName;
1855 bool is_xact_command;
1856 bool execute_is_fetch;
1857 bool was_logged =
false;
1868 (
errcode(ERRCODE_UNDEFINED_CURSOR),
1869 errmsg(
"portal \"%s\" does not exist", portal_name)));
1890 if (is_xact_command)
1896 prepStmtName =
"<unnamed>";
1902 portalParams =
NULL;
1910 prepStmtName =
"<unnamed>";
1923 if (save_log_statement_stats)
1948 execute_is_fetch = !portal->
atStart;
1956 _(
"execute fetch from") :
1959 *portal_name ?
"/" :
"",
1960 *portal_name ? portal_name :
"",
1974 (
errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
1975 errmsg(
"current transaction is aborted, "
1976 "commands ignored until end of transaction block"),
1999 if (is_xact_command)
2033 (
errmsg(
"duration: %s ms", msec_str),
2038 (
errmsg(
"duration: %s ms %s %s%s%s: %s",
2041 _(
"execute fetch from") :
2044 *portal_name ?
"/" :
"",
2045 *portal_name ? portal_name :
"",
2052 if (save_log_statement_stats)
2053 ShowUsage(
"EXECUTE MESSAGE STATISTICS");
2076 foreach(stmt_item, stmt_list)
2115 msecs = usecs / 1000;
2130 secs * 1000 + msecs, usecs % 1000);
2131 if (exceeded && !was_logged)
2152 foreach(parsetree_item, raw_parsetree_list)
2193 for (paramno = 0; paramno < params->
numParams; paramno++)
2202 paramno > 0 ?
", " :
"",
2216 for (p = pstring; *p; p++)
2246 errdetail(
"abort reason: recovery conflict");
2262 errdetail(
"User was holding shared buffer pin for too long.");
2265 errdetail(
"User was holding a relation lock for too long.");
2268 errdetail(
"User was or might have been using tablespace that must be dropped.");
2271 errdetail(
"User query might have needed to see row versions that must be removed.");
2274 errdetail(
"User transaction caused buffer deadlock with recovery.");
2277 errdetail(
"User was connected to a database that must be dropped.");
2309 if (stmt_name[0] !=
'\0')
2322 (
errcode(ERRCODE_UNDEFINED_PSTATEMENT),
2323 errmsg(
"unnamed prepared statement does not exist")));
2341 (
errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
2342 errmsg(
"current transaction is aborted, "
2343 "commands ignored until end of transaction block"),
2402 (
errcode(ERRCODE_UNDEFINED_CURSOR),
2403 errmsg(
"portal \"%s\" does not exist", portal_name)));
2416 (
errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
2417 errmsg(
"current transaction is aborted, "
2418 "commands ignored until end of transaction block"),
2470 #ifdef MEMORY_CONTEXT_CHECKING
2476 #ifdef SHOW_MEMORY_STATS
2557 if (unnamed_stmt_psrc)
2561 unnamed_stmt_psrc =
NULL;
2605 (
errcode(ERRCODE_CRASH_SHUTDOWN),
2606 errmsg(
"terminating connection because of crash of another server process"),
2607 errdetail(
"The postmaster has commanded this server process to roll back"
2608 " the current transaction and exit, because another"
2609 " server process exited abnormally and possibly corrupted"
2611 errhint(
"In a moment you should be able to reconnect to the"
2612 " database and repeat your command.")));
2642 int save_errno = errno;
2673 int save_errno = errno;
2696 (
errcode(ERRCODE_FLOATING_POINT_EXCEPTION),
2697 errmsg(
"floating-point exception"),
2698 errdetail(
"An invalid floating-point operation was signaled. "
2699 "This probably means an out-of-range result or an "
2700 "invalid operation, such as division by zero.")));
2707 int save_errno = errno;
2724 int save_errno = errno;
2808 elog(
FATAL,
"unrecognized conflict mode: %d",
2861 (
errcode(ERRCODE_QUERY_CANCELED),
2862 errmsg(
"canceling authentication due to timeout")));
2865 (
errcode(ERRCODE_ADMIN_SHUTDOWN),
2866 errmsg(
"terminating autovacuum process due to administrator command")));
2871 (
errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
2872 errmsg(
"terminating connection due to conflict with recovery"),
2881 (
errcode(ERRCODE_DATABASE_DROPPED),
2882 errmsg(
"terminating connection due to conflict with recovery"),
2887 (
errcode(ERRCODE_ADMIN_SHUTDOWN),
2888 errmsg(
"terminating connection due to administrator command")));
2897 (
errcode(ERRCODE_CONNECTION_FAILURE),
2898 errmsg(
"connection to client lost")));
2914 (
errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
2915 errmsg(
"terminating connection due to conflict with recovery"),
2917 errhint(
"In a moment you should be able to reconnect to the"
2918 " database and repeat your command.")));
2950 (
errcode(ERRCODE_LOCK_NOT_AVAILABLE),
2951 errmsg(
"canceling statement due to lock timeout")));
2957 (
errcode(ERRCODE_QUERY_CANCELED),
2958 errmsg(
"canceling statement due to statement timeout")));
2964 (
errcode(ERRCODE_QUERY_CANCELED),
2965 errmsg(
"canceling autovacuum task")));
2973 (
errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
2974 errmsg(
"canceling statement due to conflict with recovery"),
2987 (
errcode(ERRCODE_QUERY_CANCELED),
2988 errmsg(
"canceling statement due to user request")));
3002 #if defined(__ia64__) || defined(__ia64)
3004 #if defined(__hpux) && !defined(__GNUC__) && !defined __INTEL_COMPILER
3005 #include <ia64/sys/inline.h>
3006 #define ia64_get_bsp() ((char *) (_Asm_mov_from_ar(_AREG_BSP, _NO_FENCE)))
3009 #ifdef __INTEL_COMPILER
3010 #include <asm/ia64regs.h>
3013 static __inline__
char *
3018 #ifndef __INTEL_COMPILER
3020 __asm__ __volatile__(
3025 ret = (
char *) __getReg(_IA64_REG_AR_BSP);
3044 #if defined(__ia64__) || defined(__ia64)
3046 old.register_stack_base_ptr = register_stack_base_ptr;
3053 #if defined(__ia64__) || defined(__ia64)
3054 register_stack_base_ptr = ia64_get_bsp();
3072 #if defined(__ia64__) || defined(__ia64)
3074 register_stack_base_ptr = base.register_stack_base_ptr;
3102 if (stack_depth < 0)
3103 stack_depth = -stack_depth;
3117 (
errcode(ERRCODE_STATEMENT_TOO_COMPLEX),
3118 errmsg(
"stack depth limit exceeded"),
3119 errhint(
"Increase the configuration parameter \"max_stack_depth\" (currently %dkB), "
3120 "after ensuring the platform's stack depth limit is adequate.",
3132 #if defined(__ia64__) || defined(__ia64)
3133 stack_depth = (long) (ia64_get_bsp() - register_stack_base_ptr);
3136 register_stack_base_ptr !=
NULL)
3139 (
errcode(ERRCODE_STATEMENT_TOO_COMPLEX),
3140 errmsg(
"stack depth limit exceeded"),
3141 errhint(
"Increase the configuration parameter \"max_stack_depth\" (currently %dkB), "
3142 "after ensuring the platform's stack depth limit is adequate.",
3152 long newval_bytes = *newval * 1024L;
3159 GUC_check_errhint(
"Increase the platform's stack depth limit via \"ulimit -s\" or local equivalent.");
3169 long newval_bytes = newval * 1024L;
3188 sprintf(debugstr,
"debug%d", debug_flag);
3199 if (debug_flag >= 2)
3201 if (debug_flag >= 3)
3203 if (debug_flag >= 4)
3205 if (debug_flag >= 5)
3213 const char *tmp =
NULL;
3218 tmp =
"enable_seqscan";
3221 tmp =
"enable_indexscan";
3224 tmp =
"enable_indexonlyscan";
3227 tmp =
"enable_bitmapscan";
3230 tmp =
"enable_tidscan";
3233 tmp =
"enable_nestloop";
3236 tmp =
"enable_mergejoin";
3239 tmp =
"enable_hashjoin";
3259 return "log_parser_stats";
3260 else if (
optarg[1] ==
'l')
3261 return "log_planner_stats";
3265 return "log_executor_stats";
3306 if (argc > 1 && strcmp(argv[1],
"--single") == 0)
3317 #ifdef HAVE_INT_OPTERR
3332 while ((flag =
getopt(argc, argv,
"B:bc:C:D:d:EeFf:h:ijk:lN:nOo:Pp:r:S:sTt:v:W:-:")) != -1)
3479 (
errcode(ERRCODE_SYNTAX_ERROR),
3480 errmsg(
"--%s requires a value",
3484 (
errcode(ERRCODE_SYNTAX_ERROR),
3485 errmsg(
"-c %s requires a value",
3507 if (!errs && dbname && *dbname ==
NULL && argc -
optind >= 1)
3508 *dbname = strdup(argv[
optind++]);
3510 if (errs || argc !=
optind)
3518 (
errcode(ERRCODE_SYNTAX_ERROR),
3519 errmsg(
"invalid command-line argument for server process: %s", argv[
optind]),
3523 (
errcode(ERRCODE_SYNTAX_ERROR),
3524 errmsg(
"%s: invalid command-line argument: %s",
3534 #ifdef HAVE_INT_OPTRESET
3559 volatile bool send_ready_for_query =
true;
3584 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3585 errmsg(
"%s: no database nor user name specified",
3763 printf(
"\nPostgreSQL stand-alone backend %s\n", PG_VERSION);
3805 if (
sigsetjmp(local_sigjmp_buf, 1) != 0)
3896 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
3897 errmsg(
"terminating connection because protocol sync was lost")));
3907 send_ready_for_query =
true;
3943 if (send_ready_for_query)
3965 send_ready_for_query =
false;
4014 const char *query_string;
4027 send_ready_for_query =
true;
4033 const char *stmt_name;
4034 const char *query_string;
4051 for (i = 0; i < numParams; i++)
4057 paramTypes, numParams);
4076 const char *portal_name;
4134 send_ready_for_query =
true;
4140 const char *close_target;
4151 if (close_target[0] !=
'\0')
4170 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
4171 errmsg(
"invalid CLOSE message subtype %d",
4184 const char *describe_target;
4195 switch (describe_type)
4205 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
4206 errmsg(
"invalid DESCRIBE message subtype %d",
4222 send_ready_for_query =
true;
4262 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
4263 errmsg(
"invalid frontend message type %d",
4281 if (firstchar ==
'F')
4283 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
4284 errmsg(
"fastpath function calls not supported in a replication connection")));
4287 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
4288 errmsg(
"extended query protocol not supported in a replication connection")));
4301 #if defined(HAVE_GETRLIMIT) && defined(RLIMIT_STACK)
4302 static long val = 0;
4309 if (getrlimit(RLIMIT_STACK, &rlim) < 0)
4311 else if (rlim.rlim_cur == RLIM_INFINITY)
4314 else if (rlim.rlim_cur >= LONG_MAX)
4317 val = rlim.rlim_cur;
4321 #if defined(WIN32) || defined(__CYGWIN__)
4323 return WIN32_STACK_RLIMIT;
4345 struct timeval user,
4347 struct timeval elapse_t;
4352 memcpy((
char *) &user, (
char *) &r.
ru_utime,
sizeof(user));
4353 memcpy((
char *) &sys, (
char *) &r.
ru_stime,
sizeof(sys));
4354 if (elapse_t.tv_usec <
Save_t.tv_usec)
4357 elapse_t.tv_usec += 1000000;
4381 "!\t%ld.%06ld elapsed %ld.%06ld user %ld.%06ld system sec\n",
4382 (
long) (elapse_t.tv_sec -
Save_t.tv_sec),
4383 (
long) (elapse_t.tv_usec -
Save_t.tv_usec),
4389 "!\t[%ld.%06ld user %ld.%06ld sys total]\n",
4391 (
long) user.tv_usec,
4393 (
long) sys.tv_usec);
4394 #if defined(HAVE_GETRUSAGE)
4396 "!\t%ld/%ld [%ld/%ld] filesystem blocks in/out\n",
4397 r.ru_inblock -
Save_r.ru_inblock,
4399 r.ru_oublock -
Save_r.ru_oublock,
4400 r.ru_inblock, r.ru_oublock);
4402 "!\t%ld/%ld [%ld/%ld] page faults/reclaims, %ld [%ld] swaps\n",
4403 r.ru_majflt -
Save_r.ru_majflt,
4404 r.ru_minflt -
Save_r.ru_minflt,
4405 r.ru_majflt, r.ru_minflt,
4406 r.ru_nswap -
Save_r.ru_nswap,
4409 "!\t%ld [%ld] signals rcvd, %ld/%ld [%ld/%ld] messages rcvd/sent\n",
4410 r.ru_nsignals -
Save_r.ru_nsignals,
4412 r.ru_msgrcv -
Save_r.ru_msgrcv,
4413 r.ru_msgsnd -
Save_r.ru_msgsnd,
4414 r.ru_msgrcv, r.ru_msgsnd);
4416 "!\t%ld/%ld [%ld/%ld] voluntary/involuntary context switches\n",
4417 r.ru_nvcsw -
Save_r.ru_nvcsw,
4418 r.ru_nivcsw -
Save_r.ru_nivcsw,
4419 r.ru_nvcsw, r.ru_nivcsw);
4423 if (str.
data[str.
len - 1] ==
'\n')
4450 msecs = usecs / 1000;
4458 (
errmsg(
"disconnection: session time: %d:%02d:%02d.%03d "
4459 "user=%s database=%s host=%s%s%s",
4460 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
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)
#define sigaddset(set, signum)
void DropCachedPlan(CachedPlanSource *plansource)
#define sigdelset(set, signum)
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)