|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-01-09 00:27 UTC] toebs at pubsqrd dot com
Description:
------------
In short, it looks like selects on varchars columns which are long (some indeterminate value, 1000 certainly qualifies) fail with PDO via ODBC.
The same query works with the following methods;
1. PDO using mysql
2. unixODBC directly (via isql)
3. vsql (the Vertica native command line client)
4. PHP ODBC
The error given is that column binding has not occurred. This is odd - note in the script I have deliberately used fetchColumn() to avoid the need for column binding, in an effort to avoid this error.
This problem was found in 5.3.19 and also in 5.4.9.
Test script:
---------------
create table tobytest
(
string_short varchar(50),
string_long varchar(1000)
);
insert into tobytest (string_short, string_long) values ('short', 'long');
<?php
$db_connect = new PDO( "odbc:pubsquared", "dbadmin", "big science" );
$db_connect -> setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$q = $db_connect->prepare( "select string_long from tobytest" );
$q->execute();
$r = $q->fetchColumn();
print $r;
?>
Expected result:
----------------
[root@ip-1-1-1-1 ~]# php test4.php
long
[root@ip-1-1-1-1 ~]#
Actual result:
--------------
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[SL010]: <<Unknown error>>: 0 [unixODBC][Driver Manager]SQLBindCol returned SQL_ERROR on a attempt to bind a internal buffer (SQLFetchScroll[0] at /builddir/build/BUILD/php-5.4.9/ext/pdo_odbc/odbc_stmt.c:537)' in /root/test4.php:8
Stack trace:
#0 /root/test4.php(8): PDOStatement->fetchColumn()
#1 {main}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 22 06:00:01 2025 UTC |
This problem in my case does not raise any exception but simply return null on some "large" columns Environment: -------------- php -v PHP 8.0.0 (cli) (built: Nov 24 2020 17:04:03) ( NTS gcc x86_64 ) Copyright (c) The PHP Group Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies with Zend OPcache v8.0.0, Copyright (c), by Zend Technologies build with pdo_odbc: --with-pdo-odbc=unixODBC,/usr database: Vertica Analytic Database v9.2.0-3 Reproduce code: --------------- create table bug_63949 ( A varchar(80) NOT NULL, B tinyint NOT NULL, C varchar(100) NOT NULL, D smallint NOT NULL, E varchar(1024) NOT NULL, F varchar(255) NOT NULL, G varchar(255) NOT NULL, H varchar(1000) NOT NULL, I varchar(100) NOT NULL, J tinyint NOT NULL, K varchar(255) NULL ); insert into bug_63949 values ('A', '1', 'C', '2', 'E', 'F', 'G', 'H', 'I', '3', 'K'); ////////////////////////////////////////////////////////////// <?php // https://bugs.php.net/bug.php?id=63949 // https://stackoverflow.com/q/48685059/6266737 // https://stackoverflow.com/q/42301688/6266737 $sql = "select * from bug_63949;"; $ch = new PDO("odbc:VerticaDSNunixodbc"); $stmt = $ch->prepare($sql); $stmt->execute(); $res = $stmt->fetch(PDO::FETCH_ASSOC); var_dump($res); ////////////////////////////////////////////////////////////// Expected result: ---------------- array(11) { ["A"]=> string(1) "A" ["B"]=> string(1) "1" ["C"]=> string(1) "C" ["D"]=> string(1) "2" ["E"]=> string(1) "E" ["F"]=> string(1) "F" ["G"]=> string(1) "G" ["H"]=> string(1) "H" ["I"]=> string(1) "I" ["J"]=> string(1) "3" ["K"]=> string(1) "K" } Actual result: -------------- array(11) { ["A"]=> string(1) "A" ["B"]=> string(1) "1" ["C"]=> string(1) "C" ["D"]=> string(1) "2" ["E"]=> NULL ["F"]=> NULL ["G"]=> NULL ["H"]=> NULL ["I"]=> NULL ["J"]=> NULL ["K"]=> NULL } My temporary solution: ---------------------- https://stackoverflow.com/a/57820264/6266737