Re: search_path improvements WAS: search_path vs extensions

From: "David E(dot) Wheeler" <david(at)kineticode(dot)com>
To: Greg Stark <stark(at)enterprisedb(dot)com>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, Dimitri Fontaine <dfontaine(at)hi-media(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org, Stephen Frost <sfrost(at)snowman(dot)net>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
Subject: Re: search_path improvements WAS: search_path vs extensions
Date: 2009-05-30 06:19:00
Message-ID: 5A1FE6B1-9857-454C-A385-BA061DED346F@kineticode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On May 29, 2009, at 5:16 PM, Greg Stark wrote:

> On Fri, May 29, 2009 at 11:03 PM, David E. Wheeler <david(at)kineticode(dot)com
> > wrote:
>> On May 29, 2009, at 2:52 PM, Josh Berkus wrote:
>>
>>> a) the ability to "push" a schema onto the current search path
>>> b) the ability to "pull" a schema off the current search path
>>
>> push, pop, shift, unshift. :-)
>>
>> Come to think of it, I want these for arrays, too. ;-)
>
> push and unshift sure -- and you do have those for arrays, it's
> spelled ||.

Well, no, not quite, as push, pop, shift, and unshift change arrays in
place, whereas || (and array_concat() and array_append() and
array_prepend()) create and return a new array.

> I'm not so sure about pop/shift though. How would you know the element
> you want is at the beginning/end unless you just put it there?

Well, for arrays, I might use them in a function just as I currently
use them for various things in Perl. For search_path, yeah, I'd use
them for lexical scoping: unshift a path onto the search path at the
beginning of the function and shift it off at the end. Or push it onto
the end of the search path and pop it off at the end.

> I think what you really want is to use SET LOCAL or RESET to restore
> it to whatever it was before you started futzing with it. We might
> need a more flexible way to do that that isn't tied to transactions
> though.

Well, lexical scoping for the changes would help, for sure. And I
think that RESET is fine, but it would be more useful to have ways to
push and unshift, or even to splice (sometimes I might want to remove
a schema from the search path no matter where it appears in the path).

Best,

David

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2009-05-30 12:11:47 Re: pg_migrator and an 8.3-compatible tsvector data type
Previous Message Sushant Sinha 2009-05-30 05:59:29 dot to be considered as a word delimiter?