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 1iX4cZ-0003XW-9k for pgsql-bugs@arkaria.postgresql.org; Tue, 19 Nov 2019 14:36:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iX4cY-0007oi-2A for pgsql-bugs@arkaria.postgresql.org; Tue, 19 Nov 2019 14:36:46 +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 <9erthalion6@gmail.com>) id 1iX4cX-0007oZ-Mp for pgsql-bugs@lists.postgresql.org; Tue, 19 Nov 2019 14:36:45 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from <9erthalion6@gmail.com>) id 1iX4cR-0005jE-0Y for pgsql-bugs@lists.postgresql.org; Tue, 19 Nov 2019 14:36:44 +0000 Received: by mail-wr1-x442.google.com with SMTP id f2so24122563wrs.11 for ; Tue, 19 Nov 2019 06:36:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=C+Q+y8jfSJ25hVGqP/6tObsJNETuWShcifuf9ueZClI=; b=nMCS5Lu6AnSiifvQ7oxo2Rsahdlwa4p3LusY3kIcrsuF/zV87rmbO5C7Yc96Po1T31 nwhD+3f17IlY3uizA/8mNvS23PAt0qTQnLo+n8Hy/SOkxNz1xtC0HGxnp5fSTN3oQupy GQ0hQ9sLIRGv9j1K8vL3IrYf20cvB0ST9iATH39AAdTlU9qzP4USe3z+i7vrOXOKbP0v Jcvdt/kPSRasgIDn4bQ1NBFJrQl/iOqzg28eoC5ck3FpWPbNfGLnO6RyW8hbEociNox1 uZT4+NHTg2ul5Wu7uPRt9bp72NEfaMuBNOV+W6eUDN/SvWBnQtimVB8f7aZe5rxjGNbD fWiQ== 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; bh=C+Q+y8jfSJ25hVGqP/6tObsJNETuWShcifuf9ueZClI=; b=k/5wwGHIuEcyAtLHfCLckFSLMTDZmAjfkQGsa79GzxdNiEHWKEb/SpRkI7I5YQ1K30 FSIguyDblIj/i4Nsy7SHbjj7O43KpSteCdbJ4NjuQki0mj3jqeGPo6RioyNHtjc6JIL6 EW2p5qv5v2LnI1qKp5a4TwgDNgq17h3DP+Q45HEXFAFxjNVSg3/aU8tfOmP3Q+DPCWU1 vOGkrFTb0CzV4mg/+cmRj7cgSc44ZwvyJju4YZZGS6DNjpcAGaAjm9jix0n/XAVoNmWB FvXmLTuo0m/grwRT3q9+0PrdDICLEVxHwhJmX+5TUuqV+mCXHGo8FByq6swEygjiTRZa NoNQ== X-Gm-Message-State: APjAAAX8nt/mdvEbVkUMMsVzfzbAiqbLuqbWqDv64eThom4bMvZ3yvBV oUOYQ3rB+Hco73NztwD3ICBAdgbAjRg= X-Google-Smtp-Source: APXvYqy98RUoUkeQ+zDvtVeL9YHHs+dDpG8kmkHLQmmYZo7UWBQyhSYmWWA2q8f22ylFA6IfHcy0GQ== X-Received: by 2002:adf:f607:: with SMTP id t7mr6765454wrp.390.1574174197616; Tue, 19 Nov 2019 06:36:37 -0800 (PST) Received: from localhost ([185.85.220.193]) by smtp.gmail.com with ESMTPSA id b15sm26880817wrx.77.2019.11.19.06.36.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Nov 2019 06:36:35 -0800 (PST) Date: Tue, 19 Nov 2019 15:38:42 +0100 From: Dmitry Dolgov <9erthalion6@gmail.com> To: Daniel Gustafsson Cc: Tomas Vondra , Manuel Rigger , PostgreSQL mailing lists Subject: Re: Failed assertion clauses != NIL Message-ID: <20191119143842.s2rrzdg43pvw3ael@localhost> References: <20191119133839.5qj5zia4pkd3zldt@localhost> <520C6E76-53A5-4EF2-A855-8054582221A5@yesql.se> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <520C6E76-53A5-4EF2-A855-8054582221A5@yesql.se> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > On Tue, Nov 19, 2019 at 02:45:54PM +0100, Daniel Gustafsson wrote: > > On 19 Nov 2019, at 14:38, Dmitry Dolgov <9erthalion6@gmail.com> wrote: > > > >> On Tue, Nov 19, 2019 at 01:50:51PM +0100, Manuel Rigger wrote: > >> > >> when building PostgreSQL with -enable-cassert, executing the following > >> statements result in an assertion error: > >> > >> CREATE TABLE t0(c0 boolean, c1 boolean, c2 boolean); > >> INSERT INTO t0 VALUES(FALSE, FALSE, FALSE); > >> CREATE STATISTICS s0 ON c0, c2 FROM t0; > >> ANALYZE; > >> SELECT * FROM t0 WHERE t0.c2 OR t0.c1 OR t0.c0; > > > > Yes, I can reproduce it too. mcv_get_match_bitmap expects that > > stat_clauses will not be empty, but looks like in this situation > > stat_clauses is indeed NIL. clauselist_selectivity_simple right before > > actually doesn't insist on stat_clauses being non empty, probably it's > > just too strict assert. > > I might be missing something, but if the clause list is NIL, wouldn't it better > to exit earlier from statext_mcv_clauselist_selectivity rather than relax the > Assertion since we will get a 1.0 estimate either way? > > cheers ./daniel > > --- a/src/backend/statistics/extended_stats.c > +++ b/src/backend/statistics/extended_stats.c > @@ -1267,6 +1267,9 @@ statext_mcv_clauselist_selectivity(PlannerInfo *root, List *clauses, int varReli > listidx++; > } > > + if (stat_clauses == NIL) > + return 1.0; > + > /* > * First compute "simple" selectivity, i.e. without the extended > * statistics, and essentially assuming independence of the > Yep, seems like a reasonable thing to do, especially since it's already like that in a few other places in this function.