Re: plpgsql: can I use a variable in a DECLARE later whithin the DECLARE?

Поиск
Список
Период
Сортировка
От tomas@tuxteam.de
Тема Re: plpgsql: can I use a variable in a DECLARE later whithin the DECLARE?
Дата
Msg-id 20211029145030.GA13799@tuxteam.de
обсуждение исходный текст
Ответ на Re: plpgsql: can I use a variable in a DECLARE later whithin the DECLARE?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Fri, Oct 29, 2021 at 10:04:31AM -0400, Tom Lane wrote:
> <tomas@tuxteam.de> writes:
> > In plpgsql, i'm trying to use a variable initialised in a DECLARE in
> > a later initialisation expression whithin the same DECLARE:
>
> >   DECLARE
> >     x int := 23;
> >     y int := x + 4
> >   BEGIN
> >    ...
>
> > Experiments suggest that it works, but the docs are silent about that.
> > Is this a good idea, or should I be more careful and do it in a nested
> > block?
>
> I don't see any reason to foresee that it would break.

Thanks :)

> However, I notice that we don't actually have any regression tests
> checking this.  scope_test() in plpgsql.sql checks an adjacent
> question, but not exactly this one.  I'm a bit inclined now to go
> add such a test.

Even more thanks.

After a long hiatus I have the luck to play again with PostgreSQL.
Let me say: you folks rock, seriously.

Cheers
 - t

Вложения

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

Предыдущее
От: Daniel Gustafsson
Дата:
Сообщение: Re: Extension ownership and misuse of SET ROLE/SET SESSION AUTHORIZATION
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: Vulnerability identified with Postgres 13.4 for Windows