diff options
author | Bruce Momjian <bruce@momjian.us> | 2003-06-24 23:14:49 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2003-06-24 23:14:49 +0000 |
commit | 46bf65148002f03a4775e6fbb2c4f758184062c5 (patch) | |
tree | 35508e7d4793489135efdbdff9b0fd2325c3b3e3 /src/backend/parser/parse_oper.c | |
parent | 50e53236aff06a6193059b5a92e60561645338ab (diff) | |
download | postgresql-46bf65148002f03a4775e6fbb2c4f758184062c5.tar.gz postgresql-46bf65148002f03a4775e6fbb2c4f758184062c5.zip |
Array mega-patch.
Joe Conway
Diffstat (limited to 'src/backend/parser/parse_oper.c')
-rw-r--r-- | src/backend/parser/parse_oper.c | 71 |
1 files changed, 70 insertions, 1 deletions
diff --git a/src/backend/parser/parse_oper.c b/src/backend/parser/parse_oper.c index 21f73994c42..a6b66625be2 100644 --- a/src/backend/parser/parse_oper.c +++ b/src/backend/parser/parse_oper.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.64 2003/05/26 00:11:27 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.65 2003/06/24 23:14:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -137,6 +137,33 @@ Operator equality_oper(Oid argtype, bool noError) { Operator optup; + Oid elem_type = get_element_type(argtype); + + if (OidIsValid(elem_type)) + { + bool found = false; + /* + * If the datatype is an array, look for an "=" operator for the + * element datatype. We require it to be an exact or binary-compatible + * match, since most callers are not prepared to cope with adding any + * run-time type coercion steps. + */ + optup = equality_oper(elem_type, true); + if (optup != NULL) + { + found = true; + ReleaseSysCache(optup); + } + + if (!found) + { + if (!noError) + elog(ERROR, "Unable to identify an equality operator for " \ + "array type's element type %s", + format_type_be(elem_type)); + return NULL; + } + } /* * Look for an "=" operator for the datatype. We require it to be @@ -175,6 +202,33 @@ Operator ordering_oper(Oid argtype, bool noError) { Operator optup; + Oid elem_type = get_element_type(argtype); + + if (OidIsValid(elem_type)) + { + bool found = false; + /* + * If the datatype is an array, find the array element type's equality + * operator, and use its lsortop (it *must* be mergejoinable). We use + * this definition because for sorting and grouping purposes, it's + * important that the equality and ordering operators are consistent. + */ + optup = ordering_oper(elem_type, true); + if (optup != NULL) + { + found = true; + ReleaseSysCache(optup); + } + + if (!found) + { + if (!noError) + elog(ERROR, "Unable to identify an ordering operator for " \ + "array type's element type %s", + format_type_be(elem_type)); + return NULL; + } + } /* * Find the type's equality operator, and use its lsortop (it *must* @@ -221,6 +275,21 @@ equality_oper_funcid(Oid argtype) } /* + * ordering_oper_funcid - convenience routine for oprfuncid(ordering_oper()) + */ +Oid +ordering_oper_funcid(Oid argtype) +{ + Operator optup; + Oid result; + + optup = ordering_oper(argtype, false); + result = oprfuncid(optup); + ReleaseSysCache(optup); + return result; +} + +/* * ordering_oper_opid - convenience routine for oprid(ordering_oper()) * * This was formerly called any_ordering_op() |