Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1j8UHZ-0002G3-B4 for pgsql-committers@arkaria.postgresql.org; Sun, 01 Mar 2020 19:29:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j8UHX-0005z3-O9 for pgsql-committers@arkaria.postgresql.org; Sun, 01 Mar 2020 19:29:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j8UHX-0005yw-H0 for pgsql-committers@lists.postgresql.org; Sun, 01 Mar 2020 19:29:43 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j8UHV-0003mn-3n for pgsql-committers@lists.postgresql.org; Sun, 01 Mar 2020 19:29:42 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 021JTbqR029677; Sun, 1 Mar 2020 14:29:38 -0500 From: Tom Lane To: Peter Geoghegan cc: pgsql-committers Subject: Re: pgsql: Add deduplication to nbtree. In-reply-to: References: <27003.1583087095@sss.pgh.pa.us> Comments: In-reply-to Peter Geoghegan message dated "Sun, 01 Mar 2020 10:57:10 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <29675.1583090977.1@sss.pgh.pa.us> Date: Sun, 01 Mar 2020 14:29:37 -0500 Message-ID: <29676.1583090977@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Peter Geoghegan writes: > On Sun, Mar 1, 2020 at 10:24 AM Tom Lane wrote: >> I can see its point: asserting after the fact that you didn't clobber >> memory isn't a terribly safe coding method, especially in a production >> build where you won't even have the asserts. Not sure if there's a >> better way though. > I found it slightly more elegant to treat itup->t_tid as a degenerate > 1 element posting list here, but I'm not particularly attached to that > approach. The loop is only truly necessary when dealing with a posting > list tuple. > Do you think that _bt_update_posting() should avoid this loop when > itup is just a plain tuple, that lacks a posting list? I can do it > that way if you prefer. Hm. That would probably be enough to shut up Coverity, but I'm unsure whether it'd really be an improvement from the legibility and safety viewpoints. Do you want to try coding it that way and see what it comes out like? Note that we do have the ability to just dismiss the Coverity complaint, if we decide that there's no better way to write the function. But it's usually worth looking to see if it could be written more cleanly. regards, tom lane