pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Rodrigo Barboza <rodrigombufrj@gmail.com>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: PGconn and fork
Date: Wed, 08 May 2013 10:03:26 -0400
Message-ID: <21910.1368021806@sss.pgh.pa.us> (raw)
In-Reply-To: <CANs8QJajRnuU-Yz26ZQnO7ymAj+wgDvNOZ4L7sWm6y6n7ZeypQ@mail.gmail.com>
References: <CANs8QJajRnuU-Yz26ZQnO7ymAj+wgDvNOZ4L7sWm6y6n7ZeypQ@mail.gmail.com>
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-interfaces>

Rodrigo Barboza <rodrigombufrj@gmail.com> 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



view thread (3+ messages)  latest in thread

Message-ID: <21910.1368021806@sss.pgh.pa.us>
Permalink:  ../21910.1368021806@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/21910.1368021806@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: tgl@sss.pgh.pa.us, rodrigombufrj@gmail.com
  Subject: Re: PGconn and fork
  In-Reply-To: <21910.1368021806@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox