Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Ua4y6-0001DF-Io for pgsql-interfaces@arkaria.postgresql.org; Wed, 08 May 2013 14:03:42 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Ua4y5-0006oz-E6 for pgsql-interfaces@arkaria.postgresql.org; Wed, 08 May 2013 14:03:41 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Ua4xy-0006ig-1p for pgsql-interfaces@postgresql.org; Wed, 08 May 2013 14:03:34 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Ua4xs-0003FS-82 for pgsql-interfaces@postgresql.org; Wed, 08 May 2013 14:03:33 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.5/8.14.5) with ESMTP id r48E3QFI021911; Wed, 8 May 2013 10:03:26 -0400 (EDT) From: Tom Lane To: Rodrigo Barboza cc: pgsql-interfaces@postgresql.org Subject: Re: PGconn and fork In-reply-to: References: Comments: In-reply-to Rodrigo Barboza message dated "Wed, 08 May 2013 10:29:48 -0300" Date: Wed, 08 May 2013 10:03:26 -0400 Message-ID: <21910.1368021806@sss.pgh.pa.us> X-Pg-Spam-Score: -3.3 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-interfaces Precedence: bulk Sender: pgsql-interfaces-owner@postgresql.org Rodrigo Barboza writes: > I have a program in C, the createas a connection, do stuff, fork, exit > child and continues life. > Supose that when I create de PGconn, I have 1 active connection in postgres. > When I fork, does it count as a second connection? I mean, will postrges > interpretate 2 active connections or they only share the same connection? > I know that if the child process execute some query, I can get unexpected > results, but it doesn't, so I am safe about that. > I'm only worried that this can increase the number of connections and reach > the limit of max_connections. No, the child process will just have another reference to the open socket that connects to the server. The reason why it's dangerous to send queries from such a process is exactly that, to the server, it looks like the same connection as the parent process. regards, tom lane -- Sent via pgsql-interfaces mailing list (pgsql-interfaces@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-interfaces