Re: Patch: Allow SQL-language functions to reference parameters by parameter name - Mailing list pgsql-hackers

From Hitoshi Harada
Subject Re: Patch: Allow SQL-language functions to reference parameters by parameter name
Date
Msg-id CAP7QgmkzZt_thq4NxswTHhMwt7FOgxD=zOuy1pc8Hp_cSMMCog@mail.gmail.com
Whole thread Raw
In response to Re: Patch: Allow SQL-language functions to reference parameters by parameter name  (Hitoshi Harada <umi.tanuki@gmail.com>)
Responses Re: Patch: Allow SQL-language functions to reference parameters by parameter name
Re: Patch: Allow SQL-language functions to reference parameters by parameter name
List pgsql-hackers
On Wed, Jan 18, 2012 at 1:11 AM, Hitoshi Harada <umi.tanuki@gmail.com> wrote:
> On Sat, Jan 14, 2012 at 8:10 AM, Matthew Draper <matthew@trebex.net> wrote:
>>
>> I just remembered to make time to advance this from WIP to proposed
>> patch this week... and then worked out I'm rudely dropping it into the
>> last commitfest at the last minute. :/
>
> The patch applies clean against master but compiles with warnings.
> functions.c: In function ‘prepare_sql_fn_parse_info’:
> functions.c:212: warning: unused variable ‘argnum’
> functions.c: In function ‘sql_fn_post_column_ref’:
> functions.c:341: warning: implicit declaration of function ‘ParseFuncOrColumn’
> functions.c:345: warning: assignment makes pointer from integer without a cast
>
> (Now it occurred to me that forgetting the #include parse_func.h might
> hit this breakage..., so I'll fix it here and continue to test, but if
> you'll fix it yourself, let me know)

I fixed it here and it now works with my environment. The regression
tests pass, the feature seems working as aimed, but it seems to me
that it needs more test cases and documentation. For the tests, I
believe at least we need "ambiguous" case given upthread, so that we
can ensure to keep compatibility. For the document, it should describe
the name resolution rule, as stated in the patch comment.

Aside from them, I wondered at first what if the function is
schema-qualified. Say,

CREATE FUNCTION s.f(a int) RETURNS int AS $$ SELECT b FROM t WHERE a = s.f.a
$$ LANGUAGE sql;

It actually errors out, since function-name-qualified parameter only
accepts function name without schema name, but it looked weird to me
at first. No better idea from me at the moment, though.

I mark this "Waiting on Author" for now.

Thanks,
--
Hitoshi Harada


pgsql-hackers by date:

Previous
From: Gražvydas Valeika
Date:
Subject: Re: Strange primary key constraint influence to grouping
Next
From: Hitoshi Harada
Date:
Subject: Re: Publish checkpoint timing and sync files summary data to pg_stat_bgwriter