Re: allow referring to functions without arguments when unique

From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: allow referring to functions without arguments when unique
Date: 2017-03-10 05:03:12
Message-ID: 565c3261-09bf-7feb-2658-b0802466b059@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 3/7/17 00:32, Michael Paquier wrote:
>> OK. After a lookup, I am just seeing opfamily, opclass missing, so
>> this patch is doing it as you describe.

I'm not sure what you mean here.

>> @@ -7198,6 +7198,33 @@ function_with_argtypes:
>> n->objargs = extractArgTypes($2);
>> $$ = n;
>> }
>> This may not have arguments listed, so is function_with_argtypes really adapted?

Well, we could do something like function_with_opt_argtypes?

>> + /*
>> + * If no arguments were specified, the name must yield a unique candidate.
>> + */
>> + if (nargs == -1 && clist)
>> + {
>> + if (clist->next)
>> + ereport(ERROR,
>> I would have used list_length here for clarity.

This is actually not a "List" node.

>> The comment at the top of LookupFuncName() needs a refresh. The caller
>> can as well just use a function name without arguments.

Fixed.

> =# set search_path to 'public,popo';

I think you mean

set search_path to public,popo;

> =# drop function dup2;
> ERROR: 42883: function dup2() does not exist
> LOCATION: LookupFuncName, parse_func.c:1944
> In this case I would have expected an error telling that the name is
> ambiguous. FuncnameGetCandidates() returns an empty list.

Your example works correctly if you set the schema path correctly.
However, the error message is misleading with the parentheses. I have
updated that to create a different error message for this case, and
added a test case.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment Content-Type Size
v2-0001-Allow-referring-to-functions-without-arguments-wh.patch application/x-patch 25.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2017-03-10 05:03:46 Re: [PATCH] Enabling atomics on ARM64
Previous Message Petr Jelinek 2017-03-10 04:59:39 Logical replication origin tracking fix