Skip to content

Commit 1b44ece

Browse files
committed
Disable offsetnumber assertion in ginPostingListDecodeAllSegments()
Fix issue: #1222 As comments in itemptr_to_uint64: Greenplum allow 16 bits for the offsetnumber, which turns the below upstream assertion into an always-true comparison which generates a compiler warning; thus we need to keep this commented out. For sql in issue 1222, we will get assert failure as: DETAIL: FailedAssertion("!(((_Bool) ((( ((void) ((_Bool) (! (!(((_Bool) (((const void*)(&segment->first) != ((void *)0)) && ((&segment->first)->ip_posid != 0))))) || (ExceptionalCondition("!(((_Bool) (((const void*)(&segment->first) != ((void *)0)) && ((&segment->first)->ip_posid != 0))))", ("FailedAssertion"), "ginpostinglist.c", 338), 0)))), ( (&segment->first)->ip_posid ) ) != ((OffsetNumber) 0)) && (( ((void) ((_Bool) (! (!(((_Bool) (((const void*)(&segment->first) != ((void *)0)) && ((&segment->first)->ip_posid != 0))))) || (ExceptionalCondition("!(((_Bool) (((const void*)(&segment->first) != ((void *)0)) && ((&segment->first)->ip_posid != 0))))", ("FailedAssertion"), "ginpostinglist.c", 338), 0)))), ( (&segment->first)->ip_posid ) ) <= ((OffsetNumber) (32768 / sizeof(ItemIdData)))))))", File: "ginpostinglist.c", Line: 338) Reported-by: assam258-5892 [email protected] Reproduced-by: Zhang Mingli [email protected] Authored-by: Zhang Mingli [email protected]
1 parent b8c6a63 commit 1b44ece

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

src/backend/access/gin/ginpostinglist.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,13 @@ ginPostingListDecodeAllSegments(GinPostingList *segment, int len, int *ndecoded_
335335
}
336336

337337
/* copy the first item */
338+
/*
339+
* Keep this commented out.
340+
* See comments in itemptr_to_uint64().
341+
*/
342+
#if 0
338343
Assert(OffsetNumberIsValid(ItemPointerGetOffsetNumber(&segment->first)));
344+
#endif
339345
Assert(ndecoded == 0 || ginCompareItemPointers(&segment->first, &result[ndecoded - 1]) > 0);
340346
result[ndecoded] = segment->first;
341347
ndecoded++;

src/test/regress/expected/gin.out

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,3 +310,12 @@ select count(*) from t_gin_test_tbl where j @> '{}'::int[];
310310
reset enable_seqscan;
311311
reset enable_bitmapscan;
312312
drop table t_gin_test_tbl;
313+
--
314+
-- Github issue: https://github.com/apache/cloudberry/issues/1222
315+
--
316+
begin;
317+
create table t_issue_1222(i int4[]) with (appendonly=true);
318+
create index t_issue_1222_idx on t_issue_1222 using gin (i)
319+
with (fastupdate = on, gin_pending_list_limit = 4096);
320+
insert into t_issue_1222 select array[1, 2, g] from generate_series(1, 400000) g;
321+
abort;

src/test/regress/expected/gin_optimizer.out

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,3 +308,12 @@ select count(*) from t_gin_test_tbl where j @> '{}'::int[];
308308
reset enable_seqscan;
309309
reset enable_bitmapscan;
310310
drop table t_gin_test_tbl;
311+
--
312+
-- Github issue: https://github.com/apache/cloudberry/issues/1222
313+
--
314+
begin;
315+
create table t_issue_1222(i int4[]) with (appendonly=true);
316+
create index t_issue_1222_idx on t_issue_1222 using gin (i)
317+
with (fastupdate = on, gin_pending_list_limit = 4096);
318+
insert into t_issue_1222 select array[1, 2, g] from generate_series(1, 400000) g;
319+
abort;

src/test/regress/sql/gin.sql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,13 @@ reset enable_seqscan;
172172
reset enable_bitmapscan;
173173

174174
drop table t_gin_test_tbl;
175+
176+
--
177+
-- Github issue: https://github.com/apache/cloudberry/issues/1222
178+
--
179+
begin;
180+
create table t_issue_1222(i int4[]) with (appendonly=true);
181+
create index t_issue_1222_idx on t_issue_1222 using gin (i)
182+
with (fastupdate = on, gin_pending_list_limit = 4096);
183+
insert into t_issue_1222 select array[1, 2, g] from generate_series(1, 400000) g;
184+
abort;

0 commit comments

Comments
 (0)