ChenHuajun / pg_roaringbitmap

RoaringBitmap extension for PostgreSQL
Apache License 2.0
223 stars 37 forks source link

Incorrect 'rb_and' #22

Closed r-s-c137 closed 2 years ago

r-s-c137 commented 2 years ago
set roaringbitmap.output_format='array';
SELECT 
'{100373,1824001,1824002,1829130,1854001,1854002,1861001,1861002,1975442,2298640,2334385,2349001,2349002,2350001,2350002,2351001,2351002,2352001,2352002,2353001,2353002,2353213,2353374,2354522,2355794,2355795,2355807,2355808,2355815,2355866,2355938,2355939,2355945,2355954,2355965,2355994,2356017,2356038,2356088,2356089,2356104,2356105,2356115,2356135,2356136,2356155,2356269,2356270,2356296,2356365,2356566,2356567,2356657,2356799,2356800,2357006,2357034,2357035,2357221,2357328,2357329,2357354,2357362,2357363,2357432,2357549,2357653,2456327,2456331,2456335,2456336,2456348,2456396,2456403,2456420,2456441,2456452,2456466,2456485,2456486,2456491,2456504,2456506,2456513,2456538,2456545,2456546,2456586,2456587,2456606,2456608,2456633,2456656,2456704,2456744,2456745,2456770,2456772,2456775,2456779,2456859,2456860,2456871,2456874,2456875,2456883,2456908,2456940,2457034,2457035,2457088,2780493,2780512,2780527,2780530,2780537,2780538,2780545,2780546,2780547,2780610,2780666,2780667,2780680,2780687,2780690,2780703,2780705,2780708,2780756,2780771,2780775,2780776,2780779,2780784,2780785,2780786,2780787,2780792,2780805,2780810,2780811,2780826,2780827,2780832,2780950,2780953,2780972,2781132,2781140,2781206,2781210,2781512,2781522,2781523,2781526,2781527,2781533,2781541,2781542,2781543,2781555,2781558,2781559,2781563,2781572,2781573,2781578,2781580,2781581,2782084,2782096,2782108,2782310,2782311,2782378,2782379,2782380,2782381,2782404,2782405,2782413,2782498,2782499,2782501,2782505,2782510,2782512,2782513,2782520,2782526,2782546,2782604,2782605,2782606,2782708,2782709,2782721,2782722,2782726,2782727,2782729,2782814,2782815,2782826,2782856,2782857,2782859,2782869,2782875,2782876,2782877,2782880,2782884,2782901,2782904,2782905,2782911,2782925,2782931,2782936,2782937,2782940,2782950,2782951,2782956,2782957,2782958,2782974,2782976,2782977,2783001,2783002,2783007,2783011,2783012,2783083,2783092,2783109,2783287,2783292,2783307,2783314,2783316,2783318,2783324,2783325,2783331,2783342,2783343,2783345,2783346,2783351,2783363,2783366,2783367,2783394,2783399,2783406,2783407,2783435,2783445,2783457,2783480,2783481,2783493,2783494,2783495,2783496,2783622,2783627,2783630,2783663,2783664,2783665,2783676,2783682,2783684,2783685,2783689,2783692,2783768,2783769,2783770,2783771,2783772,2783773,2783777,2783886,2783887,2783907,2783908,2783909,2783910,2783911,2783929,2783930,2783945,2783975,2783992,2783993,2783994,2784008,2784137,2784139,2784140,2784144,2784150,2784161,2784170,2784173,2784690,2784706,2784711,2784712,2784715,2784733,2784734,2784735,2784736,2784740,2784760,2784765,2784766,2784795,2784796,2784800,2784808,2784809,2784845,2784869,2784888,2931661,3056131,3056138,3056139,3056143,3056149,3056150,3056153,3056154,3056161,3056189,3056278,3056280,3056303,3056319,3056330,3056331,3056336,3056347,3056357,3056358,3056362,3056379,3056388,3056417,3056418,3056430,3056438,3056439,3056468,3056510,3056537,3056598,3056599,3056620,3056622,3056629,3056755,3056756,3056772,3056858,3056863,3057048,3057083,3058082,3074582,3074583,3074590,3074610,3074632,3074709,3074710,3074718,3074719,3074726,3074729,3074734,3074763,3074764,3074777,3074916,3074923,3074924,3075006,3075043,3075102,3075103,3075162,3075380,3075410,3075414,3075425,3075426,3075433,3075451,3075454,3075460,3075511,3075512,3075539,3075636,3075675,3075711,3075722,3075724,3075859,3075860,3075868,3075873,3075876,3075880,3075902,3075903,3075915,3076267,3076271,3076296,3076345,3076369,3076970,3077005,3077008,3077011,3077012,3077016,3077049,3077057,3077058,3077108,3077112,3077113,3077768,3133758,3439871,3444001,3444002,3446494,3538802,3614189,3702002,3702005,3716002,3716004,3730002,3730004,3745002,3745004,3760002,3760004,3775002,3775004,3790002,3790004,3805002,3805004,3820002,3820004,3835002,3835004,3850002,3850004,3865002,3865004,3880001,3880002,3890001,3890002,3900001,3900002,3910001,3910003,3924986,4061003,4061005,4079001,4079004,4102001,4102002,4112001,4112002,4225270,4244963,4247140,4248784,4249335,4250213,4250770,4251112,4251448,4251828,4252080,4252195,4252356,4252945,4445926,4534001,4534002,4561001,4561002,4576662,4577121,4592001,4592002,4592052,4602001,4602002,4602053,4616001,4616002,4616050,4634001,4634002,4634052,4656001,4656002,4656053,4717001,4717002,4735001,4735002,4744444,4748001,4748002,4748633,4766150,4770336,4771801,4773222,4774042,4775108,4776060,4777046,4812706,4812707,4812708,4812709,4812710,4812711,4812712,4812884,4826943,5047999,5063901,5089695,5099592,5131628,5141471,5147815,5159744,5184860,5188459,5189547,5190810,5193479,5194763,5194914,5212574,5434002,5434003,5434004,5434005,5434006,5434008,5434009,5434010,5434011,5434012,5434013,5434014,5434015,5434016,5434017,5434018,5434019,5434020,5434021,5434022,5434023,5495698,6279613,6865796,7241838,8230284,9415231,10414056,10415122,10416429,10436157,10438019,11273182,11289406,13041992,13060882,13178675,13258515,14283014,14292141,14476355,15165031,15355608,15423053,15430343,15482464,15485792,15488935,16083130,16113628,16113833}'::roaringbitmap
&
'{2353213}'::roaringbitmap

------------------------
?column?
{}

The result should be '{2353213}'

ChenHuajun commented 2 years ago

Thanks for report. The following also can reproduce this problem

postgres=# SELECT
'{100373,1829130,1861002,1975442,2353213,2456403}'::roaringbitmap & '{2353213}'::roaringbitmap;
 ?column?
----------
 {}
(1 row)

The mistake comes from keyscardsAdvanceUntil(), affected functions include at least rb_and,rb_and_cardinality,rb_andnot,rb_andnot_cardinality,rb_contains,rb_containedby and rb_intersect