diff --git a/src/backend/utils/adt/rowtypes.c b/src/backend/utils/adt/rowtypes.c index db843a0fbf..653dde3ee5 100644 --- a/src/backend/utils/adt/rowtypes.c +++ b/src/backend/utils/adt/rowtypes.c @@ -1843,23 +1843,6 @@ hash_record(PG_FUNCTION_ARGS) if (att->attisdropped) continue; - /* - * Lookup the hash function if not done already - */ - typentry = my_extra->columns[i].typentry; - if (typentry == NULL || - typentry->type_id != att->atttypid) - { - typentry = lookup_type_cache(att->atttypid, - TYPECACHE_HASH_PROC_FINFO); - if (!OidIsValid(typentry->hash_proc_finfo.fn_oid)) - ereport(ERROR, - (errcode(ERRCODE_UNDEFINED_FUNCTION), - errmsg("could not identify a hash function for type %s", - format_type_be(typentry->type_id)))); - my_extra->columns[i].typentry = typentry; - } - /* Compute hash of element */ if (nulls[i]) { @@ -1867,6 +1850,23 @@ hash_record(PG_FUNCTION_ARGS) } else { + /* + * Lookup the hash function if not done already + */ + typentry = my_extra->columns[i].typentry; + if (typentry == NULL || + typentry->type_id != att->atttypid) + { + typentry = lookup_type_cache(att->atttypid, + TYPECACHE_HASH_PROC_FINFO); + if (!OidIsValid(typentry->hash_proc_finfo.fn_oid)) + ereport(ERROR, + (errcode(ERRCODE_UNDEFINED_FUNCTION), + errmsg("could not identify a hash function for type %s", + format_type_be(typentry->type_id)))); + my_extra->columns[i].typentry = typentry; + } + LOCAL_FCINFO(locfcinfo, 1); InitFunctionCallInfoData(*locfcinfo, &typentry->hash_proc_finfo, 1,