pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kyle <kyle@actarg.com>
To: pgsql-sql@postgresql.org
Cc: Jonathan Bartlett <johnnyb6@SDF.lonestar.org>
Subject: Setting session global variables
Date: Thu, 17 May 2001 08:57:16 -0600
Message-ID: <3B03E6CC.6D2A30FE@actarg.com> (raw)
References: <200105170129.f4H1TZA95638@postgresql.org>

>
> Is there a way to set a session global variable in PostgreSQL?  The
> only
> thing I see are examples of setting config variables.

Not sure if session variables are your best solution, but here's how you
implement them:

-- Warning: this defines a global variable in the tcl interpretor.  This
could
-- crash with other TCL procedures if the same name were used during the
same connection.

-- Store a value in a variable.  This is helpful for caching values in a
transaction
-- Calling sequence: store(variable,value)
create function store(text,text) returns int4 as '
    global store_vars
    return [set store_vars($1) $2]
    ' LANGUAGE 'pltcl';

-- Fetch a value from a variable.
-- Calling sequence: recall(variable)
create function recall(text) returns int4 as '
    global store_vars
    return [subst $store_vars($1)]
    ' LANGUAGE 'pltcl';

Attachments:

kyle.vcf (text/x-vcard, 184B) download begin:vcard n:Bateman;Kyle x-mozilla-html:FALSE org:Action Target Inc. adr:;;;;;; version:2.1 email;internet:kyle@actarg.com title:President x-mozilla-cpt:;0 fn:Kyle Bateman end:vcard

view thread (4+ messages)

Message-ID: <3B03E6CC.6D2A30FE@actarg.com>
Permalink:  ../3B03E6CC.6D2A30FE@actarg.com/
Also on:    postgresql.org/message-id/3B03E6CC.6D2A30FE@actarg.com

 · 

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: kyle@actarg.com, johnnyb6@SDF.lonestar.org
  Subject: Re: Setting session global variables
  In-Reply-To: <3B03E6CC.6D2A30FE@actarg.com>

* 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