@@ -67,6 +67,7 @@ fill_type_cmp_fmgr_info(FmgrInfo *finfo, Oid type1, Oid type2)
67
67
TypeCacheEntry * tce_1 ,
68
68
* tce_2 ;
69
69
70
+ /* Check type compatibility */
70
71
if (IsBinaryCoercible (type1 , type2 ))
71
72
type1 = type2 ;
72
73
@@ -76,6 +77,7 @@ fill_type_cmp_fmgr_info(FmgrInfo *finfo, Oid type1, Oid type2)
76
77
tce_1 = lookup_type_cache (type1 , TYPECACHE_BTREE_OPFAMILY );
77
78
tce_2 = lookup_type_cache (type2 , TYPECACHE_BTREE_OPFAMILY );
78
79
80
+ /* Both types should belong to the same opfamily */
79
81
if (tce_1 -> btree_opf != tce_2 -> btree_opf )
80
82
goto fill_type_cmp_fmgr_info_error ;
81
83
@@ -84,13 +86,16 @@ fill_type_cmp_fmgr_info(FmgrInfo *finfo, Oid type1, Oid type2)
84
86
tce_2 -> btree_opintype ,
85
87
BTORDER_PROC );
86
88
87
- if (cmp_proc_oid == InvalidOid )
89
+ /* No such function, emit ERROR */
90
+ if (!OidIsValid (cmp_proc_oid ))
88
91
goto fill_type_cmp_fmgr_info_error ;
89
92
93
+ /* Fill FmgrInfo struct */
90
94
fmgr_info (cmp_proc_oid , finfo );
91
95
92
- return ; /* exit safely */
96
+ return ; /* everything is OK */
93
97
98
+ /* Handle errors (no such function) */
94
99
fill_type_cmp_fmgr_info_error :
95
100
elog (ERROR , "missing comparison function for types %s & %s" ,
96
101
format_type_be (type1 ), format_type_be (type2 ));
0 commit comments