pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Robert Edwards <bob@cs.anu.edu.au>
To: Aaron Bono <postgresql@aranya.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: on connect/on disconnect
Date: Mon, 11 Sep 2006 14:52:23 +1000
Message-ID: <4504EB87.3090502@cs.anu.edu.au> (raw)
In-Reply-To: <bf05e51c0609102128u7a6d98e3g9faf634a71736bd@mail.gmail.com>
References: <4504B474.9010801@cs.anu.edu.au>
	<bf05e51c0609102128u7a6d98e3g9faf634a71736bd@mail.gmail.com>


Hi Aaron,

Thanks for your response. I guess I wasn't clear about "users". I am
referring to database users, not application users (although they
are the same in my application in any case - that is, each application
user is known to the database as a different database user).

As I understand it, connection pooling, as used by a web app, still
needs to connect "per-database-user" (and usually this is the same
"web-server" user). If the web app is connecting to the database
server as different database users, then different connections would
be set up. If the number of open connections exceeds the number
allowed to the database server, then older unused connections would
be terminated to allow new ones to be created. Is this correct?

Or is it possible, over the same connection, to change the database
user? My understanding of the frontend/backend protocol is that this
is not allowed.

Anyway, I still need to know if running functions during connection
setup and tear-down, or change of user, is possible or not.

Cheers,

Bob Edwards.

Aaron Bono wrote:
> On 9/10/06, *Robert Edwards* <bob@cs.anu.edu.au 
> <mailto:bob@cs.anu.edu.au>> wrote:
> 
>     (this is my first post to this list...)
> 
>     I am wondering if Postgres, and/or SQL in general, has a facility to
>     run a function at connection set-up time (after a successful connection
>     attempt) and/or at session completion (or disconnect)?
> 
>     I want to pre-populate a table (actually an INSERT rule on a view)
>     with some user-specific data that is unlikely to change during the
>     session and which is "difficult" to process (ie. affects performance
>     to do it too often).
> 
>     Clearly, I can do this manually anyway as the first operation after
>     a connection is established, but I would like also to clear it out
>     when the session terminates (so, I guess I am really interested in
>     a "trigger" of some sort on end-of-session).
> 
>     Purely session/connection-based temporary tables would also do what
>     I need, but temporary tables don't seem to be able to work that way.
> 
> 
>  
> What kind of operation are you wanting to do?  Would it work if an 
> application like a web site used connection pooling - thus sharing the 
> session across application users and rarely if ever 
> connecting/disconnecting?
> 
> ==================================================================
>    Aaron Bono
>    Aranya Software Technologies, Inc.
>    http://www.aranya.com
>    http://codeelixir.com
> ==================================================================




view thread (9+ messages)  latest in thread

Message-ID: <4504EB87.3090502@cs.anu.edu.au>
Permalink:  ../4504EB87.3090502@cs.anu.edu.au/
Also on:    postgresql.org/message-id/4504EB87.3090502@cs.anu.edu.au

 · 

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-sql@postgresql.org
  Cc: bob@cs.anu.edu.au, postgresql@aranya.com
  Subject: Re: on connect/on disconnect
  In-Reply-To: <4504EB87.3090502@cs.anu.edu.au>

* 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