Re: [HACKERS] Re: proposal - using names as primary names of plpgsqlfunction parameters instead $ based names - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: [HACKERS] Re: proposal - using names as primary names of plpgsqlfunction parameters instead $ based names
Date
Msg-id CAFj8pRChBGtbMmH4Ajma8Bo8jYeQV-5EvsroFd=SupXmDn_zJQ@mail.gmail.com
Whole thread Raw
In response to Re: [HACKERS] Re: proposal - using names as primary names of plpgsqlfunction parameters instead $ based names  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Responses Re: [HACKERS] Re: proposal - using names as primary names of plpgsqlfunction parameters instead $ based names  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-hackers


2017-05-19 3:14 GMT+02:00 Peter Eisentraut <peter.eisentraut@2ndquadrant.com>:
On 5/15/17 14:34, Pavel Stehule wrote:
>     Now, I when I working on plpgsql_check, I have to check function
>     parameters. I can use fn_vargargnos and out_param_varno for list of
>     arguments and related varno(s). when I detect some issue, I am using
>     refname. It is not too nice now, because these refnames are $ based.
>     Long names are alias only. There are not a possibility to find
>     related alias.
>
>     So, my proposal. Now, we can use names as refname of parameter
>     variable. $ based name can be used as alias. From user perspective
>     there are not any change.
>
>     Comments, notes?
>
> here is a patch

I don't understand what this is changing.  There are not documentation
or test changes.

This change is visible only for tools like plpgsql_check probably and similar tools. Now, this info is not available from user space (maybe only from some error message, I have to recheck it)

What is changed.

PLpgSQL variables has field refname - it can be used if you iterate over variables or it is used for some error messages. When some variables is searching, then namespace aliases are used. Now for any function argument is created variable with refname "$x" and namespace aliases "$x" and "name" if name exists. There are not any way, how to get a aliases related to variable. When I raise a warning in plpgsql about function arguments I have to print $x based messages, what is not too readable if function has lot of parameters. 

The proposal is the change of refname "$x" to "name" for all variables created for function arguments.

There are another possibilities - maintain list of all aliases for variables or dynamically search all related aliases in namespace tree. Both little bit more code. 

Regards

Pavel
   

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

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: [HACKERS] [Proposal] Allow users to specify multiple tables inVACUUM commands
Next
From: "Bossart, Nathan"
Date:
Subject: Re: [HACKERS] [Proposal] Allow users to specify multiple tables inVACUUM commands