aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_func.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-03-16 06:35:07 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-03-16 06:35:07 +0000
commitd14c8aab99577d7dd06e9d50f3ac9c09d0334131 (patch)
tree4741b82093bd82052d865f784e47622e8954d106 /src/backend/parser/parse_func.c
parentd4a2c86eaf6f5e6c656dd54a7e1967a927cfa2e9 (diff)
downloadpostgresql-d14c8aab99577d7dd06e9d50f3ac9c09d0334131.tar.gz
postgresql-d14c8aab99577d7dd06e9d50f3ac9c09d0334131.zip
Turns out that Mazurkiewicz's gripe about 'function inheritance' is
actually a type-coercion problem. If you have a function defined on class A, and class B inherits from A, then the function ought to work on class B as well --- but coerce_type didn't know that. Now it does.
Diffstat (limited to 'src/backend/parser/parse_func.c')
-rw-r--r--src/backend/parser/parse_func.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c
index eb4884accbb..e24007a4393 100644
--- a/src/backend/parser/parse_func.c
+++ b/src/backend/parser/parse_func.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.74 2000/03/14 23:06:32 thomas Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.75 2000/03/16 06:35:07 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -68,7 +68,6 @@ static Oid *func_select_candidate(int nargs, Oid *input_typeids,
static int agg_get_candidates(char *aggname, Oid typeId, CandidateList *candidates);
static Oid agg_select_candidate(Oid typeid, CandidateList candidates);
-#define ISCOMPLEX(type) (typeidTypeRelid(type) ? true : false)
/*
** ParseNestedFuncOrColumn
@@ -1360,6 +1359,40 @@ gen_cross_product(InhPaths *arginh, int nargs)
}
+/*
+ * Given two type OIDs, determine whether the first is a complex type
+ * (class type) that inherits from the second.
+ */
+bool
+typeInheritsFrom(Oid subclassTypeId, Oid superclassTypeId)
+{
+ Oid relid;
+ Oid *supervec;
+ int nsupers,
+ i;
+ bool result;
+
+ if (!ISCOMPLEX(subclassTypeId) || !ISCOMPLEX(superclassTypeId))
+ return false;
+ relid = typeidTypeRelid(subclassTypeId);
+ if (relid == InvalidOid)
+ return false;
+ nsupers = find_inheritors(relid, &supervec);
+ result = false;
+ for (i = 0; i < nsupers; i++)
+ {
+ if (supervec[i] == superclassTypeId)
+ {
+ result = true;
+ break;
+ }
+ }
+ if (supervec)
+ pfree(supervec);
+ return result;
+}
+
+
/* make_arguments()
* Given the number and types of arguments to a function, and the
* actual arguments and argument types, do the necessary typecasting.