Re: ResourceOwner refactoring - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: ResourceOwner refactoring
Date
Msg-id 908491f9-57ff-5061-30c6-d15d3dbf0e67@iki.fi
Whole thread Raw
In response to Re: ResourceOwner refactoring  (Zhihong Yu <zyu@yugabyte.com>)
Responses Re: ResourceOwner refactoring  (Zhihong Yu <zyu@yugabyte.com>)
List pgsql-hackers
Thanks for having a look!

On 14/07/2021 18:18, Zhihong Yu wrote:
> For the loop over the hash:
> 
> +       for (int idx = 0; idx < capacity; idx++)
>          {
> -           if (olditemsarr[i] != resarr->invalidval)
> -               ResourceArrayAdd(resarr, olditemsarr[i]);
> +           while (owner->hash[idx].kind != NULL &&
> +                  owner->hash[idx].kind->phase == phase)
> ...
> +   } while (capacity != owner->capacity);
> 
> Since the phase variable doesn't seem to change for the while loop, I 
> wonder what benefit the while loop has (since the release is governed by 
> phase).

Hmm, the phase variable doesn't change, but could the element at 
'owner->hash[idx]' change? I'm not sure about that. The loop is supposed 
to handle the case that the hash table grows; could that replace the 
element at 'owner->hash[idx]' with something else, with different phase? 
The check is very cheap, so I'm inclined to keep it to be sure.

- Heikki



pgsql-hackers by date:

Previous
From: Justin Pryzby
Date:
Subject: Re: Avoid repeated PQfnumber() in pg_dump
Next
From: vignesh C
Date:
Subject: Re: libpq compression