=?iso-8859-1?Q?Tiago_Ant=E3o?= <tra(at)fct(dot)unl(dot)pt> writes:
> Isn't the problem more general than just nextval?
Yes it is, and that's why I'm not very excited about the idea of
adding special-case logic for nextval/currval into the optimizer.
It's fairly easy to get around this problem in plpgsql, eg
declare x int;
begin
x := currval('seq');
return f1 from foo where seqfld = x;
so I really am going to resist suggestions that the optimizer should
make invalid assumptions about currval by itself ...
regards, tom lane