"Christopher Kings-Lynne" <[EMAIL PROTECTED]> writes: >> 5. Ignore the current code which allows functions to return multiple >> results as expressions; we can leave it there, but deprecate it with the >> intention of eventual removal.
> What does the current 'setof' pl/pgsql business actually _do_? plpgsql doesn't handle setof at all, AFAIR. SQL-language functions do. The gold is hidden in src/backend/executor/*.c. The SQL function executor (functions.c) suspends the query plan for the function's final SELECT, and re-executes it to get one more result row each time it's re-called. That's okay as far as it goes; but look at what happens when such a function is called from a SELECT targetlist. The ExprMultipleResult flag from the function propagates up through execQual.c, to ExecTargetList which forms a new result tuple for each function result. All the node executor routines that call ExecProject have to be prepared to deal with that (eg, first if() in ExecScan). This is all really messy, both in the implementation and in the conception IMHO; for example, the behavior with multiple SRFs in the same targetlist is really pretty stupid (and it was worse when the code left Berkeley). I'd like to deprecate and eventually remove the whole feature. SRFs in FROM (as table sources) make way more sense than SRFs in targetlists. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])