"Francis" <fmarkham(at)gmail(dot)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