36 #define VALID_LONG_MESSAGE_TYPE(id) \
37 ((id) == PqMsg_CopyData || \
38 (id) == PqMsg_DataRow || \
39 (id) == PqMsg_ErrorResponse || \
40 (id) == PqMsg_FunctionCallResponse || \
41 (id) == PqMsg_NoticeResponse || \
42 (id) == PqMsg_NotificationResponse || \
43 (id) == PqMsg_RowDescription)
108 if (avail < msgLength)
187 "message type 0x%02x arrived from server while idle",
529 goto advance_and_error;
538 goto advance_and_error;
550 goto advance_and_error;
556 result->
binary = (nfields > 0) ? 1 : 0;
559 for (
i = 0;
i < nfields;
i++)
578 goto advance_and_error;
585 columnid = (int) ((
int16) columnid);
586 typlen = (int) ((
int16) typlen);
594 goto advance_and_error;
677 const char *
errmsg = NULL;
683 goto advance_and_error;
688 goto not_enough_data;
697 goto advance_and_error;
702 for (
i = 0;
i < nparams;
i++)
707 goto not_enough_data;
777 goto advance_and_error;
780 if (tupnfields != nfields)
783 goto advance_and_error;
795 goto advance_and_error;
802 for (
i = 0;
i < nfields;
i++)
809 goto advance_and_error;
811 rowbuf[
i].
len = vlen;
827 goto advance_and_error;
885 bool have_position =
false;
941 have_position =
true;
1018 const char *querytext = NULL;
1079 querypos = atoi(
val);
1098 querypos = atoi(
val);
1112 if (querytext && querypos > 0)
1165 if (
val || valf || vall)
1187 #define DISPLAY_SIZE 60
1188 #define MIN_RIGHT_CUT 10
1211 wquery = strdup(query);
1224 slen = strlen(wquery) + 1;
1226 qidx = (
int *)
malloc(slen *
sizeof(
int));
1232 scridx = (
int *)
malloc(slen *
sizeof(
int));
1258 for (cno = 0; wquery[qoffset] !=
'\0'; cno++)
1260 char ch = wquery[qoffset];
1262 qidx[cno] = qoffset;
1263 scridx[cno] = scroffset;
1271 wquery[qoffset] =
' ';
1277 else if (ch ==
'\r' || ch ==
'\n')
1283 wquery[qidx[cno - 1]] !=
'\r')
1320 qidx[iend] = qoffset;
1321 scridx[iend] = scroffset;
1362 wquery[qidx[iend]] =
'\0';
1391 scroffset += scridx[loc] - scridx[ibeg];
1392 for (
i = 0;
i < scroffset;
i++)
1421 their_version = tmp;
1427 for (
int i = 0;
i < num;
i++)
1439 if (their_version < conn->pversion)
1447 "protocol extensions not supported by server: %s", num),
1453 if (!(their_version < conn->pversion) && !(num > 0))
1525 nmlen = strlen(svname);
1531 strcpy(newNotify->
relname, svname);
1534 newNotify->
be_pid = be_pid;
1535 newNotify->
next = NULL;
1582 for (
i = 0;
i < nfields;
i++)
1616 switch (xact_status)
1666 if (avail < msgLength - 4)
1784 *buffer = (
char *)
malloc(msgLength + 1);
1785 if (*buffer == NULL)
1791 (*buffer)[msgLength] =
'\0';
1843 if (s[status - 1] ==
'\n')
1845 s[status - 1] =
'\0';
2010 int *result_buf,
int *actual_result_len,
2014 bool needInput =
false;
2036 for (
i = 0;
i < nargs; ++
i)
2104 if (avail < msgLength)
2135 if (*actual_result_len != -1)
2243 startpacket = (
char *)
malloc(*packetlen);
2278 #define ADD_STARTUP_OPTION(optname, optval) \
2281 strcpy(packet + packet_len, optname); \
2282 packet_len += strlen(optname) + 1; \
2284 strcpy(packet + packet_len, optval); \
2285 packet_len += strlen(optval) + 1; \
2310 if ((
val = getenv(next_eo->
envName)) != NULL)
2319 packet[packet_len] =
'\0';
#define Assert(condition)
#define MemSet(start, val, len)
static void PGresult * res
int errmsg(const char *fmt,...)
void pqDropConnection(PGconn *conn, bool flushInput)
void pqSaveMessageField(PGresult *res, char code, const char *value)
void pqCommandQueueAdvance(PGconn *conn, bool isReadyForQuery, bool gotSync)
void pqSetResultError(PGresult *res, PQExpBuffer errorMessage, int offset)
void pqSaveErrorResult(PGconn *conn)
char * pqResultStrdup(PGresult *res, const char *str)
int pqRowProcessor(PGconn *conn, const char **errmsgp)
int PQgetlineAsync(PGconn *conn, char *buffer, int bufsize)
void pqInternalNotice(const PGNoticeHooks *hooks, const char *fmt,...)
PGresult * PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status)
void pqSaveParameterStatus(PGconn *conn, const char *name, const char *value)
void pqClearAsyncResult(PGconn *conn)
int PQisBusy(PGconn *conn)
void * pqResultAlloc(PGresult *res, size_t nBytes, bool isBinary)
char * PQresultErrorField(const PGresult *res, int fieldcode)
PGresult * PQgetResult(PGconn *conn)
PGresult * pqPrepareAsyncResult(PGconn *conn)
int pqReadData(PGconn *conn)
int pqPutInt(int value, size_t bytes, PGconn *conn)
int pqFlush(PGconn *conn)
int pqPutMsgStart(char msg_type, PGconn *conn)
int pqSkipnchar(size_t len, PGconn *conn)
int pqGetc(char *result, PGconn *conn)
int pqGetInt(int *result, size_t bytes, PGconn *conn)
int pqGetnchar(char *s, size_t len, PGconn *conn)
int pqWait(int forRead, int forWrite, PGconn *conn)
int pqGets(PQExpBuffer buf, PGconn *conn)
int pqCheckInBufferSpace(size_t bytes_needed, PGconn *conn)
int pqPutnchar(const char *s, size_t len, PGconn *conn)
int PQmblenBounded(const char *s, int encoding)
void libpq_append_conn_error(PGconn *conn, const char *fmt,...)
int pqPutMsgEnd(PGconn *conn)
void pqBuildErrorMessage3(PQExpBuffer msg, const PGresult *res, PGVerbosity verbosity, PGContextVisibility show_context)
void pqParseInput3(PGconn *conn)
static int build_startup_packet(const PGconn *conn, char *packet, const PQEnvironmentOption *options)
int pqEndcopy3(PGconn *conn)
static int getNotify(PGconn *conn)
PGresult * pqFunctionCall3(PGconn *conn, Oid fnid, int *result_buf, int *actual_result_len, int result_is_int, const PQArgBlock *args, int nargs)
static int getAnotherTuple(PGconn *conn, int msgLength)
static int getRowDescriptions(PGconn *conn, int msgLength)
static void reportErrorPosition(PQExpBuffer msg, const char *query, int loc, int encoding)
int pqGetlineAsync3(PGconn *conn, char *buffer, int bufsize)
int pqGetCopyData3(PGconn *conn, char **buffer, int async)
int pqGetNegotiateProtocolVersion3(PGconn *conn)
static int getParameterStatus(PGconn *conn)
#define VALID_LONG_MESSAGE_TYPE(id)
static int getCopyStart(PGconn *conn, ExecStatusType copytype)
static void handleSyncLoss(PGconn *conn, char id, int msgLength)
static int getReadyForQuery(PGconn *conn)
#define ADD_STARTUP_OPTION(optname, optval)
static int getCopyDataMessage(PGconn *conn)
static int getParamDescriptions(PGconn *conn, int msgLength)
int pqGetline3(PGconn *conn, char *s, int maxlen)
int pqGetErrorNotice3(PGconn *conn, bool isError)
char * pqBuildStartupPacket3(PGconn *conn, int *packetlen, const PQEnvironmentOption *options)
void pqTraceOutputMessage(PGconn *conn, const char *message, bool toServer)
#define libpq_ngettext(s, p, n)
#define pqIsnonblocking(conn)
#define pgHavePendingResult(conn)
int pg_strcasecmp(const char *s1, const char *s2)
size_t strlcpy(char *dst, const char *src, size_t siz)
#define PG_DIAG_INTERNAL_QUERY
#define PG_DIAG_SCHEMA_NAME
#define PG_DIAG_CONSTRAINT_NAME
#define PG_DIAG_DATATYPE_NAME
#define PG_DIAG_SOURCE_LINE
#define PG_DIAG_STATEMENT_POSITION
#define PG_DIAG_SOURCE_FILE
#define PG_DIAG_MESSAGE_HINT
#define PG_DIAG_TABLE_NAME
#define PG_DIAG_MESSAGE_PRIMARY
#define PG_DIAG_COLUMN_NAME
#define PG_DIAG_MESSAGE_DETAIL
#define PG_DIAG_SOURCE_FUNCTION
#define PG_DIAG_INTERNAL_POSITION
#define PG_PROTOCOL_MAJOR(v)
#define PG_PROTOCOL_MINOR(v)
void initPQExpBuffer(PQExpBuffer str)
void resetPQExpBuffer(PQExpBuffer str)
void appendPQExpBuffer(PQExpBuffer str, const char *fmt,...)
void appendPQExpBufferChar(PQExpBuffer str, char ch)
void appendPQExpBufferStr(PQExpBuffer str, const char *data)
void termPQExpBuffer(PQExpBuffer str)
#define PQExpBufferDataBroken(buf)
#define PqMsg_CloseComplete
#define PqMsg_NotificationResponse
#define PqMsg_BindComplete
#define PqMsg_ParameterDescription
#define PqMsg_FunctionCall
#define PqMsg_ReadyForQuery
#define PqMsg_CopyInResponse
#define PqMsg_EmptyQueryResponse
#define PqMsg_RowDescription
#define PqMsg_CopyBothResponse
#define PqMsg_ParameterStatus
#define PqMsg_BackendKeyData
#define PqMsg_CommandComplete
#define PqMsg_ErrorResponse
#define PqMsg_NoticeResponse
#define PqMsg_CopyOutResponse
#define PqMsg_ParseComplete
PQnoticeReceiver noticeRec
PGTransactionStatusType xactStatus
PQExpBufferData workBuffer
char * client_encoding_initial
PQExpBufferData errorMessage
PGAsyncStatusType asyncStatus
PGpipelineStatus pipelineStatus
PGNoticeHooks noticeHooks
PGcmdQueueEntry * cmd_queue_head
PGContextVisibility show_context
PGNoticeHooks noticeHooks
char cmdStatus[CMDSTATUS_LEN]
PGMessageField * errFields
PGresParamDesc * paramDescs
ExecStatusType resultStatus
int pg_encoding_dsplen(int encoding, const char *mbstr)
int pg_encoding_max_length(int encoding)