51 #include "pg_config_paths.h"
66 return PG_VERSION_NUM;
118 while (inCursor < inEnd && inBuffer[inCursor])
121 if (inCursor >= inEnd)
240 "integer of size %lu not supported by pqGetInt",
241 (
unsigned long) bytes);
273 "integer of size %lu not supported by pqPutInt",
274 (
unsigned long) bytes);
294 if (bytes_needed <= (
size_t) newsize)
307 }
while (newsize > 0 && bytes_needed > (
size_t) newsize);
309 if (newsize > 0 && bytes_needed <= (
size_t) newsize)
325 }
while (newsize > 0 && bytes_needed > (
size_t) newsize);
327 if (newsize > 0 && bytes_needed <= (
size_t) newsize)
341 "cannot allocate memory for output buffer\n");
358 if (bytes_needed <= (
size_t) newsize)
388 if (bytes_needed <= (
size_t) newsize)
401 }
while (newsize > 0 && bytes_needed > (
size_t) newsize);
403 if (newsize > 0 && bytes_needed <= (
size_t) newsize)
419 }
while (newsize > 0 && bytes_needed > (
size_t) newsize);
421 if (newsize > 0 && bytes_needed <= (
size_t) newsize)
435 "cannot allocate memory for input buffer\n");
631 #if defined(EWOULDBLOCK) && (!defined(EAGAIN) || (EWOULDBLOCK != EAGAIN))
638 goto definitelyFailed;
726 #if defined(EWOULDBLOCK) && (!defined(EAGAIN) || (EWOULDBLOCK != EAGAIN))
733 goto definitelyFailed;
752 "\tThis probably means the server terminated abnormally\n"
753 "\tbefore or while processing the request.");
850 #if defined(EWOULDBLOCK) && (!defined(EAGAIN) || (EWOULDBLOCK != EAGAIN))
1091 struct pollfd input_fd;
1094 if (!forRead && !forWrite)
1098 input_fd.events = POLLERR;
1099 input_fd.revents = 0;
1102 input_fd.events |= POLLIN;
1104 input_fd.events |= POLLOUT;
1111 time_t
now = time(NULL);
1119 return poll(&input_fd, 1, timeout_ms);
1125 struct timeval timeout;
1126 struct timeval *ptr_timeout;
1128 if (!forRead && !forWrite)
1131 FD_ZERO(&input_mask);
1132 FD_ZERO(&output_mask);
1133 FD_ZERO(&except_mask);
1135 FD_SET(sock, &input_mask);
1138 FD_SET(sock, &output_mask);
1139 FD_SET(sock, &except_mask);
1146 time_t
now = time(NULL);
1152 timeout.tv_usec = 0;
1153 ptr_timeout = &timeout;
1156 return select(sock + 1, &input_mask, &output_mask,
1157 &except_mask, ptr_timeout);
1211 str = getenv(
"PGCLIENTENCODING");
1225 libpq_binddomain(
void)
1234 static volatile bool already_bound =
false;
1240 int save_errno = GetLastError();
1242 int save_errno = errno;
1247 ldir = getenv(
"PGLOCALEDIR");
1251 already_bound =
true;
1253 SetLastError(save_errno);
1268 libpq_ngettext(
const char *msgid,
const char *msgid_plural,
unsigned long n)
1285 int save_errno = errno;
1314 int save_errno = errno;
Datum now(PG_FUNCTION_ARGS)
#define PG_TEXTDOMAIN(domain)
#define dngettext(d, s, p, n)
void pqDropConnection(PGconn *conn, bool flushInput)
void pqInternalNotice(const PGNoticeHooks *hooks, const char *fmt,...)
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 pqReadReady(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 PQmblen(const char *s, int encoding)
int pqWait(int forRead, int forWrite, PGconn *conn)
int pqGets(PQExpBuffer buf, PGconn *conn)
int PQdsplen(const char *s, int encoding)
static int pqSocketPoll(int sock, int forRead, int forWrite, time_t end_time)
int pqCheckInBufferSpace(size_t bytes_needed, PGconn *conn)
static int pqPutMsgBytes(const void *buf, size_t len, PGconn *conn)
int pqPutnchar(const char *s, size_t len, PGconn *conn)
static int pqSendSome(PGconn *conn, int len)
static int pqGets_internal(PQExpBuffer buf, PGconn *conn, bool resetbuffer)
int pqPuts(const char *s, PGconn *conn)
void libpq_append_error(PQExpBuffer errorMessage, const char *fmt,...)
static int pqSocketCheck(PGconn *conn, int forRead, int forWrite, time_t end_time)
int pqWaitTimed(int forRead, int forWrite, PGconn *conn, time_t finish_time)
int PQmblenBounded(const char *s, int encoding)
void libpq_append_conn_error(PGconn *conn, const char *fmt,...)
int pqGets_append(PQExpBuffer buf, PGconn *conn)
int pqWriteReady(PGconn *conn)
int pqPutMsgEnd(PGconn *conn)
bool pgtls_read_pending(PGconn *conn)
ssize_t pqsecure_write(PGconn *conn, const void *ptr, size_t len)
ssize_t pqsecure_read(PGconn *conn, void *ptr, size_t len)
void pqTraceOutputMessage(PGconn *conn, const char *message, bool toServer)
void pqTraceOutputNoTypeByteMessage(PGconn *conn, const char *message)
#define libpq_ngettext(s, p, n)
#define pqIsnonblocking(conn)
static void const char * fmt
static void const char fflush(stdout)
Assert(fmt[strlen(fmt) - 1] !='\n')
#define pg_char_to_encoding
#define PG_STRERROR_R_BUFLEN
#define ALL_CONNECTION_FAILURE_ERRNOS
size_t strnlen(const char *str, size_t maxlen)
void resetPQExpBuffer(PQExpBuffer str)
void appendBinaryPQExpBuffer(PQExpBuffer str, const char *data, size_t datalen)
bool appendPQExpBufferVA(PQExpBuffer str, const char *fmt, va_list args)
void appendPQExpBufferChar(PQExpBuffer str, char ch)
void appendPQExpBufferStr(PQExpBuffer str, const char *data)
#define PQExpBufferBroken(str)
PQExpBufferData errorMessage
PGNoticeHooks noticeHooks
int pg_encoding_dsplen(int encoding, const char *mbstr)
int pg_encoding_mblen(int encoding, const char *mbstr)
#define select(n, r, w, e, timeout)