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.89) (envelope-from ) id 1hlKP9-0006qT-M0 for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Jul 2019 21:45:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hlKP8-00031J-HO for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Jul 2019 21:45:34 +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 1hlKP8-00031C-8h for pgsql-hackers@lists.postgresql.org; Wed, 10 Jul 2019 21:45:34 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hlKP6-0000v1-6Q; Wed, 10 Jul 2019 21:45:33 +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 x6ALjOM9017043; Wed, 10 Jul 2019 17:45:24 -0400 From: Tom Lane To: Tomas Vondra cc: Andreas Seltenreich , pgsql-hackers@lists.postgresql.org, Tomas Vondra Subject: Re: [sqlsmith] Crash in mcv_get_match_bitmap In-reply-to: <20190710212609.5mrl7hltbozoxpq7@development> References: <8736jdhbhc.fsf@ansel.ydns.eu> <15097.1562792274@sss.pgh.pa.us> <20190710212609.5mrl7hltbozoxpq7@development> Comments: In-reply-to Tomas Vondra message dated "Wed, 10 Jul 2019 23:26:09 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <17041.1562795124.1@sss.pgh.pa.us> Date: Wed, 10 Jul 2019 17:45:24 -0400 Message-ID: <17042.1562795124@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Tomas Vondra writes: > Yeah, that's a bug. Will fix (not sure how yet). You could do worse than replace this: ok = (NumRelids(clause) == 1) && (is_pseudo_constant_clause(lsecond(expr->args)) || (varonleft = false, is_pseudo_constant_clause(linitial(expr->args)))); with something like if (IsA(linitial(expr->args), Var) && IsA(lsecond(expr->args), Const)) ok = true, varonleft = true; else if (IsA(linitial(expr->args), Const) && IsA(lsecond(expr->args), Var)) ok = true, varonleft = false; Or possibly get rid of varonleft as such, and merge extraction of the "var" and "cst" variables into this test. BTW, I bet passing a unary-argument OpExpr also makes this code unhappy. regards, tom lane