On 07/12/10 10:48, Josh Berkus wrote: > >> It seems plausible to fix the first one, but how would you fix the >> second one? You either allow SET ROLE (which you need, to support the >> pooler changing authorization), or you don't. There doesn't seem to be >> a usable middleground. > > Well, this is why such a pooler would *have* to be built into the > backend. It would need to be able to SET ROLE even though SET ROLE > would not be accepted over the client connection.
There's actually another way to do that that could be retrofitted onto an existing external pooler. It's not lovely, but if the approach above proved too hard... SET ROLE could accept a cookie / one-time password that had to be passed to RESET ROLE in order for RESET ROLE to accept the command. SET ROLE fred WITH COOKIE 'goqu8Mi6choht8ie'; -- hand to the user -- blah blah user work blah -- returned by the user RESET ROLE WITH COOKIE 'goqu8Mi6choht8ie'; The tricky bit might be that the user should still be permitted to SET ROLE, but only to roles that the role the pooler switched them to ("fred") has rights to SET ROLE to, not to roles that the pooler user its self has rights to switch to. > We'd also need > bookkeeping to track the ROLE (and other GUCs) of each client connection > and reset them whenever that client connection switches back. I'm really interested in this direction. Taken just a little further, it could bring Pg to the point where query executors (backends) are separated from connection state, so a given backend could pick up and work on queries by several different connections in rapid succession. The advantage there is that idle connections would become cheap, low-overhead affairs. As I (poorly) understand how Pg is designed it'd only be possible for a backend to work on queries that act on the same database, it couldn't really switch databases. That'd still be a real bonus especially for newer users who don't realize they *need* a connection pool. -- System & Network Administrator POST Newspapers -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers