Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: Packages in oracle Style



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



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group