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 1hlLO6-0001Mf-Es for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Jul 2019 22:48:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hlLO3-0000k5-Mz for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Jul 2019 22:48:31 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hlLO3-0000hw-Ai for pgsql-hackers@lists.postgresql.org; Wed, 10 Jul 2019 22:48:31 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hlLNv-00005O-Nj; Wed, 10 Jul 2019 22:48:29 +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 x6AMmGk8019587; Wed, 10 Jul 2019 18:48:16 -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: <20190710215904.ncaqlswrylliisv3@development> References: <8736jdhbhc.fsf@ansel.ydns.eu> <15097.1562792274@sss.pgh.pa.us> <20190710212609.5mrl7hltbozoxpq7@development> <17042.1562795124@sss.pgh.pa.us> <20190710215904.ncaqlswrylliisv3@development> Comments: In-reply-to Tomas Vondra message dated "Wed, 10 Jul 2019 23:59:04 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <19585.1562798896.1@sss.pgh.pa.us> Date: Wed, 10 Jul 2019 18:48:16 -0400 Message-ID: <19586.1562798896@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Oh ... while we're piling on here, it just sunk into me that mcv_get_match_bitmap is deciding what the semantics of an operator are by seeing what it's using for a selectivity estimator. That is just absolutely, completely wrong. For starters, it means that the whole mechanism fails for any operator that wants to use a specialized estimator --- hardly an unreasonable thing to do. For another, it's going to be pretty unreliable for extensions, because I do not think they're all careful about using the right estimator --- a lot of 'em probably still haven't adapted to the introduction of separate <= / >= estimators, for instance. The right way to determine operator semantics is to look to see whether they are in a btree opclass. That's what the rest of the planner does, and there is no good reason for the mcv code to do it some other way. regards, tom lane