24 #ifdef HAVE_NETINET_TCP_H
25 #include <netinet/tcp.h>
38 #define VALID_LONG_MESSAGE_TYPE(id) \
39 ((id) == 'T' || (id) == 'D' || (id) == 'd' || (id) == 'V' || \
40 (id) == 'E' || (id) == 'N' || (id) == 'A')
105 if (avail < msgLength)
196 "message type 0x%02x arrived from server while idle",
405 libpq_gettext(
"server sent data (\"D\" message) without prior row description (\"T\" message)\n"));
448 libpq_gettext(
"unexpected response from server; first received character was \"%c\"\n"),
473 libpq_gettext(
"message contents do not agree with length in message type \"%c\"\n"),
493 libpq_gettext(
"lost synchronization with server: got message type \"%c\", length %d\n"),
537 goto advance_and_error;
546 goto advance_and_error;
558 goto advance_and_error;
564 result->
binary = (nfields > 0) ? 1 : 0;
567 for (
i = 0;
i < nfields;
i++)
586 goto advance_and_error;
593 columnid = (int) ((
int16) columnid);
594 typlen = (int) ((
int16) typlen);
602 goto advance_and_error;
685 const char *
errmsg = NULL;
691 goto advance_and_error;
696 goto not_enough_data;
705 goto advance_and_error;
710 for (
i = 0;
i < nparams;
i++)
715 goto not_enough_data;
785 goto advance_and_error;
788 if (tupnfields != nfields)
791 goto advance_and_error;
803 goto advance_and_error;
810 for (
i = 0;
i < nfields;
i++)
817 goto advance_and_error;
819 rowbuf[
i].
len = vlen;
835 goto advance_and_error;
893 bool have_position =
false;
949 have_position =
true;
1027 const char *querytext = NULL;
1088 querypos = atoi(
val);
1107 querypos = atoi(
val);
1121 if (querytext && querypos > 0)
1174 if (
val || valf || vall)
1196 #define DISPLAY_SIZE 60
1197 #define MIN_RIGHT_CUT 10
1220 wquery = strdup(query);
1233 slen = strlen(wquery) + 1;
1235 qidx = (
int *)
malloc(slen *
sizeof(
int));
1241 scridx = (
int *)
malloc(slen *
sizeof(
int));
1267 for (cno = 0; wquery[qoffset] !=
'\0'; cno++)
1269 char ch = wquery[qoffset];
1271 qidx[cno] = qoffset;
1272 scridx[cno] = scroffset;
1280 wquery[qoffset] =
' ';
1286 else if (ch ==
'\r' || ch ==
'\n')
1292 wquery[qidx[cno - 1]] !=
'\r')
1329 qidx[iend] = qoffset;
1330 scridx[iend] = scroffset;
1371 wquery[qidx[iend]] =
'\0';
1400 scroffset += scridx[loc] - scridx[ibeg];
1401 for (
i = 0;
i < scroffset;
i++)
1478 nmlen = strlen(svname);
1484 strcpy(newNotify->
relname, svname);
1487 newNotify->
be_pid = be_pid;
1488 newNotify->
next = NULL;
1535 for (
i = 0;
i < nfields;
i++)
1569 switch (xact_status)
1619 if (avail < msgLength - 4)
1737 *buffer = (
char *)
malloc(msgLength + 1);
1738 if (*buffer == NULL)
1745 (*buffer)[msgLength] =
'\0';
1798 if (s[
status - 1] ==
'\n')
1845 if (avail <= bufsize)
1966 int *result_buf,
int *actual_result_len,
1970 bool needInput =
false;
1992 for (
i = 0;
i < nargs; ++
i)
2060 if (avail < msgLength)
2091 if (*actual_result_len != -1)
2203 startpacket = (
char *)
malloc(*packetlen);
2238 #define ADD_STARTUP_OPTION(optname, optval) \
2241 strcpy(packet + packet_len, optname); \
2242 packet_len += strlen(optname) + 1; \
2244 strcpy(packet + packet_len, optval); \
2245 packet_len += strlen(optval) + 1; \
2270 if ((
val = getenv(next_eo->
envName)) != NULL)
2279 packet[packet_len] =
'\0';
#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 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)
void PQclear(PGresult *res)
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)
void pqCommandQueueAdvance(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)
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)
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 pqIsnonblocking(conn)
#define pgHavePendingResult(conn)
Assert(fmt[strlen(fmt) - 1] !='\n')
static void static void status(const char *fmt,...) pg_attribute_printf(1
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
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)
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)