Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8f4a1ab

Browse files
committed
Fix bug in the new ResourceOwner implementation.
When the hash table is in use, ResoureOwnerSort() moves any elementsfrom the small fixed-size array to the hash table, and sorts it. Whenthe hash table is not in use, it sorts the elements in the smallfixed-size array directly. However, ResourceOwnerSort() andResourceOwnerReleaseAll() had different idea on when the hash table isin use: ResourceOwnerSort() checked owner->nhash != 0, andResourceOwnerReleaseAll() checked owner->hash != NULL. If the hashtable was allocated but was currently empty, you hit an assertionfailure.Reported-by: Alexander Lakhin <exclusion@gmail.com>Discussion:https://www.postgresql.org/message-id/be58d565-9e95-d417-4e47-f6bd408dea4b@gmail.com
1 parent322f55b commit8f4a1ab

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

‎src/backend/utils/resowner/resowner.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,13 @@ ResourceOwnerReleaseAll(ResourceOwner owner, ResourceReleasePhase phase,
349349
ResourceElem*items;
350350
uint32nitems;
351351

352-
/* ResourceOwnerSort must've been called already */
352+
/*
353+
* ResourceOwnerSort must've been called already. All the resources are
354+
* either in the array or the hash.
355+
*/
353356
Assert(owner->releasing);
354357
Assert(owner->sorted);
355-
if (!owner->hash)
358+
if (owner->nhash==0)
356359
{
357360
items=owner->arr;
358361
nitems=owner->narr;
@@ -393,7 +396,7 @@ ResourceOwnerReleaseAll(ResourceOwner owner, ResourceReleasePhase phase,
393396
kind->ReleaseResource(value);
394397
nitems--;
395398
}
396-
if (!owner->hash)
399+
if (owner->nhash==0)
397400
owner->narr=nitems;
398401
else
399402
owner->nhash=nitems;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp