51#include "pg_config_paths.h"
65 return PG_VERSION_NUM;
117 while (inCursor < inEnd && inBuffer[inCursor])
120 if (inCursor >= inEnd)
239 "integer of size %lu not supported by pqGetInt",
240 (
unsigned long) bytes);
272 "integer of size %lu not supported by pqPutInt",
273 (
unsigned long) bytes);
293 if (bytes_needed <= (
size_t) newsize)
306 }
while (newsize > 0 && bytes_needed > (
size_t) newsize);
308 if (newsize > 0 && bytes_needed <= (
size_t) newsize)
324 }
while (newsize > 0 && bytes_needed > (
size_t) newsize);
326 if (newsize > 0 && bytes_needed <= (
size_t) newsize)
340 "cannot allocate memory for output buffer\n");
357 if (bytes_needed <= (
size_t) newsize)
387 if (bytes_needed <= (
size_t) newsize)
400 }
while (newsize > 0 && bytes_needed > (
size_t) newsize);
402 if (newsize > 0 && bytes_needed <= (
size_t) newsize)
418 }
while (newsize > 0 && bytes_needed > (
size_t) newsize);
420 if (newsize > 0 && bytes_needed <= (
size_t) newsize)
434 "cannot allocate memory for input buffer\n");
645#if defined(EWOULDBLOCK) && (!defined(EAGAIN) || (EWOULDBLOCK != EAGAIN))
652 goto definitelyFailed;
740#if defined(EWOULDBLOCK) && (!defined(EAGAIN) || (EWOULDBLOCK != EAGAIN))
747 goto definitelyFailed;
766 "\tThis probably means the server terminated abnormally\n"
767 "\tbefore or while processing the request.");
864#if defined(EWOULDBLOCK) && (!defined(EAGAIN) || (EWOULDBLOCK != EAGAIN))
1119 struct pollfd input_fd;
1122 if (!forRead && !forWrite)
1126 input_fd.events = POLLERR;
1127 input_fd.revents = 0;
1130 input_fd.events |= POLLIN;
1132 input_fd.events |= POLLOUT;
1149 return poll(&input_fd, 1, timeout_ms);
1155 struct timeval timeout;
1156 struct timeval *ptr_timeout;
1158 if (!forRead && !forWrite)
1161 FD_ZERO(&input_mask);
1162 FD_ZERO(&output_mask);
1163 FD_ZERO(&except_mask);
1165 FD_SET(sock, &input_mask);
1168 FD_SET(sock, &output_mask);
1169 FD_SET(sock, &except_mask);
1177 timeout.tv_usec = 0;
1178 ptr_timeout = &timeout;
1192 timeout.tv_usec = 0;
1194 ptr_timeout = &timeout;
1197 return select(sock + 1, &input_mask, &output_mask,
1198 &except_mask, ptr_timeout);
1211 struct timeval tval;
1267 str = getenv(
"PGCLIENTENCODING");
1281libpq_binddomain(
void)
1290 static volatile bool already_bound =
false;
1297 int save_errno = GetLastError();
1299 int save_errno = errno;
1312 ldir = getenv(
"PGLOCALEDIR");
1316 already_bound =
true;
1322 SetLastError(save_errno);
1337libpq_ngettext(
const char *msgid,
const char *msgid_plural,
unsigned long n)
1354 int save_errno = errno;
1358 Assert(fmt[strlen(fmt) - 1] !=
'\n');
1367 va_start(
args, fmt);
1383 int save_errno = errno;
1387 Assert(fmt[strlen(fmt) - 1] !=
'\n');
1396 va_start(
args, fmt);
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)
void pqParseDone(PGconn *conn, int newInStart)
int pqReadReady(PGconn *conn)
static int pqSocketCheck(PGconn *conn, int forRead, int forWrite, pg_usec_time_t end_time)
int pqPutMsgStart(char msg_type, PGconn *conn)
int pqSkipnchar(size_t len, PGconn *conn)
int PQsocketPoll(int sock, int forRead, int forWrite, pg_usec_time_t end_time)
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)
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)
pg_usec_time_t PQgetCurrentTimeUSec(void)
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,...)
int PQmblenBounded(const char *s, int encoding)
void libpq_append_conn_error(PGconn *conn, const char *fmt,...)
int pqWaitTimed(int forRead, int forWrite, PGconn *conn, pg_usec_time_t end_time)
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)
Assert(PointerIsAligned(start, uint64))
#define libpq_ngettext(s, p, n)
#define pqIsnonblocking(conn)
#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)
int pthread_mutex_unlock(pthread_mutex_t *mp)
int pthread_mutex_lock(pthread_mutex_t *mp)
#define PTHREAD_MUTEX_INITIALIZER
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)
int gettimeofday(struct timeval *tp, void *tzp)