PostgreSQL Source Code
git master
|
#include "postgres_fe.h"
#include <signal.h>
#include <time.h>
#include <unistd.h>
#include <sys/select.h>
#include <poll.h>
#include "libpq-fe.h"
#include "libpq-int.h"
#include "mb/pg_wchar.h"
#include "pg_config_paths.h"
#include "port/pg_bswap.h"
Go to the source code of this file.
Functions | |
static int | pqPutMsgBytes (const void *buf, size_t len, PGconn *conn) |
static int | pqSendSome (PGconn *conn, int len) |
static int | pqSocketCheck (PGconn *conn, int forRead, int forWrite, pg_usec_time_t end_time) |
int | PQlibVersion (void) |
int | pqGetc (char *result, PGconn *conn) |
int | pqPutc (char c, PGconn *conn) |
static int | pqGets_internal (PQExpBuffer buf, PGconn *conn, bool resetbuffer) |
int | pqGets (PQExpBuffer buf, PGconn *conn) |
int | pqGets_append (PQExpBuffer buf, PGconn *conn) |
int | pqPuts (const char *s, PGconn *conn) |
int | pqGetnchar (char *s, size_t len, PGconn *conn) |
int | pqSkipnchar (size_t len, PGconn *conn) |
int | pqPutnchar (const char *s, size_t len, PGconn *conn) |
int | pqGetInt (int *result, size_t bytes, PGconn *conn) |
int | pqPutInt (int value, size_t bytes, PGconn *conn) |
int | pqCheckOutBufferSpace (size_t bytes_needed, PGconn *conn) |
int | pqCheckInBufferSpace (size_t bytes_needed, PGconn *conn) |
void | pqParseDone (PGconn *conn, int newInStart) |
int | pqPutMsgStart (char msg_type, PGconn *conn) |
int | pqPutMsgEnd (PGconn *conn) |
int | pqReadData (PGconn *conn) |
int | pqFlush (PGconn *conn) |
int | pqWait (int forRead, int forWrite, PGconn *conn) |
int | pqWaitTimed (int forRead, int forWrite, PGconn *conn, pg_usec_time_t end_time) |
int | pqReadReady (PGconn *conn) |
int | pqWriteReady (PGconn *conn) |
int | PQsocketPoll (int sock, int forRead, int forWrite, pg_usec_time_t end_time) |
pg_usec_time_t | PQgetCurrentTimeUSec (void) |
int | PQmblen (const char *s, int encoding) |
int | PQmblenBounded (const char *s, int encoding) |
int | PQdsplen (const char *s, int encoding) |
int | PQenv2encoding (void) |
void | libpq_append_error (PQExpBuffer errorMessage, const char *fmt,...) |
void | libpq_append_conn_error (PGconn *conn, const char *fmt,...) |
void libpq_append_conn_error | ( | PGconn * | conn, |
const char * | fmt, | ||
... | |||
) |
Definition at line 1372 of file fe-misc.c.
References appendPQExpBufferChar(), appendPQExpBufferVA(), generate_unaccent_rules::args, Assert, conn, pg_conn::errorMessage, fmt, libpq_gettext, PQExpBufferBroken, va_end(), and va_start().
Referenced by build_client_final_message(), build_client_first_message(), check_expected_areq(), connectFailureMessage(), connectNoDelay(), fillPGconn(), handleSyncLoss(), init_allowed_encryption_methods(), initialize_SSL(), lo_create(), lo_export(), lo_import_internal(), lo_initialize(), lo_lseek64(), lo_read(), lo_tell64(), lo_truncate(), lo_truncate64(), lo_write(), open_client_SSL(), openssl_verify_peer_name_matches_certificate_ip(), openssl_verify_peer_name_matches_certificate_name(), pg_fe_sendauth(), pg_GSS_load_servicename(), pg_GSS_read(), pg_GSS_write(), pg_password_sendauth(), pg_SASL_continue(), pg_SASL_init(), pgpassfileWarning(), pgtls_get_peer_certificate_hash(), pgtls_read(), pgtls_write(), pq_verify_peer_name_matches_certificate(), pq_verify_peer_name_matches_certificate_ip(), pq_verify_peer_name_matches_certificate_name(), pqAllocCmdQueueEntry(), PQcancelCreate(), PQcancelPoll(), PQcancelStart(), pqConnectOptions2(), PQconnectPoll(), pqCopyPGconn(), PQencryptPasswordConn(), pqEndcopy3(), PQenterPipelineMode(), PQescapeByteaInternal(), PQescapeInternal(), PQescapeStringInternal(), PQexecStart(), PQexitPipelineMode(), PQfn(), pqFunctionCall3(), PQgetCopyData(), pqGetCopyData3(), pqGetErrorNotice3(), pqGetline3(), pqGetNegotiateProtocolVersion3(), PQgetResult(), pqParseInput3(), pqParseIntParam(), pqPipelineProcessQueue(), pqPipelineSyncInternal(), pqPrepareAsyncResult(), PQputCopyData(), PQputCopyEnd(), pqReadData(), pqSaveWriteError(), pqsecure_open_gss(), pqsecure_raw_read(), PQsendFlushRequest(), PQsendPrepare(), PQsendQueryGuts(), PQsendQueryInternal(), PQsendQueryParams(), PQsendQueryPrepared(), PQsendQueryStart(), PQsendTypedCommand(), PQsetdbLogin(), pqSocketCheck(), pqWaitTimed(), read_server_final_message(), read_server_first_message(), scram_exchange(), select_next_encryption_method(), setKeepalivesCount(), setKeepalivesIdle(), setKeepalivesInterval(), setTCPUserTimeout(), and store_conn_addrinfo().
void libpq_append_error | ( | PQExpBuffer | errorMessage, |
const char * | fmt, | ||
... | |||
) |
Definition at line 1343 of file fe-misc.c.
References appendPQExpBufferChar(), appendPQExpBufferVA(), generate_unaccent_rules::args, Assert, fmt, libpq_gettext, PQExpBufferBroken, va_end(), and va_start().
Referenced by conninfo_add_defaults(), conninfo_array_parse(), conninfo_init(), conninfo_parse(), conninfo_storeval(), conninfo_uri_decode(), conninfo_uri_parse_options(), conninfo_uri_parse_params(), parseServiceFile(), parseServiceInfo(), pg_fe_getusername(), and read_attr_value().
int pqCheckInBufferSpace | ( | size_t | bytes_needed, |
PGconn * | conn | ||
) |
Definition at line 351 of file fe-misc.c.
References appendPQExpBufferStr(), conn, pg_conn::errorMessage, pg_conn::inBuffer, pg_conn::inBufSize, pg_conn::inCursor, pg_conn::inEnd, pg_conn::inStart, and realloc.
Referenced by getCopyDataMessage(), PQconnectPoll(), pqFunctionCall3(), pqParseInput3(), and pqReadData().
int pqCheckOutBufferSpace | ( | size_t | bytes_needed, |
PGconn * | conn | ||
) |
Definition at line 287 of file fe-misc.c.
References appendPQExpBufferStr(), conn, pg_conn::errorMessage, pg_conn::outBuffer, pg_conn::outBufSize, and realloc.
Referenced by PQputCopyData(), pqPutMsgBytes(), and pqPutMsgStart().
int PQdsplen | ( | const char * | s, |
int | encoding | ||
) |
Definition at line 1244 of file fe-misc.c.
References encoding, and pg_encoding_dsplen().
Referenced by get_prompt(), pg_wcsformat(), pg_wcssize(), pg_wcswidth(), and strlen_max_width().
int PQenv2encoding | ( | void | ) |
Definition at line 1253 of file fe-misc.c.
References encoding, pg_char_to_encoding, PG_SQL_ASCII, and str.
Referenced by main().
int pqFlush | ( | PGconn * | conn | ) |
Definition at line 968 of file fe-misc.c.
References conn, fflush(), pg_conn::outCount, pg_conn::Pfdebug, and pqSendSome().
Referenced by pg_SASL_init(), PQconnectPoll(), PQconsumeInput(), pqEndcopy3(), PQexitPipelineMode(), PQflush(), pqFunctionCall3(), PQgetResult(), pqPacketSend(), pqPipelineFlush(), pqPipelineSyncInternal(), PQputCopyData(), PQputCopyEnd(), PQsendQueryInternal(), PQsetnonblocking(), and sendTerminateConn().
int pqGetc | ( | char * | result, |
PGconn * | conn | ||
) |
Definition at line 77 of file fe-misc.c.
References conn, pg_conn::inBuffer, pg_conn::inCursor, and pg_conn::inEnd.
Referenced by getCopyDataMessage(), getCopyStart(), getReadyForQuery(), PQconnectPoll(), pqFunctionCall3(), pqGetErrorNotice3(), and pqParseInput3().
pg_usec_time_t PQgetCurrentTimeUSec | ( | void | ) |
Definition at line 1200 of file fe-misc.c.
References gettimeofday().
Referenced by pqConnectDBComplete(), PQsocketPoll(), and wait_until_connected().
int pqGetInt | ( | int * | result, |
size_t | bytes, | ||
PGconn * | conn | ||
) |
Definition at line 216 of file fe-misc.c.
References conn, pg_conn::inBuffer, pg_conn::inCursor, pg_conn::inEnd, pg_conn::noticeHooks, pg_ntoh16, pg_ntoh32, and pqInternalNotice().
Referenced by getAnotherTuple(), getCopyDataMessage(), getCopyStart(), getNotify(), getParamDescriptions(), getRowDescriptions(), PQconnectPoll(), pqFunctionCall3(), pqGetNegotiateProtocolVersion3(), and pqParseInput3().
int pqGetnchar | ( | char * | s, |
size_t | len, | ||
PGconn * | conn | ||
) |
Definition at line 165 of file fe-misc.c.
References conn, pg_conn::inBuffer, pg_conn::inCursor, pg_conn::inEnd, and len.
Referenced by pg_password_sendauth(), pg_SASL_continue(), and pqFunctionCall3().
int pqGets | ( | PQExpBuffer | buf, |
PGconn * | conn | ||
) |
Definition at line 136 of file fe-misc.c.
References buf, conn, and pqGets_internal().
Referenced by getNotify(), getParameterStatus(), getRowDescriptions(), pg_SASL_init(), pqGetErrorNotice3(), pqGetNegotiateProtocolVersion3(), and pqParseInput3().
int pqGets_append | ( | PQExpBuffer | buf, |
PGconn * | conn | ||
) |
Definition at line 142 of file fe-misc.c.
References buf, conn, and pqGets_internal().
Referenced by PQconnectPoll().
|
static |
Definition at line 109 of file fe-misc.c.
References appendBinaryPQExpBuffer(), buf, conn, pg_conn::inBuffer, pg_conn::inCursor, pg_conn::inEnd, and resetPQExpBuffer().
Referenced by pqGets(), and pqGets_append().
int PQlibVersion | ( | void | ) |
int PQmblen | ( | const char * | s, |
int | encoding | ||
) |
Definition at line 1224 of file fe-misc.c.
References encoding, and pg_encoding_mblen().
Referenced by appendStringLiteral(), get_prompt(), pg_wcsformat(), pg_wcssize(), pg_wcswidth(), and strlen_max_width().
int PQmblenBounded | ( | const char * | s, |
int | encoding | ||
) |
Definition at line 1234 of file fe-misc.c.
References encoding, pg_encoding_mblen(), and strnlen().
Referenced by command_no_begin(), do_field(), patternToSQLRegex(), quote_if_needed(), reportErrorPosition(), skip_white_space(), splitTableColumnsSpec(), strip_quotes(), and strtokx().
void pqParseDone | ( | PGconn * | conn, |
int | newInStart | ||
) |
Definition at line 443 of file fe-misc.c.
References conn, pg_conn::inBuffer, pg_conn::inStart, pg_conn::Pfdebug, and pqTraceOutputMessage().
Referenced by getCopyDataMessage(), PQconnectPoll(), pqFunctionCall3(), pqGetCopyData3(), and pqParseInput3().
int pqPutc | ( | char | c, |
PGconn * | conn | ||
) |
Definition at line 92 of file fe-misc.c.
References conn, and pqPutMsgBytes().
Referenced by PQsendQueryGuts(), and PQsendTypedCommand().
int pqPutInt | ( | int | value, |
size_t | bytes, | ||
PGconn * | conn | ||
) |
Definition at line 253 of file fe-misc.c.
References conn, pg_conn::noticeHooks, pg_hton16, pg_hton32, pqInternalNotice(), pqPutMsgBytes(), and value.
Referenced by pg_SASL_init(), pqFunctionCall3(), PQsendPrepare(), and PQsendQueryGuts().
|
static |
Definition at line 509 of file fe-misc.c.
References buf, conn, len, pg_conn::outBuffer, pg_conn::outMsgEnd, and pqCheckOutBufferSpace().
Referenced by pqPutc(), pqPutInt(), pqPutnchar(), and pqPuts().
int pqPutMsgEnd | ( | PGconn * | conn | ) |
Definition at line 532 of file fe-misc.c.
References conn, pg_conn::outBuffer, pg_conn::outCount, pg_conn::outMsgEnd, pg_conn::outMsgStart, pg_conn::Pfdebug, pg_hton32, pqSendSome(), pqTraceOutputMessage(), and pqTraceOutputNoTypeByteMessage().
Referenced by pg_SASL_init(), pqEndcopy3(), pqFunctionCall3(), pqPacketSend(), pqPipelineSyncInternal(), PQputCopyData(), PQputCopyEnd(), PQsendFlushRequest(), PQsendPrepare(), PQsendQueryGuts(), PQsendQueryInternal(), PQsendTypedCommand(), and sendTerminateConn().
int pqPutMsgStart | ( | char | msg_type, |
PGconn * | conn | ||
) |
Definition at line 473 of file fe-misc.c.
References conn, pg_conn::outBuffer, pg_conn::outCount, pg_conn::outMsgEnd, pg_conn::outMsgStart, and pqCheckOutBufferSpace().
Referenced by pg_SASL_init(), pqEndcopy3(), pqFunctionCall3(), pqPacketSend(), pqPipelineSyncInternal(), PQputCopyData(), PQputCopyEnd(), PQsendFlushRequest(), PQsendPrepare(), PQsendQueryGuts(), PQsendQueryInternal(), PQsendTypedCommand(), and sendTerminateConn().
int pqPutnchar | ( | const char * | s, |
size_t | len, | ||
PGconn * | conn | ||
) |
Definition at line 202 of file fe-misc.c.
References conn, len, and pqPutMsgBytes().
Referenced by pg_SASL_init(), pqFunctionCall3(), pqPacketSend(), PQputCopyData(), and PQsendQueryGuts().
int pqPuts | ( | const char * | s, |
PGconn * | conn | ||
) |
Definition at line 152 of file fe-misc.c.
References conn, and pqPutMsgBytes().
Referenced by pg_SASL_init(), PQputCopyEnd(), PQsendPrepare(), PQsendQueryGuts(), PQsendQueryInternal(), and PQsendTypedCommand().
int pqReadData | ( | PGconn * | conn | ) |
Definition at line 580 of file fe-misc.c.
References ALL_CONNECTION_FAILURE_ERRNOS, conn, CONNECTION_BAD, EAGAIN, EINTR, EWOULDBLOCK, pg_conn::inBuffer, pg_conn::inBufSize, pg_conn::inCursor, pg_conn::inEnd, pg_conn::inStart, libpq_append_conn_error(), PGINVALID_SOCKET, pqCheckInBufferSpace(), pqDropConnection(), pqReadReady(), pqsecure_read(), pg_conn::sock, SOCK_ERRNO, pg_conn::ssl_in_use, and pg_conn::status.
Referenced by PQcancelPoll(), PQconnectPoll(), PQconsumeInput(), pqFunctionCall3(), pqGetCopyData3(), pqGetline3(), PQgetResult(), and pqSendSome().
int pqReadReady | ( | PGconn * | conn | ) |
Definition at line 1032 of file fe-misc.c.
References conn, and pqSocketCheck().
Referenced by gss_read(), and pqReadData().
|
static |
Definition at line 799 of file fe-misc.c.
References conn, EAGAIN, EINTR, EWOULDBLOCK, len, libpq_gettext, Min, pg_conn::outBuffer, pg_conn::outCount, PGINVALID_SOCKET, pqIsnonblocking, pqReadData(), pqsecure_write(), pqWait(), remaining, pg_conn::sock, SOCK_ERRNO, pg_conn::write_err_msg, and pg_conn::write_failed.
Referenced by pqFlush(), and pqPutMsgEnd().
int pqSkipnchar | ( | size_t | len, |
PGconn * | conn | ||
) |
Definition at line 187 of file fe-misc.c.
References conn, pg_conn::inCursor, pg_conn::inEnd, and len.
Referenced by getAnotherTuple().
|
static |
Definition at line 1056 of file fe-misc.c.
References conn, EINTR, end_time, libpq_append_conn_error(), PG_STRERROR_R_BUFLEN, PGINVALID_SOCKET, pgtls_read_pending(), PQsocketPoll(), pg_conn::sock, SOCK_ERRNO, SOCK_STRERROR, and pg_conn::ssl_in_use.
Referenced by pqReadReady(), pqWaitTimed(), and pqWriteReady().
int PQsocketPoll | ( | int | sock, |
int | forRead, | ||
int | forWrite, | ||
pg_usec_time_t | end_time | ||
) |
Definition at line 1106 of file fe-misc.c.
References end_time, now(), PQgetCurrentTimeUSec(), and select.
Referenced by pqSocketCheck(), and wait_until_connected().
int pqWait | ( | int | forRead, |
int | forWrite, | ||
PGconn * | conn | ||
) |
Definition at line 993 of file fe-misc.c.
References conn, and pqWaitTimed().
Referenced by pqFunctionCall3(), pqGetCopyData3(), pqGetline3(), PQgetResult(), and pqSendSome().
int pqWaitTimed | ( | int | forRead, |
int | forWrite, | ||
PGconn * | conn, | ||
pg_usec_time_t | end_time | ||
) |
Definition at line 1009 of file fe-misc.c.
References conn, end_time, libpq_append_conn_error(), and pqSocketCheck().
Referenced by pqConnectDBComplete(), and pqWait().
int pqWriteReady | ( | PGconn * | conn | ) |
Definition at line 1042 of file fe-misc.c.
References conn, and pqSocketCheck().