Re: Add function to return the thread safety status of libpq

Lists: pgsql-patches
From: Qingqing Zhou <zhouqq(at)cs(dot)toronto(dot)edu>
To: pgsql-patches(at)postgresql(dot)org
Subject: Add function to return the thread safety status of libpq
Date: 2005-12-03 05:22:01
Message-ID: Pine.LNX.4.58.0512030016330.5049@eon.cs
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches


This is half of an item in TODO list. I patch this because now pgbench is
threaded in Win32, so it is better to check thread safety of libpq.dll.

Patch ecpg could be done in a similar way, but I am not sure how we will
use this function there ...

Regards,
Qingqing

---

Index: fe-connect.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v
retrieving revision 1.324
diff -c -r1.324 fe-connect.c
*** fe-connect.c 22 Nov 2005 18:17:32 -0000 1.324
--- fe-connect.c 3 Dec 2005 05:15:29 -0000
***************
*** 2860,2865 ****
--- 2860,2875 ----
return PG_PROTOCOL_MAJOR(conn->pversion);
}

+ bool
+ PQthreadSafe(void)
+ {
+ #ifdef ENABLE_THREAD_SAFETY
+ return true;
+ #else
+ return false;
+ #endif
+ }
+
int
PQserverVersion(const PGconn *conn)
{
Index: libpq-fe.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/interfaces/libpq/libpq-fe.h,v
retrieving revision 1.122
diff -c -r1.122 libpq-fe.h
*** libpq-fe.h 23 Nov 2005 04:23:28 -0000 1.122
--- libpq-fe.h 3 Dec 2005 05:15:29 -0000
***************
*** 264,269 ****
--- 264,270 ----
extern const char *PQparameterStatus(const PGconn *conn,
const char *paramName);
extern int PQprotocolVersion(const PGconn *conn);
+ extern bool PQthreadSafe(void);
extern int PQserverVersion(const PGconn *conn);
extern char *PQerrorMessage(const PGconn *conn);
extern int PQsocket(const PGconn *conn);


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Qingqing Zhou <zhouqq(at)cs(dot)toronto(dot)edu>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: Add function to return the thread safety status of libpq
Date: 2005-12-03 06:13:48
Message-ID: 27229.1133590428@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Qingqing Zhou <zhouqq(at)cs(dot)toronto(dot)edu> writes:
> This is half of an item in TODO list. I patch this because now pgbench is
> threaded in Win32, so it is better to check thread safety of libpq.dll.

ISTM this was proposed once before, and rejected on the grounds that
no one could present a convincing use case. Exactly where is there
an application that will support both threaded and nonthreaded libpq
*at run time*? Is there a point in checking the thread-safety of
libpq when you can't check the thread-safety of libc?

BTW, an acceptable patch that changes libpq's API would require
documentation and exports.txt updates...

regards, tom lane


From: "Qingqing Zhou" <zhouqq(at)cs(dot)toronto(dot)edu>
To: pgsql-patches(at)postgresql(dot)org
Subject: Re: Add function to return the thread safety status of libpq
Date: 2005-12-03 06:19:26
Message-ID: dmrdbl$25so$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches


"Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote
>
> Is there a point in checking the thread-safety of
> libpq when you can't check the thread-safety of libc?
>

Exactly :-(

Regards,
Qingqing