Re: BUG #5448: psql \set does not terminate if variable is referenced recursively

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Francis" <fmarkham(at)gmail(dot)com>,<pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #5448: psql \set does not terminate if variable is referenced recursively
Date: 2010-05-05 15:54:25
Message-ID: 4BE14E6102000025000312DF@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2010-05-05 16:20:03 Re: BUG #5448: psql \set does not terminate if variable is referenced recursively
Previous Message Heikki Linnakangas 2010-05-05 15:14:46 Re: BUG #5449: "elements" are not parameter