Re: Plan invalidation vs temp sequences

From: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>
To: Gregory Stark <stark(at)enterprisedb(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Plan invalidation vs temp sequences
Date: 2007-10-11 10:00:03
Message-ID: 470DF423.4030005@phlo.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Gregory Stark wrote:
> "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
>
>> There doesn't seem to be any very nice way to fix this. There is
>> not any existing support mechanism (comparable to query_tree_walker)
>> for scanning whole plan trees, which means that searching a cached plan
>> for regclass Consts is going to involve a chunk of new code no matter
>> how we approach it. We might want to do that someday --- in particular,
>> if we ever try to extend the plan inval mechanism to react to
>> redefinitions of non-table objects, we'd likely need some such thing
>> anyway. I'm disinclined to try to do it for 8.3 though. The use-case
>> for temp sequences seems a bit narrow and there are several workarounds
>> (see followups to bug report), so I'm feeling this is a
>> fix-some-other-day kind of issue.
>
> Given that sequences are in fact relations is there some way to work around
> the issue at least in this case by stuffing the sequence's relid someplace
> which the plan invalldation code can check for it?

Hm... couldn't this be worked around by doing
create or replace function dynamic_oid(text) returning regclass as
'select $1::regclass' language 'pl/pgsql' stable;
And then writing
nextval(dynamic_oid('mysequence')).

I didn't test this, but it it actually works, maybe we should just stick this
into the docs somewhere. It's probably too late to add that function to the
backend, though...

As long as mysequence is really a temporary sequence, this wont even have
searchpath issues I think, because those are always on top of the searchpatch
anyway, aren't they?

greetings, Florian Pflug

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Trevor Talbot 2007-10-11 10:55:38 Re: Timezone database changes
Previous Message Heikki Linnakangas 2007-10-11 08:36:22 Re: Including Snapshot Info with Indexes