|
6 | 6 | * Copyright (c) 2003, PostgreSQL Global Development Group |
7 | 7 | * |
8 | 8 | * IDENTIFICATION |
9 | | - * $PostgreSQL: pgsql/src/backend/utils/adt/array_userfuncs.c,v 1.13 2004/08/29 05:06:49 momjian Exp $ |
| 9 | + * $PostgreSQL: pgsql/src/backend/utils/adt/array_userfuncs.c,v 1.14 2004/12/17 20:59:58 tgl Exp $ |
10 | 10 | * |
11 | 11 | *------------------------------------------------------------------------- |
12 | 12 | */ |
@@ -165,6 +165,22 @@ array_cat(PG_FUNCTION_ARGS) |
165 | 165 | v1=PG_GETARG_ARRAYTYPE_P(0); |
166 | 166 | v2=PG_GETARG_ARRAYTYPE_P(1); |
167 | 167 |
|
| 168 | +element_type1=ARR_ELEMTYPE(v1); |
| 169 | +element_type2=ARR_ELEMTYPE(v2); |
| 170 | + |
| 171 | +/* Check we have matching element types */ |
| 172 | +if (element_type1!=element_type2) |
| 173 | +ereport(ERROR, |
| 174 | +(errcode(ERRCODE_DATATYPE_MISMATCH), |
| 175 | +errmsg("cannot concatenate incompatible arrays"), |
| 176 | +errdetail("Arrays with element types %s and %s are not " |
| 177 | +"compatible for concatenation.", |
| 178 | +format_type_be(element_type1), |
| 179 | +format_type_be(element_type2)))); |
| 180 | + |
| 181 | +/* OK, use it */ |
| 182 | +element_type=element_type1; |
| 183 | + |
168 | 184 | /*---------- |
169 | 185 | * We must have one of the following combinations of inputs: |
170 | 186 | * 1) one empty array, and one non-empty array |
@@ -200,22 +216,6 @@ array_cat(PG_FUNCTION_ARGS) |
200 | 216 | "compatible for concatenation.", |
201 | 217 | ndims1,ndims2))); |
202 | 218 |
|
203 | | -element_type1=ARR_ELEMTYPE(v1); |
204 | | -element_type2=ARR_ELEMTYPE(v2); |
205 | | - |
206 | | -/* Check we have matching element types */ |
207 | | -if (element_type1!=element_type2) |
208 | | -ereport(ERROR, |
209 | | -(errcode(ERRCODE_DATATYPE_MISMATCH), |
210 | | -errmsg("cannot concatenate incompatible arrays"), |
211 | | -errdetail("Arrays with element types %s and %s are not " |
212 | | -"compatible for concatenation.", |
213 | | -format_type_be(element_type1), |
214 | | -format_type_be(element_type2)))); |
215 | | - |
216 | | -/* OK, use it */ |
217 | | -element_type=element_type1; |
218 | | - |
219 | 219 | /* get argument array details */ |
220 | 220 | lbs1=ARR_LBOUND(v1); |
221 | 221 | lbs2=ARR_LBOUND(v2); |
|