Bug #63949 [Com]: selects on long varchar fields returns empty with PDO ODBC

2013-01-29 Thread paul dot posts at gmail dot com
Edit report at https://bugs.php.net/bug.php?id=63949&edit=1

 ID: 63949
 Comment by: paul dot posts at gmail dot com
 Reported by:toebs at pubsqrd dot com
 Summary:selects on long varchar fields returns empty with
 PDO ODBC
 Status: Open
 Type:   Bug
 Package:PDO related
 Operating System:   Amazon Linux
 PHP Version:5.4.10
 Block user comment: N
 Private report: N

 New Comment:

Also seeing this using pdo+odbc with MSSQL 2012. varchar(max) and varchar(256) 
columns were both causing heap overflow. Casting the columns to a text column 
resulted in returning the correct data as a workaround.


Previous Comments:

[2013-01-09 08:41:31] toebs at pubsqrd dot com

Typo in the email address.  Correct email is "to...@pubsqrd.com".


[2013-01-09 00:27:02] 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');

 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]: 
<>: 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}






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


Bug #63949 [Com]: selects on long varchar fields returns empty with PDO ODBC

2013-01-29 Thread paul dot posts at gmail dot com
Edit report at https://bugs.php.net/bug.php?id=63949&edit=1

 ID: 63949
 Comment by: paul dot posts at gmail dot com
 Reported by:toebs at pubsqrd dot com
 Summary:selects on long varchar fields returns empty with
 PDO ODBC
 Status: Open
 Type:   Bug
 Package:PDO related
 Operating System:   Amazon Linux
 PHP Version:5.4.10
 Block user comment: N
 Private report: N

 New Comment:

Apologies, our testing showed that cast to text was not a viable workaround.


Previous Comments:

[2013-01-30 00:08:44] paul dot posts at gmail dot com

Also seeing this using pdo+odbc with MSSQL 2012. varchar(max) and varchar(256) 
columns were both causing heap overflow. Casting the columns to a text column 
resulted in returning the correct data as a workaround.


[2013-01-09 08:41:31] toebs at pubsqrd dot com

Typo in the email address.  Correct email is "to...@pubsqrd.com".


[2013-01-09 00:27:02] 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');

 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]: 
<>: 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}






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


Bug #61777 [Com]: Cannot bind parameters with pdo_odbc and SQL Server Native Client 11.0

2013-01-29 Thread paul dot posts at gmail dot com
Edit report at https://bugs.php.net/bug.php?id=61777&edit=1

 ID: 61777
 Comment by: paul dot posts at gmail dot com
 Reported by:frozen at frozen-solid dot net
 Summary:Cannot bind parameters with pdo_odbc and SQL Server
 Native Client 11.0
 Status: Open
 Type:   Bug
 Package:PDO related
 Operating System:   Ubuntu 12.04
 PHP Version:5.3.10
 Block user comment: N
 Private report: N

 New Comment:

Can confirm that patches in bug 50444 correct this issue for me as well.


Previous Comments:

[2012-10-18 17:05:26] kraven at kraven dot org

I believe this is related to the SQLLEN.  PHP bug 5044 has a patch.

MS bug here where developer says its SQLLEN:
http://connect.microsoft.com/SQLServer/feedback/details/737751/cannot-bind-
parameters-with-php-pdo-odbc-and-sql-native-client-11-0

I applied the patches in bug 50444 and now it's working for me.


[2012-05-15 18:59:11] burnhamrobertp at gmail dot com

Debian Squeeze 2.6.32-5-amd64
PHP 5.3.3 (also reproducible under PHP 5.4.0-3)

The test case and error information are exactly the same.


[2012-04-19 18:45:03] frozen at frozen-solid dot net

Description:

When trying to bind parameters to a prepared statement, bindValue() and 
bindParam() both return false with the error code HY004, [SQL Server Native 
Client 
11.0]Invalid SQL data type (SQLBindParameter[0] at /build/buildd/php5-
5.3.10/ext/pdo_odbc/odbc_stmt.c:379)

It does not matter whether you pass in PDO::PARAM_STR or PARAM_INT or no data 
type 
specification, the error is the same every time.

Using parameters with odbc_connect() and odbc_prepare() work as expected, so 
the 
issue is directly related to PDO, not to ODBC or Microsoft's driver.

Test script:
---
$db = new PDO('odbc:sqltest', 'wwwuser', 'btsb');

$strSql = 'select top 10 * from oltmaster where titleno = :no';

$q = $db->prepare($strSql);

var_dump($q->bindValue(':no', '029803'));
var_dump($q->errorInfo());

Expected result:

boolean true

array
  0 => string '' (length=0)
  1 => int 0
  2 => string ' ((null)[0] at (null):0)' (length=24)
  3 => string '' (length=0)

Actual result:
--
boolean false

array
  0 => string 'HY004' (length=5)
  1 => int 0
  2 => string '[Microsoft][SQL Server Native Client 11.0]Invalid SQL data type 
(SQLBindParameter[0] at 
/build/buildd/php5-5.3.10/ext/pdo_odbc/odbc_stmt.c:379)' 
(length=143)
  3 => string 'HY004' (length=5)







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