Re: Packages in oracle Style - Mailing list pgsql-hackers

From Joe Conway
Subject Re: Packages in oracle Style
Date
Msg-id 48416FA8.40008@joeconway.com
Whole thread Raw
In response to Re: Packages in oracle Style  (<coutinho@mondriantecnologia.com>)
Responses Re: Packages in oracle Style  ("Harald Armin Massa" <haraldarminmassa@gmail.com>)
List pgsql-hackers
coutinho@mondriantecnologia.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


pgsql-hackers by date:

Previous
From: Jan Urbański
Date:
Subject: Re: proposal: Preference SQL
Next
From: Tom Lane
Date:
Subject: Re: Overhauling GUCS