Re: [PATCH] A hook for session start

From: Nico Williams <nico(at)cryptonector(dot)com>
To: Craig Ringer <craig(at)2ndquadrant(dot)com>
Cc: Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Fabrízio de Royes Mello <fabriziomello(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: Re: [PATCH] A hook for session start
Date: 2017-10-05 20:30:06
Message-ID: 20171005203005.GX1251@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jul 21, 2017 at 11:10:52PM +0800, Craig Ringer wrote:
> What practical use cases are there for acting post-auth but that can't wait
> until the user tries to do something?

Creating TEMP schema that triggers and functions might need.

Doing CREATE TEMP TABLE IF NOT EXISTS in triggers slows things down.

It'd be super nice if PostgreSQL had some sort of persistent TEMP
schema option, where you can have schema elements that are persistent
in that they're always there, but where the data is all TEMP. Oracle
has this and they call it GLOBAL TEMP IIRC. There would be some
caveats, such as not being able to have FKs between these sorts of
persistent temp tables and persistent tables.

In the absence of such a feature, a session hook/trigger is a great
workaround.

> Can a user do anything remotely interesting or useful without hitting
> either ExecutorStart_hook or ProcessUtility_hook? They can parse queries I
> guess but you could just set your hook up in the parser instead. If you
> hook the parser all they can do is open an idle session and sit there...

In any other hook you'd have to check whether the session setup work you
wanted to do has been done. That could be potentially slow.

I actually have an all SQL implementation of session/begin/commit
triggers. The session triggers in that implementation only run on the
first DML statement, which could be too late for OP's purpose.

Nico
--

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Nico Williams 2017-10-05 20:31:40 Re: [PATCH] A hook for session start
Previous Message Fabrízio de Royes Mello 2017-10-05 19:18:59 Re: [PATCH] A hook for session start