ID: 34607 Comment by: cjbj at hotmail dot com Reported By: robcolbert at yahoo dot com Status: Open Bug Type: OCI8 related Operating System: Fedora Core 4 PHP Version: 5.0.5 New Comment:
I was just about to log a similar bug. Here is my testcase: <?php /* With new oci8 driver output is Notice: Undefined variable: undef2 in testcase.php on line 35 Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate -153092209 bytes) in testcase.php on line 37 With old oci8 extension, output is Notice: Undefined variable: undef2 in testcase.php on line 35 array(1) { ["DUMMY"]=> array(0) { } } */ define('ORA_CON_UN', 'hr'); define('ORA_CON_PW', 'hr'); define('ORA_CON_DB', '//localhost/orcl'); $statement = "select * from dual where dummy = :mybv"; $conn = oci_connect(ORA_CON_UN, ORA_CON_PW, ORA_CON_DB); $stid = oci_parse($conn, $statement); $r = oci_bind_by_name($stid, ":mybv", $undef, $undef2); $r = oci_execute($stid, OCI_DEFAULT); $r = oci_fetch_all($stid, $results); echo "<pre>"; var_dump($results); echo "</pre>"; ?> Previous Comments: ------------------------------------------------------------------------ [2005-09-23 05:44:12] robcolbert at yahoo dot com Description: ------------ It is not possible to use oci_bind_by_name to assign a NULL value to a placeholder. The OCI will attempt to allocate a very large (negative) amount of memory and cause the script to exit due to memory depletion. I'm not sure if this is a bug or intended behavior, but it was frustrating to figure out, and limits the programmer's ability to use a truly generic statement for all cases. I have found myself having to code constructs such as: if( $SomeVarB == NULL ) { $SQL = "INSERT INTO table (a, b) VALUES (:a, NULL)"; $stid = $oci_parse($conn, $SQL); oci_bind_by_name($stid, ":a", $SomeVarA); } else { $SQL = "INSERT INTO table (a, b) VALUES (:a, :b)"; $stid = $oci_parse($conn, $SQL); oci_bind_by_name($stid, ":a", $SomeVarA); oci_bind_by_name($stid, ":b", $SomeVarB); } This is bloating scripts unnecessarily, and I expect that other programmers are experiencing similar results. It would be better if NULL could be specified as the input variable value to mean that the OCI should use NULL for the given placeholder's value such as: $SomeVarB = NULL; oci_bind_by_name($stid, ":b", $SomeVarB); Reproduce code: --------------- $SomeVarB = NULL; oci_bind_by_name($stid, ":placeholder", $SomeVarB); Expected result: ---------------- The OCI should use the NULL SQL value supplied as the value of the $variable input parameter. The OCI should attempt to allocate an enormous amount of memory and cause the script to terminate. If NULL cannot be handled as an input $variable value, then it is expected for the API to return an error code and allow the application to handle the error rather than causing an abortive condition (script termination) to occur. Actual result: -------------- PHP Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate -153092209 bytes). ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=34607&edit=1