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

Re: PG + PHP, was Re: Zend survey result about dbms...

From: Mike Mascari <mascarm(at)mascari(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Richard Huxton <dev(at)archonet(dot)com>, newsy(at)lewczuk(dot)com,Lista dyskusyjna pgsql-php <pgsql-php(at)postgresql(dot)org>,Lista dyskusyjna pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: PG + PHP, was Re: Zend survey result about dbms...
Date: 2003-09-20 22:18:48
Message-ID: 3F6CD248.8040006@mascari.com (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-php
Tom Lane wrote:

> Richard Huxton <dev(at)archonet(dot)com> writes:
> 
>>One thing I think would be useful is another pseudo-var in PG,
>>something like APP_SESSION_VAR which can be set and then used in PG
>>queries.
> 
> 
>>Tom - if I offered to produce a patch for something like this - either a var 
>>or a function pair (get_app_session_var(), set_app_session_var(varchar)) 
>>would it be likely to be accepted?
> 
> 
> It'd depend a lot on the details of what you propose, I think.  True
> variables seem like they'd be rather invasive, not to mention possibly
> error-prone (is "foo" a variable or a column reference?).  However you
> could do something pretty self-contained in the form of a couple of
> functions.  I'd suggest they support more than just one variable, btw.
> How about "set_session_variable(varname, varvalue)" and
> "get_session_variable(varname)"?
> 
> I should think we'd at least accept that as a contrib module; whether it
> would become mainstream would probably depend on the level of interest.

In the past, one hack would be to use setenv() and getenv() of the
backend to implement these functions. What about a contrib module that:

1) At set_session_variable(), a getenv() on the key
(PG_APP_SESSION_VAR) is made to see if memory has already been
allocated for a private variable map. If so, add the variable to the
map, else allocate a new map and set it's address using setenv().

2) At get_session_variable() a getenv() on the key
(PG_APP_SESSION_VAR) is made to see if a map exists. If so, it looks
into the map for the value of the name specified and returns it.

3) At get reset_session_variables() a getenv() on the key
(PG_APP_SESSION_VAR) is made to see if a map exists. If so, it is emptied.

This way, no change to any internal postgres code is required, the
memory allocated to the session-specific variables gets released at
backend closing, etc.

Would something like that be acceptable?

Mike Mascari
mascarm(at)mascari(dot)com







In response to

Responses

pgsql-php by date

Next:From: Tom LaneDate: 2003-09-20 22:29:01
Subject: Re: PG + PHP, was Re: Zend survey result about dbms...
Previous:From: Frank FinnerDate: 2003-09-20 20:42:07
Subject: Re: Interview questions?

pgsql-general by date

Next:From: Tom LaneDate: 2003-09-20 22:29:01
Subject: Re: PG + PHP, was Re: Zend survey result about dbms...
Previous:From: Marc G. FournierDate: 2003-09-20 22:01:58
Subject: Re: Catalog vs. user table format (was Re: State of Beta

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group