Re: BUG #18134: ROW_COUNT do not set to 0 when psql's \gset command get no rows returned

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Japin Li <japinli(at)hotmail(dot)com>, amutu(at)amutu(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18134: ROW_COUNT do not set to 0 when psql's \gset command get no rows returned
Date: 2023-10-01 00:44:07
Message-ID: 1615012.1696121047@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Michael Paquier <michael(at)paquier(dot)xyz> writes:
> On Wed, Sep 27, 2023 at 06:00:58PM +0800, Japin Li wrote:
>> It seems SaveResultVariables() was lost when executing failed. Attached fix it.

> Yeah, I think that you're right here, the variables should be set.
> SetResultVariables() ought to be called even if \gset failed to return
> a result.

Agreed. The adjacent comment is now a lie though. Maybe just

- /* set variables on last result if all went well */
+ /* set variables from last result */

Bigger-picture question: should we back-patch this, or just fix it in
HEAD? It's wrong, but I'm not sure it's so obviously wrong that there
could not be somebody depending on the existing behavior.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Paquier 2023-10-01 00:54:22 Re: BUG #18134: ROW_COUNT do not set to 0 when psql's \gset command get no rows returned
Previous Message Tom Lane 2023-10-01 00:39:37 Re: BUG #18135: Incorrect memory access occurs when attaching a partition with an index