Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lVclC-00020h-7o for pgsql-hackers@arkaria.postgresql.org; Sun, 11 Apr 2021 16:16:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lVclB-0003pf-2Q for pgsql-hackers@arkaria.postgresql.org; Sun, 11 Apr 2021 16:16:29 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lVclA-0003pY-Rx for pgsql-hackers@lists.postgresql.org; Sun, 11 Apr 2021 16:16:28 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lVcl8-0000ao-Ka for pgsql-hackers@lists.postgresql.org; Sun, 11 Apr 2021 16:16:27 +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 13BGG4wB2680035; Sun, 11 Apr 2021 12:16:05 -0400 From: Tom Lane To: Fabien COELHO cc: Peter Eisentraut , Michael Paquier , Julien Rouhaud , "shiy.fnst@fujitsu.com" , "pgsql-hackers@lists.postgresql.org" Subject: Re: psql - add SHOW_ALL_RESULTS option In-reply-to: <2671235.1618154047@sss.pgh.pa.us> References: <1ec5ef49-b5c8-4129-e680-fe42f8d0670b@2ndquadrant.com> <20210408163050.fca7dwb37zszbsmm@nol> <20210408171135.ekhdf5nvqss554q3@nol> <2671235.1618154047@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Sun, 11 Apr 2021 11:14:07 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2680033.1618157764.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sun, 11 Apr 2021 12:16:04 -0400 Message-ID: <2680034.1618157764@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ... btw, Coverity also doesn't like this fragment of the patch: /srv/coverity/git/pgsql-git/postgresql/src/bin/psql/common.c: 1084 in Show= NoticeMessage() 1078 static void 1079 ShowNoticeMessage(t_notice_messages *notes) 1080 { 1081 PQExpBufferData *current =3D notes->in_flip ? ¬es->flip : &no= tes->flop; 1082 if (current->data !=3D NULL && *current->data !=3D '\0') 1083 pg_log_info("%s", current->data); >>> CID 1476041: Null pointer dereferences (FORWARD_NULL) >>> Passing "current" to "resetPQExpBuffer", which dereferences null "= current->data". 1084 resetPQExpBuffer(current); 1085 } 1086 = 1087 /* 1088 * SendQueryAndProcessResults: utility function for use by SendQu= ery() 1089 * and PSQLexecWatch(). Its point here is that either the test of "current->data !=3D NULL" is useless, or resetPQExpBuffer needs such a test too. I'm inclined to guess the former. (Just as a matter of style, I don't care for the flip/flop terminology here, not least because it's not clear why exactly two buffers suffice and will suffice forevermore. I'd be inclined to use an array of two buffers with an index variable.) regards, tom lane