@@ -94,6 +94,7 @@ static Oid findTypeSendFunction(List *procname, Oid typeOid);
94
94
static Oid findTypeTypmodinFunction (List * procname );
95
95
static Oid findTypeTypmodoutFunction (List * procname );
96
96
static Oid findTypeAnalyzeFunction (List * procname , Oid typeOid );
97
+ static Oid findTypeSubscriptionFunction (List * procname , Oid typeOid );
97
98
static Oid findRangeSubOpclass (List * opcname , Oid subtype );
98
99
static Oid findRangeCanonicalFunction (List * procname , Oid typeOid );
99
100
static Oid findRangeSubtypeDiffFunction (List * procname , Oid subtype );
@@ -520,7 +521,7 @@ DefineType(List *names, List *parameters)
520
521
analyzeOid = findTypeAnalyzeFunction (analyzeName , typoid );
521
522
522
523
if (subscriptionName )
523
- subscriptionOid = findTypeAnalyzeFunction (subscriptionName , typoid );
524
+ subscriptionOid = findTypeSubscriptionFunction (subscriptionName , typoid );
524
525
525
526
/*
526
527
* Check permissions on functions. We choose to require the creator/owner
@@ -1916,6 +1917,33 @@ findTypeAnalyzeFunction(List *procname, Oid typeOid)
1916
1917
return procOid ;
1917
1918
}
1918
1919
1920
+ static Oid
1921
+ findTypeSubscriptionFunction (List * procname , Oid typeOid )
1922
+ {
1923
+ Oid argList [1 ];
1924
+ Oid procOid ;
1925
+
1926
+ /*
1927
+ * Analyze functions always take one INTERNAL argument and return INTERNAL.
1928
+ */
1929
+ argList [0 ] = INTERNALOID ;
1930
+
1931
+ procOid = LookupFuncName (procname , 1 , argList , true);
1932
+ if (!OidIsValid (procOid ))
1933
+ ereport (ERROR ,
1934
+ (errcode (ERRCODE_UNDEFINED_FUNCTION ),
1935
+ errmsg ("function %s does not exist" ,
1936
+ func_signature_string (procname , 1 , NIL , argList ))));
1937
+
1938
+ if (get_func_rettype (procOid ) != INTERNALOID )
1939
+ ereport (ERROR ,
1940
+ (errcode (ERRCODE_INVALID_OBJECT_DEFINITION ),
1941
+ errmsg ("type subscription function %s must return type %s" ,
1942
+ NameListToString (procname ), "internal" )));
1943
+
1944
+ return procOid ;
1945
+ }
1946
+
1919
1947
/*
1920
1948
* Find suitable support functions and opclasses for a range type.
1921
1949
*/
0 commit comments