diff options
Diffstat (limited to 'src/interfaces')
-rw-r--r-- | src/interfaces/libpq/Makefile | 11 | ||||
-rw-r--r-- | src/interfaces/libpq/fe-connect.c | 6 | ||||
-rw-r--r-- | src/interfaces/libpq/fe-exec.c | 23 | ||||
-rw-r--r-- | src/interfaces/libpq/fe-misc.c | 8 | ||||
-rw-r--r-- | src/interfaces/libpq/fe-print.c | 17 | ||||
-rw-r--r-- | src/interfaces/libpq/fe-secure.c | 31 | ||||
-rw-r--r-- | src/interfaces/libpq/libpq-int.h | 8 | ||||
-rw-r--r-- | src/interfaces/libpq/pthread-win32.c | 4 |
8 files changed, 54 insertions, 54 deletions
diff --git a/src/interfaces/libpq/Makefile b/src/interfaces/libpq/Makefile index 84ac0e1372b..45751e7397e 100644 --- a/src/interfaces/libpq/Makefile +++ b/src/interfaces/libpq/Makefile @@ -5,7 +5,7 @@ # Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group # Portions Copyright (c) 1994, Regents of the University of California # -# $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.134 2005/06/27 02:04:26 neilc Exp $ +# $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.135 2005/08/23 20:45:06 momjian Exp $ # #------------------------------------------------------------------------- @@ -43,9 +43,7 @@ libpqrc.o: libpq.rc windres -i libpq.rc -o libpqrc.o ifeq ($(enable_thread_safety), yes) -# This doesn't work yet because configure test fails. 2004-06-19 OBJS += pthread-win32.o -PTHREAD_H_WIN32 = pthread.h endif endif @@ -59,7 +57,7 @@ SHLIB_LINK += -lshfolder -lwsock32 -lws2_32 $(filter -leay32 -lssleay32 -lcomerr endif -all: $(PTHREAD_H_WIN32) def-files $(srcdir)/libpq.rc all-lib +all: def-files $(srcdir)/libpq.rc all-lib # Shared library stuff include $(top_srcdir)/src/Makefile.shlib @@ -122,11 +120,6 @@ $(srcdir)/blibpqdll.def: exports.txt $(srcdir)/libpq.rc: libpq.rc.in $(top_builddir)/src/Makefile.global sed -e 's/\(VERSION.*\),0 *$$/\1,'`date '+%y%j' | sed 's/^0*//'`'/' < $< > $@ -ifneq ($(PTHREAD_H_WIN32), "") -pthread.h: $(top_srcdir)/src/interfaces/libpq/pthread.h.win - rm -f $@ && $(LN_S) $< . -endif - fe-connect.o: fe-connect.c $(top_builddir)/src/port/pg_config_paths.h $(top_builddir)/src/port/pg_config_paths.h: diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index de784d928c1..6f67a5e854f 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.317 2005/08/11 22:53:41 tgl Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.318 2005/08/23 20:45:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -55,8 +55,12 @@ #endif #ifdef ENABLE_THREAD_SAFETY +#ifdef WIN32 +#include "pthread-win32.h" +#else #include <pthread.h> #endif +#endif #include "libpq/ip.h" #include "mb/pg_wchar.h" diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c index 2f3bd87317d..e5a1e737c36 100644 --- a/src/interfaces/libpq/fe-exec.c +++ b/src/interfaces/libpq/fe-exec.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.171 2005/08/13 01:34:30 momjian Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.172 2005/08/23 20:45:07 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -2156,25 +2156,16 @@ PQoidValue(const PGresult *res) char *endptr = NULL; unsigned long result; - if (!res || !res->cmdStatus || strncmp(res->cmdStatus, "INSERT ", 7) != 0) + if (!res || + !res->cmdStatus || + strncmp(res->cmdStatus, "INSERT ", 7) != 0 || + res->cmdStatus[7] < '0' || + res->cmdStatus[7] > '9') return InvalidOid; -#ifdef WIN32 - SetLastError(0); -#else - errno = 0; -#endif result = strtoul(res->cmdStatus + 7, &endptr, 10); - if (!endptr || (*endptr != ' ' && *endptr != '\0') -#ifndef WIN32 - /* - * On WIN32, errno is not thread-safe and GetLastError() isn't set by - * strtoul(), so we can't check on this platform. - */ - || errno == ERANGE -#endif - ) + if (!endptr || (*endptr != ' ' && *endptr != '\0')) return InvalidOid; else return (Oid) result; diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c index 5a0def12f47..50ec10eade3 100644 --- a/src/interfaces/libpq/fe-misc.c +++ b/src/interfaces/libpq/fe-misc.c @@ -23,7 +23,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-misc.c,v 1.116 2005/07/08 15:24:41 tgl Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-misc.c,v 1.117 2005/08/23 20:45:07 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1133,7 +1133,11 @@ libpq_gettext(const char *msgid) if (!already_bound) { /* dgettext() preserves errno, but bindtextdomain() doesn't */ - int save_errno = errno; +#ifdef WIN32 + int save_errno = GetLastError(); +#else + int save_errno = errno; +#endif const char *ldir; already_bound = true; diff --git a/src/interfaces/libpq/fe-print.c b/src/interfaces/libpq/fe-print.c index 762383feba1..33882d8ca79 100644 --- a/src/interfaces/libpq/fe-print.c +++ b/src/interfaces/libpq/fe-print.c @@ -10,7 +10,7 @@ * didn't really belong there. * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-print.c,v 1.60 2005/06/12 00:00:21 neilc Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-print.c,v 1.61 2005/08/23 20:45:07 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -88,7 +88,7 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po) int total_line_length = 0; int usePipe = 0; char *pagerenv; -#ifdef ENABLE_THREAD_SAFETY +#if defined(ENABLE_THREAD_SAFETY) && !defined(WIN32) sigset_t osigset; bool sigpipe_masked = false; bool sigpipe_pending; @@ -189,14 +189,14 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po) if (fout) { usePipe = 1; +#ifndef WIN32 #ifdef ENABLE_THREAD_SAFETY if (pq_block_sigpipe(&osigset, &sigpipe_pending) == 0) sigpipe_masked = true; #else -#ifndef WIN32 oldsigpipehandler = pqsignal(SIGPIPE, SIG_IGN); -#endif -#endif +#endif /* ENABLE_THREAD_SAFETY */ +#endif /* WIN32 */ } else fout = stdout; @@ -311,16 +311,15 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po) _pclose(fout); #else pclose(fout); -#endif + #ifdef ENABLE_THREAD_SAFETY /* we can't easily verify if EPIPE occurred, so say it did */ if (sigpipe_masked) pq_reset_sigpipe(&osigset, sigpipe_pending, true); #else -#ifndef WIN32 pqsignal(SIGPIPE, oldsigpipehandler); -#endif -#endif +#endif /* ENABLE_THREAD_SAFETY */ +#endif /* WIN32 */ } if (po->html3 && !po->expanded) fputs("</table>\n", fout); diff --git a/src/interfaces/libpq/fe-secure.c b/src/interfaces/libpq/fe-secure.c index c681dccf5c0..8f12d791acb 100644 --- a/src/interfaces/libpq/fe-secure.c +++ b/src/interfaces/libpq/fe-secure.c @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.67 2005/01/10 00:37:12 tgl Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.68 2005/08/23 20:45:07 momjian Exp $ * * NOTES * [ Most of these notes are wrong/obsolete, but perhaps not all ] @@ -103,8 +103,12 @@ #include <sys/stat.h> #ifdef ENABLE_THREAD_SAFETY +#ifdef WIN32 +#include "pthread-win32.h" +#else #include <pthread.h> #endif +#endif #ifndef HAVE_STRDUP #include "strdup.h" @@ -388,20 +392,21 @@ ssize_t pqsecure_write(PGconn *conn, const void *ptr, size_t len) { ssize_t n; - + +#ifndef WIN32 #ifdef ENABLE_THREAD_SAFETY sigset_t osigmask; bool sigpipe_pending; bool got_epipe = false; + if (pq_block_sigpipe(&osigmask, &sigpipe_pending) < 0) return -1; #else -#ifndef WIN32 pqsigfunc oldsighandler = pqsignal(SIGPIPE, SIG_IGN); -#endif -#endif - +#endif /* ENABLE_THREAD_SAFETY */ +#endif /* WIN32 */ + #ifdef USE_SSL if (conn->ssl) { @@ -431,7 +436,7 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len) if (n == -1) { -#ifdef ENABLE_THREAD_SAFETY +#if defined(ENABLE_THREAD_SAFETY) && !defined(WIN32) if (SOCK_ERRNO == EPIPE) got_epipe = true; #endif @@ -473,19 +478,19 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len) #endif { n = send(conn->sock, ptr, len, 0); -#ifdef ENABLE_THREAD_SAFETY +#if defined(ENABLE_THREAD_SAFETY) && !defined(WIN32) if (n < 0 && SOCK_ERRNO == EPIPE) got_epipe = true; #endif } - + +#ifndef WIN32 #ifdef ENABLE_THREAD_SAFETY pq_reset_sigpipe(&osigmask, sigpipe_pending, got_epipe); #else -#ifndef WIN32 pqsignal(SIGPIPE, oldsighandler); -#endif -#endif +#endif /* ENABLE_THREAD_SAFETY */ +#endif /* WIN32 */ return n; } @@ -1232,7 +1237,7 @@ PQgetssl(PGconn *conn) #endif /* USE_SSL */ -#ifdef ENABLE_THREAD_SAFETY +#if defined(ENABLE_THREAD_SAFETY) && !defined(WIN32) /* * Block SIGPIPE for this thread. This prevents send()/write() from exiting diff --git a/src/interfaces/libpq/libpq-int.h b/src/interfaces/libpq/libpq-int.h index d9cc783237b..cb87a1379d2 100644 --- a/src/interfaces/libpq/libpq-int.h +++ b/src/interfaces/libpq/libpq-int.h @@ -12,7 +12,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-int.h,v 1.104 2005/06/27 02:04:26 neilc Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-int.h,v 1.105 2005/08/23 20:45:07 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,7 +30,11 @@ #endif #ifdef ENABLE_THREAD_SAFETY +#ifdef WIN32 +#include "pthread-win32.h" +#else #include <pthread.h> +#endif #include <signal.h> #endif @@ -481,7 +485,7 @@ extern void pqsecure_close(PGconn *); extern ssize_t pqsecure_read(PGconn *, void *ptr, size_t len); extern ssize_t pqsecure_write(PGconn *, const void *ptr, size_t len); -#ifdef ENABLE_THREAD_SAFETY +#if defined(ENABLE_THREAD_SAFETY) && !defined(WIN32) extern int pq_block_sigpipe(sigset_t *osigset, bool *sigpipe_pending); extern void pq_reset_sigpipe(sigset_t *osigset, bool sigpipe_pending, bool got_epipe); diff --git a/src/interfaces/libpq/pthread-win32.c b/src/interfaces/libpq/pthread-win32.c index 5c5236f99f3..9b6dffff3f2 100644 --- a/src/interfaces/libpq/pthread-win32.c +++ b/src/interfaces/libpq/pthread-win32.c @@ -5,14 +5,14 @@ * * Copyright (c) 2004-2005, PostgreSQL Global Development Group * IDENTIFICATION -* $PostgreSQL: pgsql/src/interfaces/libpq/pthread-win32.c,v 1.5 2005/04/29 13:42:21 momjian Exp $ +* $PostgreSQL: pgsql/src/interfaces/libpq/pthread-win32.c,v 1.6 2005/08/23 20:45:07 momjian Exp $ * *------------------------------------------------------------------------- */ #include <windows.h> -#include "pthread.h" +#include "pthread-win32.h" HANDLE pthread_self() |