40 "PGRES_NONFATAL_ERROR",
44 "PGRES_PIPELINE_SYNC",
45 "PGRES_PIPELINE_ABORTED",
53 .errMsg =
"out of memory\n",
73 const Oid *paramTypes,
143#define PGRESULT_DATA_BLOCKSIZE 2048
144#define PGRESULT_ALIGN_BOUNDARY MAXIMUM_ALIGNOF
145#define PGRESULT_BLOCK_OVERHEAD Max(sizeof(PGresult_data), PGRESULT_ALIGN_BOUNDARY)
146#define PGRESULT_SEP_ALLOC_THRESHOLD (PGRESULT_DATA_BLOCKSIZE / 2)
263 if (numAttributes <= 0 || !attDescs)
384 for (
i = 0;
i < dest->nEvents;
i++)
394 dest->events[
i].passThrough))
395 dest->events[
i].resultInitialized =
true;
415 if (!events || count <= 0)
423 for (
i = 0;
i < count;
i++)
470 "row number %d is out of range 0..%d",
1036#if INT_MAX >= (SIZE_MAX / 2)
1101 prev = pstatus, pstatus = pstatus->
next)
1124 pstatus->
name = ptr;
1127 pstatus->
value = ptr;
1153 else if (
strcmp(
name,
"standard_conforming_strings") == 0)
1158 else if (
strcmp(
name,
"server_version") == 0)
1194 else if (
strcmp(
name,
"default_transaction_read_only") == 0)
1199 else if (
strcmp(
name,
"in_hot_standby") == 0)
1204 else if (
strcmp(
name,
"scram_iterations") == 0)
1268 for (
i = 0;
i < nfields;
i++)
1510 const char *command,
1512 const Oid *paramTypes,
1554 const char *stmtName,
const char *query,
1590 if (
nParams > 0 && paramTypes)
1651 const char *stmtName,
1775 const char *command,
1776 const char *stmtName,
1778 const Oid *paramTypes,
1804 if (
nParams > 0 && paramTypes)
2294 const char *command,
2296 const Oid *paramTypes,
2324 const char *stmtName,
const char *query,
2341 const char *stmtName,
2873 if (!buffer || length <= 0)
3331 "internal error: cannot send pipeline while in COPY\n");
3446 if (!res || !res->
errMsg)
3534 "column number %d is out of range 0..%d",
3550 "row number %d is out of range 0..%d",
3557 "column number %d is out of range 0..%d",
3572 "parameter number %d is out of range 0..%d",
3788 static char buf[24];
3796 if (
len >
sizeof(
buf) - 1)
3812 char *endptr =
NULL;
3813 unsigned long result;
3823 if (!endptr || (*endptr !=
' ' && *endptr !=
'\0'))
3826 return (
Oid) result;
3851 while (*p && *p !=
' ')
3871 for (
c = p; *
c;
c++)
3883 "could not interpret result from server: %s",
4089 char *to,
const char *from,
size_t length,
4093 const char *
source = from;
4179 for (
i = 0;
i < charlen;
i++)
4195 char *to,
const char *from,
size_t length,
4259 else if (*s ==
'\\')
4318 result =
rp = (
char *)
malloc(result_size);
4393 "escaped string size exceeds the maximum allowed (%zu)",
4411static const char hextbl[] =
"0123456789abcdef";
4414 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
4415 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
4416 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
4417 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
4418 -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
4419 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
4420 -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
4421 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
4429 if (
c > 0 &&
c < 127)
4451static unsigned char *
4456 const unsigned char *
vp;
4458 unsigned char *result;
4461 const size_t bslash_len = (std_strings ? 1 : 2);
4491 else if (*
vp ==
'\'')
4496 else if (*
vp ==
'\\')
4529 unsigned char c = *
vp;
4541 *
rp++ = (
c >> 6) +
'0';
4542 *
rp++ = ((
c >> 3) & 07) +
'0';
4543 *
rp++ = (
c & 07) +
'0';
4570 "escaped bytea size exceeds the maximum allowed (%zu)",
4600#define ISFIRSTOCTDIGIT(CH) ((CH) >= '0' && (CH) <= '3')
4601#define ISOCTDIGIT(CH) ((CH) >= '0' && (CH) <= '7')
4602#define OCTVAL(CH) ((CH) - '0')
4621 unsigned char *buffer,
4633 const unsigned char *s;
4638 buffer = (
unsigned char *)
malloc(buflen > 0 ? buflen : 1);
4654 if (!*s ||
v1 == (
char) -1)
4657 if (
v2 != (
char) -1)
4658 *p++ = (
v1 << 4) |
v2;
4661 buflen = p - buffer;
#define unconstify(underlying_type, expr)
#define IS_HIGHBIT_SET(ch)
#define Assert(condition)
#define SQL_STR_DOUBLE(ch, escape_backslash)
int errmsg(const char *fmt,...)
static int PQsendQueryInternal(PGconn *conn, const char *query, bool newQuery)
int PQsendQueryParams(PGconn *conn, const char *command, int nParams, const Oid *paramTypes, const char *const *paramValues, const int *paramLengths, const int *paramFormats, int resultFormat)
int PQsendQueryContinue(PGconn *conn, const char *query)
int PQsetSingleRowMode(PGconn *conn)
static char get_hex(char c)
int PQbinaryTuples(const PGresult *res)
int PQflush(PGconn *conn)
PGresult * PQcopyResult(const PGresult *src, int flags)
void PQfreemem(void *ptr)
static unsigned char * PQescapeByteaInternal(PGconn *conn, const unsigned char *from, size_t from_length, size_t *to_length, bool std_strings, bool use_hex)
int PQgetline(PGconn *conn, char *buffer, int length)
void * pqResultAlloc(PGresult *res, size_t nBytes, bool isBinary)
static bool canChangeResultMode(PGconn *conn)
static size_t PQescapeStringInternal(PGconn *conn, char *to, const char *from, size_t length, int *error, int encoding, bool std_strings)
Oid PQftype(const PGresult *res, int field_num)
char * PQresultVerboseErrorMessage(const PGresult *res, PGVerbosity verbosity, PGContextVisibility show_context)
PGresult * PQdescribePrepared(PGconn *conn, const char *stmt)
PGresult * PQexecParams(PGconn *conn, const char *command, int nParams, const Oid *paramTypes, const char *const *paramValues, const int *paramLengths, const int *paramFormats, int resultFormat)
int PQexitPipelineMode(PGconn *conn)
PGresult * PQexecPrepared(PGconn *conn, const char *stmtName, int nParams, const char *const *paramValues, const int *paramLengths, const int *paramFormats, int resultFormat)
int PQsendClosePortal(PGconn *conn, const char *portal)
static PGcmdQueueEntry * pqAllocCmdQueueEntry(PGconn *conn)
int PQsetResultAttrs(PGresult *res, int numAttributes, PGresAttDesc *attDescs)
unsigned char * PQunescapeBytea(const unsigned char *strtext, size_t *retbuflen)
void pqSaveMessageField(PGresult *res, char code, const char *value)
static int check_tuple_field_number(const PGresult *res, int tup_num, int field_num)
PGresult * pqPrepareAsyncResult(PGconn *conn)
static void pqSaveWriteError(PGconn *conn)
int PQenterPipelineMode(PGconn *conn)
void pqCommandQueueAdvance(PGconn *conn, bool isReadyForQuery, bool gotSync)
void pqSetResultError(PGresult *res, PQExpBuffer errorMessage, int offset)
size_t PQescapeStringConn(PGconn *conn, char *to, const char *from, size_t length, int *error)
void pqSaveErrorResult(PGconn *conn)
PGresult * PQclosePrepared(PGconn *conn, const char *stmt)
char *const pgresStatus[]
#define PGRESULT_DATA_BLOCKSIZE
PGresult * PQclosePortal(PGconn *conn, const char *portal)
static int pqPipelineSyncInternal(PGconn *conn, bool immediate_flush)
Oid PQparamtype(const PGresult *res, int param_num)
static int check_param_number(const PGresult *res, int param_num)
int pqRowProcessor(PGconn *conn, const char **errmsgp)
int PQnparams(const PGresult *res)
int PQsendClosePrepared(PGconn *conn, const char *stmt)
static PGresult * PQexecFinish(PGconn *conn)
int PQfformat(const PGresult *res, int field_num)
static void pqAppendCmdQueueEntry(PGconn *conn, PGcmdQueueEntry *entry)
static int PQsendQueryGuts(PGconn *conn, const char *command, const char *stmtName, int nParams, const Oid *paramTypes, const char *const *paramValues, const int *paramLengths, const int *paramFormats, int resultFormat)
int PQendcopy(PGconn *conn)
static int pqPipelineFlush(PGconn *conn)
int PQputCopyEnd(PGconn *conn, const char *errormsg)
static int PQsendTypedCommand(PGconn *conn, char command, char type, const char *target)
int PQsendPipelineSync(PGconn *conn)
int PQputnbytes(PGconn *conn, const char *buffer, int nbytes)
int PQputline(PGconn *conn, const char *string)
int PQgetlineAsync(PGconn *conn, char *buffer, int bufsize)
static const PGresult OOM_result
#define PGRESULT_BLOCK_OVERHEAD
int PQputCopyData(PGconn *conn, const char *buffer, int nbytes)
static PGresult * getCopyResult(PGconn *conn, ExecStatusType copytype)
PGresult * PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status)
static PGEvent * dupEvents(PGEvent *events, int count, size_t *memSize)
PGresult * PQprepare(PGconn *conn, const char *stmtName, const char *query, int nParams, const Oid *paramTypes)
static bool static_std_strings
void pqInternalNotice(const PGNoticeHooks *hooks, const char *fmt,...)
int PQsendDescribePrepared(PGconn *conn, const char *stmt)
static const char hextbl[]
static bool PQexecStart(PGconn *conn)
size_t PQescapeString(char *to, const char *from, size_t length)
int PQconsumeInput(PGconn *conn)
static char * PQescapeInternal(PGconn *conn, const char *str, size_t len, bool as_ident)
#define ISFIRSTOCTDIGIT(CH)
static void parseInput(PGconn *conn)
Oid PQftable(const PGresult *res, int field_num)
int PQfnumber(const PGresult *res, const char *field_name)
unsigned char * PQescapeBytea(const unsigned char *from, size_t from_length, size_t *to_length)
int PQsetnonblocking(PGconn *conn, int arg)
char * PQescapeLiteral(PGconn *conn, const char *str, size_t len)
PGresult * PQfn(PGconn *conn, int fnid, int *result_buf, int *result_len, int result_is_int, const PQArgBlock *args, int nargs)
int PQsendPrepare(PGconn *conn, const char *stmtName, const char *query, int nParams, const Oid *paramTypes)
#define PGRESULT_SEP_ALLOC_THRESHOLD
PGresult * PQdescribePortal(PGconn *conn, const char *portal)
int PQfmod(const PGresult *res, int field_num)
void pqClearAsyncResult(PGconn *conn)
int PQftablecol(const PGresult *res, int field_num)
int PQsetChunkedRowsMode(PGconn *conn, int chunkSize)
static int static_client_encoding
int PQsetvalue(PGresult *res, int tup_num, int field_num, char *value, int len)
int PQsendQuery(PGconn *conn, const char *query)
int PQpipelineSync(PGconn *conn)
char * PQoidStatus(const PGresult *res)
int PQsendDescribePortal(PGconn *conn, const char *portal)
char * PQresStatus(ExecStatusType status)
size_t PQresultMemorySize(const PGresult *res)
void * PQresultAlloc(PGresult *res, size_t nBytes)
int PQisBusy(PGconn *conn)
PGresult * PQexec(PGconn *conn, const char *query)
unsigned char * PQescapeByteaConn(PGconn *conn, const unsigned char *from, size_t from_length, size_t *to_length)
int PQsendQueryPrepared(PGconn *conn, const char *stmtName, int nParams, const char *const *paramValues, const int *paramLengths, const int *paramFormats, int resultFormat)
static void pqPipelineProcessQueue(PGconn *conn)
char * PQescapeIdentifier(PGconn *conn, const char *str, size_t len)
int PQsendFlushRequest(PGconn *conn)
int pqSaveParameterStatus(PGconn *conn, const char *name, const char *value)
int PQisnonblocking(const PGconn *conn)
char * pqResultStrdup(PGresult *res, const char *str)
Oid PQoidValue(const PGresult *res)
static bool pqAddTuple(PGresult *res, PGresAttValue *tup, const char **errmsgp)
#define PGRESULT_ALIGN_BOUNDARY
static int check_field_number(const PGresult *res, int field_num)
int PQfsize(const PGresult *res, int field_num)
PGnotify * PQnotifies(PGconn *conn)
static bool PQsendQueryStart(PGconn *conn, bool newQuery)
static const int8 hexlookup[128]
int PQgetCopyData(PGconn *conn, char **buffer, int async)
static void pqRecycleCmdQueueEntry(PGconn *conn, PGcmdQueueEntry *entry)
int pqPutc(char c, PGconn *conn)
int pqReadData(PGconn *conn)
int pqPutInt(int value, size_t bytes, PGconn *conn)
int pqCheckOutBufferSpace(size_t bytes_needed, PGconn *conn)
int pqFlush(PGconn *conn)
int pqPutMsgStart(char msg_type, PGconn *conn)
int pqWait(int forRead, int forWrite, PGconn *conn)
int pqPutnchar(const void *s, size_t len, PGconn *conn)
int pqPuts(const char *s, PGconn *conn)
int pqPutMsgEnd(PGconn *conn)
void pqBuildErrorMessage3(PQExpBuffer msg, const PGresult *res, PGVerbosity verbosity, PGContextVisibility show_context)
void pqParseInput3(PGconn *conn)
int pqEndcopy3(PGconn *conn)
PGresult * pqFunctionCall3(PGconn *conn, Oid fnid, int *result_buf, int *actual_result_len, int result_is_int, const PQArgBlock *args, int nargs)
int pqGetlineAsync3(PGconn *conn, char *buffer, int bufsize)
int pqGetCopyData3(PGconn *conn, char **buffer, int async)
int pqGetline3(PGconn *conn, char *s, int maxlen)
static bool pg_add_size_overflow(size_t a, size_t b, size_t *result)
#define PQresultErrorMessage
#define PQresultErrorField
int PQfireResultCreateEvents(PGconn *conn, PGresult *res)
#define PQfreeNotify(ptr)
#define PG_COPYRES_TUPLES
#define PG_COPYRES_EVENTS
#define PG_COPYRES_NOTICEHOOKS
#define PQ_QUERY_PARAM_MAX_LIMIT
#define pqClearConnErrorState(conn)
union pgresult_data PGresult_data
#define pqIsnonblocking(conn)
#define OUTBUFFER_THRESHOLD
#define pgHavePendingResult(conn)
void libpq_append_conn_error(PGconn *conn, const char *fmt,...)
static rewind_source * source
static char buf[DEFAULT_XLOG_SEG_SIZE]
#define pg_char_to_encoding
unsigned char pg_tolower(unsigned char ch)
#define PG_DIAG_SEVERITY_NONLOCALIZED
#define PG_DIAG_MESSAGE_PRIMARY
void initPQExpBuffer(PQExpBuffer str)
void appendPQExpBufferStr(PQExpBuffer str, const char *data)
void termPQExpBuffer(PQExpBuffer str)
#define PQExpBufferBroken(str)
#define PQExpBufferDataBroken(buf)
PQnoticeReceiver noticeRec
PQnoticeProcessor noticeProc
struct PGcmdQueueEntry * next
char contents[FLEXIBLE_ARRAY_MEMBER]
struct pgParameterStatus * next
PGTernaryBool in_hot_standby
PGcmdQueueEntry * cmd_queue_recycle
PGcmdQueueEntry * cmd_queue_tail
PGTernaryBool default_transaction_read_only
pgParameterStatus * pstatus
PQExpBufferData errorMessage
PGAsyncStatusType asyncStatus
int scram_sha_256_iterations
PGpipelineStatus pipelineStatus
PGNoticeHooks noticeHooks
PGcmdQueueEntry * cmd_queue_head
PGNoticeHooks noticeHooks
char cmdStatus[CMDSTATUS_LEN]
PGMessageField * errFields
PGresParamDesc * paramDescs
ExecStatusType resultStatus
static StringInfoData tmpbuf
void pg_encoding_set_invalid(int encoding, char *dst)
int pg_encoding_mblen_or_incomplete(int encoding, const char *mbstr, size_t remaining)
int pg_encoding_verifymbstr(int encoding, const char *mbstr, int len)
int pg_encoding_mblen(int encoding, const char *mbstr)
int pg_encoding_verifymbchar(int encoding, const char *mbstr, int len)