Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qmkaF-008nVp-2z for pgsql-bugs@arkaria.postgresql.org; Sun, 01 Oct 2023 00:45:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qmkaD-00HZFr-NI for pgsql-bugs@arkaria.postgresql.org; Sun, 01 Oct 2023 00:45:17 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qmkaD-00HZFQ-A6 for pgsql-bugs@lists.postgresql.org; Sun, 01 Oct 2023 00:45:17 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qmkaA-007X3N-VM for pgsql-bugs@lists.postgresql.org; Sun, 01 Oct 2023 00:45:16 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 3910i7Yv1615013; Sat, 30 Sep 2023 20:44:07 -0400 From: Tom Lane To: Michael Paquier cc: Japin Li , amutu@amutu.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18134: ROW_COUNT do not set to 0 when psql's \gset command get no rows returned In-reply-to: References: <18134-87126d90cb4dd049@postgresql.org> Comments: In-reply-to Michael Paquier message dated "Sun, 01 Oct 2023 08:48:10 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1615011.1696121047.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sat, 30 Sep 2023 20:44:07 -0400 Message-ID: <1615012.1696121047@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Michael Paquier 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