|
PostgreSQL Source Code git master
|
#include "postgres_fe.h"#include <ctype.h>#include <limits.h>#include <math.h>#include <pwd.h>#include <signal.h>#include <unistd.h>#include "command.h"#include "common.h"#include "common/logging.h"#include "copy.h"#include "crosstabview.h"#include "fe_utils/cancel.h"#include "fe_utils/mbprint.h"#include "fe_utils/string_utils.h"#include "portability/instr_time.h"#include "settings.h"
Go to the source code of this file.
Variables | |
| volatile sig_atomic_t | sigint_interrupt_enabled = false |
| sigjmp_buf | sigint_interrupt_jmp |
Definition at line 416 of file common.c.
References CheckConnection(), _psqlSettings::db, error(), fb(), pg_log_error, pg_log_info, PGRES_BAD_RESPONSE, PGRES_COMMAND_OK, PGRES_COPY_IN, PGRES_COPY_OUT, PGRES_EMPTY_QUERY, PGRES_FATAL_ERROR, PGRES_NONFATAL_ERROR, PGRES_PIPELINE_ABORTED, PGRES_PIPELINE_SYNC, PGRES_TUPLES_CHUNK, PGRES_TUPLES_OK, PQerrorMessage(), PQresultStatus, and pset.
Referenced by DescribeQuery(), ExecQueryAndProcessResults(), and PSQLexec().
Definition at line 354 of file common.c.
References _, connection_warnings(), ConnectionUp(), _psqlSettings::cur_cmd_interactive, _psqlSettings::db, _psqlSettings::dead_conn, EXIT_BADCONN, fb(), fprintf, pg_log_error, pipelineReset(), PQfinish(), PQreset(), pset, ResetCancelConn(), SyncVariables(), and UnsyncVariables().
Referenced by AcceptResult(), and ExecQueryAndProcessResults().
Definition at line 2660 of file common.c.
References _psqlSettings::bind_nparams, _psqlSettings::bind_params, fb(), free, i, pset, PSQL_SEND_END_PIPELINE_MODE, PSQL_SEND_EXTENDED_CLOSE, PSQL_SEND_EXTENDED_PARSE, PSQL_SEND_EXTENDED_QUERY_PARAMS, PSQL_SEND_EXTENDED_QUERY_PREPARED, PSQL_SEND_FLUSH, PSQL_SEND_FLUSH_REQUEST, PSQL_SEND_GET_RESULTS, PSQL_SEND_PIPELINE_SYNC, PSQL_SEND_QUERY, PSQL_SEND_START_PIPELINE_MODE, _psqlSettings::send_mode, and _psqlSettings::stmtName.
Referenced by exec_command_bind(), exec_command_bind_named(), exec_command_close_prepared(), exec_command_g(), exec_command_gexec(), exec_command_gset(), exec_command_parse(), exec_command_sendpipeline(), exec_command_watch(), and SendQuery().
Definition at line 582 of file common.c.
References ClearOrSaveResult(), _psqlSettings::db, fb(), PQgetResult, and pset.
Referenced by ExecQueryAndProcessResults().
Definition at line 558 of file common.c.
References _psqlSettings::last_error_result, PGRES_FATAL_ERROR, PGRES_NONFATAL_ERROR, PQclear, PQresultStatus, and pset.
Referenced by ClearOrSaveAllResults(), DescribeQuery(), ExecQueryAndProcessResults(), PSQLexec(), and SendQuery().
Definition at line 110 of file common.c.
References fb(), restore_sigpipe_trap(), and SetShellResultVariables().
Referenced by ExecQueryAndProcessResults().
Definition at line 2265 of file common.c.
References _psqlSettings::encoding, fb(), pg_strncasecmp(), PQmblenBounded(), pset, and skip_white_space().
Referenced by SendQuery().
Definition at line 336 of file common.c.
References CONNECTION_BAD, _psqlSettings::db, PQstatus(), and pset.
Referenced by CheckConnection(), and SendQuery().
Definition at line 1350 of file common.c.
References _, AcceptResult(), appendPQExpBuffer(), appendPQExpBufferChar(), appendPQExpBufferStr(), before(), buf, ClearOrSaveResult(), _psqlSettings::db, fb(), fprintf, gettext_noop, i, initPQExpBuffer(), INSTR_TIME_GET_MILLISEC, INSTR_TIME_SET_CURRENT, INSTR_TIME_SET_ZERO, INSTR_TIME_SUBTRACT, name, pg_log_info, PGRES_COMMAND_OK, PQclear, PQdescribePrepared(), PQerrorMessage(), PQescapeLiteral(), PQexec(), PQfmod(), PQfname, PQfreemem(), PQftype(), PQnfields, PQprepare(), PQresultStatus, printfPQExpBuffer(), PrintQueryResult(), pset, _psqlSettings::queryFout, SetResultVariables(), termPQExpBuffer(), and _psqlSettings::timing.
Referenced by SendQuery().
Definition at line 1466 of file common.c.
References Assert, _psqlSettings::available_results, _psqlSettings::db, fb(), PG_USED_FOR_ASSERTS_ONLY, PGRES_FATAL_ERROR, PGRES_PIPELINE_ABORTED, PGRES_PIPELINE_SYNC, _psqlSettings::piped_syncs, PQclear, PQgetResult, PQresultStatus, pset, and _psqlSettings::requested_results.
Referenced by ExecQueryAndProcessResults().
|
static |
Definition at line 1556 of file common.c.
References AcceptResult(), Assert, _psqlSettings::available_results, before(), _psqlSettings::bind_nparams, _psqlSettings::bind_params, buf, cancel_pressed, CheckConnection(), ClearOrSaveAllResults(), ClearOrSaveResult(), CloseGOutput(), ClosePager(), _psqlSettings::copyStream, _psqlSettings::crosstab_flag, _psqlSettings::db, discardAbortedPipelineResults(), error(), EXIT_BADCONN, fb(), _psqlSettings::fetch_count, _psqlSettings::gexec_flag, _psqlSettings::gfname, _psqlSettings::gset_prefix, HandleCopyResult(), INSTR_TIME_GET_MILLISEC, INSTR_TIME_SET_CURRENT, INSTR_TIME_SET_ZERO, INSTR_TIME_SUBTRACT, INT64_FORMAT, _psqlSettings::logfile, PageOutput(), pg_log_info, pg_log_warning, PGRES_COPY_BOTH, PGRES_COPY_IN, PGRES_COPY_OUT, PGRES_PIPELINE_ABORTED, PGRES_PIPELINE_SYNC, PGRES_TUPLES_CHUNK, PGRES_TUPLES_OK, _psqlSettings::piped_commands, _psqlSettings::piped_syncs, _psqlSettings::popt, PQ_PIPELINE_OFF, PQcmdStatus, PQenterPipelineMode(), PQerrorMessage(), PQexitPipelineMode(), PQflush(), PQgetResult, PQntuples, PQpipelineStatus(), PQpipelineSync(), PQresultErrorMessage, PQresultStatus, PQsendClosePrepared(), PQsendFlushRequest(), PQsendPipelineSync(), PQsendPrepare(), PQsendQuery(), PQsendQueryParams(), PQsendQueryPrepared(), PQsetChunkedRowsMode(), printQuery(), PrintQueryResult(), PrintQueryStatus(), pset, PSQL_SEND_END_PIPELINE_MODE, PSQL_SEND_EXTENDED_CLOSE, PSQL_SEND_EXTENDED_PARSE, PSQL_SEND_EXTENDED_QUERY_PARAMS, PSQL_SEND_EXTENDED_QUERY_PREPARED, PSQL_SEND_FLUSH, PSQL_SEND_FLUSH_REQUEST, PSQL_SEND_GET_RESULTS, PSQL_SEND_PIPELINE_SYNC, PSQL_SEND_QUERY, PSQL_SEND_START_PIPELINE_MODE, _psqlSettings::queryFout, _psqlSettings::requested_results, _psqlSettings::send_mode, SetPipelineVariables(), SetResultVariables(), SetupGOutput(), SetVariable(), _psqlSettings::show_all_results, snprintf, printTableOpt::start_table, _psqlSettings::stmtName, success, _psqlSettings::timing, printQueryOpt::topt, and _psqlSettings::vars.
Referenced by PSQLexecWatch(), and SendQuery().
Definition at line 861 of file common.c.
References cancel_pressed, _psqlSettings::echo, fb(), _psqlSettings::gexec_flag, _psqlSettings::on_error_stop, PQgetisnull, PQgetvalue, PQnfields, PQntuples, pset, PSQL_ECHO_ALL, SendQuery(), _psqlSettings::singlestep, and success.
Referenced by PrintQueryResult().
Definition at line 2576 of file common.c.
References fb(), filename, fn(), free, get_home_path(), MAXPGPATH, psprintf(), and strlcpy().
Referenced by exec_command_edit(), exec_command_g(), exec_command_include(), exec_command_lo(), exec_command_out(), exec_command_s(), exec_command_write(), initializeInput(), parse_slash_copy(), and process_psqlrc().
Definition at line 2540 of file common.c.
References _psqlSettings::db, fb(), opts, pg_strdup(), PQconninfo(), PQconninfoFree(), and pset.
Referenced by SyncVariables().
Definition at line 937 of file common.c.
References Assert, _psqlSettings::copyStream, _psqlSettings::cur_cmd_source, _psqlSettings::db, fb(), handleCopyIn(), handleCopyOut(), PGRES_COPY_IN, PGRES_COPY_OUT, PQbinaryTuples(), PQclear, PQresultStatus, pset, _psqlSettings::queryFout, ResetCancelConn(), SetCancelConn(), and success.
Referenced by ExecQueryAndProcessResults().
Definition at line 2480 of file common.c.
References _psqlSettings::db, fb(), PQparameterStatus(), pset, and val.
Referenced by check_role(), check_session_authorization(), get_prompt(), getSubscriptions(), InitializeSessionUserId(), SetCurrentRoleId(), SetOuterUserId(), SetSessionAuthorization(), and SetSessionUserId().
Definition at line 279 of file common.c.
References arg, fb(), and pg_log_info.
Referenced by do_connect(), and main().
Definition at line 56 of file common.c.
References fb(), and pg_log_error.
Referenced by setQFout(), and SetupGOutput().
Definition at line 128 of file common.c.
References _psqlSettings::available_results, _psqlSettings::piped_commands, _psqlSettings::piped_syncs, pset, and _psqlSettings::requested_results.
Referenced by CheckConnection().
Definition at line 740 of file common.c.
References _, _psqlSettings::db, fb(), fprintf, PQconsumeInput(), PQfreemem(), PQnotifies(), pset, and _psqlSettings::queryFout.
Referenced by SendQuery().
|
static |
Definition at line 1039 of file common.c.
References _psqlSettings::crosstab_flag, ExecQueryTuples(), fb(), _psqlSettings::gexec_flag, _psqlSettings::gset_prefix, pg_log_error, PGRES_BAD_RESPONSE, PGRES_COMMAND_OK, PGRES_COPY_IN, PGRES_COPY_OUT, PGRES_EMPTY_QUERY, PGRES_FATAL_ERROR, PGRES_NONFATAL_ERROR, PGRES_PIPELINE_ABORTED, PGRES_TUPLES_OK, PQresultStatus, PrintQueryStatus(), PrintQueryTuples(), PrintResultInCrosstab(), pset, _psqlSettings::show_all_results, StoreQueryTuple(), and success.
Referenced by DescribeQuery(), and ExecQueryAndProcessResults().
Definition at line 992 of file common.c.
References buf, fb(), printTableOpt::format, fprintf, html_escaped_print(), _psqlSettings::logfile, PGRES_TUPLES_OK, _psqlSettings::popt, PQcmdStatus, PQoidValue(), PQresultStatus, PRINT_HTML, pset, _psqlSettings::queryFout, _psqlSettings::quiet, SetVariable(), snprintf, printQueryOpt::topt, and _psqlSettings::vars.
Referenced by ExecQueryAndProcessResults(), and PrintQueryResult().
|
static |
Definition at line 773 of file common.c.
References fb(), _psqlSettings::logfile, pg_log_error, _psqlSettings::popt, printQuery(), pset, and _psqlSettings::queryFout.
Referenced by PrintQueryResult().
Definition at line 596 of file common.c.
References _, days, fb(), and printf.
Referenced by PSQLexecWatch(), and SendQuery().
Definition at line 309 of file common.c.
References cancel_pressed, fb(), sigint_interrupt_enabled, and sigint_interrupt_jmp.
Referenced by psql_setup_cancel_handler().
| char * psql_get_variable | ( | const char * | varname, |
| PsqlScanQuoteType | quote, | ||
| void * | passthrough | ||
| ) |
Definition at line 188 of file common.c.
References appendShellStringNoError(), buf, conditional_active(), _psqlSettings::db, error(), fb(), free, GetVariable(), initPQExpBuffer(), pg_log_error, pg_log_info, pg_strdup(), PQerrorMessage(), PQescapeIdentifier(), PQescapeLiteral(), PQfreemem(), PQUOTE_PLAIN, PQUOTE_SHELL_ARG, PQUOTE_SQL_IDENT, PQUOTE_SQL_LITERAL, pset, value, and _psqlSettings::vars.
Definition at line 325 of file common.c.
References psql_cancel_callback(), and setup_cancel_handler().
Referenced by main().
Definition at line 655 of file common.c.
References _, AcceptResult(), ClearOrSaveResult(), _psqlSettings::db, _psqlSettings::echo_hidden, fb(), fprintf, _psqlSettings::logfile, pg_log_error, PQexec(), printf, pset, PSQL_ECHO_HIDDEN_NOEXEC, PSQL_ECHO_HIDDEN_OFF, ResetCancelConn(), and SetCancelConn().
Referenced by add_tablespace_footer(), addFooterToPublicationDesc(), describeAccessMethods(), describeAggregates(), describeConfigurationParameters(), describeFunctions(), describeOneTableDetails(), describeOneTSConfig(), describeOneTSParser(), describeOperators(), describePublications(), describeRoleGrants(), describeRoles(), describeSubscriptions(), describeTableDetails(), describeTablespaces(), describeTypes(), do_lo_import(), exec_command_password(), fail_lo_xact(), finish_lo_xact(), listAllDbs(), listCasts(), listCollations(), listConversions(), listDbRoleSettings(), listDefaultACLs(), listDomains(), listEventTriggers(), listExtendedStats(), listExtensionContents(), listExtensions(), listForeignDataWrappers(), listForeignServers(), listForeignTables(), listLanguages(), listLargeObjects(), listOneExtensionContents(), listOperatorClasses(), listOperatorFamilies(), listOpFamilyFunctions(), listOpFamilyOperators(), listPartitionedTables(), listPublications(), listSchemas(), listTables(), listTSConfigs(), listTSConfigsVerbose(), listTSDictionaries(), listTSParsers(), listTSParsersVerbose(), listTSTemplates(), listUserMappings(), main(), objectDescription(), permissionsList(), and start_lo_xact().
| int PSQLexecWatch | ( | const char * | query, |
| const printQueryOpt * | opt, | ||
| FILE * | printQueryFout, | ||
| int | min_rows | ||
| ) |
Definition at line 710 of file common.c.
References _psqlSettings::db, ExecQueryAndProcessResults(), fb(), pg_log_error, PrintTiming(), pset, ResetCancelConn(), SetCancelConn(), and _psqlSettings::timing.
Referenced by do_watch().
Definition at line 2704 of file common.c.
References connstr, fb(), and uri_prefix_length().
Referenced by do_connect().
Definition at line 1118 of file common.c.
References _, _psqlSettings::autocommit, buf, cancel_pressed, clean_extended_state(), ClearOrSaveResult(), command_no_begin(), ConnectionUp(), _psqlSettings::crosstab_flag, _psqlSettings::ctv_args, _psqlSettings::cur_cmd_interactive, _psqlSettings::db, DescribeQuery(), _psqlSettings::echo, _psqlSettings::encoding, printTableOpt::encoding, ExecQueryAndProcessResults(), fb(), fprintf, free, _psqlSettings::gdesc_flag, _psqlSettings::gexec_flag, _psqlSettings::gfname, _psqlSettings::gsavepopt, _psqlSettings::gset_prefix, i, lengthof, _psqlSettings::logfile, _psqlSettings::on_error_rollback, pg_encoding_to_char, pg_free(), pg_log_error, pg_log_info, PGRES_COMMAND_OK, _psqlSettings::popt, PQclear, PQclientEncoding(), PQerrorMessage(), PQexec(), PQresultStatus, PQTRANS_ACTIVE, PQTRANS_IDLE, PQTRANS_INERROR, PQTRANS_INTRANS, PQTRANS_UNKNOWN, PQtransactionStatus(), printf, PrintNotifications(), PrintTiming(), pset, PSQL_ECHO_ERRORS, PSQL_ECHO_QUERIES, PSQL_ERROR_ROLLBACK_OFF, PSQL_ERROR_ROLLBACK_ON, ResetCancelConn(), restorePsetInfo(), SetCancelConn(), SetVariable(), _psqlSettings::singlestep, _psqlSettings::timing, printQueryOpt::topt, and _psqlSettings::vars.
Referenced by do_copy(), ExecQueryTuples(), main(), and MainLoop().
Definition at line 2520 of file common.c.
References _psqlSettings::db, fb(), PQparameterStatus(), PQuser(), pset, and val.
Referenced by get_prompt().
Definition at line 534 of file common.c.
References _psqlSettings::available_results, buf, _psqlSettings::piped_commands, _psqlSettings::piped_syncs, pset, SetVariable(), snprintf, and _psqlSettings::vars.
Referenced by ExecQueryAndProcessResults().
Definition at line 144 of file common.c.
References fb(), openQueryOutputFile(), pset, _psqlSettings::queryFout, _psqlSettings::queryFoutPipe, restore_sigpipe_trap(), set_sigpipe_trap_state(), and SetShellResultVariables().
Referenced by exec_command_out(), main(), and parse_psql_options().
Definition at line 476 of file common.c.
References fb(), PG_DIAG_MESSAGE_PRIMARY, PG_DIAG_SQLSTATE, PQcmdTuples, PQresultErrorField, pset, SetVariable(), success, and _psqlSettings::vars.
Referenced by DescribeQuery(), and ExecQueryAndProcessResults().
Definition at line 516 of file common.c.
References buf, fb(), pset, SetVariable(), snprintf, _psqlSettings::vars, and wait_result_to_exit_code().
Referenced by CloseGOutput(), do_copy(), do_shell(), evaluate_backtick(), exec_command_write(), and setQFout().
Definition at line 90 of file common.c.
References disable_sigpipe_trap(), fb(), _psqlSettings::gfname, openQueryOutputFile(), and pset.
Referenced by ExecQueryAndProcessResults().
Definition at line 2201 of file common.c.
References _psqlSettings::encoding, fb(), PQmblenBounded(), and pset.
Referenced by command_no_begin().
Definition at line 2500 of file common.c.
References _psqlSettings::db, fb(), PQparameterStatus(), pset, and val.
Referenced by get_create_object_cmd(), main(), MainLoop(), and parse_slash_copy().
Definition at line 797 of file common.c.
References fb(), free, _psqlSettings::gset_prefix, i, pg_log_error, pg_log_warning, PQfname, PQgetisnull, PQgetvalue, PQnfields, PQntuples, pset, psprintf(), SetVariable(), success, value, VariableHasHook(), and _psqlSettings::vars.
Referenced by PrintQueryResult().
Definition at line 2634 of file common.c.
References connstr, fb(), short_uri_designator, and uri_designator.
Referenced by recognized_connection_string().
| volatile sig_atomic_t sigint_interrupt_enabled = false |
Definition at line 304 of file common.c.
Referenced by exec_command_password(), exec_command_prompt(), gets_fromFile(), gets_interactive(), handleCopyIn(), MainLoop(), prompt_for_password(), and psql_cancel_callback().
| sigjmp_buf sigint_interrupt_jmp |
Definition at line 306 of file common.c.
Referenced by exec_command_password(), exec_command_prompt(), handleCopyIn(), MainLoop(), prompt_for_password(), and psql_cancel_callback().