aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_oper.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-04-02 03:49:42 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-04-02 03:49:42 +0000
commit57690c6803525f879fe96920a05e979ece073e71 (patch)
tree42e82eaa1e9c8247b39a2ad783bf190b5001acfe /src/backend/parser/parse_oper.c
parenta482a3e58b3e5830899560c555e57e4184b8e6be (diff)
downloadpostgresql-57690c6803525f879fe96920a05e979ece073e71.tar.gz
postgresql-57690c6803525f879fe96920a05e979ece073e71.zip
Support enum data types. Along the way, use macros for the values of
pg_type.typtype whereever practical. Tom Dunstan, with some kibitzing from Tom Lane.
Diffstat (limited to 'src/backend/parser/parse_oper.c')
-rw-r--r--src/backend/parser/parse_oper.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/src/backend/parser/parse_oper.c b/src/backend/parser/parse_oper.c
index c8d295047b3..42bd04fa01e 100644
--- a/src/backend/parser/parse_oper.c
+++ b/src/backend/parser/parse_oper.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/parse_oper.c,v 1.94 2007/02/01 19:10:27 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/parse_oper.c,v 1.95 2007/04/02 03:49:39 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -886,8 +886,8 @@ make_scalar_array_op(ParseState *pstate, List *opname,
declared_arg_types[1] = opform->oprright;
/*
- * enforce consistency with ANYARRAY and ANYELEMENT argument and return
- * types, possibly adjusting return type or declared_arg_types (which will
+ * enforce consistency with polymorphic argument and return types,
+ * possibly adjusting return type or declared_arg_types (which will
* be used as the cast destination by make_fn_arguments)
*/
rettype = enforce_generic_type_consistency(actual_arg_types,
@@ -911,15 +911,25 @@ make_scalar_array_op(ParseState *pstate, List *opname,
/*
* Now switch back to the array type on the right, arranging for any
- * needed cast to be applied.
+ * needed cast to be applied. Beware of polymorphic operators here;
+ * enforce_generic_type_consistency may or may not have replaced a
+ * polymorphic type with a real one.
*/
- res_atypeId = get_array_type(declared_arg_types[1]);
- if (!OidIsValid(res_atypeId))
- ereport(ERROR,
- (errcode(ERRCODE_UNDEFINED_OBJECT),
- errmsg("could not find array type for data type %s",
- format_type_be(declared_arg_types[1])),
- parser_errposition(pstate, location)));
+ if (IsPolymorphicType(declared_arg_types[1]))
+ {
+ /* assume the actual array type is OK */
+ res_atypeId = atypeId;
+ }
+ else
+ {
+ res_atypeId = get_array_type(declared_arg_types[1]);
+ if (!OidIsValid(res_atypeId))
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_OBJECT),
+ errmsg("could not find array type for data type %s",
+ format_type_be(declared_arg_types[1])),
+ parser_errposition(pstate, location)));
+ }
actual_arg_types[1] = atypeId;
declared_arg_types[1] = res_atypeId;
@@ -986,8 +996,8 @@ make_op_expr(ParseState *pstate, Operator op,
}
/*
- * enforce consistency with ANYARRAY and ANYELEMENT argument and return
- * types, possibly adjusting return type or declared_arg_types (which will
+ * enforce consistency with polymorphic argument and return types,
+ * possibly adjusting return type or declared_arg_types (which will
* be used as the cast destination by make_fn_arguments)
*/
rettype = enforce_generic_type_consistency(actual_arg_types,