Jeroen van Vianen <jeroen@design.nl> writes:
>> What I was hoping for was something that would *first* determine whether
>> foo is a sequence and *then* do the transformation only if so.
> I thought about this, but couldn't figure out how to test for foo being a
> sequence.
IIRC, foo is a sequence if it has relkind 'S'. You can check the
relkind by looking into the struct returned by heap_open. The main
thing that needs to be thought about is how to ensure that the sequence
object won't be added to the query's rangetable list if it is used in
a way that looks like a table reference. It may be that hacking up
ParseFuncOrColumn will be enough to prevent that, or it may not...
regards, tom lane