Bug #52746 [Fbk->NoF]: PDO SQLite error "bind or column index out of range" with some placeholders
| From: | php-bugs at lists dot php dot net | Date: | Sun, 08 Mar 2020 04:22:04 +0000 |
| Subject: | Bug #52746 [Fbk->NoF]: PDO SQLite error "bind or column index out of range" with some placeholders | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-225945@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=52746&edit=1
ID: 52746
Updated by: php-bugs@lists.php.net
Reported by: damien at tournoud dot net
Summary: PDO SQLite error "bind or column index out of range"
with some placeholders
-Status: Feedback
+Status: No Feedback
Type: Bug
Package: PDO SQLite
PHP Version: 5.3.3
Assigned To: cmb
Private report: N
New Comment:
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
Previous Comments:
------------------------------------------------------------------------
[2020-02-24 07:48:38] cmb@php.net
I cannot reproduce this with current PHP 7.3 (Windows, bundled
libsqlite); can anybody else reproduce this with any of actively
supported PHP versions[1]?
[1] <https://www.php.net/supported-versions.php>
------------------------------------------------------------------------
[2010-08-31 11:33:16] damien at tournoud dot net
This seems to work properly with unnamed placeholders.
For named placeholders, it seems to only fail when the placeholder is part of a branch of the query
that is deadcode, and could potentially be removed by the optimizer:
FAILS: SELECT SUM(1) expression FROM (SELECT :value value FROM sqlite_master) my_table
PASS: SELECT SUM(value) expression FROM (SELECT :value value FROM sqlite_master) my_table
------------------------------------------------------------------------
[2010-08-31 11:15:22] damien at tournoud dot net
That's on Debian, so it is using the system library. I'm able to reproduce that behavior
on a wide range of PHP and SQLite versions:
PHP 5.2.6-1+lenny9 -- SQLite 3.5.9 (external)
PHP 5.3.2-0.dotdeb.2 -- SQLite 3.6.21 (external)
PHP trunk -- SQLite 3.7.0.1 (bundled)
------------------------------------------------------------------------
[2010-08-31 10:46:49] pajoye@php.net
hi Damien,
Do you use the bundled sqlite or a system version? If the latter, which version is it?
------------------------------------------------------------------------
[2010-08-30 20:20:28] damien at tournoud dot net
Description:
------------
The following snippet results in a PDOException with message "SQLSTATE[HY000]: General error:
25 bind or column index out of range".
For some reasons, relatively similar queries work (for example, without the aggregation, as in:
"SELECT * FROM (SELECT :value value FROM sqlite_master) my_table" or without the table as
in "SELECT COUNT(*) expression FROM (SELECT :value value) my_table").
Test script:
---------------
<?php
$db = new PDO('sqlite:/tmp/sqlite.db');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$query = $db->prepare('SELECT COUNT(*) expression FROM (SELECT :value value FROM
sqlite_master) my_table');
$query->execute(array(':value' => 'my_value'));
?>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=52746&edit=1