Bug #77118 [NEW]: PDOStatement::fetchColumn() of a non-existing column triggers a warning
From: morozov at tut dot by
Operating system: Linux
PHP version: 7.2.11
Package: PDO OCI
Bug Type: Bug
Bug description:PDOStatement::fetchColumn() of a non-existing column triggers a warning
Description:
------------
When an invalid column number is provided to
PDOStatement::fetchColumn(), MySQL, PostgreSQL and SQLite drivers return
NULL without triggering a warning.
Unlike the above, the Oracle driver triggers a misleading warning:
column %d data was too large for buffer and was truncated to fit it.
Test script:
---------------
$conn = new
PDO('oci:dbname=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SID=XE)))',
'system', 'oracle');
// incorrect column, positional parameter
$stmt = $conn->prepare('SELECT ? FROM DUAL');
$stmt->execute([1]);
$value = $stmt->fetchColumn(1);
var_dump($value);
Expected result:
----------------
NULL
Actual result:
--------------
NULL
Warning: PDOStatement::fetchColumn(): column 1 data was too large for
buffer and was truncated to fit it in test.php on line 20
Call Stack:
0.0001 365728 1. {main}() test.php:0
0.0189 372584 2. PDOStatement->fetchColumn() test.php:20
--
Edit bug report at https://bugs.php.net/bug.php?id=77118&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77118&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77118&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77118&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=77118&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=77118&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=77118&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=77118&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=77118&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=77118&r=support
Expected behavior: https://bugs.php.net/fix.php?id=77118&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=77118&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=77118&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=77118&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77118&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=77118&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=77118&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=77118&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77118&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=77118&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=77118&r=mysqlcfg
Thread (2 messages)
- morozov at tut dot by