PostgreSQL Source Code: src/backend/tcop/postgres.c File Reference (original) (raw)
Go to the source code of this file.
Functions | |
---|---|
static int | InteractiveBackend (StringInfo inBuf) |
static int | interactive_getc (void) |
static int | SocketBackend (StringInfo inBuf) |
static int | ReadCommand (StringInfo inBuf) |
static void | forbidden_in_wal_sender (char firstchar) |
static bool | check_log_statement (List *stmt_list) |
static int | errdetail_execute (List *raw_parsetree_list) |
static int | errdetail_params (ParamListInfo params) |
static int | errdetail_abort (void) |
static void | bind_param_error_callback (void *arg) |
static void | start_xact_command (void) |
static void | finish_xact_command (void) |
static bool | IsTransactionExitStmt (Node *parsetree) |
static bool | IsTransactionExitStmtList (List *pstmts) |
static bool | IsTransactionStmtList (List *pstmts) |
static void | drop_unnamed_stmt (void) |
static void | log_disconnections (int code, Datum arg) |
static void | enable_statement_timeout (void) |
static void | disable_statement_timeout (void) |
void | ProcessClientReadInterrupt (bool blocked) |
void | ProcessClientWriteInterrupt (bool blocked) |
List * | pg_parse_query (const char *query_string) |
List * | pg_analyze_and_rewrite_fixedparams (RawStmt *parsetree, const char *query_string, const Oid *paramTypes, int numParams, QueryEnvironment *queryEnv) |
List * | pg_analyze_and_rewrite_varparams (RawStmt *parsetree, const char *query_string, Oid **paramTypes, int *numParams, QueryEnvironment *queryEnv) |
List * | pg_analyze_and_rewrite_withcb (RawStmt *parsetree, const char *query_string, ParserSetupHook parserSetup, void *parserSetupArg, QueryEnvironment *queryEnv) |
List * | pg_rewrite_query (Query *query) |
PlannedStmt * | pg_plan_query (Query *querytree, const char *query_string, int cursorOptions, ParamListInfo boundParams) |
List * | pg_plan_queries (List *querytrees, const char *query_string, int cursorOptions, ParamListInfo boundParams) |
static void | exec_simple_query (const char *query_string) |
static void | exec_parse_message (const char *query_string, const char *stmt_name, Oid *paramTypes, int numParams) |
static void | exec_bind_message (StringInfo input_message) |
static void | exec_execute_message (const char *portal_name, long max_rows) |
int | check_log_duration (char *msec_str, bool was_logged) |
static int | errdetail_recovery_conflict (ProcSignalReason reason) |
static void | exec_describe_statement_message (const char *stmt_name) |
static void | exec_describe_portal_message (const char *portal_name) |
void | quickdie (SIGNAL_ARGS) |
void | die (SIGNAL_ARGS) |
void | StatementCancelHandler (SIGNAL_ARGS) |
void | FloatExceptionHandler (SIGNAL_ARGS) |
void | HandleRecoveryConflictInterrupt (ProcSignalReason reason) |
static void | ProcessRecoveryConflictInterrupt (ProcSignalReason reason) |
static void | ProcessRecoveryConflictInterrupts (void) |
void | ProcessInterrupts (void) |
bool | check_client_connection_check_interval (int *newval, void **extra, GucSource source) |
bool | check_stage_log_stats (bool *newval, void **extra, GucSource source) |
bool | check_log_stats (bool *newval, void **extra, GucSource source) |
void | assign_transaction_timeout (int newval, void *extra) |
bool | check_restrict_nonsystem_relation_kind (char **newval, void **extra, GucSource source) |
void | assign_restrict_nonsystem_relation_kind (const char *newval, void *extra) |
void | set_debug_options (int debug_flag, GucContext context, GucSource source) |
bool | set_plan_disabling_options (const char *arg, GucContext context, GucSource source) |
const char * | get_stats_option_name (const char *arg) |
void | process_postgres_switches (int argc, char *argv[], GucContext ctx, const char **dbname) |
void | PostgresSingleUserMain (int argc, char *argv[], const char *username) |
void | PostgresMain (const char *dbname, const char *username) |
void | ResetUsage (void) |
void | ShowUsage (const char *title) |
Variables | |
---|---|
const char * | debug_query_string |
CommandDest | whereToSendOutput = DestDebug |
bool | Log_disconnections = false |
int | log_statement = LOGSTMT_NONE |
int | PostAuthDelay = 0 |
int | client_connection_check_interval = 0 |
int | restrict_nonsystem_relation_kind |
static bool | xact_started = false |
static bool | DoingCommandRead = false |
static bool | doing_extended_query_message = false |
static bool | ignore_till_sync = false |
static CachedPlanSource * | unnamed_stmt_psrc = NULL |
static const char * | userDoption = NULL |
static bool | EchoQuery = false |
static bool | UseSemiNewlineNewline = false |
static volatile sig_atomic_t | RecoveryConflictPending = false |
static volatile sig_atomic_t | RecoveryConflictPendingReasons [NUM_PROCSIGNALS] |
static MemoryContext | row_description_context = NULL |
static StringInfoData | row_description_buf |
static struct rusage | Save_r |
static struct timeval | Save_t |
◆ valgrind_report_error_query
| #define valgrind_report_error_query | ( | | query | ) | ((void) 0) | | -------------------------------------- | - | | ----- | - | ---------- |
◆ BindParamCbData
◆ assign_restrict_nonsystem_relation_kind()
void assign_restrict_nonsystem_relation_kind | ( | const char * | newval, |
---|---|---|---|
void * | extra | ||
) |
◆ assign_transaction_timeout()
void assign_transaction_timeout | ( | int | newval, |
---|---|---|---|
void * | extra | ||
) |
◆ bind_param_error_callback()
static void bind_param_error_callback ( void * arg) | static |
---|
Definition at line 2592 of file postgres.c.
2593{
2596 char *quotedval;
2597
2598 if (data->paramno < 0)
2599 return;
2600
2601
2602 if (data->paramval)
2603 {
2607 quotedval = buf.data;
2608 }
2609 else
2610 quotedval = NULL;
2611
2612 if (data->portalName && data->portalName[0] != '\0')
2613 {
2614 if (quotedval)
2615 errcontext("portal \"%s\" parameter $%d = %s",
2616 data->portalName, data->paramno + 1, quotedval);
2617 else
2618 errcontext("portal \"%s\" parameter $%d",
2619 data->portalName, data->paramno + 1);
2620 }
2621 else
2622 {
2623 if (quotedval)
2624 errcontext("unnamed portal parameter $%d = %s",
2625 data->paramno + 1, quotedval);
2626 else
2627 errcontext("unnamed portal parameter $%d",
2628 data->paramno + 1);
2629 }
2630
2631 if (quotedval)
2632 pfree(quotedval);
2633}
int log_parameter_max_length_on_error
void pfree(void *pointer)
void initStringInfo(StringInfo str)
void appendStringInfoStringQuoted(StringInfo str, const char *s, int maxlen)
References appendStringInfoStringQuoted(), arg, buf, data, errcontext, initStringInfo(), log_parameter_max_length_on_error, and pfree().
Referenced by exec_bind_message().
◆ check_client_connection_check_interval()
bool check_client_connection_check_interval | ( | int * | newval, |
---|---|---|---|
void ** | extra, | ||
GucSource | source | ||
) |
◆ check_log_duration()
int check_log_duration | ( | char * | msec_str, |
---|---|---|---|
bool | was_logged | ||
) |
Definition at line 2423 of file postgres.c.
2424{
2427 {
2428 long secs;
2429 int usecs;
2430 int msecs;
2431 bool exceeded_duration;
2432 bool exceeded_sample_duration;
2433 bool in_sample = false;
2434
2437 &secs, &usecs);
2438 msecs = usecs / 1000;
2439
2440
2441
2442
2443
2444
2449
2454
2455
2456
2457
2458
2459
2460 if (exceeded_sample_duration)
2464
2466 {
2467 snprintf(msec_str, 32, "%ld.%03d",
2468 secs * 1000 + msecs, usecs % 1000);
2469 if ((exceeded_duration || in_sample || xact_is_sampled) && !was_logged)
2470 return 2;
2471 else
2472 return 1;
2473 }
2474 }
2475
2476 return 0;
2477}
void TimestampDifference(TimestampTz start_time, TimestampTz stop_time, long *secs, int *microsecs)
TimestampTz GetCurrentTimestamp(void)
int log_min_duration_statement
int log_min_duration_sample
double log_statement_sample_rate
double pg_prng_double(pg_prng_state *state)
pg_prng_state pg_global_prng_state
TimestampTz GetCurrentStatementStartTimestamp(void)
References GetCurrentStatementStartTimestamp(), GetCurrentTimestamp(), log_duration, log_min_duration_sample, log_min_duration_statement, log_statement_sample_rate, pg_global_prng_state, pg_prng_double(), snprintf, TimestampDifference(), and xact_is_sampled.
Referenced by exec_bind_message(), exec_execute_message(), exec_parse_message(), exec_simple_query(), and HandleFunctionRequest().
◆ check_log_statement()
static bool check_log_statement ( List * stmt_list) | static |
---|
◆ check_log_stats()
bool check_log_stats | ( | bool * | newval, |
---|---|---|---|
void ** | extra, | ||
GucSource | source | ||
) |
◆ check_restrict_nonsystem_relation_kind()
bool check_restrict_nonsystem_relation_kind | ( | char ** | newval, |
---|---|---|---|
void ** | extra, | ||
GucSource | source | ||
) |
Definition at line 3613 of file postgres.c.
3614{
3615 char *rawstring;
3616 List *elemlist;
3618 int flags = 0;
3619
3620
3622
3624 {
3625
3627 pfree(rawstring);
3629 return false;
3630 }
3631
3632 foreach(l, elemlist)
3633 {
3634 char *tok = (char *) lfirst(l);
3635
3638 else if (pg_strcasecmp(tok, "foreign-table") == 0)
3640 else
3641 {
3643 pfree(rawstring);
3645 return false;
3646 }
3647 }
3648
3649 pfree(rawstring);
3651
3652
3654 if (!*extra)
3655 return false;
3656 *((int *) *extra) = flags;
3657
3658 return true;
3659}
void * guc_malloc(int elevel, size_t size)
void list_free(List *list)
char * pstrdup(const char *in)
int pg_strcasecmp(const char *s1, const char *s2)
#define RESTRICT_RELKIND_FOREIGN_TABLE
#define RESTRICT_RELKIND_VIEW
bool SplitIdentifierString(char *rawstring, char separator, List **namelist)
References GUC_check_errdetail, guc_malloc(), lfirst, list_free(), LOG, newval, pfree(), pg_strcasecmp(), pstrdup(), RESTRICT_RELKIND_FOREIGN_TABLE, RESTRICT_RELKIND_VIEW, and SplitIdentifierString().
◆ check_stage_log_stats()
bool check_stage_log_stats | ( | bool * | newval, |
---|---|---|---|
void ** | extra, | ||
GucSource | source | ||
) |
◆ die()
Definition at line 3026 of file postgres.c.
3027{
3028
3030 {
3033 }
3034
3035
3037
3038
3040
3041
3042
3043
3044
3045
3046
3049}
volatile sig_atomic_t InterruptPending
volatile sig_atomic_t ProcDiePending
bool proc_exit_inprogress
void SetLatch(Latch *latch)
SessionEndType pgStatSessionEndCause
CommandDest whereToSendOutput
static bool DoingCommandRead
void ProcessInterrupts(void)
References DestRemote, DISCONNECT_KILLED, DoingCommandRead, InterruptPending, MyLatch, pgStatSessionEndCause, proc_exit_inprogress, ProcDiePending, ProcessInterrupts(), SetLatch(), and whereToSendOutput.
Referenced by PostgresMain().
◆ disable_statement_timeout()
static void disable_statement_timeout ( void ) | static |
---|
◆ drop_unnamed_stmt()
static void drop_unnamed_stmt ( void ) | static |
---|
◆ enable_statement_timeout()
static void enable_statement_timeout ( void ) | static |
---|
◆ errdetail_abort()
static int errdetail_abort ( void ) | static |
---|
◆ errdetail_execute()
static int errdetail_execute ( List * raw_parsetree_list) | static |
---|
Definition at line 2486 of file postgres.c.
2487{
2489
2490 foreach(parsetree_item, raw_parsetree_list)
2491 {
2493
2495 {
2498
2500 if (pstmt)
2501 {
2502 errdetail("prepare: %s", pstmt->plansource->query_string);
2503 return 0;
2504 }
2505 }
2506 }
2507
2508 return 0;
2509}
PreparedStatement * FetchPreparedStatement(const char *stmt_name, bool throwError)
#define IsA(nodeptr, _type_)
#define lfirst_node(type, lc)
References errdetail(), FetchPreparedStatement(), IsA, lfirst_node, RawStmt::stmt, and stmt.
Referenced by exec_simple_query().
◆ errdetail_params()
◆ errdetail_recovery_conflict()
◆ exec_bind_message()
static void exec_bind_message ( StringInfo input_message) | static |
---|
Definition at line 1624 of file postgres.c.
1625{
1626 const char *portal_name;
1627 const char *stmt_name;
1628 int numPFormats;
1629 int16 *pformats = NULL;
1630 int numParams;
1631 int numRFormats;
1632 int16 *rformats = NULL;
1636 char *query_string;
1637 char *saved_stmt_name;
1641 bool snapshot_set = false;
1642 char msec_str[32];
1646
1647
1650
1653 *portal_name ? portal_name : "",
1654 *stmt_name ? stmt_name : "")));
1655
1656
1657 if (stmt_name[0] != '\0')
1658 {
1660
1663 }
1664 else
1665 {
1666
1668 if (!psrc)
1670 (errcode(ERRCODE_UNDEFINED_PSTATEMENT),
1671 errmsg("unnamed prepared statement does not exist")));
1672 }
1673
1674
1675
1676
1678
1680
1682 {
1684
1686 {
1688 break;
1689 }
1690 }
1691
1693
1694 if (save_log_statement_stats)
1696
1697
1698
1699
1700
1701
1702
1704
1705
1707
1708
1709 numPFormats = pq_getmsgint(input_message, 2);
1710 if (numPFormats > 0)
1711 {
1713 for (int i = 0; i < numPFormats; i++)
1715 }
1716
1717
1719
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)));
1725
1728 (errcode(ERRCODE_PROTOCOL_VIOLATION),
1729 errmsg("bind message supplies %d parameters, but prepared statement \"%s\" requires %d",
1730 numParams, stmt_name, psrc->num_params)));
1731
1732
1733
1734
1735
1736
1737
1738
1739
1743 numParams != 0))
1745 (errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
1746 errmsg("current transaction is aborted, "
1747 "commands ignored until end of transaction block"),
1749
1750
1751
1752
1753
1754 if (portal_name[0] == '\0')
1755 portal = CreatePortal(portal_name, true, true);
1756 else
1757 portal = CreatePortal(portal_name, false, false);
1758
1759
1760
1761
1762
1763
1764
1766
1767
1769
1770
1771 if (stmt_name[0])
1772 saved_stmt_name = pstrdup(stmt_name);
1773 else
1774 saved_stmt_name = NULL;
1775
1776
1777
1778
1779
1780
1781
1782
1783 if (numParams > 0 ||
1786 {
1788 snapshot_set = true;
1789 }
1790
1791
1792
1793
1794 if (numParams > 0)
1795 {
1796 char **knownTextValues = NULL;
1798
1799
1800
1801
1802
1804 one_param_data.paramno = -1;
1805 one_param_data.paramval = NULL;
1808 params_errcxt.arg = &one_param_data;
1810
1812
1813 for (int paramno = 0; paramno < numParams; paramno++)
1814 {
1818 bool isNull;
1820 char csave;
1822
1823 one_param_data.paramno = paramno;
1824 one_param_data.paramval = NULL;
1825
1827 isNull = (plength == -1);
1828
1829 if (!isNull)
1830 {
1831 char *pvalue;
1832
1833
1834
1835
1836
1837
1838
1839
1841 csave = pvalue[plength];
1842 pvalue[plength] = '\0';
1844 }
1845 else
1846 {
1847 pbuf.data = NULL;
1848 csave = 0;
1849 }
1850
1851 if (numPFormats > 1)
1852 pformat = pformats[paramno];
1853 else if (numPFormats > 0)
1854 pformat = pformats[0];
1855 else
1856 pformat = 0;
1857
1858 if (pformat == 0)
1859 {
1860 Oid typinput;
1861 Oid typioparam;
1862 char *pstring;
1863
1865
1866
1867
1868
1869
1870 if (isNull)
1871 pstring = NULL;
1872 else
1874
1875
1876 one_param_data.paramval = pstring;
1877
1879
1880 one_param_data.paramval = NULL;
1881
1882
1883
1884
1885
1886
1887 if (pstring)
1888 {
1890 {
1892
1894
1895 if (knownTextValues == NULL)
1896 knownTextValues = palloc0_array(char *, numParams);
1897
1899 knownTextValues[paramno] = pstrdup(pstring);
1900 else
1901 {
1902
1903
1904
1905
1906
1907
1908
1909 knownTextValues[paramno] =
1913 }
1914
1916 }
1917 if (pstring != pbuf.data)
1919 }
1920 }
1921 else if (pformat == 1)
1922 {
1923 Oid typreceive;
1924 Oid typioparam;
1926
1927
1928
1929
1931
1932 if (isNull)
1933 bufptr = NULL;
1934 else
1935 bufptr = &pbuf;
1936
1938
1939
1940 if (!isNull && pbuf.cursor != pbuf.len)
1942 (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
1943 errmsg("incorrect binary data format in bind parameter %d",
1944 paramno + 1)));
1945 }
1946 else
1947 {
1949 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1950 errmsg("unsupported format code: %d",
1951 pformat)));
1952 pval = 0;
1953 }
1954
1955
1956 if (!isNull)
1957 pbuf.data[plength] = csave;
1958
1961
1962
1963
1964
1965
1968 }
1969
1970
1972
1973
1974
1975
1976
1977
1981 knownTextValues,
1983 }
1984 else
1985 params = NULL;
1986
1987
1989
1990
1991
1992
1993
1995 params_data.params = params;
1998 params_errcxt.arg = ¶ms_data;
2000
2001
2002 numRFormats = pq_getmsgint(input_message, 2);
2003 if (numRFormats > 0)
2004 {
2006 for (int i = 0; i < numRFormats; i++)
2008 }
2009
2011
2012
2013
2014
2015
2016
2017 cplan = GetCachedPlan(psrc, params, NULL, NULL);
2018
2019
2020
2021
2022
2023
2024
2026 saved_stmt_name,
2027 query_string,
2030 cplan);
2031
2032
2033 foreach(lc, portal->stmts)
2034 {
2036
2038 {
2040 break;
2041 }
2042 }
2043
2044
2045 if (snapshot_set)
2047
2048
2049
2050
2052
2053
2054
2055
2057
2058
2059
2060
2061
2063
2064
2065
2066
2069
2070
2071
2072
2074 {
2075 case 1:
2077 (errmsg("duration: %s ms", msec_str),
2079 break;
2080 case 2:
2082 (errmsg("duration: %s ms bind %s%s%s: %s",
2083 msec_str,
2084 *stmt_name ? stmt_name : "",
2085 *portal_name ? "/" : "",
2086 *portal_name ? portal_name : "",
2090 break;
2091 }
2092
2093 if (save_log_statement_stats)
2094 ShowUsage("BIND MESSAGE STATISTICS");
2095
2097
2099}
void pgstat_report_plan_id(uint64 plan_id, bool force)
void pgstat_report_query_id(uint64 query_id, bool force)
void pgstat_report_activity(BackendState state, const char *cmd_str)
#define unconstify(underlying_type, expr)
int errmsg_internal(const char *fmt,...)
int errhidestmt(bool hide_stmt)
ErrorContextCallback * error_context_stack
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
#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)
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)
MemoryContext MessageContext
char * pnstrdup(const char *in, Size len)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
ParamListInfo makeParamList(int numParams)
void ParamsErrorCallback(void *arg)
bool analyze_requires_snapshot(RawStmt *parseTree)
#define MAX_MULTIBYTE_CHAR_LEN
CachedPlan * GetCachedPlan(CachedPlanSource *plansource, ParamListInfo boundParams, ResourceOwner owner, QueryEnvironment *queryEnv)
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)
static int errdetail_abort(void)
int check_log_duration(char *msec_str, bool was_logged)
const char * debug_query_string
void ShowUsage(const char *title)
static int errdetail_params(ParamListInfo params)
static void bind_param_error_callback(void *arg)
static bool IsTransactionExitStmt(Node *parsetree)
static void start_xact_command(void)
#define valgrind_report_error_query(query)
unsigned int pq_getmsgint(StringInfo msg, int b)
void pq_getmsgend(StringInfo msg)
const char * pq_getmsgstring(StringInfo msg)
void pq_putemptymessage(char msgtype)
const char * pq_getmsgbytes(StringInfo msg, int datalen)
void PortalSetResultFormat(Portal portal, int nFormats, int16 *formats)
void PortalStart(Portal portal, ParamListInfo params, int eflags, Snapshot snapshot)
#define PqMsg_BindComplete
static void set_ps_display(const char *activity)
Snapshot GetTransactionSnapshot(void)
void PushActiveSnapshot(Snapshot snapshot)
void PopActiveSnapshot(void)
static void initReadOnlyStringInfo(StringInfo str, char *data, int len)
const char * query_string
struct RawStmt * raw_parse_tree
struct ErrorContextCallback * previous
void(* callback)(void *arg)
ParamExternData params[FLEXIBLE_ARRAY_MEMBER]
MemoryContext portalContext
CachedPlanSource * plansource
bool IsAbortedTransactionBlockState(void)
References analyze_requires_snapshot(), ErrorContextCallback::arg, bind_param_error_callback(), BuildParamLogString(), ErrorContextCallback::callback, check_log_duration(), CachedPlanSource::commandTag, CreatePortal(), StringInfoData::cursor, StringInfoData::data, DEBUG2, debug_query_string, DestRemote, ereport, errcode(), errdetail_abort(), errdetail_params(), errhidestmt(), errmsg(), errmsg_internal(), ERROR, error_context_stack, FetchPreparedStatement(), GetCachedPlan(), GetTransactionSnapshot(), getTypeBinaryInputInfo(), getTypeInputInfo(), i, initReadOnlyStringInfo(), InvalidSnapshot, IsAbortedTransactionBlockState(), ParamExternData::isnull, IsTransactionExitStmt(), StringInfoData::len, lfirst_node, LOG, log_parameter_max_length_on_error, log_statement_stats, makeParamList(), MAX_MULTIBYTE_CHAR_LEN, MemoryContextSwitchTo(), MessageContext, PortalData::name, CachedPlanSource::num_params, OidInputFunctionCall(), OidReceiveFunctionCall(), palloc0_array, palloc_array, PARAM_FLAG_CONST, CachedPlanSource::param_types, BindParamCbData::paramno, ParamListInfoData::params, ParamsErrorCbData::params, ParamsErrorCallback(), BindParamCbData::paramval, ParamListInfoData::paramValuesStr, ParamExternData::pflags, pfree(), pg_client_to_server(), pgstat_report_activity(), pgstat_report_plan_id(), pgstat_report_query_id(), plan, PreparedStatement::plansource, pnstrdup(), PopActiveSnapshot(), PortalData::portalContext, PortalDefineQuery(), BindParamCbData::portalName, ParamsErrorCbData::portalName, PortalSetResultFormat(), PortalStart(), pq_getmsgbytes(), pq_getmsgend(), pq_getmsgint(), pq_getmsgstring(), pq_putemptymessage(), PqMsg_BindComplete, ErrorContextCallback::previous, pstrdup(), ParamExternData::ptype, PushActiveSnapshot(), CachedPlanSource::query_list, CachedPlanSource::query_string, CachedPlanSource::raw_parse_tree, ResetUsage(), set_ps_display(), ShowUsage(), start_xact_command(), STATE_RUNNING, RawStmt::stmt, CachedPlan::stmt_list, PortalData::stmts, UINT64CONST, unconstify, unnamed_stmt_psrc, valgrind_report_error_query, ParamExternData::value, and whereToSendOutput.
Referenced by PostgresMain().
◆ exec_describe_portal_message()
static void exec_describe_portal_message ( const char * portal_name) | static |
---|
Definition at line 2734 of file postgres.c.
2735{
2737
2738
2739
2740
2741
2743
2744
2746
2750 (errcode(ERRCODE_UNDEFINED_CURSOR),
2751 errmsg("portal \"%s\" does not exist", portal_name)));
2752
2753
2754
2755
2756
2757
2758
2759
2760
2764 (errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
2765 errmsg("current transaction is aborted, "
2766 "commands ignored until end of transaction block"),
2768
2770 return;
2771
2777 else
2779}
Portal GetPortalByName(const char *name)
static StringInfoData row_description_buf
List * FetchPortalTargetList(Portal portal)
void SendRowDescriptionMessage(StringInfo buf, TupleDesc typeinfo, List *targetlist, int16 *formats)
References DestRemote, ereport, errcode(), errdetail_abort(), errmsg(), ERROR, FetchPortalTargetList(), PortalData::formats, GetPortalByName(), IsAbortedTransactionBlockState(), MemoryContextSwitchTo(), MessageContext, PortalIsValid, pq_putemptymessage(), PqMsg_NoData, row_description_buf, SendRowDescriptionMessage(), start_xact_command(), PortalData::tupDesc, and whereToSendOutput.
Referenced by PostgresMain().
◆ exec_describe_statement_message()
static void exec_describe_statement_message ( const char * stmt_name) | static |
---|
Definition at line 2641 of file postgres.c.
2642{
2644
2645
2646
2647
2648
2650
2651
2653
2654
2655 if (stmt_name[0] != '\0')
2656 {
2658
2661 }
2662 else
2663 {
2664
2666 if (!psrc)
2668 (errcode(ERRCODE_UNDEFINED_PSTATEMENT),
2669 errmsg("unnamed prepared statement does not exist")));
2670 }
2671
2672
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2687 (errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
2688 errmsg("current transaction is aborted, "
2689 "commands ignored until end of transaction block"),
2691
2693 return;
2694
2695
2696
2697
2700
2702 {
2704
2706 }
2708
2709
2710
2711
2713 {
2714 List *tlist;
2715
2716
2718
2721 tlist,
2722 NULL);
2723 }
2724 else
2726}
List * CachedPlanGetTargetList(CachedPlanSource *plansource, QueryEnvironment *queryEnv)
void pq_beginmessage_reuse(StringInfo buf, char msgtype)
void pq_endmessage_reuse(StringInfo buf)
static void pq_sendint32(StringInfo buf, uint32 i)
static void pq_sendint16(StringInfo buf, uint16 i)
#define PqMsg_ParameterDescription
References Assert(), CachedPlanGetTargetList(), DestRemote, ereport, errcode(), errdetail_abort(), errmsg(), ERROR, FetchPreparedStatement(), CachedPlanSource::fixed_result, i, IsAbortedTransactionBlockState(), MemoryContextSwitchTo(), MessageContext, CachedPlanSource::num_params, CachedPlanSource::param_types, PreparedStatement::plansource, pq_beginmessage_reuse(), pq_endmessage_reuse(), pq_putemptymessage(), pq_sendint16(), pq_sendint32(), PqMsg_NoData, PqMsg_ParameterDescription, CachedPlanSource::resultDesc, row_description_buf, SendRowDescriptionMessage(), start_xact_command(), unnamed_stmt_psrc, and whereToSendOutput.
Referenced by PostgresMain().
◆ exec_execute_message()
static void exec_execute_message ( const char * portal_name, long max_rows ) | static |
---|
Definition at line 2107 of file postgres.c.
2108{
2112 bool completed;
2114 const char *sourceText;
2115 const char *prepStmtName;
2118 bool is_xact_command;
2119 bool execute_is_fetch;
2120 bool was_logged = false;
2121 char msec_str[32];
2124 const char *cmdtagname;
2125 size_t cmdtaglen;
2127
2128
2132
2136 (errcode(ERRCODE_UNDEFINED_CURSOR),
2137 errmsg("portal \"%s\" does not exist", portal_name)));
2138
2139
2140
2141
2142
2143 if (portal->commandTag == CMDTAG_UNKNOWN)
2144 {
2147 return;
2148 }
2149
2150
2152
2153
2154
2155
2156
2157
2158
2162 else
2163 prepStmtName = "";
2165
2166
2167
2168
2170
2172
2173 foreach(lc, portal->stmts)
2174 {
2176
2178 {
2180 break;
2181 }
2182 }
2183
2184 foreach(lc, portal->stmts)
2185 {
2187
2189 {
2191 break;
2192 }
2193 }
2194
2196
2198
2199 if (save_log_statement_stats)
2201
2203
2204
2205
2206
2207
2211
2212
2213
2214
2215
2217
2218
2219
2220
2221
2222
2223
2224 execute_is_fetch = !portal->atStart;
2225
2226
2228 {
2230 (errmsg("%s %s%s%s: %s",
2231 execute_is_fetch ?
2232 _("execute fetch from") :
2233 _("execute"),
2234 prepStmtName,
2235 *portal_name ? "/" : "",
2236 *portal_name ? portal_name : "",
2237 sourceText),
2240 was_logged = true;
2241 }
2242
2243
2244
2245
2246
2250 (errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
2251 errmsg("current transaction is aborted, "
2252 "commands ignored until end of transaction block"),
2254
2255
2257
2258
2259
2260
2261
2263 params_data.params = portalParams;
2266 params_errcxt.arg = ¶ms_data;
2268
2269 if (max_rows <= 0)
2271
2273 max_rows,
2274 true,
2275 receiver,
2276 receiver,
2277 &qc);
2278
2279 receiver->rDestroy(receiver);
2280
2281
2283
2284 if (completed)
2285 {
2287 {
2288
2289
2290
2291
2292
2293
2294
2295
2297
2298
2299
2300
2301
2302
2303 portalParams = NULL;
2304 }
2305 else
2306 {
2307
2308
2309
2310
2312
2313
2314
2315
2316
2318
2319
2320
2321
2322
2324 }
2325
2326
2328 }
2329 else
2330 {
2331
2334
2335
2336
2337
2338
2340 }
2341
2342
2343
2344
2346 {
2347 case 1:
2349 (errmsg("duration: %s ms", msec_str),
2351 break;
2352 case 2:
2354 (errmsg("duration: %s ms %s %s%s%s: %s",
2355 msec_str,
2356 execute_is_fetch ?
2357 _("execute fetch from") :
2358 _("execute"),
2359 prepStmtName,
2360 *portal_name ? "/" : "",
2361 *portal_name ? portal_name : "",
2362 sourceText),
2365 break;
2366 }
2367
2368 if (save_log_statement_stats)
2369 ShowUsage("EXECUTE MESSAGE STATISTICS");
2370
2372
2374}
const char * GetCommandTagNameAndLen(CommandTag commandTag, Size *len)
void EndCommand(const QueryCompletion *qc, CommandDest dest, bool force_undecorated_output)
DestReceiver * CreateDestReceiver(CommandDest dest)
void BeginCommand(CommandTag commandTag, CommandDest dest)
void NullCommand(CommandDest dest)
#define CHECK_FOR_INTERRUPTS()
static void disable_statement_timeout(void)
static bool IsTransactionStmtList(List *pstmts)
static bool check_log_statement(List *stmt_list)
static bool IsTransactionExitStmtList(List *pstmts)
static void finish_xact_command(void)
bool PortalRun(Portal portal, long count, bool isTopLevel, DestReceiver *dest, DestReceiver *altdest, QueryCompletion *qc)
void SetRemoteDestReceiverParams(DestReceiver *self, Portal portal)
#define PqMsg_PortalSuspended
void set_ps_display_with_len(const char *activity, size_t len)
ParamListInfo portalParams
const char * prepStmtName
void(* rDestroy)(DestReceiver *self)
void CommandCounterIncrement(void)
#define XACT_FLAGS_PIPELINING
#define XACT_FLAGS_NEEDIMMEDIATECOMMIT
References _, ErrorContextCallback::arg, Assert(), PortalData::atStart, BeginCommand(), ErrorContextCallback::callback, CHECK_FOR_INTERRUPTS, check_log_duration(), check_log_statement(), CommandCounterIncrement(), PortalData::commandTag, CreateDestReceiver(), debug_query_string, generate_unaccent_rules::dest, DestRemote, DestRemoteExecute, disable_statement_timeout(), EndCommand(), ereport, errcode(), errdetail_abort(), errdetail_params(), errhidestmt(), errmsg(), ERROR, error_context_stack, FETCH_ALL, finish_xact_command(), GetCommandTagNameAndLen(), GetPortalByName(), IsAbortedTransactionBlockState(), IsTransactionExitStmtList(), IsTransactionStmtList(), lfirst_node, LOG, log_statement_stats, MyXactFlags, PortalData::name, NIL, NullCommand(), ParamsErrorCbData::params, ParamsErrorCallback(), pgstat_report_activity(), pgstat_report_plan_id(), pgstat_report_query_id(), PortalIsValid, ParamsErrorCbData::portalName, PortalData::portalParams, PortalRun(), pq_putemptymessage(), PqMsg_PortalSuspended, PortalData::prepStmtName, ErrorContextCallback::previous, pstrdup(), _DestReceiver::rDestroy, ResetUsage(), set_ps_display_with_len(), SetRemoteDestReceiverParams(), ShowUsage(), PortalData::sourceText, start_xact_command(), STATE_RUNNING, stmt, PortalData::stmts, UINT64CONST, valgrind_report_error_query, whereToSendOutput, XACT_FLAGS_NEEDIMMEDIATECOMMIT, and XACT_FLAGS_PIPELINING.
Referenced by PostgresMain().
◆ exec_parse_message()
static void exec_parse_message ( const char * query_string, const char * stmt_name, Oid * paramTypes, int numParams ) | static |
---|
Definition at line 1389 of file postgres.c.
1393{
1396 List *parsetree_list;
1397 RawStmt *raw_parse_tree;
1398 List *querytree_list;
1400 bool is_named;
1402 char msec_str[32];
1403
1404
1405
1406
1408
1410
1412
1413 if (save_log_statement_stats)
1415
1418 *stmt_name ? stmt_name : "",
1419 query_string)));
1420
1421
1422
1423
1424
1425
1426
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442 is_named = (stmt_name[0] != '\0');
1443 if (is_named)
1444 {
1445
1447 }
1448 else
1449 {
1450
1452
1453 unnamed_stmt_context =
1455 "unnamed prepared statement",
1458 }
1459
1460
1461
1462
1463
1465
1466
1467
1468
1469
1470
1473 (errcode(ERRCODE_SYNTAX_ERROR),
1474 errmsg("cannot insert multiple commands into a prepared statement")));
1475
1476 if (parsetree_list != NIL)
1477 {
1478 bool snapshot_set = false;
1479
1481
1482
1483
1484
1485
1486
1487
1488
1489
1493 (errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
1494 errmsg("current transaction is aborted, "
1495 "commands ignored until end of transaction block"),
1497
1498
1499
1500
1501
1504
1505
1506
1507
1509 {
1511 snapshot_set = true;
1512 }
1513
1514
1515
1516
1517
1518
1520 query_string,
1521 ¶mTypes,
1522 &numParams,
1523 NULL);
1524
1525
1526 if (snapshot_set)
1528 }
1529 else
1530 {
1531
1532 raw_parse_tree = NULL;
1534 CMDTAG_UNKNOWN);
1535 querytree_list = NIL;
1536 }
1537
1538
1539
1540
1541
1542
1543
1544 if (unnamed_stmt_context)
1546
1547
1549 querytree_list,
1550 unnamed_stmt_context,
1551 paramTypes,
1552 numParams,
1553 NULL,
1554 NULL,
1556 true);
1557
1558
1560
1561 if (is_named)
1562 {
1563
1564
1565
1567 }
1568 else
1569 {
1570
1571
1572
1575 }
1576
1578
1579
1580
1581
1582
1583
1585
1586
1587
1588
1591
1592
1593
1594
1596 {
1597 case 1:
1599 (errmsg("duration: %s ms", msec_str),
1601 break;
1602 case 2:
1604 (errmsg("duration: %s ms parse %s: %s",
1605 msec_str,
1606 *stmt_name ? stmt_name : "",
1607 query_string),
1609 break;
1610 }
1611
1612 if (save_log_statement_stats)
1613 ShowUsage("PARSE MESSAGE STATISTICS");
1614
1616}
void StorePreparedStatement(const char *stmt_name, CachedPlanSource *plansource, bool from_sql)
void MemoryContextSetParent(MemoryContext context, MemoryContext new_parent)
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
#define CURSOR_OPT_PARALLEL_OK
static int list_length(const List *l)
#define linitial_node(type, l)
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)
List * pg_parse_query(const char *query_string)
List * pg_analyze_and_rewrite_varparams(RawStmt *parsetree, const char *query_string, Oid **paramTypes, int *numParams, QueryEnvironment *queryEnv)
static void drop_unnamed_stmt(void)
#define PqMsg_ParseComplete
CommandTag CreateCommandTag(Node *parsetree)
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, analyze_requires_snapshot(), CHECK_FOR_INTERRUPTS, check_log_duration(), CommandCounterIncrement(), CompleteCachedPlan(), CachedPlanSource::context, CreateCachedPlan(), CreateCommandTag(), CURSOR_OPT_PARALLEL_OK, DEBUG2, debug_query_string, DestRemote, drop_unnamed_stmt(), ereport, errcode(), errdetail_abort(), errhidestmt(), errmsg(), errmsg_internal(), ERROR, GetTransactionSnapshot(), IsAbortedTransactionBlockState(), IsTransactionExitStmt(), linitial_node, list_length(), LOG, log_statement_stats, MemoryContextSetParent(), MemoryContextSwitchTo(), MessageContext, NIL, pg_analyze_and_rewrite_varparams(), pg_parse_query(), pgstat_report_activity(), PopActiveSnapshot(), pq_putemptymessage(), PqMsg_ParseComplete, PushActiveSnapshot(), ResetUsage(), SaveCachedPlan(), set_ps_display(), ShowUsage(), start_xact_command(), STATE_RUNNING, RawStmt::stmt, StorePreparedStatement(), unnamed_stmt_psrc, and whereToSendOutput.
Referenced by PostgresMain().
◆ exec_simple_query()
static void exec_simple_query ( const char * query_string) | static |
---|
Definition at line 1011 of file postgres.c.
1012{
1015 List *parsetree_list;
1018 bool was_logged = false;
1019 bool use_implicit_block;
1020 char msec_str[32];
1021
1022
1023
1024
1026
1028
1029 TRACE_POSTGRESQL_QUERY_START(query_string);
1030
1031
1032
1033
1034
1035 if (save_log_statement_stats)
1037
1038
1039
1040
1041
1042
1043
1044
1046
1047
1048
1049
1050
1051
1052
1054
1055
1056
1057
1059
1060
1061
1062
1063
1065
1066
1068 {
1070 (errmsg("statement: %s", query_string),
1073 was_logged = true;
1074 }
1075
1076
1077
1078
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089 use_implicit_block = (list_length(parsetree_list) > 1);
1090
1091
1092
1093
1094 foreach(parsetree_item, parsetree_list)
1095 {
1097 bool snapshot_set = false;
1101 List *querytree_list,
1102 *plantree_list;
1106 const char *cmdtagname;
1107 size_t cmdtaglen;
1108
1111
1112
1113
1114
1115
1116
1117
1120
1122
1124
1125
1126
1127
1128
1129
1130
1131
1132
1136 (errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
1137 errmsg("current transaction is aborted, "
1138 "commands ignored until end of transaction block"),
1140
1141
1143
1144
1145
1146
1147
1148
1149
1150
1151 if (use_implicit_block)
1153
1154
1156
1157
1158
1159
1161 {
1163 snapshot_set = true;
1164 }
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178 if (lnext(parsetree_list, parsetree_item) != NULL)
1179 {
1180 per_parsetree_context =
1182 "per-parsetree message context",
1185 }
1186 else
1188
1190 NULL, 0, NULL);
1191
1192 plantree_list = pg_plan_queries(querytree_list, query_string,
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205 if (snapshot_set)
1207
1208
1210
1211
1212
1213
1214
1216
1217 portal->visible = false;
1218
1219
1220
1221
1222
1223
1225 NULL,
1226 query_string,
1227 commandTag,
1228 plantree_list,
1229 NULL);
1230
1231
1232
1233
1235
1236
1237
1238
1239
1240
1241
1242 format = 0;
1244 {
1246
1248 {
1250
1253 format = 1;
1254 }
1255 }
1257
1258
1259
1260
1264
1265
1266
1267
1269
1270
1271
1272
1275 true,
1276 receiver,
1277 receiver,
1278 &qc);
1279
1280 receiver->rDestroy(receiver);
1281
1283
1284 if (lnext(parsetree_list, parsetree_item) == NULL)
1285 {
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295 if (use_implicit_block)
1298 }
1300 {
1301
1302
1303
1304
1306 }
1307 else
1308 {
1309
1310
1311
1312
1313
1315
1316
1317
1318
1319
1321
1322
1323
1324
1325
1326
1328 }
1329
1330
1331
1332
1333
1334
1335
1337
1338
1339 if (per_parsetree_context)
1341 }
1342
1343
1344
1345
1346
1347
1349
1350
1351
1352
1353 if (!parsetree_list)
1355
1356
1357
1358
1360 {
1361 case 1:
1363 (errmsg("duration: %s ms", msec_str),
1365 break;
1366 case 2:
1368 (errmsg("duration: %s ms statement: %s",
1369 msec_str, query_string),
1372 break;
1373 }
1374
1375 if (save_log_statement_stats)
1377
1378 TRACE_POSTGRESQL_QUERY_DONE(query_string);
1379
1381}
if(TABLE==NULL||TABLE_index==NULL)
void MemoryContextDelete(MemoryContext context)
#define CURSOR_OPT_BINARY
static ListCell * lnext(const List *l, const ListCell *c)
void PortalDrop(Portal portal, bool isTopCommit)
List * pg_plan_queries(List *querytrees, const char *query_string, int cursorOptions, ParamListInfo boundParams)
List * pg_analyze_and_rewrite_fixedparams(RawStmt *parsetree, const char *query_string, const Oid *paramTypes, int numParams, QueryEnvironment *queryEnv)
static int errdetail_execute(List *raw_parsetree_list)
void BeginImplicitTransactionBlock(void)
void EndImplicitTransactionBlock(void)
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, analyze_requires_snapshot(), Assert(), BeginCommand(), BeginImplicitTransactionBlock(), CHECK_FOR_INTERRUPTS, check_log_duration(), check_log_statement(), CommandCounterIncrement(), CreateCommandTag(), CreateDestReceiver(), CreatePortal(), CURSOR_OPT_BINARY, CURSOR_OPT_PARALLEL_OK, PortalData::cursorOptions, debug_query_string, generate_unaccent_rules::dest, DestRemote, disable_statement_timeout(), drop_unnamed_stmt(), EndCommand(), EndImplicitTransactionBlock(), ereport, errcode(), errdetail_abort(), errdetail_execute(), errhidestmt(), errmsg(), ERROR, FETCH_ALL, finish_xact_command(), format, GetCommandTagNameAndLen(), GetPortalByName(), GetTransactionSnapshot(), if(), InvalidSnapshot, IsA, IsAbortedTransactionBlockState(), IsTransactionExitStmt(), lfirst_node, list_length(), lnext(), LOG, log_statement_stats, MemoryContextDelete(), MemoryContextSwitchTo(), MessageContext, MyXactFlags, NullCommand(), pg_analyze_and_rewrite_fixedparams(), pg_parse_query(), pg_plan_queries(), pgstat_report_activity(), pgstat_report_plan_id(), pgstat_report_query_id(), PopActiveSnapshot(), PortalDefineQuery(), PortalDrop(), PortalIsValid, PortalRun(), PortalSetResultFormat(), PortalStart(), PushActiveSnapshot(), _DestReceiver::rDestroy, ResetUsage(), set_ps_display_with_len(), SetRemoteDestReceiverParams(), ShowUsage(), start_xact_command(), STATE_RUNNING, RawStmt::stmt, stmt, PortalData::visible, whereToSendOutput, and XACT_FLAGS_NEEDIMMEDIATECOMMIT.
Referenced by PostgresMain().
◆ finish_xact_command()
static void finish_xact_command ( void ) | static |
---|
◆ FloatExceptionHandler()
Definition at line 3073 of file postgres.c.
3074{
3075
3077 (errcode(ERRCODE_FLOATING_POINT_EXCEPTION),
3078 errmsg("floating-point exception"),
3079 errdetail("An invalid floating-point operation was signaled. "
3080 "This probably means an out-of-range result or an "
3081 "invalid operation, such as division by zero.")));
3082}
References ereport, errcode(), errdetail(), errmsg(), and ERROR.
Referenced by AutoVacLauncherMain(), AutoVacWorkerMain(), BackgroundWorkerMain(), plperl_init_interp(), PostgresMain(), and ReplSlotSyncWorkerMain().
◆ forbidden_in_wal_sender()
static void forbidden_in_wal_sender ( char firstchar) | static |
---|
◆ get_stats_option_name()
const char * get_stats_option_name | ( | const char * | arg | ) |
---|
Definition at line 3750 of file postgres.c.
3751{
3752 switch (arg[0])
3753 {
3754 case 'p':
3755 if (optarg[1] == 'a')
3756 return "log_parser_stats";
3757 else if (optarg[1] == 'l')
3758 return "log_planner_stats";
3759 break;
3760
3761 case 'e':
3762 return "log_executor_stats";
3763 break;
3764 }
3765
3766 return NULL;
3767}
PGDLLIMPORT char * optarg
Referenced by PostmasterMain(), and process_postgres_switches().
◆ HandleRecoveryConflictInterrupt()
◆ interactive_getc()
static int interactive_getc ( void ) | static |
---|
◆ InteractiveBackend()
static int InteractiveBackend ( StringInfo inBuf) | static |
---|
Definition at line 236 of file postgres.c.
237{
238 int c;
239
240
241
242
245
247
248
249
250
252 {
253 if (c == '\n')
254 {
256 {
257
258
259
260
261 if (inBuf->len > 1 &&
262 inBuf->data[inBuf->len - 1] == '\n' &&
263 inBuf->data[inBuf->len - 2] == ';')
264 {
265
266 break;
267 }
268 }
269 else
270 {
271
272
273
274
275 if (inBuf->len > 0 &&
276 inBuf->data[inBuf->len - 1] == '\\')
277 {
278
279 inBuf->data[--inBuf->len] = '\0';
280
281 continue;
282 }
283 else
284 {
285
287 break;
288 }
289 }
290 }
291
292
294 }
295
296
297 if (c == EOF && inBuf->len == 0)
298 return EOF;
299
300
301
302
303
304
306
307
308
309
311 printf("statement: %s\n", inBuf->data);
313
315}
static bool UseSemiNewlineNewline
static int interactive_getc(void)
void resetStringInfo(StringInfo str)
void appendStringInfoChar(StringInfo str, char ch)
References appendStringInfoChar(), StringInfoData::data, EchoQuery, interactive_getc(), StringInfoData::len, PqMsg_Query, printf, resetStringInfo(), generate_unaccent_rules::stdout, and UseSemiNewlineNewline.
Referenced by ReadCommand().
◆ IsTransactionExitStmt()
static bool IsTransactionExitStmt ( Node * parsetree) | static |
---|
◆ IsTransactionExitStmtList()
static bool IsTransactionExitStmtList ( List * pstmts) | static |
---|
◆ IsTransactionStmtList()
static bool IsTransactionStmtList ( List * pstmts) | static |
---|
◆ log_disconnections()
static void log_disconnections ( int code, Datum arg ) | static |
---|
Definition at line 5168 of file postgres.c.
5169{
5171 long secs;
5172 int usecs;
5173 int msecs;
5174 int hours,
5175 minutes,
5176 seconds;
5177
5180 &secs, &usecs);
5181 msecs = usecs / 1000;
5182
5187
5189 (errmsg("disconnection: session time: %d:%02d:%02d.%03d "
5190 "user=%s database=%s host=%s%s%s",
5191 hours, minutes, seconds, msecs,
5192 port->user_name, port->database_name, port->remote_host,
5193 port->remote_port[0] ? " port=" : "", port->remote_port)));
5194}
TimestampTz MyStartTimestamp
References ereport, errmsg(), GetCurrentTimestamp(), LOG, MyProcPort, MyStartTimestamp, port, SECS_PER_HOUR, SECS_PER_MINUTE, and TimestampDifference().
Referenced by PostgresMain().
◆ pg_analyze_and_rewrite_fixedparams()
List * pg_analyze_and_rewrite_fixedparams | ( | RawStmt * | parsetree, |
---|---|---|---|
const char * | query_string, | ||
const Oid * | paramTypes, | ||
int | numParams, | ||
QueryEnvironment * | queryEnv | ||
) |
Definition at line 665 of file postgres.c.
670{
672 List *querytree_list;
673
674 TRACE_POSTGRESQL_QUERY_REWRITE_START(query_string);
675
676
677
678
681
683 queryEnv);
684
686 ShowUsage("PARSE ANALYSIS STATISTICS");
687
688
689
690
692
693 TRACE_POSTGRESQL_QUERY_REWRITE_DONE(query_string);
694
695 return querytree_list;
696}
Query * parse_analyze_fixedparams(RawStmt *parseTree, const char *sourceText, const Oid *paramTypes, int numParams, QueryEnvironment *queryEnv)
List * pg_rewrite_query(Query *query)
References log_parser_stats, parse_analyze_fixedparams(), pg_rewrite_query(), ResetUsage(), and ShowUsage().
Referenced by _SPI_execute_plan(), _SPI_prepare_plan(), BeginCopyTo(), exec_simple_query(), execute_sql_string(), and RevalidateCachedQuery().
◆ pg_analyze_and_rewrite_varparams()
List * pg_analyze_and_rewrite_varparams | ( | RawStmt * | parsetree, |
---|---|---|---|
const char * | query_string, | ||
Oid ** | paramTypes, | ||
int * | numParams, | ||
QueryEnvironment * | queryEnv | ||
) |
Definition at line 704 of file postgres.c.
709{
711 List *querytree_list;
712
713 TRACE_POSTGRESQL_QUERY_REWRITE_START(query_string);
714
715
716
717
720
722 queryEnv);
723
724
725
726
727 for (int i = 0; i < *numParams; i++)
728 {
729 Oid ptype = (*paramTypes)[i];
730
731 if (ptype == InvalidOid || ptype == UNKNOWNOID)
733 (errcode(ERRCODE_INDETERMINATE_DATATYPE),
734 errmsg("could not determine data type of parameter $%d",
735 i + 1)));
736 }
737
739 ShowUsage("PARSE ANALYSIS STATISTICS");
740
741
742
743
745
746 TRACE_POSTGRESQL_QUERY_REWRITE_DONE(query_string);
747
748 return querytree_list;
749}
Query * parse_analyze_varparams(RawStmt *parseTree, const char *sourceText, Oid **paramTypes, int *numParams, QueryEnvironment *queryEnv)
References ereport, errcode(), errmsg(), ERROR, i, InvalidOid, log_parser_stats, parse_analyze_varparams(), pg_rewrite_query(), ResetUsage(), and ShowUsage().
Referenced by exec_parse_message(), and PrepareQuery().
◆ pg_analyze_and_rewrite_withcb()
Definition at line 758 of file postgres.c.
763{
765 List *querytree_list;
766
767 TRACE_POSTGRESQL_QUERY_REWRITE_START(query_string);
768
769
770
771
774
775 query = parse_analyze_withcb(parsetree, query_string, parserSetup, parserSetupArg,
776 queryEnv);
777
779 ShowUsage("PARSE ANALYSIS STATISTICS");
780
781
782
783
785
786 TRACE_POSTGRESQL_QUERY_REWRITE_DONE(query_string);
787
788 return querytree_list;
789}
Query * parse_analyze_withcb(RawStmt *parseTree, const char *sourceText, ParserSetupHook parserSetup, void *parserSetupArg, QueryEnvironment *queryEnv)
References log_parser_stats, parse_analyze_withcb(), pg_rewrite_query(), ResetUsage(), and ShowUsage().
Referenced by _SPI_execute_plan(), _SPI_prepare_plan(), fmgr_sql_validator(), inline_set_returning_function(), prepare_next_query(), and RevalidateCachedQuery().
◆ pg_parse_query()
List * pg_parse_query | ( | const char * | query_string | ) |
---|
Definition at line 603 of file postgres.c.
604{
605 List *raw_parsetree_list;
606
607 TRACE_POSTGRESQL_QUERY_PARSE_START(query_string);
608
611
613
616
617#ifdef DEBUG_NODE_TESTS_ENABLED
618
619
620 if (Debug_copy_parse_plan_trees)
621 {
623
624
626 elog(WARNING, "copyObject() failed to produce an equal raw parse tree");
627 else
628 raw_parsetree_list = new_list;
629 }
630
631
632
633
634
635 if (Debug_write_read_parse_plan_trees)
636 {
639
641
643 elog(WARNING, "outfuncs/readfuncs failed to produce an equal raw parse tree");
644 else
645 raw_parsetree_list = new_list;
646 }
647
648#endif
649
650 TRACE_POSTGRESQL_QUERY_PARSE_DONE(query_string);
651
652 return raw_parsetree_list;
653}
List * raw_parser(const char *str, RawParseMode mode)
bool equal(const void *a, const void *b)
static List * new_list(NodeTag type, int min_size)
char * nodeToStringWithLocations(const void *obj)
References copyObject, elog, equal(), log_parser_stats, new_list(), nodeToStringWithLocations(), pfree(), RAW_PARSE_DEFAULT, raw_parser(), ResetUsage(), ShowUsage(), str, and WARNING.
Referenced by exec_parse_message(), exec_simple_query(), execute_sql_string(), fmgr_sql_validator(), ImportForeignSchema(), inline_function(), inline_set_returning_function(), and sql_compile_callback().
◆ pg_plan_queries()
List * pg_plan_queries | ( | List * | querytrees, |
---|---|---|---|
const char * | query_string, | ||
int | cursorOptions, | ||
ParamListInfo | boundParams | ||
) |
Definition at line 970 of file postgres.c.
972{
975
976 foreach(query_list, querytrees)
977 {
980
982 {
983
986 stmt->canSetTag = query->canSetTag;
989 stmt->stmt_len = query->stmt_len;
990 stmt->queryId = query->queryId;
991 }
992 else
993 {
995 boundParams);
996 }
997
999 }
1000
1001 return stmt_list;
1002}
List * lappend(List *list, void *datum)
PlannedStmt * pg_plan_query(Query *querytree, const char *query_string, int cursorOptions, ParamListInfo boundParams)
References CMD_UTILITY, Query::commandType, lappend(), lfirst_node, makeNode, NIL, pg_plan_query(), stmt, Query::stmt_location, and Query::utilityStmt.
Referenced by BuildCachedPlan(), exec_simple_query(), and execute_sql_string().
◆ pg_plan_query()
Definition at line 882 of file postgres.c.
884{
886
887
889 return NULL;
890
891
893
894 TRACE_POSTGRESQL_QUERY_PLAN_START();
895
898
899
901
904
905#ifdef DEBUG_NODE_TESTS_ENABLED
906
907
908 if (Debug_copy_parse_plan_trees)
909 {
911
912
913
914
915
916#ifdef NOT_USED
917
919 elog(WARNING, "copyObject() failed to produce an equal plan tree");
920 else
921#endif
922 plan = new_plan;
923 }
924
925
926 if (Debug_write_read_parse_plan_trees)
927 {
928 char *str;
930
932 new_plan = stringToNodeWithLocations(str);
934
935
936
937
938
939#ifdef NOT_USED
940
942 elog(WARNING, "outfuncs/readfuncs failed to produce an equal plan tree");
943 else
944#endif
945 plan = new_plan;
946 }
947
948#endif
949
950
951
952
955
956 TRACE_POSTGRESQL_QUERY_PLAN_DONE();
957
959}
Datum querytree(PG_FUNCTION_ARGS)
void elog_node_display(int lev, const char *title, const void *obj, bool pretty)
PlannedStmt * planner(Query *parse, const char *query_string, int cursorOptions, ParamListInfo boundParams)
bool ActiveSnapshotSet(void)
References ActiveSnapshotSet(), Assert(), CMD_UTILITY, copyObject, Debug_pretty_print, Debug_print_plan, elog, elog_node_display(), equal(), LOG, log_planner_stats, nodeToStringWithLocations(), pfree(), plan, planner(), querytree(), ResetUsage(), ShowUsage(), str, and WARNING.
Referenced by BeginCopyTo(), ExecCreateTableAs(), PerformCursorOpen(), pg_plan_queries(), refresh_matview_datafill(), and standard_ExplainOneQuery().
◆ pg_rewrite_query()
Definition at line 798 of file postgres.c.
799{
800 List *querytree_list;
801
805
808
810 {
811
813 }
814 else
815 {
816
818 }
819
821 ShowUsage("REWRITER STATISTICS");
822
823#ifdef DEBUG_NODE_TESTS_ENABLED
824
825
826 if (Debug_copy_parse_plan_trees)
827 {
829
831
833 elog(WARNING, "copyObject() failed to produce an equal rewritten parse tree");
834 else
836 }
837
838
839 if (Debug_write_read_parse_plan_trees)
840 {
843
844 foreach(lc, querytree_list)
845 {
848 Query *new_query = stringToNodeWithLocations(str);
849
850
851
852
853
854 new_query->queryId = curr_query->queryId;
855
858 }
859
860
862 elog(WARNING, "outfuncs/readfuncs failed to produce an equal rewritten parse tree");
863 else
865 }
866
867#endif
868
872
873 return querytree_list;
874}
bool Debug_print_rewritten
List * QueryRewrite(Query *parsetree)
References CMD_UTILITY, Query::commandType, copyObject, Debug_pretty_print, Debug_print_parse, Debug_print_rewritten, elog, elog_node_display(), equal(), lappend(), lfirst_node, list_make1, LOG, log_parser_stats, new_list(), NIL, nodeToStringWithLocations(), pfree(), QueryRewrite(), ResetUsage(), ShowUsage(), str, and WARNING.
Referenced by fmgr_sql_validator(), inline_set_returning_function(), pg_analyze_and_rewrite_fixedparams(), pg_analyze_and_rewrite_varparams(), pg_analyze_and_rewrite_withcb(), prepare_next_query(), and RevalidateCachedQuery().
◆ PostgresMain()
void PostgresMain | ( | const char * | dbname, |
---|---|---|---|
const char * | username | ||
) |
Definition at line 4184 of file postgres.c.
4185{
4186 sigjmp_buf local_sigjmp_buf;
4187
4188
4189 volatile bool send_ready_for_query = true;
4190 volatile bool idle_in_transaction_timeout_enabled = false;
4191 volatile bool idle_session_timeout_enabled = false;
4192
4195
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4215 else
4216 {
4220
4221
4222
4223
4224
4225
4226
4227
4228
4231 else
4234
4235
4236
4237
4238
4239
4240
4245
4246
4247
4248
4249
4250 pqsignal(SIGCHLD, SIG_DFL);
4251
4252 }
4253
4254
4256
4257
4258 sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
4259
4260
4261
4262
4263
4266 {
4267 int len;
4268
4272 {
4274 (errcode(ERRCODE_INTERNAL_ERROR),
4275 errmsg("could not generate random cancel key")));
4276 }
4278 }
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4292 NULL);
4293
4294
4295
4296
4297
4299 {
4302 }
4303
4305
4306
4307
4308
4309
4311
4312
4313
4314
4315
4318
4320
4321
4324
4325
4326
4327
4329 {
4331
4335
4338
4339 }
4340
4341
4343 printf("\nPostgreSQL stand-alone backend %s\n", PG_VERSION);
4344
4345
4346
4347
4348
4349
4350
4352 "MessageContext",
4354
4355
4356
4357
4358
4359
4360
4362 "RowDescriptionContext",
4367
4368
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393 if (sigsetjmp(local_sigjmp_buf, 1) != 0)
4394 {
4395
4396
4397
4398
4399
4400
4401
4402
4403
4405
4406
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4422 idle_in_transaction_timeout_enabled = false;
4423 idle_session_timeout_enabled = false;
4424
4425
4427
4428
4430
4431
4433
4434
4435
4436
4437
4439
4440
4441
4442
4443
4445
4446
4447
4448
4450
4453
4455
4456
4457
4458
4459
4460
4461
4462
4465
4466
4468
4470
4471
4472
4473
4474
4477
4478
4479
4480
4481
4482
4485
4486
4488
4489
4490
4491
4492
4493
4494
4495
4496
4499 (errcode(ERRCODE_PROTOCOL_VIOLATION),
4500 errmsg("terminating connection because protocol synchronization was lost")));
4501
4502
4504 }
4505
4506
4508
4510 send_ready_for_query = true;
4511
4512
4513
4514
4515
4516 for (;;)
4517 {
4518 int firstchar;
4520
4521
4522
4523
4524
4526
4527
4528
4529
4530#ifdef USE_VALGRIND
4531 old_valgrind_error_count = VALGRIND_COUNT_ERRORS;
4532#endif
4533
4534
4535
4536
4537
4540
4542
4543
4544
4545
4546
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565 if (send_ready_for_query)
4566 {
4568 {
4571
4572
4575 {
4576 idle_in_transaction_timeout_enabled = true;
4579 }
4580 }
4582 {
4585
4586
4589 {
4590 idle_in_transaction_timeout_enabled = true;
4593 }
4594 }
4595 else
4596 {
4597 long stats_timeout;
4598
4599
4600
4601
4602
4603
4604
4605
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4623 if (stats_timeout > 0)
4624 {
4627 stats_timeout);
4628 }
4629 else
4630 {
4631
4634 }
4635
4638
4639
4641 {
4642 idle_session_timeout_enabled = true;
4645 }
4646 }
4647
4648
4650
4651
4652
4653
4654
4655
4659 {
4660 uint64 total_duration,
4661 fork_duration,
4662 auth_duration;
4663
4665
4666 total_duration =
4669 fork_duration =
4672 auth_duration =
4675
4677 errmsg("connection ready: setup total=%.3f ms, fork=%.3f ms, authentication=%.3f ms",
4678 (double) total_duration / NS_PER_US,
4679 (double) fork_duration / NS_PER_US,
4680 (double) auth_duration / NS_PER_US));
4681 }
4682
4684 send_ready_for_query = false;
4685 }
4686
4687
4688
4689
4690
4691
4692
4694
4695
4696
4697
4698 firstchar = ReadCommand(&input_message);
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708 if (idle_in_transaction_timeout_enabled)
4709 {
4711 idle_in_transaction_timeout_enabled = false;
4712 }
4713 if (idle_session_timeout_enabled)
4714 {
4716 idle_session_timeout_enabled = false;
4717 }
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4730
4731
4732
4733
4734
4736 {
4739 }
4740
4741
4742
4743
4744
4746 continue;
4747
4748 switch (firstchar)
4749 {
4751 {
4752 const char *query_string;
4753
4754
4756
4759
4761 {
4764 }
4765 else
4767
4769
4770 send_ready_for_query = true;
4771 }
4772 break;
4773
4775 {
4776 const char *stmt_name;
4777 const char *query_string;
4778 int numParams;
4779 Oid *paramTypes = NULL;
4780
4782
4783
4785
4788 numParams = pq_getmsgint(&input_message, 2);
4789 if (numParams > 0)
4790 {
4792 for (int i = 0; i < numParams; i++)
4793 paramTypes[i] = pq_getmsgint(&input_message, 4);
4794 }
4796
4798 paramTypes, numParams);
4799
4801 }
4802 break;
4803
4806
4807
4809
4810
4811
4812
4813
4815
4816
4817 break;
4818
4820 {
4821 const char *portal_name;
4822 int max_rows;
4823
4825
4826
4828
4832
4834
4835
4836 }
4837 break;
4838
4841
4842
4844
4845
4848
4849
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4863
4865
4866
4868
4870
4871 send_ready_for_query = true;
4872 break;
4873
4875 {
4876 int close_type;
4877 const char *close_target;
4878
4880
4884
4885 switch (close_type)
4886 {
4887 case 'S':
4888 if (close_target[0] != '\0')
4890 else
4891 {
4892
4894 }
4895 break;
4896 case 'P':
4897 {
4899
4903 }
4904 break;
4905 default:
4907 (errcode(ERRCODE_PROTOCOL_VIOLATION),
4908 errmsg("invalid CLOSE message subtype %d",
4909 close_type)));
4910 break;
4911 }
4912
4915
4917 }
4918 break;
4919
4921 {
4922 int describe_type;
4923 const char *describe_target;
4924
4926
4927
4929
4933
4934 switch (describe_type)
4935 {
4936 case 'S':
4938 break;
4939 case 'P':
4941 break;
4942 default:
4944 (errcode(ERRCODE_PROTOCOL_VIOLATION),
4945 errmsg("invalid DESCRIBE message subtype %d",
4946 describe_type)));
4947 break;
4948 }
4949
4951 }
4952 break;
4953
4958 break;
4959
4962
4963
4964
4965
4966
4967
4971 send_ready_for_query = true;
4972 break;
4973
4974
4975
4976
4977
4978
4979 case EOF:
4980
4981
4983
4984
4985
4987
4988
4989
4990
4991
4994
4995
4996
4997
4998
4999
5000
5001
5003
5007
5008
5009
5010
5011
5012
5013 break;
5014
5015 default:
5017 (errcode(ERRCODE_PROTOCOL_VIOLATION),
5018 errmsg("invalid frontend message type %d",
5019 firstchar)));
5020 }
5021 }
5022}
void ProcessNotifyInterrupt(bool flush)
volatile sig_atomic_t notifyInterruptPending
void DropPreparedStatement(const char *stmt_name, bool showError)
ConnectionTiming conn_timing
@ LOG_CONNECTION_SETUP_DURATIONS
@ STATE_IDLEINTRANSACTION_ABORTED
@ STATE_IDLEINTRANSACTION
#define TIMESTAMP_MINUS_INFINITY
void ReadyForQuery(CommandDest dest)
void EmitErrorReport(void)
void FlushErrorState(void)
sigjmp_buf * PG_exception_stack
void EventTriggerOnLogin(void)
void HandleFunctionRequest(StringInfo msgBuf)
volatile sig_atomic_t QueryCancelPending
uint8 MyCancelKey[MAX_CANCEL_KEY_LENGTH]
void ProcessConfigFile(GucContext context)
void BeginReportingGUCOptions(void)
void ReportChangedGUCOptions(void)
volatile sig_atomic_t ConfigReloadPending
void SignalHandlerForConfigReload(SIGNAL_ARGS)
void on_proc_exit(pg_on_exit_callback function, Datum arg)
void jit_reset_after_error(void)
void MemoryContextReset(MemoryContext context)
MemoryContext PostmasterContext
#define RESUME_INTERRUPTS()
#define IsExternalConnectionBackend(backend_type)
#define GetProcessingMode()
#define INIT_PG_LOAD_SESSION_LIBS
#define HOLD_INTERRUPTS()
#define SetProcessingMode(mode)
BackendType MyBackendType
long pgstat_report_stat(bool force)
void pgstat_report_connect(Oid dboid)
bool pg_strong_random(void *buf, size_t len)
void PortalErrorCleanup(void)
static void exec_describe_statement_message(const char *stmt_name)
void quickdie(SIGNAL_ARGS)
static void log_disconnections(int code, Datum arg)
static void forbidden_in_wal_sender(char firstchar)
static void exec_execute_message(const char *portal_name, long max_rows)
void FloatExceptionHandler(SIGNAL_ARGS)
void StatementCancelHandler(SIGNAL_ARGS)
static bool ignore_till_sync
static void exec_simple_query(const char *query_string)
static void exec_parse_message(const char *query_string, const char *stmt_name, Oid *paramTypes, int numParams)
static void exec_bind_message(StringInfo input_message)
static MemoryContext row_description_context
static bool doing_extended_query_message
static void exec_describe_portal_message(const char *portal_name)
static int ReadCommand(StringInfo inBuf)
void InitPostgres(const char *in_dbname, Oid dboid, const char *username, Oid useroid, bits32 flags, char *out_dbname)
bool pq_is_reading_msg(void)
#define PG_PROTOCOL(m, n)
void pq_sendbytes(StringInfo buf, const void *data, int datalen)
void pq_endmessage(StringInfo buf)
int pq_getmsgbyte(StringInfo msg)
void pq_beginmessage(StringInfo buf, char msgtype)
void procsignal_sigusr1_handler(SIGNAL_ARGS)
#define MAX_CANCEL_KEY_LENGTH
#define PqMsg_CloseComplete
#define PqMsg_BackendKeyData
ReplicationSlot * MyReplicationSlot
void ReplicationSlotRelease(void)
void ReplicationSlotCleanup(bool synced_only)
void InvalidateCatalogSnapshotConditionally(void)
int IdleInTransactionSessionTimeout
TimestampTz ready_for_use
TimestampTz socket_create
void disable_all_timeouts(bool keep_indicators)
void InitializeTimeouts(void)
@ IDLE_IN_TRANSACTION_SESSION_TIMEOUT
@ IDLE_STATS_UPDATE_TIMEOUT
static uint64 TimestampDifferenceMicroseconds(TimestampTz start_time, TimestampTz stop_time)
void WalSndErrorCleanup(void)
bool exec_replication_command(const char *cmd_string)
bool IsTransactionOrTransactionBlock(void)
void SetCurrentStatementStartTimestamp(void)
void AbortCurrentTransaction(void)
References AbortCurrentTransaction(), ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, am_walsender, Assert(), ConnectionTiming::auth_end, ConnectionTiming::auth_start, BaseInit(), BeginReportingGUCOptions(), buf, CHECK_FOR_INTERRUPTS, ConfigReloadPending, conn_timing, dbname, debug_query_string, DestDebug, DestNone, DestRemote, die(), disable_all_timeouts(), disable_timeout(), DISCONNECT_CLIENT_EOF, doing_extended_query_message, DoingCommandRead, drop_unnamed_stmt(), DropPreparedStatement(), EmitErrorReport(), enable_timeout_after(), EndImplicitTransactionBlock(), ereport, errcode(), errmsg(), ERROR, error_context_stack, EventTriggerOnLogin(), exec_bind_message(), exec_describe_portal_message(), exec_describe_statement_message(), exec_execute_message(), exec_parse_message(), exec_replication_command(), exec_simple_query(), FATAL, finish_xact_command(), FloatExceptionHandler(), FlushErrorState(), forbidden_in_wal_sender(), ConnectionTiming::fork_end, ConnectionTiming::fork_start, get_timeout_active(), GetCurrentTimestamp(), GetPortalByName(), GetProcessingMode, HandleFunctionRequest(), HOLD_INTERRUPTS, i, IDLE_IN_TRANSACTION_SESSION_TIMEOUT, IDLE_SESSION_TIMEOUT, IDLE_STATS_UPDATE_TIMEOUT, IdleInTransactionSessionTimeout, IdleSessionTimeout, ignore_till_sync, INIT_PG_LOAD_SESSION_LIBS, InitializeTimeouts(), InitPostgres(), InitProcessing, initStringInfo(), InitWalSender(), InvalidateCatalogSnapshotConditionally(), InvalidOid, IsAbortedTransactionBlockState(), IsExternalConnectionBackend, IsTransactionOrTransactionBlock(), IsUnderPostmaster, jit_reset_after_error(), len, LOG, LOG_CONNECTION_SETUP_DURATIONS, log_connections, Log_disconnections, log_disconnections(), MAX_CANCEL_KEY_LENGTH, MemoryContextDelete(), MemoryContextReset(), MemoryContextSwitchTo(), MessageContext, MyBackendType, MyCancelKey, MyCancelKeyLength, MyDatabaseId, MyProcPid, MyProcPort, MyReplicationSlot, NormalProcessing, notifyInterruptPending, NS_PER_US, on_proc_exit(), palloc_array, PG_exception_stack, PG_PROTOCOL, pg_strong_random(), PGC_SIGHUP, pgstat_report_activity(), pgstat_report_connect(), pgstat_report_stat(), pgStatSessionEndCause, PortalDrop(), PortalErrorCleanup(), PortalIsValid, PostmasterContext, pq_beginmessage(), pq_comm_reset, pq_endmessage(), pq_flush, pq_getmsgbyte(), pq_getmsgend(), pq_getmsgint(), pq_getmsgstring(), pq_is_reading_msg(), pq_putemptymessage(), pq_sendbytes(), pq_sendint32(), PqMsg_BackendKeyData, PqMsg_Bind, PqMsg_Close, PqMsg_CloseComplete, PqMsg_CopyData, PqMsg_CopyDone, PqMsg_CopyFail, PqMsg_Describe, PqMsg_Execute, PqMsg_Flush, PqMsg_FunctionCall, PqMsg_Parse, PqMsg_Query, PqMsg_Sync, PqMsg_Terminate, pqsignal, printf, proc_exit(), ProcessConfigFile(), ProcessNotifyInterrupt(), procsignal_sigusr1_handler(), Port::proto, QueryCancelPending, quickdie(), ReadCommand(), ConnectionTiming::ready_for_use, ReadyForQuery(), ReplicationSlotCleanup(), ReplicationSlotRelease(), ReportChangedGUCOptions(), RESUME_INTERRUPTS, row_description_buf, row_description_context, set_ps_display(), SetCurrentStatementStartTimestamp(), SetProcessingMode, SIGCHLD, SIGHUP, SignalHandlerForConfigReload(), SIGPIPE, SIGQUIT, SIGUSR1, SIGUSR2, ConnectionTiming::socket_create, start_xact_command(), STATE_FASTPATH, STATE_IDLE, STATE_IDLEINTRANSACTION, STATE_IDLEINTRANSACTION_ABORTED, StatementCancelHandler(), TIMESTAMP_MINUS_INFINITY, TimestampDifferenceMicroseconds(), TopMemoryContext, TransactionTimeout, UnBlockSig, username, valgrind_report_error_query, WalSndErrorCleanup(), WalSndSignals(), whereToSendOutput, and xact_started.
Referenced by BackendMain(), and PostgresSingleUserMain().
◆ PostgresSingleUserMain()
void PostgresSingleUserMain | ( | int | argc, |
---|---|---|---|
char * | _argv_[], | ||
const char * | username | ||
) |
Definition at line 4055 of file postgres.c.
4057{
4058 const char *dbname = NULL;
4059
4061
4062
4064
4065
4066
4067
4069
4070
4071
4072
4074
4075
4077 {
4081 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4082 errmsg("%s: no database nor user name specified",
4084 }
4085
4086
4089
4090
4091
4092
4093
4096
4097
4098
4099
4101
4102
4104
4105
4106
4107
4109
4110
4112
4113
4114
4115
4116
4118
4119
4121
4122
4123
4124
4126
4127
4128
4129
4130
4131
4133
4134
4135
4136
4137
4139
4140
4141
4142
4143
4145
4146
4147
4148
4149
4151
4152
4153
4154
4155
4157
4158
4159
4160
4161
4163
4164
4165
4166
4167
4169}
void set_max_safe_fds(void)
bool SelectConfigFiles(const char *userDoption, const char *progname)
void InitializeGUCOptions(void)
void InitializeShmemGUCs(void)
void CreateSharedMemoryAndSemaphores(void)
void ChangeToDataDir(void)
void process_shmem_requests(void)
void InitStandaloneProcess(const char *argv0)
void process_shared_preload_libraries(void)
void CreateDataDirLockFile(bool amPostmaster)
void InitPostmasterChildSlots(void)
void process_postgres_switches(int argc, char *argv[], GucContext ctx, const char **dbname)
static const char * userDoption
void PostgresMain(const char *dbname, const char *username)
void InitializeMaxBackends(void)
void InitializeFastPathLocks(void)
void InitializeWalConsistencyChecking(void)
void LocalProcessControlFile(bool reset)
References Assert(), ChangeToDataDir(), checkDataDir(), CreateDataDirLockFile(), CreateSharedMemoryAndSemaphores(), dbname, ereport, errcode(), errmsg(), FATAL, GetCurrentTimestamp(), InitializeFastPathLocks(), InitializeGUCOptions(), InitializeMaxBackends(), InitializeShmemGUCs(), InitializeWalConsistencyChecking(), InitPostmasterChildSlots(), InitProcess(), InitStandaloneProcess(), IsUnderPostmaster, LocalProcessControlFile(), PGC_POSTMASTER, PgStartTime, PostgresMain(), proc_exit(), process_postgres_switches(), process_shared_preload_libraries(), process_shmem_requests(), progname, SelectConfigFiles(), set_max_safe_fds(), userDoption, and username.
Referenced by main().
◆ process_postgres_switches()
void process_postgres_switches | ( | int | argc, |
---|---|---|---|
char * | _argv_[], | ||
GucContext | ctx, | ||
const char ** | dbname | ||
) |
Definition at line 3790 of file postgres.c.
3792{
3794 int errs = 0;
3797
3798 if (secure)
3799 {
3800 gucsource = PGC_S_ARGV;
3801
3802
3803 if (argc > 1 && strcmp(argv[1], "--single") == 0)
3804 {
3805 argv++;
3806 argc--;
3807 }
3808 }
3809 else
3810 {
3811 gucsource = PGC_S_CLIENT;
3812 }
3813
3814#ifdef HAVE_INT_OPTERR
3815
3816
3817
3818
3819
3820
3822#endif
3823
3824
3825
3826
3827
3828
3829 while ((flag = getopt(argc, argv, "B:bC:c:D:d:EeFf:h:ijk:lN:nOPp:r:S:sTt:v:W:-:")) != -1)
3830 {
3831 switch (flag)
3832 {
3833 case 'B':
3835 break;
3836
3837 case 'b':
3838
3839 if (secure)
3841 break;
3842
3843 case 'C':
3844
3845 break;
3846
3847 case '-':
3848
3849
3850
3851
3852
3853
3854
3857 (errcode(ERRCODE_SYNTAX_ERROR),
3858 errmsg("--%s must be first argument", optarg)));
3859
3860
3861 case 'c':
3862 {
3865
3868 {
3869 if (flag == '-')
3871 (errcode(ERRCODE_SYNTAX_ERROR),
3872 errmsg("--%s requires a value",
3874 else
3876 (errcode(ERRCODE_SYNTAX_ERROR),
3877 errmsg("-c %s requires a value",
3879 }
3883 break;
3884 }
3885
3886 case 'D':
3887 if (secure)
3889 break;
3890
3891 case 'd':
3893 break;
3894
3895 case 'E':
3896 if (secure)
3898 break;
3899
3900 case 'e':
3902 break;
3903
3904 case 'F':
3906 break;
3907
3908 case 'f':
3910 errs++;
3911 break;
3912
3913 case 'h':
3915 break;
3916
3917 case 'i':
3918 SetConfigOption("listen_addresses", "*", ctx, gucsource);
3919 break;
3920
3921 case 'j':
3922 if (secure)
3924 break;
3925
3926 case 'k':
3928 break;
3929
3930 case 'l':
3932 break;
3933
3934 case 'N':
3936 break;
3937
3938 case 'n':
3939
3940 break;
3941
3942 case 'O':
3943 SetConfigOption("allow_system_table_mods", "true", ctx, gucsource);
3944 break;
3945
3946 case 'P':
3947 SetConfigOption("ignore_system_indexes", "true", ctx, gucsource);
3948 break;
3949
3950 case 'p':
3952 break;
3953
3954 case 'r':
3955
3956 if (secure)
3958 break;
3959
3960 case 'S':
3962 break;
3963
3964 case 's':
3965 SetConfigOption("log_statement_stats", "true", ctx, gucsource);
3966 break;
3967
3968 case 'T':
3969
3970 break;
3971
3972 case 't':
3973 {
3975
3976 if (tmp)
3978 else
3979 errs++;
3980 break;
3981 }
3982
3983 case 'v':
3984
3985
3986
3987
3988
3989
3990
3991
3992 if (secure)
3994 break;
3995
3996 case 'W':
3998 break;
3999
4000 default:
4001 errs++;
4002 break;
4003 }
4004
4005 if (errs)
4006 break;
4007 }
4008
4009
4010
4011
4014
4015 if (errs || argc != optind)
4016 {
4017 if (errs)
4018 optind--;
4019
4020
4023 errcode(ERRCODE_SYNTAX_ERROR),
4024 errmsg("invalid command-line argument for server process: %s", argv[optind]),
4025 errhint("Try \"%s --help\" for more information.", progname));
4026 else
4028 errcode(ERRCODE_SYNTAX_ERROR),
4029 errmsg("%s: invalid command-line argument: %s",
4031 errhint("Try \"%s --help\" for more information.", progname));
4032 }
4033
4034
4035
4036
4037
4039#ifdef HAVE_INT_OPTRESET
4040 optreset = 1;
4041#endif
4042}
int errhint(const char *fmt,...)
ProtocolVersion FrontendProtocol
char OutputFileName[MAXPGPATH]
void SetConfigOption(const char *name, const char *value, GucContext context, GucSource source)
void ParseLongOption(const char *string, char **name, char **value)
DispatchOption parse_dispatch_option(const char *name)
int getopt(int nargc, char *const *nargv, const char *ostr)
size_t strlcpy(char *dst, const char *src, size_t siz)
void set_debug_options(int debug_flag, GucContext context, GucSource source)
bool set_plan_disabling_options(const char *arg, GucContext context, GucSource source)
const char * get_stats_option_name(const char *arg)
References dbname, DISPATCH_POSTMASTER, EchoQuery, ereport, errcode(), errhint(), errmsg(), ERROR, FATAL, flag(), FrontendProtocol, get_stats_option_name(), getopt(), IsBinaryUpgrade, IsUnderPostmaster, MAXPGPATH, name, optarg, opterr, optind, OutputFileName, parse_dispatch_option(), ParseLongOption(), pfree(), PGC_POSTMASTER, PGC_S_ARGV, PGC_S_CLIENT, progname, set_debug_options(), set_plan_disabling_options(), SetConfigOption(), strlcpy(), userDoption, UseSemiNewlineNewline, and value.
Referenced by PostgresSingleUserMain(), and process_startup_options().
◆ ProcessClientReadInterrupt()
void ProcessClientReadInterrupt | ( | bool | blocked | ) |
---|
◆ ProcessClientWriteInterrupt()
void ProcessClientWriteInterrupt | ( | bool | blocked | ) |
---|
◆ ProcessInterrupts()
void ProcessInterrupts | ( | void | ) |
---|
Definition at line 3298 of file postgres.c.
3299{
3300
3302 return;
3304
3306 {
3310
3315 (errcode(ERRCODE_QUERY_CANCELED),
3316 errmsg("canceling authentication due to timeout")));
3319 (errcode(ERRCODE_ADMIN_SHUTDOWN),
3320 errmsg("terminating autovacuum process due to administrator command")));
3323 (errcode(ERRCODE_ADMIN_SHUTDOWN),
3324 errmsg("terminating logical replication worker due to administrator command")));
3326 {
3328 (errmsg_internal("logical replication launcher shutting down")));
3329
3330
3331
3332
3333
3335 }
3338 (errcode(ERRCODE_ADMIN_SHUTDOWN),
3339 errmsg("terminating walreceiver process due to administrator command")));
3342 (errcode(ERRCODE_ADMIN_SHUTDOWN),
3343 errmsg("terminating background worker \"%s\" due to administrator command",
3346 {
3348 (errmsg_internal("io worker shutting down due to administrator command")));
3349
3351 }
3352 else
3354 (errcode(ERRCODE_ADMIN_SHUTDOWN),
3355 errmsg("terminating connection due to administrator command")));
3356 }
3357
3359 {
3361
3362
3363
3364
3365
3366
3367
3369 {
3372 else
3375 }
3376 }
3377
3379 {
3380 QueryCancelPending = false;
3382
3385 (errcode(ERRCODE_CONNECTION_FAILURE),
3386 errmsg("connection to client lost")));
3387 }
3388
3389
3390
3391
3392
3393
3394
3395
3396
3398 {
3399
3400
3401
3402
3403
3404
3405
3406
3408 }
3410 {
3411 bool lock_timeout_occurred;
3412 bool stmt_timeout_occurred;
3413
3415
3416
3417
3418
3419
3422
3423
3424
3425
3426
3427
3428
3429 if (lock_timeout_occurred && stmt_timeout_occurred &&
3431 lock_timeout_occurred = false;
3432
3433 if (lock_timeout_occurred)
3434 {
3437 (errcode(ERRCODE_LOCK_NOT_AVAILABLE),
3438 errmsg("canceling statement due to lock timeout")));
3439 }
3440 if (stmt_timeout_occurred)
3441 {
3444 (errcode(ERRCODE_QUERY_CANCELED),
3445 errmsg("canceling statement due to statement timeout")));
3446 }
3448 {
3451 (errcode(ERRCODE_QUERY_CANCELED),
3452 errmsg("canceling autovacuum task")));
3453 }
3454
3455
3456
3457
3458
3459
3461 {
3464 (errcode(ERRCODE_QUERY_CANCELED),
3465 errmsg("canceling statement due to user request")));
3466 }
3467 }
3468
3471
3473 {
3474
3475
3476
3477
3478
3479
3482 {
3483 INJECTION_POINT("idle-in-transaction-session-timeout", NULL);
3485 (errcode(ERRCODE_IDLE_IN_TRANSACTION_SESSION_TIMEOUT),
3486 errmsg("terminating connection due to idle-in-transaction timeout")));
3487 }
3488 }
3489
3491 {
3492
3495 {
3498 (errcode(ERRCODE_TRANSACTION_TIMEOUT),
3499 errmsg("terminating connection due to transaction timeout")));
3500 }
3501 }
3502
3504 {
3505
3508 {
3511 (errcode(ERRCODE_IDLE_SESSION_TIMEOUT),
3512 errmsg("terminating connection due to idle-session timeout")));
3513 }
3514 }
3515
3516
3517
3518
3519
3522 {
3525 }
3526
3529
3532
3535
3538}
volatile sig_atomic_t ParallelApplyMessagePending
void ProcessParallelApplyMessages(void)
void ProcessParallelMessages(void)
volatile sig_atomic_t ParallelMessagePending
bool IsLogicalWorker(void)
volatile sig_atomic_t IdleStatsUpdateTimeoutPending
volatile sig_atomic_t LogMemoryContextPending
volatile sig_atomic_t ProcSignalBarrierPending
volatile sig_atomic_t IdleSessionTimeoutPending
volatile uint32 QueryCancelHoldoffCount
volatile sig_atomic_t IdleInTransactionSessionTimeoutPending
volatile sig_atomic_t TransactionTimeoutPending
volatile sig_atomic_t ClientConnectionLost
volatile sig_atomic_t CheckClientConnectionPending
#define INJECTION_POINT(name, arg)
bool IsLogicalLauncher(void)
void ProcessLogMemoryContextInterrupt(void)
#define AmAutoVacuumWorkerProcess()
#define AmBackgroundWorkerProcess()
#define AmWalReceiverProcess()
#define AmIoWorkerProcess()
int client_connection_check_interval
static void ProcessRecoveryConflictInterrupts(void)
bool ClientAuthInProgress
BackgroundWorker * MyBgworkerEntry
bool pq_check_connection(void)
void ProcessProcSignalBarrier(void)
void LockErrorCleanup(void)
char bgw_type[BGW_MAXLEN]
TimestampTz get_timeout_finish_time(TimeoutId id)
bool get_timeout_indicator(TimeoutId id, bool reset_indicator)
@ CLIENT_CONNECTION_CHECK_TIMEOUT
References AmAutoVacuumWorkerProcess, AmBackgroundWorkerProcess, AmIoWorkerProcess, AmWalReceiverProcess, BackgroundWorker::bgw_type, CheckClientConnectionPending, client_connection_check_interval, CLIENT_CONNECTION_CHECK_TIMEOUT, ClientAuthInProgress, ClientConnectionLost, CritSectionCount, DEBUG1, DestNone, DestRemote, DoingCommandRead, enable_timeout_after(), ereport, errcode(), errmsg(), errmsg_internal(), ERROR, FATAL, get_timeout_finish_time(), get_timeout_indicator(), IdleInTransactionSessionTimeout, IdleInTransactionSessionTimeoutPending, IdleSessionTimeout, IdleSessionTimeoutPending, IdleStatsUpdateTimeoutPending, INJECTION_POINT, InterruptHoldoffCount, InterruptPending, IsLogicalLauncher(), IsLogicalWorker(), IsTransactionOrTransactionBlock(), LOCK_TIMEOUT, LockErrorCleanup(), LogMemoryContextPending, MyBgworkerEntry, ParallelApplyMessagePending, ParallelMessagePending, pgstat_report_stat(), pq_check_connection(), proc_exit(), ProcDiePending, ProcessLogMemoryContextInterrupt(), ProcessParallelApplyMessages(), ProcessParallelMessages(), ProcessProcSignalBarrier(), ProcessRecoveryConflictInterrupts(), ProcSignalBarrierPending, QueryCancelHoldoffCount, QueryCancelPending, RecoveryConflictPending, STATEMENT_TIMEOUT, TransactionTimeout, TransactionTimeoutPending, and whereToSendOutput.
Referenced by die().
◆ ProcessRecoveryConflictInterrupt()
Definition at line 3101 of file postgres.c.
3102{
3103 switch (reason)
3104 {
3106
3107
3108
3109
3111 return;
3112
3113
3114
3115
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3129 {
3133 return;
3134 }
3135
3137
3138
3139
3140
3144
3145
3146
3147
3149 return;
3150
3151
3152
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3182 {
3183
3184
3185
3186
3187
3189 return;
3190
3191
3192
3193
3194
3195
3196
3197
3199 {
3200
3202 {
3203
3204
3205
3206
3210 return;
3211 }
3212
3213
3214
3215
3216
3217
3218
3223 errmsg("canceling statement due to conflict with recovery"),
3225 break;
3226 }
3227 }
3228
3229
3230
3231
3233
3234
3235
3236
3237
3238
3242 ERRCODE_DATABASE_DROPPED :
3244 errmsg("terminating connection due to conflict with recovery"),
3246 errhint("In a moment you should be able to reconnect to the"
3247 " database and repeat your command.")));
3248 break;
3249
3250 default:
3251 elog(FATAL, "unrecognized conflict mode: %d", (int) reason);
3252 }
3253}
bool HoldingBufferPinThatDelaysRecovery(void)
LOCALLOCK * GetAwaitedLock(void)
#define ERRCODE_T_R_SERIALIZATION_FAILURE
void pgstat_report_recovery_conflict(int reason)
static int errdetail_recovery_conflict(ProcSignalReason reason)
int GetStartupBufferPinWaitBufId(void)
void CheckDeadLockAlert(void)
bool IsSubTransaction(void)
References CheckDeadLockAlert(), DoingCommandRead, elog, ereport, errcode(), ERRCODE_T_R_SERIALIZATION_FAILURE, errdetail_recovery_conflict(), errhint(), errmsg(), ERROR, FATAL, GetAwaitedLock(), GetStartupBufferPinWaitBufId(), HoldingBufferPinThatDelaysRecovery(), InterruptPending, IsAbortedTransactionBlockState(), IsSubTransaction(), IsTransactionOrTransactionBlock(), LockErrorCleanup(), MyProc, pgstat_report_recovery_conflict(), PROCSIG_RECOVERY_CONFLICT_BUFFERPIN, PROCSIG_RECOVERY_CONFLICT_DATABASE, PROCSIG_RECOVERY_CONFLICT_LOCK, PROCSIG_RECOVERY_CONFLICT_LOGICALSLOT, PROCSIG_RECOVERY_CONFLICT_SNAPSHOT, PROCSIG_RECOVERY_CONFLICT_STARTUP_DEADLOCK, PROCSIG_RECOVERY_CONFLICT_TABLESPACE, QueryCancelHoldoffCount, RecoveryConflictPending, PGPROC::recoveryConflictPending, and RecoveryConflictPendingReasons.
Referenced by ProcessRecoveryConflictInterrupts().
◆ ProcessRecoveryConflictInterrupts()
static void ProcessRecoveryConflictInterrupts ( void ) | static |
---|
◆ quickdie()
Definition at line 2929 of file postgres.c.
2930{
2931 sigaddset(&BlockSig, SIGQUIT);
2932 sigprocmask(SIG_SETMASK, &BlockSig, NULL);
2933
2934
2935
2936
2937
2938
2940
2941
2942
2943
2944
2945
2946
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2967
2968
2969
2970
2971
2972
2973
2974
2975
2977 {
2979
2981 (errcode(ERRCODE_ADMIN_SHUTDOWN),
2982 errmsg("terminating connection because of unexpected SIGQUIT signal")));
2983 break;
2985
2987 (errcode(ERRCODE_CRASH_SHUTDOWN),
2988 errmsg("terminating connection because of crash of another server process"),
2989 errdetail("The postmaster has commanded this server process to roll back"
2990 " the current transaction and exit, because another"
2991 " server process exited abnormally and possibly corrupted"
2992 " shared memory."),
2993 errhint("In a moment you should be able to reconnect to the"
2994 " database and repeat your command.")));
2995 break;
2997
2999 (errcode(ERRCODE_ADMIN_SHUTDOWN),
3000 errmsg("terminating connection due to immediate shutdown command")));
3001 break;
3002 }
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018 _exit(2);
3019}
#define WARNING_CLIENT_ONLY
QuitSignalReason GetQuitSignalReason(void)
References BlockSig, ClientAuthInProgress, DestNone, DestRemote, ereport, errcode(), errdetail(), errhint(), errmsg(), error_context_stack, GetQuitSignalReason(), HOLD_INTERRUPTS, PMQUIT_FOR_CRASH, PMQUIT_FOR_STOP, PMQUIT_NOT_SENT, SIGQUIT, WARNING, WARNING_CLIENT_ONLY, and whereToSendOutput.
Referenced by PostgresMain().
◆ ReadCommand()
◆ ResetUsage()
Definition at line 5052 of file postgres.c.
5053{
5056}
static struct timeval Save_t
static struct rusage Save_r
int getrusage(int who, struct rusage *rusage)
int gettimeofday(struct timeval *tp, void *tzp)
References getrusage(), gettimeofday(), RUSAGE_SELF, Save_r, and Save_t.
Referenced by _bt_leader_participate_as_worker(), _bt_leafbuild(), _bt_parallel_build_main(), _SPI_pquery(), btbuild(), exec_bind_message(), exec_execute_message(), exec_parse_message(), exec_simple_query(), pg_analyze_and_rewrite_fixedparams(), pg_analyze_and_rewrite_varparams(), pg_analyze_and_rewrite_withcb(), pg_parse_query(), pg_plan_query(), pg_rewrite_query(), PortalRun(), and PortalRunMulti().
◆ set_debug_options()
◆ set_plan_disabling_options()
Definition at line 3708 of file postgres.c.
3709{
3710 const char *tmp = NULL;
3711
3712 switch (arg[0])
3713 {
3714 case 's':
3715 tmp = "enable_seqscan";
3716 break;
3717 case 'i':
3718 tmp = "enable_indexscan";
3719 break;
3720 case 'o':
3721 tmp = "enable_indexonlyscan";
3722 break;
3723 case 'b':
3724 tmp = "enable_bitmapscan";
3725 break;
3726 case 't':
3727 tmp = "enable_tidscan";
3728 break;
3729 case 'n':
3730 tmp = "enable_nestloop";
3731 break;
3732 case 'm':
3733 tmp = "enable_mergejoin";
3734 break;
3735 case 'h':
3736 tmp = "enable_hashjoin";
3737 break;
3738 }
3739 if (tmp)
3740 {
3742 return true;
3743 }
3744 else
3745 return false;
3746}
References arg, SetConfigOption(), and source.
Referenced by PostmasterMain(), and process_postgres_switches().
◆ ShowUsage()
void ShowUsage | ( | const char * | title | ) |
---|
Definition at line 5059 of file postgres.c.
5060{
5062 struct timeval user,
5063 sys;
5064 struct timeval elapse_t;
5066
5069 memcpy(&user, &r.ru_utime, sizeof(user));
5070 memcpy(&sys, &r.ru_stime, sizeof(sys));
5071 if (elapse_t.tv_usec < Save_t.tv_usec)
5072 {
5073 elapse_t.tv_sec--;
5074 elapse_t.tv_usec += 1000000;
5075 }
5077 {
5078 r.ru_utime.tv_sec--;
5079 r.ru_utime.tv_usec += 1000000;
5080 }
5082 {
5083 r.ru_stime.tv_sec--;
5084 r.ru_stime.tv_usec += 1000000;
5085 }
5086
5087
5088
5089
5090
5092
5095 "!\t%ld.%06ld s user, %ld.%06ld s system, %ld.%06ld s elapsed\n",
5096 (long) (r.ru_utime.tv_sec - Save_r.ru_utime.tv_sec),
5097 (long) (r.ru_utime.tv_usec - Save_r.ru_utime.tv_usec),
5098 (long) (r.ru_stime.tv_sec - Save_r.ru_stime.tv_sec),
5099 (long) (r.ru_stime.tv_usec - Save_r.ru_stime.tv_usec),
5100 (long) (elapse_t.tv_sec - Save_t.tv_sec),
5101 (long) (elapse_t.tv_usec - Save_t.tv_usec));
5103 "!\t[%ld.%06ld s user, %ld.%06ld s system total]\n",
5104 (long) user.tv_sec,
5105 (long) user.tv_usec,
5106 (long) sys.tv_sec,
5107 (long) sys.tv_usec);
5108#ifndef WIN32
5109
5110
5111
5112
5113
5114
5115
5117 "!\t%ld kB max resident size\n",
5119
5120 r.ru_maxrss / 1024
5121#else
5122
5123 r.ru_maxrss
5124#endif
5125 );
5127 "!\t%ld/%ld [%ld/%ld] filesystem blocks in/out\n",
5128 r.ru_inblock - Save_r.ru_inblock,
5129
5130 r.ru_oublock - Save_r.ru_oublock,
5131 r.ru_inblock, r.ru_oublock);
5133 "!\t%ld/%ld [%ld/%ld] page faults/reclaims, %ld [%ld] swaps\n",
5134 r.ru_majflt - Save_r.ru_majflt,
5135 r.ru_minflt - Save_r.ru_minflt,
5136 r.ru_majflt, r.ru_minflt,
5137 r.ru_nswap - Save_r.ru_nswap,
5138 r.ru_nswap);
5140 "!\t%ld [%ld] signals rcvd, %ld/%ld [%ld/%ld] messages rcvd/sent\n",
5141 r.ru_nsignals - Save_r.ru_nsignals,
5142 r.ru_nsignals,
5143 r.ru_msgrcv - Save_r.ru_msgrcv,
5144 r.ru_msgsnd - Save_r.ru_msgsnd,
5145 r.ru_msgrcv, r.ru_msgsnd);
5147 "!\t%ld/%ld [%ld/%ld] voluntary/involuntary context switches\n",
5148 r.ru_nvcsw - Save_r.ru_nvcsw,
5149 r.ru_nivcsw - Save_r.ru_nivcsw,
5150 r.ru_nvcsw, r.ru_nivcsw);
5151#endif
5152
5153
5154 if (str.data[str.len - 1] == '\n')
5155 str.data[--str.len] = '\0';
5156
5160
5162}
int errdetail_internal(const char *fmt,...)
void appendStringInfo(StringInfo str, const char *fmt,...)
void appendStringInfoString(StringInfo str, const char *s)
References __darwin__, appendStringInfo(), appendStringInfoString(), ereport, errdetail_internal(), errmsg_internal(), getrusage(), gettimeofday(), initStringInfo(), LOG, pfree(), rusage::ru_stime, rusage::ru_utime, RUSAGE_SELF, Save_r, Save_t, str, and user.
Referenced by _bt_leader_participate_as_worker(), _bt_leafbuild(), _bt_parallel_build_main(), _SPI_pquery(), btbuild(), exec_bind_message(), exec_execute_message(), exec_parse_message(), exec_simple_query(), pg_analyze_and_rewrite_fixedparams(), pg_analyze_and_rewrite_varparams(), pg_analyze_and_rewrite_withcb(), pg_parse_query(), pg_plan_query(), pg_rewrite_query(), PortalRun(), and PortalRunMulti().
◆ SocketBackend()
static int SocketBackend ( StringInfo inBuf) | static |
---|
Definition at line 352 of file postgres.c.
353{
354 int qtype;
355 int maxmsglen;
356
357
358
359
363
364 if (qtype == EOF)
365 {
368 (errcode(ERRCODE_CONNECTION_FAILURE),
369 errmsg("unexpected EOF on client connection with an open transaction")));
370 else
371 {
372
373
374
375
376
379 (errcode(ERRCODE_CONNECTION_DOES_NOT_EXIST),
380 errmsg_internal("unexpected EOF on client connection")));
381 }
382 return qtype;
383 }
384
385
386
387
388
389
390
391
392
393
394
395 switch (qtype)
396 {
400 break;
401
405 break;
406
411 break;
412
417 break;
418
425 break;
426
429
431
433 break;
434
438 break;
439
444 break;
445
446 default:
447
448
449
450
451
452
454 (errcode(ERRCODE_PROTOCOL_VIOLATION),
455 errmsg("invalid frontend message type %d", qtype)));
456 maxmsglen = 0;
457 break;
458 }
459
460
461
462
463
464
466 return EOF;
468
469 return qtype;
470}
#define PQ_SMALL_MESSAGE_LIMIT
#define PQ_LARGE_MESSAGE_LIMIT
#define HOLD_CANCEL_INTERRUPTS()
#define RESUME_CANCEL_INTERRUPTS()
int pq_getmessage(StringInfo s, int maxlen)
void pq_startmsgread(void)
References COMMERROR, DEBUG1, DestNone, doing_extended_query_message, ereport, errcode(), errmsg(), errmsg_internal(), FATAL, HOLD_CANCEL_INTERRUPTS, ignore_till_sync, IsTransactionState(), pq_getbyte(), pq_getmessage(), PQ_LARGE_MESSAGE_LIMIT, PQ_SMALL_MESSAGE_LIMIT, pq_startmsgread(), PqMsg_Bind, PqMsg_Close, PqMsg_CopyData, PqMsg_CopyDone, PqMsg_CopyFail, PqMsg_Describe, PqMsg_Execute, PqMsg_Flush, PqMsg_FunctionCall, PqMsg_Parse, PqMsg_Query, PqMsg_Sync, PqMsg_Terminate, RESUME_CANCEL_INTERRUPTS, and whereToSendOutput.
Referenced by ReadCommand().
◆ start_xact_command()
static void start_xact_command ( void ) | static |
---|
Definition at line 2786 of file postgres.c.
2787{
2789 {
2791
2793 }
2795 {
2796
2797
2798
2799
2800
2801
2802
2804 }
2805
2806
2807
2808
2809
2810
2811
2812
2814
2815
2822}
static void enable_statement_timeout(void)
void StartTransactionCommand(void)
References BeginImplicitTransactionBlock(), client_connection_check_interval, CLIENT_CONNECTION_CHECK_TIMEOUT, enable_statement_timeout(), enable_timeout_after(), get_timeout_active(), IsUnderPostmaster, MyProcPort, MyXactFlags, StartTransactionCommand(), XACT_FLAGS_PIPELINING, and xact_started.
Referenced by exec_bind_message(), exec_describe_portal_message(), exec_describe_statement_message(), exec_execute_message(), exec_parse_message(), exec_simple_query(), and PostgresMain().
◆ StatementCancelHandler()
◆ client_connection_check_interval
int client_connection_check_interval = 0
◆ debug_query_string
const char* debug_query_string
Definition at line 88 of file postgres.c.
Referenced by _brin_begin_parallel(), _brin_parallel_build_main(), _bt_begin_parallel(), _bt_parallel_build_main(), _gin_begin_parallel(), _gin_parallel_build_main(), check_log_of_query(), current_query(), errstart(), exec_bind_message(), exec_execute_message(), exec_parse_message(), exec_replication_command(), exec_simple_query(), initialize_worker_spi(), parallel_vacuum_init(), parallel_vacuum_main(), ParallelQueryMain(), PostgresMain(), proc_exit_prepare(), send_message_to_server_log(), worker_spi_main(), write_csvlog(), and write_jsonlog().
◆ doing_extended_query_message
bool doing_extended_query_message = false | static |
---|
◆ DoingCommandRead
bool DoingCommandRead = false | static |
---|
◆ EchoQuery
◆ ignore_till_sync
bool ignore_till_sync = false | static |
---|
◆ Log_disconnections
bool Log_disconnections = false
◆ log_statement
◆ PostAuthDelay
◆ RecoveryConflictPending
volatile sig_atomic_t RecoveryConflictPending = false | static |
---|
◆ RecoveryConflictPendingReasons
◆ restrict_nonsystem_relation_kind
int restrict_nonsystem_relation_kind
◆ row_description_buf
◆ row_description_context
◆ Save_r
◆ Save_t
◆ unnamed_stmt_psrc
◆ userDoption
const char* userDoption = NULL | static |
---|
◆ UseSemiNewlineNewline
bool UseSemiNewlineNewline = false | static |
---|
◆ whereToSendOutput
Definition at line 91 of file postgres.c.
Referenced by BackendInitialize(), BeginCopyFrom(), BeginCopyTo(), BeginReportingGUCOptions(), die(), DoCopyTo(), errfinish(), exec_bind_message(), exec_describe_portal_message(), exec_describe_statement_message(), exec_execute_message(), exec_parse_message(), exec_simple_query(), NotifyMyFrontEnd(), PostgresMain(), PostmasterMain(), pq_cleanup_redirect_to_shm_mq(), pq_redirect_to_shm_mq(), ProcessClientWriteInterrupt(), ProcessInterrupts(), quickdie(), ReadCommand(), send_message_to_server_log(), should_output_to_client(), SocketBackend(), SyncRepWaitForLSN(), SysLoggerMain(), and WalSndShutdown().
◆ xact_started
bool xact_started = false | static |
---|