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

From Tom Lane
Subject Re: BUG #5448: psql \set does not terminate if variable is referenced recursively
Date
Msg-id 6332.1273081858@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #5448: psql \set does not terminate if variable is referenced recursively  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
Responses Re: BUG #5448: psql \set does not terminate if variable is referenced recursively  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
Re: BUG #5448: psql \set does not terminate if variable is referenced recursively  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-bugs
"Kevin Grittner" <Kevin.Grittner@wicourts.gov> writes:
> Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> We could print a message and treat the inner
>> expansion as empty --- is that good enough?

> If there's any way to throw an error, that seems better.  I can
> imagine someone getting confused by silent failure here.  On the
> other hand, since this probably doesn't happen very often, maybe
> it's not worth the effort.  I could even see an argument for just
> testing for Ctrl+C before each expansion and otherwise leaving it as
> is.

The problem is there's no real support inside psql for "throwing an
error" --- we have to unwind all the state manually.  In particular,
what this problem requires is backing out the stack of flex buffers
representing pending variable expansions.  So I think we need to add
an explicit recursion test and suppress further expansion of the
variable when we see it, but there's no very simple way to just abandon
the current command altogether.

We can definitely print a message though, and I agree that just silently
suppressing recursion would be confusing.

            regards, tom lane

pgsql-bugs by date:

Previous
From: "Kevin Grittner"
Date:
Subject: Re: BUG #5448: psql \set does not terminate if variable is referenced recursively
Next
From: "Kevin Grittner"
Date:
Subject: Re: BUG #5448: psql \set does not terminate if variable is referenced recursively