Re: Any form of connection-level "session variable" ?

From: ptjm(at)interlog(dot)com (Patrick TJ McPhee)
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Any form of connection-level "session variable" ?
Date: 2007-01-05 05:45:58
Message-ID: 12prpgmn9b0926f@corp.supernews.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

In article <459D4FA0(dot)4020202(at)hardgeus(dot)com>,
John McCawley <nospam(at)hardgeus(dot)com> wrote:

% Is there any way I could establish this ID initially in some sort of
% connection-level variable, and from this point on reference that
% variable?

We do this sort of thing using a custom C function, but I've been
thinking lately you could use a custom variable class to do the same
thing.

Put
custom_variable_classes = 'session'

in your postgresql.conf, and you can have
set session.myid = 23;

then retrieve the value either by joining to pg_settings or using
show session.myid;

You can perform per-user initialisation with
alter user set session.myid = 23;

Which allows the value to persist between sessions.

I haven't done anything with this idea so I can't say how well it
works or whether there are downsides to it.
--

Patrick TJ McPhee
North York Canada
ptjm(at)interlog(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Gunnar Wagenknecht 2007-01-05 06:33:21 Re: Dependency conflicts on CentOS 4.4
Previous Message Michael Best 2007-01-05 05:24:16 Database Corruption - last chance recovery options?