Re: Packages in oracle Style

From: Joe Conway <mail(at)joeconway(dot)com>
To: coutinho(at)mondriantecnologia(dot)com
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Zdenek Kotala <Zdenek(dot)Kotala(at)sun(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Packages in oracle Style
Date: 2008-05-31 15:32:56
Message-ID: 48416FA8.40008@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

coutinho(at)mondriantecnologia(dot)com wrote:
> I have implemented a solution for global variables implemented in plpython and I need implement this in c :)

The below listed tarball is out of date at this point, but I have
updated code laying around if someone really wanted it:
http://www.joeconway.com/sessfunc.tar.gz
I've used variations of this over the years on several projects.

I've also (mis)used custom configs, e.g. in a plpgsql function:

8<----------------------------
EXECUTE 'set myvars.var1 to ''' || p_var1 || '''';
8<----------------------------

and in your "get session var" C function:

8<----------------------------
#define GET_SESSVAR_BY_NAME(SESS_VAR_NAME) \
do { \
SESS_VAR_NAME = GetConfigOptionByName("myvars." #SESS_VAR_NAME, \
NULL); \
if (!SESS_VAR_NAME) \
elog(ERROR, "Missing session variable: " #SESS_VAR_NAME); \
} while (0)

char *var1 = GET_SESSVAR_BY_NAME(var1);
8<----------------------------

Joe

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kevin Walker 2008-05-31 15:52:42 Re: proposal: Preference SQL
Previous Message Xin Wang 2008-05-31 15:32:51 Where can I find the doxyfile?