Bug #62593 [Ver]: Emulate prepares behave strangely with PARAM_BOOL
| From: | willfitch@php.net | Date: | Thu, 20 Sep 2012 16:36:17 +0000 |
| Subject: | Bug #62593 [Ver]: Emulate prepares behave strangely with PARAM_BOOL | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-173590@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=62593&edit=1
ID: 62593
Updated by: willfitch@php.net
Reported by: mascione at sviluppo dot toscana dot it
Summary: Emulate prepares behave strangely with PARAM_BOOL
Status: Verified
Type: Bug
Package: PDO related
Operating System: Ubuntu 10.04
PHP Version: 5.3.14
Assigned To: willfitch
Block user comment: N
Private report: N
New Comment:
Pull request for this fix:
https://github.com/php/php-src/pull/198
Previous Comments:
------------------------------------------------------------------------
[2012-09-18 10:04:19] v dot picture at free dot fr
Same problem with the stock version on Ubuntu 12.04: PHP 5.3.10-1ubuntu3.4
(built: Sep 12 2012)
I hope this problem will be solved soon.
------------------------------------------------------------------------
[2012-09-17 16:17:24] willfitch@php.net
I have confirmed this. The issue with disabling emulation prepares for this
purpose is that it sends the query through PQprepare, then PQexec. If you're
using middleware such as pgbouncer, this won't work.
------------------------------------------------------------------------
[2012-07-19 06:15:02] ploginoff at gmail dot com
Yes! _Yesterday_ I have * with the same bug. Solution: install 5.3.13 or disable emulate prepares
(but it is sometimes necessary).
------------------------------------------------------------------------
[2012-07-18 10:04:51] mascione at sviluppo dot toscana dot it
Description:
------------
On postgresql when I use ATTR_EMULATE_PREPARES binding params or values with PARAM_BOOL behave
strangely.
Disabling ATTR_EMULATE_PREPARES resolve the problem.
(driver specific PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT generates same problem)
(Related to bug #38386 ?)
Test script:
---------------
$db = new PDO('pgsql:dbname=testdb;user=postgres');
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
//$db->setAttribute(PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT, true);
//CREATE TABLE t(a boolean, b boolean)
$stmt = $db->prepare("INSERT INTO t(a,b) VALUES (true,false)");
$stmt->execute();
print_r($stmt->errorInfo());
$stmt = $db->prepare("INSERT INTO t(a,b) VALUES (:test,:test)");
$stmt->bindValue('test', false, PDO::PARAM_BOOL);
$stmt->execute();
print_r($stmt->errorInfo());
$stmt = $db->prepare("SELECT * FROM t WHERE :test");
$stmt->bindValue('test', true, PDO::PARAM_BOOL);
$stmt->execute();
print_r($stmt->errorInfo());
print_r($stmt->fetchAll());
Expected result:
----------------
Works without errors.
Actual result:
--------------
Array
(
[0] => 00000
[1] =>
[2] =>
)
Array
(
[0] => 42804
[1] => 7
[2] => ERROR: column "a" is of type boolean but expression is of type integer
LINE 1: INSERT INTO t(a,b) VALUES (0,'0')
^
HINT: You will need to rewrite or cast the expression.
)
Array
(
[0] => 42804
[1] => 7
[2] => ERROR: argument of WHERE must be type boolean, not type integer
LINE 1: SELECT * FROM t WHERE 1
^
)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=62593&edit=1