Index: configure =================================================================== RCS file: /cvsroot/pgsql-server/configure,v retrieving revision 1.269 diff -c -c -r1.269 configure *** configure 12 Jun 2003 16:05:09 -0000 1.269 --- configure 13 Jun 2003 23:04:32 -0000 *************** *** 855,860 **** --- 855,861 ---- --with-libraries=DIRS look for additional libraries in DIRS --with-libs=DIRS alternative spelling of --with-libraries --with-pgport=PORTNUM change default port number 5432 + --with-threads allow libpq to be thread-safe --with-tcl build Tcl and Tk interfaces --without-tk do not build Tk interfaces if Tcl is enabled --with-tclconfig=DIR tclConfig.sh and tkConfig.sh are in DIR *************** *** 2810,2815 **** --- 2811,2851 ---- IFS=$ac_save_IFS # + # Enable libpq to be thread-safe + # + echo "$as_me:$LINENO: checking allow threaded libpq" >&5 + echo $ECHO_N "checking allow threaded libpq... $ECHO_C" >&6 + + + + # Check whether --with-threads or --without-threads was given. + if test "${with_threads+set}" = set; then + withval="$with_threads" + + case $withval in + yes) + : + ;; + no) + : + ;; + *) + { { echo "$as_me:$LINENO: error: no argument expected for --with-threads option" >&5 + echo "$as_me: error: no argument expected for --with-threads option" >&2;} + { (exit 1); exit 1; }; } + ;; + esac + + else + with_threads=no + + fi; + + echo "$as_me:$LINENO: result: $with_threads" >&5 + echo "${ECHO_T}$with_threads" >&6 + + + # # Tcl/Tk # echo "$as_me:$LINENO: checking whether to build with Tcl" >&5 *************** *** 3550,3556 **** # # Pthreads # ! echo "$as_me:$LINENO: checking for ANSI C header files" >&5 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 if test "${ac_cv_header_stdc+set}" = set; then --- 3586,3592 ---- # # Pthreads # ! if test "$with_threads" = yes; then echo "$as_me:$LINENO: checking for ANSI C header files" >&5 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 if test "${ac_cv_header_stdc+set}" = set; then *************** *** 3850,3874 **** fi if test $ac_cv_header_pthread_h = yes; then ! ! cat >>confdefs.h <<\_ACEOF ! #define HAVE_THREADS 1 ! _ACEOF ! fi ! if test ! -z "$HAVE_THREADS" ! then ! case $host_os in ! # BSD/OS and NetBSD require no special libraries or flags ! netbsd*|bsdi*) ;; freebsd2*|freebsd3*|freebsd4*) THREAD_CFLAGS="-pthread" ;; freebsd*) THREAD_LIBS="-lc_r" ;; linux*) THREAD_LIBS="-lpthread" THREAD_CFLAGS="-D_REENTRANT" ;; ! # other operating systems might fail because they have pthread.h but need ! # special libs we don't know about yet. esac fi --- 3886,3923 ---- fi if test $ac_cv_header_pthread_h = yes; then ! : ! else ! { { echo "$as_me:$LINENO: error: pthread.h not found, required for --with-threads" >&5 ! echo "$as_me: error: pthread.h not found, required for --with-threads" >&2;} ! { (exit 1); exit 1; }; } fi ! case $host_os in ! netbsd*|bsdi*) ! # these require no special flags or libraries ! ;; freebsd2*|freebsd3*|freebsd4*) THREAD_CFLAGS="-pthread" ;; freebsd*) THREAD_LIBS="-lc_r" ;; linux*) THREAD_LIBS="-lpthread" THREAD_CFLAGS="-D_REENTRANT" ;; ! *) ! # other operating systems might fail because they have pthread.h but need ! # special libs we don't know about yet. ! { { echo "$as_me:$LINENO: error: ! Cannot enable threads on your platform. ! Please report your platform threading info to the PostgreSQL mailing lists ! so it can be added to the next release. Report any compile or link flags, ! or libraries required for threading support. ! " >&5 ! echo "$as_me: error: ! Cannot enable threads on your platform. ! Please report your platform threading info to the PostgreSQL mailing lists ! so it can be added to the next release. Report any compile or link flags, ! or libraries required for threading support. ! " >&2;} ! { (exit 1); exit 1; }; } esac fi *************** *** 17540,17545 **** --- 17589,17595 ---- s,@GCC@,$GCC,;t t s,@autodepend@,$autodepend,;t t s,@INCLUDES@,$INCLUDES,;t t + s,@with_threads@,$with_threads,;t t s,@with_tcl@,$with_tcl,;t t s,@with_tk@,$with_tk,;t t s,@with_perl@,$with_perl,;t t Index: configure.in =================================================================== RCS file: /cvsroot/pgsql-server/configure.in,v retrieving revision 1.260 diff -c -c -r1.260 configure.in *** configure.in 12 Jun 2003 16:05:09 -0000 1.260 --- configure.in 13 Jun 2003 23:04:34 -0000 *************** *** 320,325 **** --- 320,333 ---- IFS=$ac_save_IFS # + # Enable libpq to be thread-safe + # + AC_MSG_CHECKING([allow threaded libpq]) + PGAC_ARG_BOOL(with, threads, no, [ --with-threads allow libpq to be thread-safe]) + AC_MSG_RESULT([$with_threads]) + AC_SUBST(with_threads) + + # # Tcl/Tk # AC_MSG_CHECKING([whether to build with Tcl]) *************** *** 544,563 **** # # Pthreads # ! ! AC_CHECK_HEADER(pthread.h, ! [AC_DEFINE(HAVE_THREADS, 1, [Define to 1 if you have the threads interface.])]) ! if test ! -z "$HAVE_THREADS" ! then ! case $host_os in ! # BSD/OS and NetBSD require no special libraries or flags ! netbsd*|bsdi*) ;; freebsd2*|freebsd3*|freebsd4*) THREAD_CFLAGS="-pthread" ;; freebsd*) THREAD_LIBS="-lc_r" ;; linux*) THREAD_LIBS="-lpthread" THREAD_CFLAGS="-D_REENTRANT" ;; ! # other operating systems might fail because they have pthread.h but need ! # special libs we don't know about yet. esac fi AC_SUBST(THREAD_LIBS) --- 552,576 ---- # # Pthreads # ! if test "$with_threads" = yes; then ! AC_CHECK_HEADER(pthread.h, [], [AC_MSG_ERROR([pthread.h not found, required for --with-threads])]) ! case $host_os in ! netbsd*|bsdi*) ! # these require no special flags or libraries ! ;; freebsd2*|freebsd3*|freebsd4*) THREAD_CFLAGS="-pthread" ;; freebsd*) THREAD_LIBS="-lc_r" ;; linux*) THREAD_LIBS="-lpthread" THREAD_CFLAGS="-D_REENTRANT" ;; ! *) ! # other operating systems might fail because they have pthread.h but need ! # special libs we don't know about yet. ! AC_MSG_ERROR([ ! Cannot enable threads on your platform. ! Please report your platform threading info to the PostgreSQL mailing lists ! so it can be added to the next release. Report any compile or link flags, ! or libraries required for threading support. ! ]) esac fi AC_SUBST(THREAD_LIBS) Index: doc/src/sgml/installation.sgml =================================================================== RCS file: /cvsroot/pgsql-server/doc/src/sgml/installation.sgml,v retrieving revision 1.133 diff -c -c -r1.133 installation.sgml *** doc/src/sgml/installation.sgml 11 Jun 2003 06:56:06 -0000 1.133 --- doc/src/sgml/installation.sgml 13 Jun 2003 23:04:36 -0000 *************** *** 915,920 **** --- 915,929 ---- + + + + Allow separate libpq threads to safely control their private connection handles. + + + + + Index: doc/src/sgml/libpq.sgml =================================================================== RCS file: /cvsroot/pgsql-server/doc/src/sgml/libpq.sgml,v retrieving revision 1.123 diff -c -c -r1.123 libpq.sgml *** doc/src/sgml/libpq.sgml 14 May 2003 03:25:58 -0000 1.123 --- doc/src/sgml/libpq.sgml 13 Jun 2003 23:04:39 -0000 *************** *** 509,519 **** is leaked for each call to PQconndefaults. - - In PostgreSQL versions before 7.0, PQconndefaults returned a pointer - to a static array, rather than a dynamically allocated array. That - was not thread-safe, so the behavior has been changed. - --- 509,514 ---- *************** *** 2549,2565 **** ! libpq is thread-safe as of ! PostgreSQL 7.0, so long as no two threads ! attempt to manipulate the same PGconn object at the same ! time. In particular, you cannot issue concurrent commands from different ! threads through the same connection object. (If you need to run ! concurrent commands, start up multiple connections.) ! PGresult objects are read-only after creation, and so can be passed around ! freely between threads. --- 2544,2566 ---- ! libpq is thread-safe if the library is ! compiled using the --with-threads ! configure command-line option. (You might need to ! use other threading command-line options to compile your client code.) ! ! ! ! One restriction is that no two threads attempt to manipulate the same ! PGconn object at the same time. In particular, you cannot ! issue concurrent commands from different threads through the same ! connection object. (If you need to run concurrent commands, start up ! multiple connections.) ! PGresult objects are read-only after creation, and so can be ! passed around freely between threads. Index: src/include/pg_config.h.in =================================================================== RCS file: /cvsroot/pgsql-server/src/include/pg_config.h.in,v retrieving revision 1.50 diff -c -c -r1.50 pg_config.h.in *** src/include/pg_config.h.in 12 Jun 2003 07:36:51 -0000 1.50 --- src/include/pg_config.h.in 13 Jun 2003 23:04:41 -0000 *************** *** 468,476 **** /* Define to 1 if you have the header file. */ #undef HAVE_TERMIOS_H - /* Define to 1 if you have the threads interface. */ - #undef HAVE_THREADS - /* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use `HAVE_STRUCT_TM_TM_ZONE' instead. */ #undef HAVE_TM_ZONE --- 468,473 ----