Re: search_path improvements

From: Greg Stark <stark(at)enterprisedb(dot)com>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: search_path improvements
Date: 2009-06-01 19:05:33
Message-ID: 4136ffa0906011205o42eb2922ubd3c75c9db162cd5@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jun 1, 2009 at 7:57 PM, Alvaro Herrera
<alvherre(at)commandprompt(dot)com> wrote:
> Josh Berkus wrote:
>
>>> Well I don't mind push but I still think pop is an error. What you
>>> really want to do is restore it to the value you started with. You
>>> don't want to remove the last element since that may not be the
>>> element you added. Some function you called may have added an extra
>>> element on the head.
>>
>> Yeah, "pop" is a misnomer; what I'd want is
>> search_path_del(search_path,'admin') ... that is, a way to remove a
>> specific schema from the list.
>
> Except that "del" shouldn't delete if your "push" didn't add it because
> it was already present.  So you actually want some sort of refcounting
> there somehow.

As I said earlier I doubt "pop" or "delete" is ever going to actually
be what you want. I suspect you're far more likely to want to restore
it to what it was before you started altering it.

As support I'll point out this is what our C api has. There's no short
cut to strip out a single element of the path but the normal calling
pattern is to set aside a copy of the old path, add modify it in some
way -- often adding a schema to the head -- then restore the old path.

Note that you may want to make other modifications such as adding
several paths -- it would suck to have to hard code those twice once
to add and once to remove. Or remove a search path element and then
later restore it. Or for that matter to replace the whole search path
wholesale temporarily...

--
greg

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-06-01 19:18:28 Re: pg_standby -l might destory the archived file
Previous Message Alvaro Herrera 2009-06-01 19:04:40 Re: search_path vs extensions