Re: ERROR: negative bitmapset member not allowed in SELECT

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Manuel Rigger <rigger(dot)manuel(at)gmail(dot)com>
Cc: PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>
Subject: Re: ERROR: negative bitmapset member not allowed in SELECT
Date: 2019-07-10 20:09:58
Message-ID: 20190710200958.GA13132@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 2019-Jul-10, Manuel Rigger wrote:

> CREATE TABLE t0(c0 serial, c1 boolean);
> CREATE STATISTICS s1 ON c0, c1 FROM t0;
> INSERT INTO t0(c1) VALUES(TRUE);
> ANALYZE;
> CREATE INDEX i0 ON t0(c0, (t0.c1 AND t0.c1));
> SELECT * FROM (SELECT t0.c0 FROM t0 WHERE (((t0.c1) AND (t0.c1)) OR
> FALSE) IS TRUE) as result WHERE result.c0 IS NULL; -- unexpected:
> ERROR: negative bitmapset member not allowed

Backtrace:

#0 errfinish (dummy=dummy(at)entry=0) at /pgsql/source/master/src/backend/utils/error/elog.c:411
#1 0x0000559f2b8ca430 in elog_finish (elevel=elevel(at)entry=20, fmt=fmt(at)entry=0x559f2ba6f538 "negative bitmapset member not allowed") at /pgsql/source/master/src/backend/utils/error/elog.c:1365
#2 0x0000559f2b6801f5 in bms_is_member (x=<optimized out>, a=<optimized out>) at /pgsql/source/master/src/backend/nodes/bitmapset.c:434
#3 0x0000559f2b68021d in bms_member_index (a=a(at)entry=0x559f2da39918, x=-30672) at /pgsql/source/master/src/backend/nodes/bitmapset.c:462
#4 0x0000559f2b758841 in mcv_get_match_bitmap (root=root(at)entry=0x559f2d9e2e78, clauses=clauses(at)entry=0x559f2da3a6f0, keys=0x559f2da39918, mcvlist=mcvlist(at)entry=0x559f2da3a938, is_or=is_or(at)entry=false) at /pgsql/source/master/src/backend/statistics/mcv.c:1597
#5 0x0000559f2b75b551 in mcv_clauselist_selectivity (root=root(at)entry=0x559f2d9e2e78, stat=stat(at)entry=0x559f2da398e0, clauses=clauses(at)entry=0x559f2da3a6f0, varRelid=varRelid(at)entry=2, jointype=jointype(at)entry=JOIN_INNER, sjinfo=sjinfo(at)entry=0x0, rel=0x559f2d9e1a10, basesel=0x7ffc17135958, totalsel=0x7ffc17135960) at /pgsql/source/master/src/backend/statistics/mcv.c:1876
#6 0x0000559f2b756dc4 in statext_mcv_clauselist_selectivity (estimatedclauses=0x7ffc171359f0, rel=<optimized out>, sjinfo=<optimized out>, jointype=<optimized out>, varRelid=<optimized out>, clauses=<optimized out>, root=<optimized out>) at /pgsql/source/master/src/backend/statistics/extended_stats.c:1146
#7 statext_clauselist_selectivity (root=root(at)entry=0x559f2d9e2e78, clauses=clauses(at)entry=0x559f2da3a430, varRelid=varRelid(at)entry=2, jointype=jointype(at)entry=JOIN_INNER, sjinfo=sjinfo(at)entry=0x0, rel=<optimized out>, estimatedclauses=0x7ffc171359f0) at /pgsql/source/master/src/backend/statistics/extended_stats.c:1177
#8 0x0000559f2b6a98d1 in clauselist_selectivity (root=root(at)entry=0x559f2d9e2e78, clauses=0x559f2da3a430, varRelid=2, jointype=jointype(at)entry=JOIN_INNER, sjinfo=sjinfo(at)entry=0x0) at /pgsql/source/master/src/backend/optimizer/path/clausesel.c:94
#9 0x0000559f2b8767e6 in btcostestimate (root=0x559f2d9e2e78, path=0x559f2da38ef0, loop_count=1, indexStartupCost=0x7ffc17135c48, indexTotalCost=0x7ffc17135c50, indexSelectivity=0x7ffc17135c58, indexCorrelation=0x7ffc17135c60, indexPages=0x7ffc17135c78) at /pgsql/source/master/src/backend/utils/adt/selfuncs.c:5853
#10 0x0000559f2b6adc39 in cost_index (path=path(at)entry=0x559f2da38ef0, root=root(at)entry=0x559f2d9e2e78, loop_count=loop_count(at)entry=1, partial_path=partial_path(at)entry=false) at /pgsql/source/master/src/backend/optimizer/path/costsize.c:545
#11 0x0000559f2b6e9504 in create_index_path (root=root(at)entry=0x559f2d9e2e78, index=index(at)entry=0x559f2d9e1c28, indexclauses=indexclauses(at)entry=0x559f2da3a358, indexorderbys=indexorderbys(at)entry=0x0, indexorderbycols=indexorderbycols(at)entry=0x0, pathkeys=pathkeys(at)entry=0x0, indexscandir=ForwardScanDirection, indexonly=false, required_outer=0x0, loop_count=loop_count(at)entry=1, partial_path=false) at /pgsql/source/master/src/backend/optimizer/util/pathnode.c:1054
#12 0x0000559f2b6b67c5 in build_index_paths (root=root(at)entry=0x559f2d9e2e78, rel=rel(at)entry=0x559f2d9e1a10, index=index(at)entry=0x559f2d9e1c28, clauses=clauses(at)entry=0x7ffc17135f10, useful_predicate=<optimized out>, scantype=scantype(at)entry=ST_ANYSCAN, skip_nonnative_saop=<optimized out>, skip_lower_saop=<optimized out>) at /pgsql/source/master/src/backend/optimizer/path/indxpath.c:1039
#13 0x0000559f2b6b6ece in get_index_paths (root=root(at)entry=0x559f2d9e2e78, rel=rel(at)entry=0x559f2d9e1a10, index=index(at)entry=0x559f2d9e1c28, clauses=clauses(at)entry=0x7ffc17135f10, bitindexpaths=bitindexpaths(at)entry=0x7ffc17135ef0) at /pgsql/source/master/src/backend/optimizer/path/indxpath.c:754

--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andres Freund 2019-07-10 20:15:47 Re: ERROR: found unexpected null value in index
Previous Message Tom Lane 2019-07-10 20:02:50 Re: ERROR: found unexpected null value in index