Skip to content

Commit 1bfa84a

Browse files
committed
Set up correct findTypeSubscription function
1 parent d7c8af3 commit 1bfa84a

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

src/backend/commands/typecmds.c

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ static Oid findTypeSendFunction(List *procname, Oid typeOid);
9494
static Oid findTypeTypmodinFunction(List *procname);
9595
static Oid findTypeTypmodoutFunction(List *procname);
9696
static Oid findTypeAnalyzeFunction(List *procname, Oid typeOid);
97+
static Oid findTypeSubscriptionFunction(List *procname, Oid typeOid);
9798
static Oid findRangeSubOpclass(List *opcname, Oid subtype);
9899
static Oid findRangeCanonicalFunction(List *procname, Oid typeOid);
99100
static Oid findRangeSubtypeDiffFunction(List *procname, Oid subtype);
@@ -520,7 +521,7 @@ DefineType(List *names, List *parameters)
520521
analyzeOid = findTypeAnalyzeFunction(analyzeName, typoid);
521522

522523
if (subscriptionName)
523-
subscriptionOid = findTypeAnalyzeFunction(subscriptionName, typoid);
524+
subscriptionOid = findTypeSubscriptionFunction(subscriptionName, typoid);
524525

525526
/*
526527
* Check permissions on functions. We choose to require the creator/owner
@@ -1916,6 +1917,33 @@ findTypeAnalyzeFunction(List *procname, Oid typeOid)
19161917
return procOid;
19171918
}
19181919

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+
19191947
/*
19201948
* Find suitable support functions and opclasses for a range type.
19211949
*/

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy