|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74186 Error if sql query has a criteria's length larger than columns' max length
Submitted: 2017-03-01 05:29 UTC Modified: 2022-08-19 16:35 UTC
From: lobo__911 at hotmail dot com Assigned: cmb (profile)
Status: Duplicate Package: PDO ODBC
PHP Version: 7.0.16 OS: ALL
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.
Block user comment
Status: Assign to:
Bug Type:
From: lobo__911 at hotmail dot com
New email:
PHP Version: OS:


 [2017-03-01 05:29 UTC] lobo__911 at hotmail dot com
Please, read this github issue and follow the SO question:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-09-29 10:58 UTC]
-Status: Open +Status: Verified
 [2020-09-29 10:58 UTC]
Test script:

$pdo = new PDO($dsn, $user, $pass);

$pdo->exec("DROP TABLE bug74186");
$pdo->exec("CREATE TABLE bug74186 (col VARCHAR(10))");
$pdo->exec("INSERT INTO bug74186 VALUES ('something')");

$stmt = $pdo->prepare("SELECT * FROM bug74186 WHERE col = ?");
var_dump($stmt->execute([str_repeat("0123456789", 27)]));

Fails with: SQLSTATE[HY010]: Function sequence error.

The problem is that we're binding the parameter[1] with the proper
ColumnSize (aka. precision) of 10[1], but then putting data into
the parameter[2] which exceeds that column size.  The ODBC Driver
for SQL Server (and maybe others as well, but not, for instance,
the MySQL ODBC 8.0 Unicode Driver; according to the ODBC
Specification 3.8 either behavior seems to be conforming) is picky
about that, and SQLPutData() actually fails with [22001] String
data, right truncation; we don't catch that error, but go on
calling SQLParamData() again, what triggers the [HY010] Function
sequence error.

The same issue occurs also if the user prepares respective DML

It is not clear *how* we should solve this.  We could either be
strict about the length of bound parameters and reject these right
away, or we could be more liberal for strict drivers by silently
truncating the parameter values.  The latter would not break BC,
but might be regarded the wrong behavior.

[1] <>
[2] <>
 [2022-08-19 16:35 UTC]
-Status: Verified +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2022-08-19 16:35 UTC]
Closing in favor of <>.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Mar 24 10:03:36 2023 UTC