X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id D24099DC823 for ; Tue, 28 Feb 2006 14:17:12 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 80388-02 for ; Tue, 28 Feb 2006 14:17:12 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from candle.pha.pa.us (candle.pha.pa.us [70.90.9.53]) by postgresql.org (Postfix) with ESMTP id 0A7E99DCC26 for ; Tue, 28 Feb 2006 14:17:09 -0400 (AST) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id k1SIH7l10966; Tue, 28 Feb 2006 13:17:07 -0500 (EST) From: Bruce Momjian Message-Id: <200602281817.k1SIH7l10966@candle.pha.pa.us> Subject: Re: multiple threads using one connection In-Reply-To: <20060228150950.GC6343@surnet.cl> To: Alvaro Herrera Date: Tue, 28 Feb 2006 13:17:07 -0500 (EST) CC: Robert Gruszka , pgsql-interfaces@postgresql.org X-Mailer: ELM [version 2.4ME+ PL121 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.399 required=5 tests=[AWL=-0.101, RAZOR2_CHECK=0.5] X-Spam-Score: 0.399 X-Spam-Level: X-Archive-Number: 200602/87 X-Sequence-Number: 6051 Alvaro Herrera wrote: > Robert Gruszka wrote: > > Hi, > > > > I have multi-thread application written in Ada which uses APQ. All > > threads use the same connection (can't afford one connection per > > thread). I compiled libpq with --enable-thread-safty option. > > When two threads try to execute a query at the same time one of them is > > blocked and even when the other one finishes it is not unblocked. > > The libpq API is not really intended to be used by multiple threads > simultaneously (unless you make sure only one thread is submitting a > query and waiting for the result at any time). > > The --enable-thread-safety flag is merely to ensure that the calls to > other libraries (Kerberos, etc) are handled in a thread-safe manner. It > doesn't have any effect on the thread safety of the libpq API itself. Just to clarify, libpq is thread-safe is each thread uses its own connection object. -- Bruce Momjian http://candle.pha.pa.us SRA OSS, Inc. http://www.sraoss.com + If your life is a hard drive, Christ can be your backup. +