1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

Back out incorrect commit.

This commit is contained in:
Bruce Momjian
2005-08-23 20:48:47 +00:00
parent eef7e30cc1
commit a970a8cb95
13 changed files with 68 additions and 229 deletions

View File

@ -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:

View File

@ -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"

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -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()