Re: Struggling with set-returning functions, seeking advice

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jason Topaz <topaz(at)panix(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Struggling with set-returning functions, seeking advice
Date: 2003-07-23 15:35:11
Message-ID: 13387.1058974511@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Jason Topaz <topaz(at)panix(dot)com> writes:
> 1) Note that my first attempt (view "ranges_setview_broken", referring
> to a pgplsql set function "make_rows") fails. But when I make a
> second function with identical signature, but in language 'sql'
> (it's just a passthrough to my original pgplsql function), suddenly
> the server error goes away. This seems strange to me.

It's an implementation artifact: plpgsql uses a different implementation
method to return sets than sql does. sql's method works both in SELECT
lists and in FROM, plpgsql's only works in FROM.

The trouble with a set function in FROM is that it can't take any
parameters that are extracted from other tables in the query. There
has been some talk of fixing that by implementing SQL99's LATERAL()
syntax, but we haven't yet wrapped our heads around exactly what would
be involved there. In the meantime, the way you're doing it is probably
as good as you're going to get.

regards, tom lane

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message M Spreij 2003-07-23 15:46:02 design/copying a bunch of records
Previous Message Tom Lane 2003-07-23 14:52:33 Re: CREATE TYPE with array