@@ -75,6 +75,26 @@ init_record(RecordVar *record, TupleDesc tupdesc, Variable *variable)
75
75
76
76
Assert (variable -> typid == RECORDOID );
77
77
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
+
78
98
sprintf (hash_name , "Records hash for variable \"%s\"" , GetName (variable ));
79
99
80
100
topctx = variable -> is_transactional ?
@@ -109,24 +129,6 @@ init_record(RecordVar *record, TupleDesc tupdesc, Variable *variable)
109
129
HASH_ELEM | HASH_CONTEXT |
110
130
HASH_FUNCTION | HASH_COMPARE );
111
131
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
-
130
132
fmgr_info (typentry -> hash_proc_finfo .fn_oid , & record -> hash_proc );
131
133
fmgr_info (typentry -> cmp_proc_finfo .fn_oid , & record -> cmp_proc );
132
134
0 commit comments