Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4099647621A for ; Tue, 13 Aug 2002 10:27:40 -0400 (EDT) Received: from mta5.snet.net (mta5.snet.net [204.60.203.77]) by postgresql.org (Postfix) with ESMTP id BE97D4761F2 for ; Tue, 13 Aug 2002 10:27:34 -0400 (EDT) Received: from pop.snet.net (pop.snet.net [204.60.203.72]) by mta5.snet.net (8.12.3/8.12.3/SNET-mx-1.2/D-1.1.1.1/O-1.1.1.1) with ESMTP id g7DEOdt0027919; Tue, 13 Aug 2002 10:24:39 -0400 (EDT) X-Originating-IP: [64.252.95.167] X-SBCIS-MTA: [pop.snet.net] Received: from [192.168.1.83] (167.95.252.64.snet.net [64.252.95.167]) by pop.snet.net (8.12.3/8.12.3/SNET-pop-1.2/D-1.1.1.1/O-1.1.1.1) with ESMTP id g7DERQT0026750; Tue, 13 Aug 2002 10:27:27 -0400 (EDT) Subject: Re: Is this valid? From: Wei Weng To: Weiping He Cc: pgsql-sql@postgresql.org In-Reply-To: <3D5883CA.8030803@zhengmai.com.cn> References: <1029194489.28129.3.camel@Monet> <3D5883CA.8030803@zhengmai.com.cn> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 13 Aug 2002 10:27:28 -0400 Message-Id: <1029248854.29893.3.camel@Monet> Mime-Version: 1.0 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/203 X-Sequence-Number: 9049 On Mon, 2002-08-12 at 23:58, Weiping He wrote: > 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. > Is it going to be resource draining if I make lots of connections in a very short time? -- Wei Weng Network Software Engineer KenCast Inc.