@@ -67,6 +67,7 @@ fill_type_cmp_fmgr_info(FmgrInfo *finfo, Oid type1, Oid type2)
6767 TypeCacheEntry * tce_1 ,
6868 * tce_2 ;
6969
70+ /* Check type compatibility */
7071 if (IsBinaryCoercible (type1 , type2 ))
7172 type1 = type2 ;
7273
@@ -76,6 +77,7 @@ fill_type_cmp_fmgr_info(FmgrInfo *finfo, Oid type1, Oid type2)
7677 tce_1 = lookup_type_cache (type1 , TYPECACHE_BTREE_OPFAMILY );
7778 tce_2 = lookup_type_cache (type2 , TYPECACHE_BTREE_OPFAMILY );
7879
80+ /* Both types should belong to the same opfamily */
7981 if (tce_1 -> btree_opf != tce_2 -> btree_opf )
8082 goto fill_type_cmp_fmgr_info_error ;
8183
@@ -84,13 +86,16 @@ fill_type_cmp_fmgr_info(FmgrInfo *finfo, Oid type1, Oid type2)
8486 tce_2 -> btree_opintype ,
8587 BTORDER_PROC );
8688
87- if (cmp_proc_oid == InvalidOid )
89+ /* No such function, emit ERROR */
90+ if (!OidIsValid (cmp_proc_oid ))
8891 goto fill_type_cmp_fmgr_info_error ;
8992
93+ /* Fill FmgrInfo struct */
9094 fmgr_info (cmp_proc_oid , finfo );
9195
92- return ; /* exit safely */
96+ return ; /* everything is OK */
9397
98+ /* Handle errors (no such function) */
9499fill_type_cmp_fmgr_info_error :
95100 elog (ERROR , "missing comparison function for types %s & %s" ,
96101 format_type_be (type1 ), format_type_be (type2 ));
0 commit comments