Skip to content

Commit 9ca5c75

Browse files
committed
Cause ARRAY[] construct to return a NULL array, rather than raising an
error, if any input element is NULL. This is not what we ultimately want, but until arrays can have NULL elements, it will have to do. Patch from Joe Conway.
1 parent 082df47 commit 9ca5c75

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/backend/executor/execQual.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.136 2003/07/28 00:09:14 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.137 2003/07/30 19:02:18 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1603,6 +1603,10 @@ ExecEvalCase(CaseExprState *caseExpr, ExprContext *econtext,
16031603

16041604
/* ----------------------------------------------------------------
16051605
* ExecEvalArray - ARRAY[] expressions
1606+
*
1607+
* NOTE: currently, if any input value is NULL then we return a NULL array,
1608+
* so the ARRAY[] construct can be considered strict. Eventually this will
1609+
* change; when it does, be sure to fix contain_nonstrict_functions().
16061610
* ----------------------------------------------------------------
16071611
*/
16081612
static Datum
@@ -1642,9 +1646,10 @@ ExecEvalArray(ArrayExprState *astate, ExprContext *econtext,
16421646

16431647
dvalues[i++] = ExecEvalExpr(e, econtext, &eisnull, NULL);
16441648
if (eisnull)
1645-
ereport(ERROR,
1646-
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
1647-
errmsg("arrays cannot have NULL elements")));
1649+
{
1650+
*isNull = true;
1651+
return (Datum) 0;
1652+
}
16481653
}
16491654

16501655
/* setup for 1-D array of the given length */
@@ -1686,9 +1691,10 @@ ExecEvalArray(ArrayExprState *astate, ExprContext *econtext,
16861691

16871692
arraydatum = ExecEvalExpr(e, econtext, &eisnull, NULL);
16881693
if (eisnull)
1689-
ereport(ERROR,
1690-
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
1691-
errmsg("arrays cannot have NULL elements")));
1694+
{
1695+
*isNull = true;
1696+
return (Datum) 0;
1697+
}
16921698

16931699
array = DatumGetArrayTypeP(arraydatum);
16941700

0 commit comments

Comments
 (0)