Bug #80790 [NEW]: PDO ODBC cannot insert BLOB records to Oracle database

From: Date: Tue, 23 Feb 2021 11:48:18 +0000
Subject: Bug #80790 [NEW]: PDO ODBC cannot insert BLOB records to Oracle database
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-232345@lists.php.net to get a copy of this message
From: horvath dot szabolcs at t-systems dot hu Operating system: Red Hat Enterprise Linux Server PHP version: 7.3.27 Package: PDO ODBC Bug Type: Bug Bug description:PDO ODBC cannot insert BLOB records to Oracle database Description: ------------ Hi, We're using PHP 7.3.20 from Red Hat Software Collections. Although 7.3.27 is out there, I read thoroughly the changelog and haven't found similar bug between 7.3.20 and 7.3.27. There is a BLOB column in the database (Oracle 19c) which can be inserted with php-odbc and can't with php-pdo. We have a test case (see next chapter). The Oracle ODBC trace outputs for both PDO and ODBC version have been attached. Testfile: dd if=/dev/urandom of=testfile.txt bs={desired_size} count=1 We try to upload blob content the way as outlined in the manual (https://www.php.net/manual/en/pdo.lobs.php - Example #3 Inserting an image into a database: Oracle) There are at least two different problems: 1) php-pdo blob inserts silenty fails when the blob content is smaller than 3997 bytes. The manual says "It's also essential that you perform the insert under a transaction, otherwise your newly inserted LOB will be committed with a zero-length as part of the implicit commit that happens when the query is executed" ....okay, but we inserted under a transaction. What are we missing here? 2) php-pdo blob inserts fails with "[[Oracle][ODBC][Ora]ORA-01461: can bind a LONG value only for insert into a LONG column" error messages when the blob content is greater (or equal) than 3997 bytes. Test script: --------------- -- ODBC test script: -- $conn = odbc_connect("ORACLETEST", "eberjegyzek", "secret"); $imageBlob = file_get_contents("testfile.txt"); $query = "INSERT INTO HSZ (ID, PDF) VALUES (SEQ_HSZ.NEXTVAL, ?)"; $stmt = odbc_prepare($conn, $query); odbc_execute($stmt, [$imageBlob]) or die('Error, query failed'); -- PDO test script: -- $db = new \PDO("odbc:ORACLETEST", "eberjegyzek", "secret"); $stmt = $db->prepare("INSERT INTO HSZ(ID, PDF) VALUES(SEQ_HSZ.NEXTVAL, EMPTY_BLOB()) RETURNING PDF INTO ?"); $imageBlob = file_get_contents("testfile.txt"); $stmt->bindParam(1, $imageBlob, PDO::PARAM_LOB); $db->beginTransaction(); $stmt->execute(); $db->commit(); Test cases: SQL> select id, length(pdf), dbms_lob.getlength(pdf) FROM hsz order by ID; +---------+--------------+-------------------------+ | ID | LENGTH(PDF) | DBMS_LOB.GETLENGTH(PDF) | +------------------------+-------------------------+ | 376693 | 100 | 100 | Test case #1 php-odbc with 100 bytes of input (OK) | 376694 | 10000 | 10000 | Test case #2 php-odbc with 10000 bytes of input (OK) | 376695 | 0 | 0 | Test case #3 php-pdo with 100 bytes of input (not OK, there is no data in the PDF column) | 376696 | 0 | 0 | Test case #4 php-pdo with 3996 bytes of input (not OK, there is no data in the PDF columns) Test case #5 php-pdo with 3997 bytes of input (completely missing from the table, ORA-01461: can bind a LONG value only for insert into a LONG column) +---------+--------------+-------------------------+ Expected result: ---------------- see above (Test cases) Actual result: -------------- see above (Test cases) -- Edit bug report at https://bugs.php.net/bug.php?id=80790&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=80790&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=80790&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=80790&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=80790&r=needscript Try newer version: https://bugs.php.net/fix.php?id=80790&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=80790&r=support Expected behavior: https://bugs.php.net/fix.php?id=80790&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=80790&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=80790&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=80790&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=80790&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=80790&r=dst IIS Stability: https://bugs.php.net/fix.php?id=80790&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=80790&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=80790&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=80790&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=80790&r=mysqlcfg

« previous php.bugs (#232345) next »