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

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: pl/pgsql feature request: shorthand for argument and local variable references
Дата
Msg-id CAFj8pRBBLBFYh_kiofq9EHoDV3noryTjBmcYb_Prm_tCYZJ+rg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: pl/pgsql feature request: shorthand for argument and local variable references  ("Joel Jacobson" <joel@compiler.org>)
Ответы Re: pl/pgsql feature request: shorthand for argument and local variable references  ("Joel Jacobson" <joel@compiler.org>)
Список pgsql-hackers


čt 6. 1. 2022 v 21:04 odesílatel Joel Jacobson <joel@compiler.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@compiler.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

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: Bugs in pgoutput.c
Следующее
От: "Bossart, Nathan"
Дата:
Сообщение: Re: Add index scan progress to pg_stat_progress_vacuum