diff --git a/CHANGELOG.md b/CHANGELOG.md index fa64696f2..fe40eb836 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,8 +10,12 @@ accidentally triggering the load of a previous DB version.** * #3209 Propagate grants to compressed hypertables * #3241 Fix assertion failure in decompress_chunk_plan_create * #3250 Fix constraint triggers on hypertables +* #3251 Fix segmentation fault due to incorrect call to chunk_scan_internal * #3252 Fix blocking triggers with transition tables +**Thanks** +* @yyjdelete for reporting a crash with decompress_chunk and identifying the bug in the code + ## 2.2.1 (2021-05-05) This maintenance release contains bugfixes since the 2.2.0 release. We diff --git a/src/chunk.c b/src/chunk.c index 3657826b3..5cc586dc1 100644 --- a/src/chunk.c +++ b/src/chunk.c @@ -1322,6 +1322,24 @@ chunk_tuple_dropped_filter(TupleInfo *ti, void *arg) return stubctx->is_dropped ? SCAN_EXCLUDE : SCAN_INCLUDE; } +/* This is a modified version of chunk_tuple_dropped_filter that does + * not use ChunkStubScanCtx as the arg, it just ignores the passed in + * argument. + * We need a variant as the ScannerCtx assumes that the the filter function + * and tuple_found function share the argument. + */ +static ScanFilterResult +chunk_check_ignorearg_dropped_filter(TupleInfo *ti, void *arg) +{ + bool isnull; + Datum dropped = slot_getattr(ti->slot, Anum_chunk_dropped, &isnull); + + Assert(!isnull); + bool is_dropped = DatumGetBool(dropped); + + return is_dropped ? SCAN_EXCLUDE : SCAN_INCLUDE; +} + static ScanTupleResult chunk_tuple_found(TupleInfo *ti, void *arg) { @@ -3128,7 +3146,7 @@ ts_chunk_set_compressed_chunk(Chunk *chunk, int32 compressed_chunk_id) return chunk_scan_internal(CHUNK_ID_INDEX, scankey, 1, - chunk_tuple_dropped_filter, + chunk_check_ignorearg_dropped_filter, chunk_set_compressed_id_in_tuple, &compressed_chunk_id, 0, @@ -3151,7 +3169,7 @@ ts_chunk_clear_compressed_chunk(Chunk *chunk) return chunk_scan_internal(CHUNK_ID_INDEX, scankey, 1, - chunk_tuple_dropped_filter, + chunk_check_ignorearg_dropped_filter, chunk_clear_compressed_status_in_tuple, &compressed_chunk_id, 0,