Re: clarify equalTupleDescs()
Peter Eisentraut <peter@eisentraut.org>
From: Peter Eisentraut <peter@eisentraut.org>
To: jian he <jian.universality@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2024-02-12T11:46:57Z
Lists: pgsql-hackers
On 07.02.24 04:06, jian he wrote:
> /*
> * hashRowType
> *
> * If two tuple descriptors would be considered equal by equalRowTypes()
> * then their hash value will be equal according to this function.
> */
> uint32
> hashRowType(TupleDesc desc)
> {
> uint32 s;
> int i;
>
> s = hash_combine(0, hash_uint32(desc->natts));
> s = hash_combine(s, hash_uint32(desc->tdtypeid));
> for (i = 0; i < desc->natts; ++i)
> s = hash_combine(s, hash_uint32(TupleDescAttr(desc, i)->atttypid));
>
> return s;
> }
>
> from the hashRowType comment, should we also hash attname and atttypmod?
In principle, hashRowType() could process all the fields that
equalRowTypes() does. But since it's only a hash function, it doesn't
have to be perfect. (This is also the case for the current
hashTupleDesc().) I'm not sure where the best tradeoff is.
Commits
-
Separate equalRowTypes() from equalTupleDescs()
- 20e58105badf 17.0 landed