mirror of
https://github.com/postgres/postgres.git
synced 2025-10-21 02:52:47 +03:00
Fix reset of incorrect hash iterator in GROUPING SETS queries
This fixes an unlikely issue when fetching GROUPING SET results from
their internally stored hash tables. It was possible in rare cases that
the hash iterator would be set up incorrectly which could result in a
crash.
This was introduced in 4d143509c
, so backpatch to v18.
Many thanks to Yuri Zamyatin for reporting and helping to debug this
issue.
Bug: #19078
Reported-by: Yuri Zamyatin <yuri@yrz.am>
Author: David Rowley <dgrowleyml@gmail.com>
Reviewed-by: Jeff Davis <pgsql@j-davis.com>
Discussion: https://postgr.es/m/19078-dfd62f840a2c0766@postgresql.org
Backpatch-through: 18
This commit is contained in:
@@ -2911,7 +2911,7 @@ agg_retrieve_hash_table_in_memory(AggState *aggstate)
|
||||
|
||||
perhash = &aggstate->perhash[aggstate->current_set];
|
||||
|
||||
ResetTupleHashIterator(hashtable, &perhash->hashiter);
|
||||
ResetTupleHashIterator(perhash->hashtable, &perhash->hashiter);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
@@ -1044,6 +1044,10 @@ SH_START_ITERATE_AT(SH_TYPE * tb, SH_ITERATOR * iter, uint32 at)
|
||||
SH_SCOPE SH_ELEMENT_TYPE *
|
||||
SH_ITERATE(SH_TYPE * tb, SH_ITERATOR * iter)
|
||||
{
|
||||
/* validate sanity of the given iterator */
|
||||
Assert(iter->cur < tb->size);
|
||||
Assert(iter->end < tb->size);
|
||||
|
||||
while (!iter->done)
|
||||
{
|
||||
SH_ELEMENT_TYPE *elem;
|
||||
|
Reference in New Issue
Block a user