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 1lkosc-0005TA-Lb for pgsql-committers@arkaria.postgresql.org; Sun, 23 May 2021 14:14:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lkosZ-0008BG-HI for pgsql-committers@arkaria.postgresql.org; Sun, 23 May 2021 14:14:55 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lkosZ-0008B8-Bx for pgsql-committers@lists.postgresql.org; Sun, 23 May 2021 14:14:55 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lkosX-00035Q-Ay; Sun, 23 May 2021 14:14:54 +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 14NEEo0G457999; Sun, 23 May 2021 10:14:51 -0400 From: Tom Lane To: David Rowley cc: pgsql-committers@lists.postgresql.org Subject: Re: pgsql: Fix planner's use of Result Cache with unique joins In-reply-to: References: Comments: In-reply-to David Rowley message dated "Sat, 22 May 2021 04:22:51 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <457997.1621779290.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sun, 23 May 2021 10:14:50 -0400 Message-ID: <457998.1621779290@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk David Rowley writes: > Fix planner's use of Result Cache with unique joins Coverity is not happy with this: /srv/coverity/git/pgsql-git/postgresql/src/backend/optimizer/path/joinpath= .c: 532 in get_resultcache_path() 526 * determining if the join is unique. 527 * 528 * XXX this could be enabled if the remaining join quals were = made part of 529 * the inner scan's filter instead of the join filter. Maybe = it's worth 530 * considering doing that? 531 */ >>> CID 1484914: Null pointer dereferences (FORWARD_NULL) >>> Dereferencing null pointer "inner_path->param_info". 532 if (extra->inner_unique && 533 list_length(inner_path->param_info->ppi_clauses) < 534 list_length(extra->restrictlist)) 535 return NULL; 536 = This complaint is triggered because elsewhere in the same function, you're careful to check for inner_path->param_info being null before trying to dereference it: if ((inner_path->param_info =3D=3D NULL || inner_path->param_info->ppi_clauses =3D=3D NIL) && innerrel->lateral_vars =3D=3D NIL) return NULL; Coverity reasons that it's probably a bug that you didn't do the same here; and I think it's right. regards, tom lane