[php-src] Issue #9372: ODBC HY010 when binding parameter that is larger than the column definition
| From: | jfowler8708 | Date: | Thu, 18 Aug 2022 19:26:09 +0000 |
| Subject: | [php-src] Issue #9372: ODBC HY010 when binding parameter that is larger than the column definition | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-242247@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/9372
Author: jfowler8708
### Description
The following code:
```php
<?php
$connection = new \PDO("odbc:DRIVER={ODBC Driver 17 for SQL Server};host=<host>",
"<username>", "<password>");
$query = "select itm_code from item where itm_number = :itemNumber";
$parameters = [":itemNumber" => "123456"]; // itm_number column defined as
varchar(5) parameter is char(6)
$prepared = $connection->prepare($query);
$results = $prepared->execute($parameters);
?>
```
Resulted in this output:
```
SQLSTATE[HY010]: Function sequence error: [unixODBC][Driver Manager]Function sequence error
(SQLExecute[0] at /build/php8.1-8.1.9/ext/pdo_odbc/odbc_stmt.c:254)
```
The error only happens when the bound parameter is larger than the column as defined. Does not
happen when using literals within the query string. I would expect to just receive 0 results not an
error.
### PHP Version
PHP 8.1.9
### Operating System
Debain 10.11