From:             robcolbert at yahoo dot com
Operating system: Fedora Core 4
PHP version:      5.0.5
PHP Bug Type:     OCI8 related
Bug description:  oci_bind_by_name fails when $variable has NULL value

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 bug report at http://bugs.php.net/?id=34607&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=34607&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=34607&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=34607&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=34607&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=34607&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=34607&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=34607&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=34607&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=34607&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=34607&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=34607&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=34607&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=34607&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=34607&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=34607&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=34607&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=34607&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=34607&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=34607&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=34607&r=mysqlcfg

Reply via email to