ID:               27281
 User updated by:  russell dot brown at insignia dot com
 Reported By:      russell dot brown at insignia dot com
 Status:           Bogus
 Bug Type:         ODBC related
 Operating System: Windows 2000
 PHP Version:      4.3.4
 New Comment:

I've tried adding the lines below to the top of the code, trying
PASSTHROUGH, CONVERT and RETURN, but they appear to have no effect
whatsoever, even in CLI mode:

ini_set("odbc.defaultlrl", "200000");

ini_set("odbc.defaultbinmode", ODBC_BINMODE_PASSTHROUGH);



These ini settings definitely have an effect if you are downloading the
data from ODBC->PHP, but not PHP->ODBC.


Previous Comments:
------------------------------------------------------------------------

[2004-02-16 12:48:35] [EMAIL PROTECTED]

Please read this manual page:



http://www.php.net/manual/en/ref.odbc.php



Especially the part about the couple of php.ini options there are for
ODBC extension. (and read the user comments on
http://www.php.net/odbc_execute for more info)





------------------------------------------------------------------------

[2004-02-16 12:18:57] russell dot brown at insignia dot com

Description:
------------
If you use the quoted filename feature of odbc_execute() to load a
binary file into a blob field using the ODBC driver, it appears to use
text mode to open the file, and hence it truncates the data at the
first 0x1A sequence. 



If I use the command-line this appears to work perfectly, but via the
SAPI Apache2 dll it performs the truncation. It does not seem to be due
to it running as a different user, I've tried the tests logged in as
the user on the command-line and the results are the same.



It also doesn't seem to be possible to work around, because of another
problem where if you open the file yourself in binary mode and try to
send the data as a parameter to odbc_execute(), it will only upload
~4000 bytes. However, it does this on the command-line as well, so it
is more generally broken (I'll raise a separate bug request if you want
about this - I have some SQL logs which might be helpful).



The code example provided will perform both methods of upload (set
$method=1 for quoted filename, $method!=1 for uploading from memory
buffer), to make it easy to compare and contrast the differences. You
*must* upload a binary file more than 4096 bytes in size, and it must
contain at least 1 EOF somewhere in the first 4000 bytes to reproduce
the problem exactly. I'm talking to an Oracle 8.1.7 rdbms on a Solaris
box. I'm using an Oracle 8.1.7 client and corresponding ODBC driver
version.



Please also note that I have not been able to test this against any
other database, ODBC driver, or against the apache 1.x SAPI dll. My
reason for using ODBC rather than the Oracle8 libraries (and the
generic Oracle lib doesn't handle blob fields) is because I'm about to
move to using Oracle9 for which there are no php libraries available
yet.

Reproduce code:
---------------
$binfile = "d:/blobs/testfile2.bin";

$blobid = 1000;

$method = 1;

if ($method == 1) {

        $parms = array("'".$binfile."'");

        $size_before = filesize($binfile);

} else {

        $buffer = "";

        $fh = fopen($binfile, "rb");

        while (!feof($fh)) { $buffer .= fgets($fh, 10240);}

        $parms = array($buffer);

        $size_before = strlen($buffer);

}

$conn = odbc_connect("xxxx", "xxxx", "xxxx");

//$res = odbc_prepare($conn, "INSERT INTO SSP_BLOB (BLOB_ID, BITS)
VALUES ('$blobid', ?)");

$res = odbc_prepare($conn, "UPDATE SSP_BLOB SET BITS=? WHERE
BLOB_ID='$blobid'");

if (!odbc_execute($res, $parms)) { print "Execute failed:
".odbc_errormsg()."\n";}

$res = odbc_exec($conn, "SELECT DBMS_LOB.GETLENGTH(bits) FROM SSP_BLOB
WHERE BLOB_ID='$blobid'");

if (odbc_fetch_row($res)) {

        $size_after = odbc_result($res, 1);

        print "Size before: $size_before\nSize after: $size_after\n";

}

Expected result:
----------------
In an example uploading a 44,194 byte file, with the first EOF at the
182nd byte, in all cases one would expect output of:



Size before: 44194

Size after: 44194

Actual result:
--------------
Using same upload file as described in expected result:



Method 1 via CLI:

Size before: 44194

Size after: 44194



Method 1 via SAPI:

Size before: 44194 Size after: 182



Method !1 via CLI:

Size before: 44194

Size after: 4000



Method !1 via SAPI:

Size before: 44194 Size after: 4000


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=27281&edit=1

Reply via email to