php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40289 pdo_odbc Extention throws HY090 with doing binary sqlbindcol
Submitted: 2007-01-30 16:03 UTC Modified: 2009-05-03 01:00 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: podunk dot vn at gmail dot com Assigned: wez (profile)
Status: No Feedback Package: PDO related
PHP Version: 5.2.0 OS: windows xp sp2/IIS/ASAPI
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: podunk dot vn at gmail dot com
New email:
PHP Version: OS:

 

 [2007-01-30 16:03 UTC] podunk dot vn at gmail dot com
Description:
------------
When selecting a varbinary(MAX) field from a microsoft sql 2005 database, using the Microsoft ODBC Driver Manager for SQL, and binding the result to a PHP variable, the Driver Manager fails with the following error:

array (
  0 => 'HY090',
  1 => 0,
  2 => '[Microsoft][ODBC Driver Manager] Invalid string or buffer length (SQLBindCol[0] at ext\\pdo_odbc\\odbc_stmt.c:430)',
  3 => 'HY090',
)

More information on HY090 can be found at: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlbindcol.asp

Just a guess: the BufferLength isn't being set in odbc_stmt.c somewhere.

Reproduce code:
---------------
$stmt = $db->prepare("select data from cms_files where fid=11");
$db->execute($stmt);
$db->bindColumn($stmt, 1, $lob, PDO::PARAM_LOB);
$db->fetch_bound($stmt);

Expected result:
----------------
$lob populated with binary data.

Actual result:
--------------
Driver Manager throws:

array (
  0 => 'HY090',
  1 => 0,
  2 => '[Microsoft][ODBC Driver Manager] Invalid string or buffer length (SQLBindCol[0] at ext\\pdo_odbc\\odbc_stmt.c:430)',
  3 => 'HY090',
)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-01-30 16:14 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip


 [2007-01-30 17:16 UTC] podunk dot vn at gmail dot com
I got around this by changing the field type from VARBINARY(MAX) to VARCHAR(MAX) in MSSQL 2005.  It would still be nice to use the new VARBINARY(MAX) field type.

I'm downloading the latest win32 snapshot now to see if this bug is fixed in it.
 [2007-01-30 18:01 UTC] podunk dot vn at gmail dot com
The latest win32 snapshot DOES NOT fix this bug.
 [2007-01-30 18:03 UTC] tony2001@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.


 [2007-01-30 18:39 UTC] podunk dot vn at gmail dot com
<?php
$sql = "
USE [websvr]
GO
/****** Object:  Table [dbo].[cms_files]    Script Date: 01/30/2007 13:25:58 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[cms_files](
	[fid] [int] IDENTITY(1,1) NOT NULL,
	[data] [varbinary](max) NULL,
	[content_type] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[name] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[label] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[pagid] [int] NOT NULL,
 CONSTRAINT [PK_files] PRIMARY KEY CLUSTERED 
(
	[fid] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
";
$db = new PDO('odbc:DSN=******;HOSTNAME=*********;PORT=****;DBNAME=******;PROTOCOL=TCPIP;UID=********;PWD=********;');
$db->query($sql);
$db->query("SET IDENTITY_INSERT cms_files ON");
$stmt = $db->prepare("insert into cms_files (data,content_type,name,label,pagid,fid) values (?, ?, ?, ?, ?, ?)");
$fp = fopen($_FILES['file']['tmp_name'], 'rb');
$stmt->bindParam(1, $fp, PDO::PARAM_LOB);
$stmt->bindParam(2, $_FILES['file']['type']);
$stmt->bindParam(3, $_FILES['file']['name']);
$stmt->bindParam(4, 'test');
$stmt->bindParam(5, 1);
$stmt->bindParam(6, 1);
$stmt->execute();

$stmt = $db->prepare("select content_type,data from cms_files where fid=1");
$stmt->execute();
$stmt->bindColumn(1, $type, PDO::PARAM_STR, 256);
$stmt->bindColumn(2, $lob, PDO::PARAM_LOB);
$stmt->fetch(PDO::FETCH_BOUND);
header("Content-Type: $type");
fpassthru($lob);
print($lob);
?>
 [2007-03-28 12:44 UTC] wez@php.net
Are you using the "SQL Native Client" driver, or the old "SQL Server" driver?
 [2007-03-28 13:33 UTC] podunk dot vn at gmail dot com
SQL Server
 [2009-04-25 14:42 UTC] jani@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2009-05-03 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 29 17:01:29 2024 UTC