Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E56B047582B for ; Mon, 12 Aug 2002 23:59:21 -0400 (EDT) Received: from mail.zhengmai.com.cn (unknown [202.99.6.10]) by postgresql.org (Postfix) with ESMTP id 97184475806 for ; Mon, 12 Aug 2002 23:59:20 -0400 (EDT) Received: from zhengmai.com.cn ([61.149.8.171]) by mail.zhengmai.com.cn (8.9.3/8.9.3) with ESMTP id LAA13546; Tue, 13 Aug 2002 11:56:10 +0800 (BST) Message-ID: <3D5883CA.8030803@zhengmai.com.cn> Date: Tue, 13 Aug 2002 11:58:02 +0800 From: Weiping He User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.1b) Gecko/20020721 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Wei Weng Cc: pgsql-sql@postgresql.org Subject: Re: Is this valid? References: <1029194489.28129.3.camel@Monet> Content-Type: text/plain; charset=x-gbk; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/195 X-Sequence-Number: 9041 Wei Weng wrote: >I am not sure if this is the right mailing list I talk to. Please let me >know if I had violated any unwritten rules. :) > >I have a global variable PGconn* m_pgconn that is the connection handle >for connecting to the postgresql database. Can I access/use the handle >from multiple threads? Say I have a thread that does some insertion >through this handle/database connection(m_pgconn) and also another >thread that do some insertion *on the same table* through this >handle(m_pgconn), will that break? > >Thanks > > > > I don't think it's a good idea to use global variable in multi-thread environment. I think use different handle in differents is better. libpq is thread safe, but it doesn't necessary mean that you could free of your own code. regards laser