Tiago Antão <tra@fct.unl.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;beginx := 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