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))
1110 struct pollfd input_fd;
1113 if (!forRead && !forWrite)
1117 input_fd.events = POLLERR;
1118 input_fd.revents = 0;
1121 input_fd.events |= POLLIN;
1123 input_fd.events |= POLLOUT;
1140 return poll(&input_fd, 1, timeout_ms);
1146 struct timeval timeout;
1147 struct timeval *ptr_timeout;
1149 if (!forRead && !forWrite)
1152 FD_ZERO(&input_mask);
1153 FD_ZERO(&output_mask);
1154 FD_ZERO(&except_mask);
1156 FD_SET(sock, &input_mask);
1159 FD_SET(sock, &output_mask);
1160 FD_SET(sock, &except_mask);
1168 timeout.tv_usec = 0;
1169 ptr_timeout = &timeout;
1183 timeout.tv_usec = 0;
1185 ptr_timeout = &timeout;
1188 return select(sock + 1, &input_mask, &output_mask,
1189 &except_mask, ptr_timeout);
1202 struct timeval tval;
1258 str = getenv(
"PGCLIENTENCODING");
1272 libpq_binddomain(
void)
1281 static volatile bool already_bound =
false;
1288 int save_errno = GetLastError();
1290 int save_errno = errno;
1303 ldir = getenv(
"PGLOCALEDIR");
1307 already_bound =
true;
1313 SetLastError(save_errno);
1328 libpq_ngettext(
const char *msgid,
const char *msgid_plural,
unsigned long n)
1345 int save_errno = errno;
1374 int save_errno = errno;
Datum now(PG_FUNCTION_ARGS)
#define Assert(condition)
#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)
#define libpq_ngettext(s, p, n)
#define pqIsnonblocking(conn)
static void const char * fmt
static void const char fflush(stdout)
#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)