From 23fea6461dba016a44caa913632eca907991ac0b Mon Sep 17 00:00:00 2001 From: Andy Sautins Date: Tue, 11 Sep 2001 21:03:58 +0000 Subject: [PATCH] Handle assign/append of NULL values to collections correctly. Now works consistently with how the rest of the library operates. If the value passed in is a null string, the value is set to null --- ext/oci8/oci8.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c index 9eee4eba68..747a02625b 100644 --- a/ext/oci8/oci8.c +++ b/ext/oci8/oci8.c @@ -4458,6 +4458,7 @@ PHP_FUNCTION(ocicollappend) OCINumber num; OCIString *ocistr = (OCIString *)0; OCIInd new_ind = OCI_IND_NOTNULL; + OCIInd null_ind = OCI_IND_NULL; OCIDate dt; int inx; double ndx; @@ -4472,6 +4473,26 @@ PHP_FUNCTION(ocicollappend) WRONG_PARAM_COUNT; } + /* + * Handle NULLS. For consistency with the rest of the OCI8 library, when + * a value passed in is a 0 length string, consider it a null + */ + convert_to_string_ex(arg); + if((*arg)->value.str.len == 0) { + CALL_OCI_RETURN(connection->error, OCICollAppend( + OCI(pEnv), + connection->pError, + (dword *)0, + &null_ind, + coll->coll)); + if (connection->error) { + oci_error(connection->pError, "OCICollAppend - NULL", connection->error); + RETURN_FALSE; + } + + RETURN_TRUE; + } + switch(coll->element_typecode) { case OCI_TYPECODE_DATE: convert_to_string_ex(arg); @@ -4719,6 +4740,7 @@ PHP_FUNCTION(ocicollassignelem) oci_collection *coll; OCINumber num; OCIInd new_ind = OCI_IND_NOTNULL; + OCIInd null_ind = OCI_IND_NULL; ub4 ndx; int inx; OCIString *ocistr = (OCIString *)0; @@ -4743,6 +4765,29 @@ PHP_FUNCTION(ocicollassignelem) oci_error(connection->pError, "OCICollAssignElem", connection->error); RETURN_FALSE; } + + /* + * Handle NULLS. For consistency with the rest of the OCI8 library, when + * a value passed in is a 0 length string, consider it a null + */ + convert_to_string_ex(val); + + if((*val)->value.str.len == 0) { + CALL_OCI_RETURN(connection->error, OCICollAssignElem( + OCI(pEnv), + connection->pError, + ndx, + (dword *)0, + &null_ind, + coll->coll)); + if (connection->error) { + oci_error(connection->pError, "OCICollAssignElem - NULL", connection->error); + RETURN_FALSE; + } + + RETURN_TRUE; + } + switch(coll->element_typecode) { case OCI_TYPECODE_DATE: convert_to_string_ex(val); -- 2.50.1