aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/array_userfuncs.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-12-17 20:59:58 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-12-17 20:59:58 +0000
commitd0a6042f9ff93c4d485c4fb6afd9f4f4a41f7a85 (patch)
tree08cca5f579130ca48799a68c6e6931daa734b7ea /src/backend/utils/adt/array_userfuncs.c
parentbd3bc4076e9fb701456acef2370237baab839583 (diff)
downloadpostgresql-d0a6042f9ff93c4d485c4fb6afd9f4f4a41f7a85.tar.gz
postgresql-d0a6042f9ff93c4d485c4fb6afd9f4f4a41f7a85.zip
Make array_cat more paranoid about checking datatypes in empty arrays.
Diffstat (limited to 'src/backend/utils/adt/array_userfuncs.c')
-rw-r--r--src/backend/utils/adt/array_userfuncs.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/backend/utils/adt/array_userfuncs.c b/src/backend/utils/adt/array_userfuncs.c
index 00146b2403e..9f2f34c3edd 100644
--- a/src/backend/utils/adt/array_userfuncs.c
+++ b/src/backend/utils/adt/array_userfuncs.c
@@ -6,7 +6,7 @@
* Copyright (c) 2003, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/array_userfuncs.c,v 1.13 2004/08/29 05:06:49 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/array_userfuncs.c,v 1.14 2004/12/17 20:59:58 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -165,6 +165,22 @@ array_cat(PG_FUNCTION_ARGS)
v1 = PG_GETARG_ARRAYTYPE_P(0);
v2 = PG_GETARG_ARRAYTYPE_P(1);
+ element_type1 = ARR_ELEMTYPE(v1);
+ element_type2 = ARR_ELEMTYPE(v2);
+
+ /* Check we have matching element types */
+ if (element_type1 != element_type2)
+ ereport(ERROR,
+ (errcode(ERRCODE_DATATYPE_MISMATCH),
+ errmsg("cannot concatenate incompatible arrays"),
+ errdetail("Arrays with element types %s and %s are not "
+ "compatible for concatenation.",
+ format_type_be(element_type1),
+ format_type_be(element_type2))));
+
+ /* OK, use it */
+ element_type = element_type1;
+
/*----------
* We must have one of the following combinations of inputs:
* 1) one empty array, and one non-empty array
@@ -200,22 +216,6 @@ array_cat(PG_FUNCTION_ARGS)
"compatible for concatenation.",
ndims1, ndims2)));
- element_type1 = ARR_ELEMTYPE(v1);
- element_type2 = ARR_ELEMTYPE(v2);
-
- /* Check we have matching element types */
- if (element_type1 != element_type2)
- ereport(ERROR,
- (errcode(ERRCODE_DATATYPE_MISMATCH),
- errmsg("cannot concatenate incompatible arrays"),
- errdetail("Arrays with element types %s and %s are not "
- "compatible for concatenation.",
- format_type_be(element_type1),
- format_type_be(element_type2))));
-
- /* OK, use it */
- element_type = element_type1;
-
/* get argument array details */
lbs1 = ARR_LBOUND(v1);
lbs2 = ARR_LBOUND(v2);