Re: BUG #5448: psql \set does not terminate if variable is referenced recursively - Mailing list pgsql-bugs

From Kevin Grittner
Subject Re: BUG #5448: psql \set does not terminate if variable is referenced recursively
Date
Msg-id 4BE14E6102000025000312DF@gw.wicourts.gov
Whole thread Raw
In response to BUG #5448: psql \set does not terminate if variable is referenced recursively  ("Francis" <fmarkham@gmail.com>)
Responses Re: BUG #5448: psql \set does not terminate if variable is referenced recursively
List pgsql-bugs
"Francis" <fmarkham@gmail.com> wrote:

> psql \set does not terminate if a variable is referenced
> recursively.  For example, the following will hang the psql client
> in a nasty way:
>
> db=# \set n 1
> db=# \set n (:n + 1)

It seem to me that the above doesn't hang the psql client, but a
subsequent reference to :n does.  It doesn't have to be a direct
self-reference, either; any circular reference seems to do it.  It
doesn't respond to Ctrl+C during this recursion.

pgbench=# \set n 1
pgbench=# \set x (:n+1)
pgbench=# select :x;
 ?column?
----------
        2
(1 row)

pgbench=# \set n 5
pgbench=# select :x;
 ?column?
----------
        6
(1 row)

pgbench=# \set n (:x+1)
pgbench=# select :x;
[CAUTION: psql sucked CPU time and ate RAM until I killed it]

-Kevin

pgsql-bugs by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: BUG #5449: "elements" are not parameter
Next
From: Tom Lane
Date:
Subject: Re: BUG #5448: psql \set does not terminate if variable is referenced recursively