@@ -75,6 +75,26 @@ init_record(RecordVar *record, TupleDesc tupdesc, Variable *variable)
7575
7676 Assert (variable -> typid == RECORDOID );
7777
78+ /* First get hash and match functions for key type. */
79+ keyid = GetTupleDescAttr (tupdesc , 0 )-> atttypid ;
80+ typentry = lookup_type_cache (keyid ,
81+ TYPECACHE_HASH_PROC_FINFO |
82+ TYPECACHE_CMP_PROC_FINFO );
83+
84+ if (!OidIsValid (typentry -> hash_proc_finfo .fn_oid ))
85+ ereport (ERROR ,
86+ (errcode (ERRCODE_UNDEFINED_FUNCTION ),
87+ errmsg ("could not identify a hash function for type %s" ,
88+ format_type_be (keyid ))));
89+
90+ if (!OidIsValid (typentry -> cmp_proc_finfo .fn_oid ))
91+ ereport (ERROR ,
92+ (errcode (ERRCODE_UNDEFINED_FUNCTION ),
93+ errmsg ("could not identify a matching function for type %s" ,
94+ format_type_be (keyid ))));
95+
96+ /* Initialize the record */
97+
7898 sprintf (hash_name , "Records hash for variable \"%s\"" , GetName (variable ));
7999
80100 topctx = variable -> is_transactional ?
@@ -109,24 +129,6 @@ init_record(RecordVar *record, TupleDesc tupdesc, Variable *variable)
109129 HASH_ELEM | HASH_CONTEXT |
110130 HASH_FUNCTION | HASH_COMPARE );
111131
112- /* Get hash and match functions for key type. */
113- keyid = GetTupleDescAttr (record -> tupdesc , 0 )-> atttypid ;
114- typentry = lookup_type_cache (keyid ,
115- TYPECACHE_HASH_PROC_FINFO |
116- TYPECACHE_CMP_PROC_FINFO );
117-
118- if (!OidIsValid (typentry -> hash_proc_finfo .fn_oid ))
119- ereport (ERROR ,
120- (errcode (ERRCODE_UNDEFINED_FUNCTION ),
121- errmsg ("could not identify a hash function for type %s" ,
122- format_type_be (keyid ))));
123-
124- if (!OidIsValid (typentry -> cmp_proc_finfo .fn_oid ))
125- ereport (ERROR ,
126- (errcode (ERRCODE_UNDEFINED_FUNCTION ),
127- errmsg ("could not identify a matching function for type %s" ,
128- format_type_be (keyid ))));
129-
130132 fmgr_info (typentry -> hash_proc_finfo .fn_oid , & record -> hash_proc );
131133 fmgr_info (typentry -> cmp_proc_finfo .fn_oid , & record -> cmp_proc );
132134
0 commit comments