Re: Plan invalidation vs temp sequences - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Plan invalidation vs temp sequences
Date
Msg-id 12935.1192112281@sss.pgh.pa.us
Whole thread Raw
In response to Re: Plan invalidation vs temp sequences  ("Florian G. Pflug" <fgp@phlo.org>)
Responses Re: Plan invalidation vs temp sequences
List pgsql-hackers
"Florian G. Pflug" <fgp@phlo.org> writes:
> Gregory Stark wrote:
>> 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?

Well, we *have* the sequence's Oid in the regclass constant, the problem
is the difficulty of digging through the plan tree to find it.  I did
consider having the planner extract it and save it aside somewhere, but
there doesn't seem to be any very convenient place to do that, short of
an extra traversal of the query tree, which is pretty annoying/expensive
for data that will probably never be needed for most queries.

> 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')).

The cast-to-text workaround that I suggested does exactly that.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Richard Huxton
Date:
Subject: Re: full text search in 8.3
Next
From: Oleg Bartunov
Date:
Subject: Re: full text search in 8.3