Maybe helpful, maybe not. The next postgres version, with "create
or replace" will allow self referencing recursive functions. (You
need "create or replace" because currently the "create function"
will fail due to the reference to a function that does not exist
yet. Postgres
may support self referencing queries with a simple "create function"
but I don't know that for sure yet.)
I've written a recursive sql getparents function (using a hack that
emulates "create or replace") that gets all the parents and returns
a rowset. I don't really have the data available to test the
performance of this function but it seems like it should be fast.
See
https://openacs.org/bboard/q-and-a-fetch-msg.tcl?msg_id=0003Fq&topic_id=12&topic=OpenACS%204%2e0%20Design