Skip to content

Commit d0a6042

Browse files
committed
Make array_cat more paranoid about checking datatypes in empty arrays.
1 parent bd3bc40 commit d0a6042

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/backend/utils/adt/array_userfuncs.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright (c) 2003, PostgreSQL Global Development Group
77
*
88
* 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 $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -165,6 +165,22 @@ array_cat(PG_FUNCTION_ARGS)
165165
v1 = PG_GETARG_ARRAYTYPE_P(0);
166166
v2 = PG_GETARG_ARRAYTYPE_P(1);
167167

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+
168184
/*----------
169185
* We must have one of the following combinations of inputs:
170186
* 1) one empty array, and one non-empty array
@@ -200,22 +216,6 @@ array_cat(PG_FUNCTION_ARGS)
200216
"compatible for concatenation.",
201217
ndims1, ndims2)));
202218

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-
219219
/* get argument array details */
220220
lbs1 = ARR_LBOUND(v1);
221221
lbs2 = ARR_LBOUND(v2);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy