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 1hlKcK-0007Z2-Ti for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Jul 2019 21:59:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hlKcJ-000078-3E for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Jul 2019 21:59:11 +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 1hlKcI-0008TN-Pu for pgsql-hackers@lists.postgresql.org; Wed, 10 Jul 2019 21:59:10 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hlKcF-00011F-Hu for pgsql-hackers@lists.postgresql.org; Wed, 10 Jul 2019 21:59:10 +0000 Received: by mail-wr1-x441.google.com with SMTP id n9so4040682wrr.4 for ; Wed, 10 Jul 2019 14:59:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=rX6YbP4McVMEmMGG00h7o1JfkOpsXI485q2mxkoKdlw=; b=DtsrMupU2rJbIZbh/B6xgjBaiD0Lah70wXEBGYzLzJLXOHonB1EauTlqyfELIFS8Io jKDsTAX9VS5oXM+ZW9yZPeO7KTm9JoS1ripmVt8otl8qDc0T3S0ZpRn4Cs1zpv55DVCu JYYcuR3C8dqWonCFe1acnY9PVF4WLiw5T86XGD9yZwG5jVUk8E+FxyqesPYV3G3kJo2P APbHX/WCPzbx2kdOFkN6Ft96KQa06gqC27ZEpA1fu6qRJAU339aD3VawX5GW+jVXVtTc oSAXVaNLpGmbd53XkseINPTzihiB2AOcGnW2CDeR4WTmhlC1cfbLGcg2+fuQlP+j00k8 /NsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=rX6YbP4McVMEmMGG00h7o1JfkOpsXI485q2mxkoKdlw=; b=NOQKoiUwUieOXzKUeRVfr2NWWMTczuftDqy+Ql3jJNX5tES9HgydGx1qUKgizEnsVC SrJpEcinErk378T8yhPZCilUYsrbcx0+mbaOLoIglKMAdKH7GOsSxD+qcVY1ZG9ASjS5 aOUvCi6w3qb0yvxwTBR2FpvhM/9sk5oJV8bzhotXlc+IylWoZw5r0kzjgZHZh/WwbWtI dU9fud5l3aNP8H9WG69y9Ykrco90PBjvFFvhxdjeJlcsStnGF/LvQoDSTzgvmuKfeQTN 10SHl3XtSuVFvWu6nq4EUv+eEb42M7KMcJZD+RwnQRP2Y71fcuCNhTVyNX8zym1QtOcR lTmw== X-Gm-Message-State: APjAAAWLaDepK9Yu8vwZBenMhVb/CGJ90VlkvpOek3Hf2axZ0Igwd8ap XCrnfOZzNfD3Y7PzjZD8XU6fRA== X-Google-Smtp-Source: APXvYqxPb8opG6w1l3YNeadOg/7putK4jxblBlZ4xOPJn/RLp5L6OzKk9unLvUfkI0AWLLpXHkqH9w== X-Received: by 2002:a5d:6650:: with SMTP id f16mr1207370wrw.89.1562795946327; Wed, 10 Jul 2019 14:59:06 -0700 (PDT) Received: from localhost (ip-86-49-253-160.net.upcbroadband.cz. [86.49.253.160]) by smtp.gmail.com with ESMTPSA id e7sm3582415wmd.0.2019.07.10.14.59.05 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 10 Jul 2019 14:59:05 -0700 (PDT) Date: Wed, 10 Jul 2019 23:59:04 +0200 From: Tomas Vondra To: Tom Lane Cc: Andreas Seltenreich , pgsql-hackers@lists.postgresql.org, Tomas Vondra Subject: Re: [sqlsmith] Crash in mcv_get_match_bitmap Message-ID: <20190710215904.ncaqlswrylliisv3@development> References: <8736jdhbhc.fsf@ansel.ydns.eu> <15097.1562792274@sss.pgh.pa.us> <20190710212609.5mrl7hltbozoxpq7@development> <17042.1562795124@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <17042.1562795124@sss.pgh.pa.us> User-Agent: NeoMutt/20180716-1444-295967 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Wed, Jul 10, 2019 at 05:45:24PM -0400, Tom Lane wrote: >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. > OK, thanks for the suggestion. I probably also need to look at the "is compatible" test in extended_stats.c which also looks at the clauses. It may not crash as it does not attempt to extract the const values etc. but it likely needs to be in sync with this part. >BTW, I bet passing a unary-argument OpExpr also makes this code >unhappy. Whooops :-( regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services