array expression NULL fix [was: [HACKERS] odd behavior/possible bug]

Поиск
Список
Период
Сортировка
Искать

array expression NULL fix [was: [HACKERS] odd behavior/possible bug]

От:
Joe Conway <mail@joeconway.com>
Дата:
Tom Lane wrote:
> Joe Conway  writes:
>>That probably makes good sense, at least until we can deal with NULL 
>>elements. Would that patch count as a bug fix?
> 
> Either one would count as a bug fix IMHO.  Anyone else have an opinion
> on which to do?

Here's a patch that replaces the ERROR with a NULL return value when an 
element in an array expression is NULL.

Joe
Index: src/backend/executor/execQual.c
===================================================================
RCS file: /opt/src/cvs/pgsql-server/src/backend/executor/execQual.c,v
retrieving revision 1.135
diff -c -r1.135 execQual.c
*** src/backend/executor/execQual.c	21 Jul 2003 17:05:08 -0000	1.135
--- src/backend/executor/execQual.c	24 Jul 2003 22:44:44 -0000
***************
*** 1642,1650 ****
  
  			dvalues[i++] = ExecEvalExpr(e, econtext, &eisnull, NULL);
  			if (eisnull)
! 				ereport(ERROR,
! 						(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
! 						 errmsg("arrays cannot have NULL elements")));
  		}
  
  		/* setup for 1-D array of the given length */
--- 1642,1651 ----
  
  			dvalues[i++] = ExecEvalExpr(e, econtext, &eisnull, NULL);
  			if (eisnull)
! 			{
! 				*isNull = true;
! 				return (Datum) 0;
! 			}
  		}
  
  		/* setup for 1-D array of the given length */
***************
*** 1686,1694 ****
  
  			arraydatum = ExecEvalExpr(e, econtext, &eisnull, NULL);
  			if (eisnull)
! 				ereport(ERROR,
! 						(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
! 						 errmsg("arrays cannot have NULL elements")));
  
  			array = DatumGetArrayTypeP(arraydatum);
  
--- 1687,1696 ----
  
  			arraydatum = ExecEvalExpr(e, econtext, &eisnull, NULL);
  			if (eisnull)
! 			{
! 				*isNull = true;
! 				return (Datum) 0;
! 			}
  
  			array = DatumGetArrayTypeP(arraydatum);
  

Re: array expression NULL fix [was: [HACKERS] odd behavior/possible bug]

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Joe Conway  writes:
> Here's a patch that replaces the ERROR with a NULL return value when an 
> element in an array expression is NULL.

Applied.  I also added a comment to remind us to change
contain_nonstrict_functions() when ARRAY's behavior is changed again.

			regards, tom lane
FAQ