1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-21 05:21:08 +03:00

Array mega-patch.

Joe Conway
This commit is contained in:
Bruce Momjian
2003-06-24 23:14:49 +00:00
parent 50e53236af
commit 46bf651480
42 changed files with 2617 additions and 678 deletions

View File

@@ -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*
@@ -220,6 +274,21 @@ equality_oper_funcid(Oid argtype)
return result;
}
/*
* 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())
*