diff options
| author | Bruce Momjian | 2005-08-23 20:48:47 +0000 |
|---|---|---|
| committer | Bruce Momjian | 2005-08-23 20:48:47 +0000 |
| commit | a970a8cb95bd3f4d3a4b924904d248c9dd322ee0 (patch) | |
| tree | 4fbb5211d2a35c9e86323d1907deaf2bf63a6be2 /src/interfaces | |
| parent | eef7e30cc13158cb1fde7f4b148dd14e83331a35 (diff) | |
Back out incorrect commit.
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 45751e7397e..f496d595ecb 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.135 2005/08/23 20:45:06 momjian Exp $ +# $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.136 2005/08/23 20:48:46 momjian Exp $ # #------------------------------------------------------------------------- @@ -43,7 +43,9 @@ 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 @@ -57,7 +59,7 @@ SHLIB_LINK += -lshfolder -lwsock32 -lws2_32 $(filter -leay32 -lssleay32 -lcomerr endif -all: def-files $(srcdir)/libpq.rc all-lib +all: $(PTHREAD_H_WIN32) def-files $(srcdir)/libpq.rc all-lib # Shared library stuff include $(top_srcdir)/src/Makefile.shlib @@ -120,6 +122,11 @@ $(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 6f67a5e854f..ff4f4285d08 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.318 2005/08/23 20:45:06 momjian Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.319 2005/08/23 20:48:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -55,12 +55,8 @@ #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 e5a1e737c36..eeb4819fb00 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.172 2005/08/23 20:45:07 momjian Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.173 2005/08/23 20:48:47 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -2156,16 +2156,25 @@ PQoidValue(const PGresult *res) char *endptr = NULL; unsigned long result; - if (!res || - !res->cmdStatus || - strncmp(res->cmdStatus, "INSERT ", 7) != 0 || - res->cmdStatus[7] < '0' || - res->cmdStatus[7] > '9') + if (!res || !res->cmdStatus || strncmp(res->cmdStatus, "INSERT ", 7) != 0) return InvalidOid; +#ifdef WIN32 + SetLastError(0); +#else + errno = 0; +#endif result = strtoul(res->cmdStatus + 7, &endptr, 10); - if (!endptr || (*endptr != ' ' && *endptr != '\0')) + 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 + ) return InvalidOid; else return (Oid) result; diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c index 50ec10eade3..f4ae2ca2d93 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.117 2005/08/23 20:45:07 momjian Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-misc.c,v 1.118 2005/08/23 20:48:47 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1133,11 +1133,7 @@ libpq_gettext(const char *msgid) if (!already_bound) { /* dgettext() preserves errno, but bindtextdomain() doesn't */ -#ifdef WIN32 - int save_errno = GetLastError(); -#else - int save_errno = errno; -#endif + int save_errno = errno; const char *ldir; already_bound = true; diff --git a/src/interfaces/libpq/fe-print.c b/src/interfaces/libpq/fe-print.c index 33882d8ca79..38bc1ceee6c 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.61 2005/08/23 20:45:07 momjian Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-print.c,v 1.62 2005/08/23 20:48:47 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; -#if defined(ENABLE_THREAD_SAFETY) && !defined(WIN32) +#ifdef ENABLE_THREAD_SAFETY 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 /* ENABLE_THREAD_SAFETY */ -#endif /* WIN32 */ +#endif +#endif } else fout = stdout; @@ -311,15 +311,16 @@ 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 /* ENABLE_THREAD_SAFETY */ -#endif /* WIN32 */ +#endif +#endif } 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 8f12d791acb..0852047d8db 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.68 2005/08/23 20:45:07 momjian Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.69 2005/08/23 20:48:47 momjian Exp $ * * NOTES * [ Most of these notes are wrong/obsolete, but perhaps not all ] @@ -103,12 +103,8 @@ #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" @@ -392,21 +388,20 @@ 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 /* ENABLE_THREAD_SAFETY */ -#endif /* WIN32 */ - +#endif +#endif + #ifdef USE_SSL if (conn->ssl) { @@ -436,7 +431,7 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len) if (n == -1) { -#if defined(ENABLE_THREAD_SAFETY) && !defined(WIN32) +#ifdef ENABLE_THREAD_SAFETY if (SOCK_ERRNO == EPIPE) got_epipe = true; #endif @@ -478,19 +473,19 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len) #endif { n = send(conn->sock, ptr, len, 0); -#if defined(ENABLE_THREAD_SAFETY) && !defined(WIN32) +#ifdef ENABLE_THREAD_SAFETY 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 /* ENABLE_THREAD_SAFETY */ -#endif /* WIN32 */ +#endif +#endif return n; } @@ -1237,7 +1232,7 @@ PQgetssl(PGconn *conn) #endif /* USE_SSL */ -#if defined(ENABLE_THREAD_SAFETY) && !defined(WIN32) +#ifdef ENABLE_THREAD_SAFETY /* * 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 cb87a1379d2..d8687a8a88e 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.105 2005/08/23 20:45:07 momjian Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-int.h,v 1.106 2005/08/23 20:48:47 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,11 +30,7 @@ #endif #ifdef ENABLE_THREAD_SAFETY -#ifdef WIN32 -#include "pthread-win32.h" -#else #include <pthread.h> -#endif #include <signal.h> #endif @@ -485,7 +481,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); -#if defined(ENABLE_THREAD_SAFETY) && !defined(WIN32) +#ifdef ENABLE_THREAD_SAFETY 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 9b6dffff3f2..e5be8a95331 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.6 2005/08/23 20:45:07 momjian Exp $ +* $PostgreSQL: pgsql/src/interfaces/libpq/pthread-win32.c,v 1.7 2005/08/23 20:48:47 momjian Exp $ * *------------------------------------------------------------------------- */ #include <windows.h> -#include "pthread-win32.h" +#include "pthread.h" HANDLE pthread_self() |
