Re: ecpg threading vs win32 - Mailing list pgsql-patches

From ITAGAKI Takahiro
Subject Re: ecpg threading vs win32
Date
Msg-id 20070319092204.6B50.ITAGAKI.TAKAHIRO@oss.ntt.co.jp
Whole thread Raw
In response to ecpg threading vs win32  (Magnus Hagander <magnus@hagander.net>)
Responses Re: ecpg threading vs win32  (Magnus Hagander <magnus@hagander.net>)
List pgsql-patches
Magnus Hagander <magnus@hagander.net> wrote:

> This patch replaces the pthreads code in ecpg with native win32 threads,
> in order to make it threadsafe. The idea is not to have to download the
> non-standard pthreads library on windows.
>
> Does it seem like it should be doing the right thing? Does somebody have
> a good test-case where ecpg breaks when not built thread-safe? (which
> would then also break when built thread-safe with a broken implementation)

I have two questions about thread-safe ecpg.

Q1. Don't you use CRITICAL_SECTION instead of Mutex (CreateMutex)?
   I've heard there is a performance benefit in CRITICAL_SECTION.
   If the mutex is shared only in one process, CS might be a better solution.
        http://japan.internet.com/developer/img/article/873/17801.gif
        http://world.std.com/~jmhart/csmutx.htm

Q2. Do we need to use PQescapeStringConn() instead of PQescapeString()?
   PQescapeString() is used to escape literals, and the documentation says
   PQescapeStringConn() should be used in multi-threaded client programs.
        http://momjian.us/main/writings/pgsql/sgml/libpq-exec.html#LIBPQ-EXEC-ESCAPE-STRING
   | PQescapeString can be used safely in single-threaded client programs
   | that work with only one PostgreSQL connection at a time



Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center



pgsql-patches by date:

Previous
From: Tom Lane
Date:
Subject: Re: Code-Cleanup: char* -> const char*
Next
From: ITAGAKI Takahiro
Date:
Subject: vacuumdb cancel handler