Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd0a6042

Browse files
committed
Make array_cat more paranoid about checking datatypes in empty arrays.
1 parentbd3bc40 commitd0a6042

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)

[8]ページ先頭

©2009-2025 Movatter.jp