Re: Re: proposal - using names as primary names of plpgsql function parameters instead $ based names

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Re: proposal - using names as primary names of plpgsql function parameters instead $ based names
Date: 2017-05-19 03:48:08
Message-ID: CAFj8pRChBGtbMmH4Ajma8Bo8jYeQV-5EvsroFd=SupXmDn_zJQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2017-05-19 3:14 GMT+02:00 Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)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
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bossart, Nathan 2017-05-19 03:55:01 Re: [Proposal] Allow users to specify multiple tables in VACUUM commands
Previous Message Michael Paquier 2017-05-19 03:26:57 Re: [Proposal] Allow users to specify multiple tables in VACUUM commands