Bug 1931825

Summary: PDO ODBC truncates BLOB records at every 256th byte
Product: Red Hat Software Collections Reporter: asah
Component: phpAssignee: Remi Collet <rcollet>
Status: CLOSED CURRENTRELEASE QA Contact: rhel-cs-infra-services-qe <rhel-cs-infra-services-qe>
Severity: high Docs Contact:
Priority: unspecified    
Version: rh-php73CC: bmikulov, dmasirka, icesalov, jfindysz, jorton
Target Milestone: alphaKeywords: Triaged, ZStream
Target Release: 3.7Flags: pm-rhel: mirror+
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1977764 (view as bug list) Environment:
Last Closed: 2021-08-20 13:16:51 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1977764    

Description asah 2021-02-23 10:47:31 UTC
Description of problem:
PDO ODBC truncates BLOB records at every 256th byte


Test script:
---------------
1. ODBC version:
$conn = odbc_connect("ORACLETEST", "user", "password");
$query = "SELECT pdf FROM PAYROLL WHERE USER_ID = 999 AND ROWNUM = 1 ORDER BY YEAR DESC, MONTH DESC";
if(!$conn) die("Connection failed");
if($result = odbc_exec($conn, $query))
{
    odbc_longreadlen($result, 131072);
    while(odbc_fetch_row($result)){
        print strlen(odbc_result($result,1));
    }
}

2. PDO ODBC version:
$pdo = new PDO("odbc:ORACLETEST", "user",  "password" );
$stmt = $pdo->prepare('SELECT pdf FROM PAYROLL WHERE USER_ID = 999 AND ROWNUM = 1 ORDER BY YEAR DESC, MONTH DESC');
$stmt->bindColumn(1, $data, PDO::PARAM_LOB);
$stmt->execute();
$stmt->fetch(PDO::FETCH_BOUND);
print strlen($data);

Upstream Fix:
https://github.com/php/php-src/pull/6716
https://bugs.php.net/bug.php?id=80783

Version-Release number of selected component (if applicable):
rh-php73-php-odbc-7.3.20-1.el7.x86_64
rh-php73-php-pdo-7.3.20-1.el7.x86_64



Expected result:
----------------
The actual data in the database is 25744 bytes long.


Actual result:
--------------
ODBC version returns with the length of 25744, and that's fine.

PDO ODBC version returns with the length of 25644 byte, which is 100 bytes smaller than expected.

Comment 4 Remi Collet 2021-04-08 07:25:06 UTC
Upstream fix (with tests)
https://github.com/php/php-src/commit/bccca0b53aa60a62e2988c750fc73c02d109e642

This will be in 7.4.18 and 8.0.5 planned for May (7.4.17 and 8.0.4 which have been delayed won't have it)

Comment 5 Remi Collet 2021-04-08 09:10:48 UTC
Looks like this extension have terrible side effects related to various drivers and different implementation

At least, I think we should wait for upstream feedback on
https://github.com/php/php-src/pull/6842

Comment 13 Joe Orton 2021-08-20 13:17:11 UTC
This issue was resolved via RHSCL errata https://access.redhat.com/errata/RHSA-2021:2992