Re: [COMMITTERS] pgsql: Add notion of a "transform function" that can simplify function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Noah Misch <noah(at)leadboat(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [COMMITTERS] pgsql: Add notion of a "transform function" that can simplify function
Date: 2012-03-23 16:27:37
Message-ID: 14603.1332520057@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

I wrote:
> However, see my response to Robert: why are we passing the original node
> to the transform function at all? It would be more useful and easier to
> work with to pass the function's fully-processed argument list, I believe.

After a bit of looking around, I realize that the current implementation
of transform functions is flat-out wrong, because whenever a transform
actually fires, it proceeds to throw away all the work that
eval_const_expressions has done on the input, and instead return some
lightly-modified version of the original node tree. Thus for example
in the regression database:

regression=# create function foo(x float8, y int) returns numeric as
regression-# 'select ($1 + $2)::numeric' language sql;
CREATE FUNCTION

regression=# select "numeric"(foo(y := 1, x := f1), -1) from float8_tbl;
ERROR: unrecognized node type: 310

since the adjustment of foo's named arguments is thrown away.

So this patch is going to need some work. I continue to not see any
particular reason why the transform function should need the original
node tree. I think what it *should* be getting is the OID of the
function (currently, it's impossible for one transform to serve more
than one function, which seems like it might be useful); the input
collation (currently, transforms are basically unusable for any
collation-sensitive function), and the pre-simplified argument list.

regards, tom lane

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2012-03-23 16:52:31 Re: [COMMITTERS] pgsql: Add notion of a "transform function" that can simplify function
Previous Message Noah Misch 2012-03-23 16:09:56 Re: [COMMITTERS] pgsql: Add notion of a "transform function" that can simplify function

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2012-03-23 16:29:28 Re: query cache
Previous Message Dimitri Fontaine 2012-03-23 16:12:22 Re: Finer Extension dependencies