diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2021-09-08 09:25:46 +0200 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2021-09-08 09:55:04 +0200 |
commit | a3d2b1bbe904b0ca8d9fdde20f25295ff3e21f79 (patch) | |
tree | 86ba72f03e89d0c15db995c86234a5ab180c6a66 /src/backend/utils/cache | |
parent | 98dbef90eb29b13079ba3bd260b3c5818904ee86 (diff) | |
download | postgresql-a3d2b1bbe904b0ca8d9fdde20f25295ff3e21f79.tar.gz postgresql-a3d2b1bbe904b0ca8d9fdde20f25295ff3e21f79.zip |
Disable anonymous record hash support except in special cases
Commit 01e658fa74 added hash support for row types. This also added
support for hashing anonymous record types, using the same approach
that the type cache uses for comparison support for record types: It
just reports that it works, but it might fail at run time if a
component type doesn't actually support the operation. We get away
with that for comparison because most types support that. But some
types don't support hashing, so the current state can result in
failures at run time where the planner chooses hashing over sorting,
whereas that previously worked if only sorting was an option.
We do, however, want the record hashing support for path tracking in
recursive unions, and the SEARCH and CYCLE clauses built on that. In
that case, hashing is the only plan option. So enable that, this
commit implements the following approach: The type cache does not
report that hashing is available for the record type. This undoes
that part of 01e658fa74. Instead, callers that require hashing no
matter what can override that result themselves. This patch only
touches the callers to make the aforementioned recursive query cases
work, namely the parse analysis of unions, as well as the hash_array()
function.
Reported-by: Sait Talha Nisanci <sait.nisanci@microsoft.com>
Bug: #17158
Discussion: https://www.postgresql.org/message-id/flat/17158-8a2ba823982537a4%40postgresql.org
Diffstat (limited to 'src/backend/utils/cache')
-rw-r--r-- | src/backend/utils/cache/typcache.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/backend/utils/cache/typcache.c b/src/backend/utils/cache/typcache.c index 326fae62e22..70e5c51297d 100644 --- a/src/backend/utils/cache/typcache.c +++ b/src/backend/utils/cache/typcache.c @@ -1515,14 +1515,17 @@ cache_record_field_properties(TypeCacheEntry *typentry) /* * For type RECORD, we can't really tell what will work, since we don't * have access here to the specific anonymous type. Just assume that - * everything will (we may get a failure at runtime ...) + * equality and comparison will (we may get a failure at runtime). We + * could also claim that hashing works, but then if code that has the + * option between a comparison-based (sort-based) and a hash-based plan + * chooses hashing, stuff could fail that would otherwise work if it chose + * a comparison-based plan. In practice more types support comparison + * than hashing. */ if (typentry->type_id == RECORDOID) { typentry->flags |= (TCFLAGS_HAVE_FIELD_EQUALITY | - TCFLAGS_HAVE_FIELD_COMPARE | - TCFLAGS_HAVE_FIELD_HASHING | - TCFLAGS_HAVE_FIELD_EXTENDED_HASHING); + TCFLAGS_HAVE_FIELD_COMPARE); } else if (typentry->typtype == TYPTYPE_COMPOSITE) { |