diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2024-03-17 05:58:04 +0100 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2024-03-17 05:58:04 +0100 |
commit | 20e58105badff383bd43f0b97e532771768f94df (patch) | |
tree | 4bff7fadb1d4fbf269477787dae80b81c27c4596 /src/backend/utils/cache/typcache.c | |
parent | b7831865159d5fb6f0d263e6023f0986589fe254 (diff) | |
download | postgresql-20e58105badff383bd43f0b97e532771768f94df.tar.gz postgresql-20e58105badff383bd43f0b97e532771768f94df.zip |
Separate equalRowTypes() from equalTupleDescs()
This introduces a new function equalRowTypes() that is effectively a
subset of equalTupleDescs() but only compares the number of attributes
and attribute name, type, typmod, and collation. This is enough for
most existing uses of equalTupleDescs(), which are changed to use the
new function. The only remaining callers of equalTupleDescs() are
those that really want to check the full tuple descriptor as such,
without concern about record or row or record type semantics.
The existing function hashTupleDesc() is renamed to hashRowType(),
because it now corresponds more to equalRowTypes().
The purpose of this change is to be clearer about the semantics of the
equality asked for by each caller. (At least one caller had a comment
that questioned whether equalTupleDescs() was too restrictive.) For
example, 4f622503d6d removed attstattarget from the tuple descriptor
structure. It was not fully clear at the time how this should affect
equalTupleDescs(). Now the answer is clear: By their own definitions,
equalRowTypes() does not care, and equalTupleDescs() just compares
whatever is in the tuple descriptor but does not care why it is in
there.
Reviewed-by: Tomas Vondra <tomas.vondra@enterprisedb.com>
Discussion: https://www.postgresql.org/message-id/flat/f656d6d9-6660-4518-a006-2f65cafbebd1%40eisentraut.org
Diffstat (limited to 'src/backend/utils/cache/typcache.c')
-rw-r--r-- | src/backend/utils/cache/typcache.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/backend/utils/cache/typcache.c b/src/backend/utils/cache/typcache.c index 0d4d0b0a154..d86c3b06fa0 100644 --- a/src/backend/utils/cache/typcache.c +++ b/src/backend/utils/cache/typcache.c @@ -147,7 +147,7 @@ typedef struct TypeCacheEnumData * We use a separate table for storing the definitions of non-anonymous * record types. Once defined, a record type will be remembered for the * life of the backend. Subsequent uses of the "same" record type (where - * sameness means equalTupleDescs) will refer to the existing table entry. + * sameness means equalRowTypes) will refer to the existing table entry. * * Stored record types are remembered in a linear array of TupleDescs, * which can be indexed quickly with the assigned typmod. There is also @@ -231,7 +231,7 @@ shared_record_table_compare(const void *a, const void *b, size_t size, else t2 = k2->u.local_tupdesc; - return equalTupleDescs(t1, t2) ? 0 : 1; + return equalRowTypes(t1, t2) ? 0 : 1; } /* @@ -249,7 +249,7 @@ shared_record_table_hash(const void *a, size_t size, void *arg) else t = k->u.local_tupdesc; - return hashTupleDesc(t); + return hashRowType(t); } /* Parameters for SharedRecordTypmodRegistry's TupleDesc table. */ @@ -1927,7 +1927,7 @@ record_type_typmod_hash(const void *data, size_t size) { RecordCacheEntry *entry = (RecordCacheEntry *) data; - return hashTupleDesc(entry->tupdesc); + return hashRowType(entry->tupdesc); } /* @@ -1939,7 +1939,7 @@ record_type_typmod_compare(const void *a, const void *b, size_t size) RecordCacheEntry *left = (RecordCacheEntry *) a; RecordCacheEntry *right = (RecordCacheEntry *) b; - return equalTupleDescs(left->tupdesc, right->tupdesc) ? 0 : 1; + return equalRowTypes(left->tupdesc, right->tupdesc) ? 0 : 1; } /* |