Re: pl/pgsql feature request: shorthand for argument and local variable references

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Joel Jacobson <joel(at)compiler(dot)org>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pl/pgsql feature request: shorthand for argument and local variable references
Date: 2022-01-06 20:38:38
Message-ID: CAFj8pRBBLBFYh_kiofq9EHoDV3noryTjBmcYb_Prm_tCYZJ+rg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

čt 6. 1. 2022 v 21:04 odesílatel Joel Jacobson <joel(at)compiler(dot)org> napsal:

> On Thu, Jan 6, 2022, at 20:24, Pavel Stehule wrote:
> > But there is nothing similar in standard.
> > Standard doesn't specify any column or table or label names in the
> custom area.
>
> I think that's an unfair comparison.
> This isn't at all the same thing as dictating column or table names.
> I merely suggest reusing an existing reserved keyword.
>
> >>čt 6. 1. 2022 v 20:03 odesílatel Joel Jacobson <joel(at)compiler(dot)org>
> napsal:
> >>
> >>If "in." would work, due to "in" being a reserved SQL keyword,
> >>don't you think the benefits of a SQL standardized solution would
> outweigh our
> >>personal preferences on what word each one of us prefer?
> >
> >I know that "in" is a reserved word in SQL, but I have not any knowledge
> of it being used as alias in SQL functions or in >SQL/PSM functions.
>
> Are you concerned "in" might already be used as an alias somehow?
>

I did not fully correct sentence. I wanted to write "alias of arguments of
SQL functions or SQL/PSM functions". I am sorry.

> I did some testing:
>
> "in" can be used as a column alias:
>
> => SELECT 123 AS in;
> in
> -----
> 123
> (1 row)
>
> But it cannot be used as a table alias, which is what matters:
>
> => WITH in AS (SELECT 1) SELECT * FROM in;
> ERROR: syntax error at or near "in"
>
> => SELECT * FROM t in;
> ERROR: syntax error at or near "in"
>
> => SELECT * FROM t AS in;
> ERROR: syntax error at or near "in"
>
> It's also currently not possible to use it as a PL/pgSQL alias:
>
> => CREATE FUNCTION f(id int)
> RETURNS void
> LANGUAGE plpgsql AS $$
> DECLARE
> in ALIAS FOR $1;
> BEGIN
> END
> $$;
> ERROR: syntax error at or near "in"
> LINE 5: in ALIAS FOR $1;
>
>
I didn't say, so "IN" cannot be used. Technically, maybe (I didn't write a
patch). I say, semantically - how I understand the meaning of the word "in"
is not good to use it for generic alias of function arguments (when we have
out arguments too).

Pavel

> /Joel
>
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bossart, Nathan 2022-01-06 20:41:30 Re: Add index scan progress to pg_stat_progress_vacuum
Previous Message Robert Haas 2022-01-06 20:34:28 Re: Bugs in pgoutput.c