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 1hlagR-0004nI-1f for pgsql-hackers@arkaria.postgresql.org; Thu, 11 Jul 2019 15:08:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hlagP-0008K9-UT for pgsql-hackers@arkaria.postgresql.org; Thu, 11 Jul 2019 15:08:29 +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 1hlagP-0008JH-Hi for pgsql-hackers@lists.postgresql.org; Thu, 11 Jul 2019 15:08:29 +0000 Received: from mail-lj1-x241.google.com ([2a00:1450:4864:20::241]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hlagM-00019k-Q5 for pgsql-hackers@lists.postgresql.org; Thu, 11 Jul 2019 15:08:28 +0000 Received: by mail-lj1-x241.google.com with SMTP id v18so6144014ljh.6 for ; Thu, 11 Jul 2019 08:08:26 -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=DFUK6QBnZkhVJStDYkvAr83yEHSoInb5a3uFrBSU2L4=; b=IuwzRPXR1wEGHnTOf0nV4ni99nzuM9P8vKUFe4to1u1QhAOuWzQjbg8DFI156fO/hW hZ5LyrbwfCs8w18Js4yy9ywVOo3IVuosamBXCUK5JgYvOV6BlhucCRJsj+gFk4NJoT1b QzCFthrV8tKSIO3JNTdAimh7LpJDUvkdBsi44JXBvLjee6vM3Roroi2KNtU6qFge6ICE U3aclCET4LxfVGkUz0LQxHprmhDrVM/TNJNFe6zLrtsHbKaDpN15qCyIDmcqEAcHetDc JehPYkQ4QnAUmXeGVbMs8aqkfKrpMYIHq3WOgIo18YpOIvJpoEq8DyAx8RjoXYZRK5vN cGRQ== 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=DFUK6QBnZkhVJStDYkvAr83yEHSoInb5a3uFrBSU2L4=; b=FKls4HIvR0jNLHzJeCTiS2TPvB9rASn4ypMG5Jgu0t1mxjgvx2dfzIvtKaY0PfxBOe Cq20BWEnc/CO49bSR9QYTwT0zC/QNWu+bN8m23H8cgc0X8jBmWR1Z/Fwxdq0njwfmzVt Q+xXcAlO8WRkvO9pGgpGqHCc+WpZO2E5aKWV9SEUJNbGCWZVBd689qTnlCbJhl48+Csx bCRA/Bj+BIQRDPT+rjuH4SrHnzkTsNoskbVu54WOs710ksaHPOvlbnmzhnIoelWh5OPH +NwMrQgzLrzc8JC3w4TbO+H32NLH4gNcQbAu2qLS3Vz6xmIE75z5m9ZX5A5GDft98Hyf jmYw== X-Gm-Message-State: APjAAAWtvls9TdTcxSmho4++631tqf06b3LtN5UKvcksjE3BreSyGumi Y9ft3grVrz6uuVOPApt2JJfX3A== X-Google-Smtp-Source: APXvYqz7A1JgSQS4/EG6cu0AfYqGwonXoMzkadLASSuO8temqnKTpUBW08ubx7rV22JreTZp/1FK/Q== X-Received: by 2002:a2e:8082:: with SMTP id i2mr2857831ljg.121.1562857705023; Thu, 11 Jul 2019 08:08:25 -0700 (PDT) Received: from localhost (84-10-196-130.dynamic.chello.pl. [84.10.196.130]) by smtp.gmail.com with ESMTPSA id b192sm767636lfg.75.2019.07.11.08.08.24 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 11 Jul 2019 08:08:24 -0700 (PDT) Date: Thu, 11 Jul 2019 17:08:22 +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: <20190711150822.z7cirna2fjtrfcnu@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> <19586.1562798896@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <19586.1562798896@sss.pgh.pa.us> User-Agent: NeoMutt/20180716-1444-295967-dirty List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Wed, Jul 10, 2019 at 06:48:16PM -0400, Tom Lane wrote: >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. > Hmmm, but that will mean we're unable to estimate operators that are not part of a btree opclass. Which is a bit annoying, because that would also affect equalities (and thus functional dependencies), in which case the type may easily have just hash opclass or something. But maybe I just don't understand how the btree opclass detection works and it'd be fine for sensibly defined operators. Can you point me to code doing this elsewhere in the planner? We may need to do something about code in pg10, because functional dependencies this too (although just with F_EQSEL). But maybe we should leave pg10 alone, we got exactly 0 reports about it until now anyway. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services