Re: targetlist functions part 1 (was [HACKERS] targetlist - Mailing list pgsql-patches

From Tom Lane
Subject Re: targetlist functions part 1 (was [HACKERS] targetlist
Date
Msg-id 11576.1043185027@sss.pgh.pa.us
Whole thread Raw
In response to Re: targetlist functions part 1 (was [HACKERS] targetlist  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-patches
Peter Eisentraut <peter_e@gmx.net> writes:
> Tom Lane writes:
>> Do you see another way to pass non-constant arguments to the
>> table-generating function?

> SELECT * FROM table1 AS t1, table2 AS t2, func1(t1.col, t2.col) ... ?

> That's a syntax that would make sense to me.

That syntax makes no sense whatsoever to me.  You are imputing a
causal connection between FROM elements that are at the same level,
which is just totally contrary to any sane understanding of SQL
semantics.  Exactly which t1.col value(s) do you see the above syntax
as passing to the func()?  Your answer had better not mention the
WHERE clause, because the input tables have to be determined before
WHERE has anything to operate on.

> With sufficiently blurred vision one might even find SQL99's clause
>          <collection derived table> ::=
>               UNNEST <left paren> <collection value expression> <right paren>
> applicable.  Or maybe not.

Hm.  I'm not sure what UNNEST does, but now that you bring SQL99 into
the picture, what about WITH?  That might solve the problem, because
(I think) WITH tables are logically determined before the main SELECT
begins to execute.

            regards, tom lane

pgsql-patches by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: targetlist functions part 1 (was [HACKERS] targetlist
Next
From: Rod Taylor
Date:
Subject: SEQUENCEs and NO MAXVALUE NO MINVALUE