From:             mascione at sviluppo dot toscana dot it
Operating system: Ubuntu 10.04
PHP version:      5.3.14
Package:          PDO related
Bug Type:         Bug
Bug description:Emulate prepares behave strangely with PARAM_BOOL

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 bug report at https://bugs.php.net/bug.php?id=62593&edit=1
-- 
Try a snapshot (PHP 5.4):            
https://bugs.php.net/fix.php?id=62593&r=trysnapshot54
Try a snapshot (PHP 5.3):            
https://bugs.php.net/fix.php?id=62593&r=trysnapshot53
Try a snapshot (trunk):              
https://bugs.php.net/fix.php?id=62593&r=trysnapshottrunk
Fixed in SVN:                        
https://bugs.php.net/fix.php?id=62593&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=62593&r=needdocs
Fixed in release:                    
https://bugs.php.net/fix.php?id=62593&r=alreadyfixed
Need backtrace:                      
https://bugs.php.net/fix.php?id=62593&r=needtrace
Need Reproduce Script:               
https://bugs.php.net/fix.php?id=62593&r=needscript
Try newer version:                   
https://bugs.php.net/fix.php?id=62593&r=oldversion
Not developer issue:                 
https://bugs.php.net/fix.php?id=62593&r=support
Expected behavior:                   
https://bugs.php.net/fix.php?id=62593&r=notwrong
Not enough info:                     
https://bugs.php.net/fix.php?id=62593&r=notenoughinfo
Submitted twice:                     
https://bugs.php.net/fix.php?id=62593&r=submittedtwice
register_globals:                    
https://bugs.php.net/fix.php?id=62593&r=globals
PHP 4 support discontinued:          
https://bugs.php.net/fix.php?id=62593&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=62593&r=dst
IIS Stability:                       
https://bugs.php.net/fix.php?id=62593&r=isapi
Install GNU Sed:                     
https://bugs.php.net/fix.php?id=62593&r=gnused
Floating point limitations:          
https://bugs.php.net/fix.php?id=62593&r=float
No Zend Extensions:                  
https://bugs.php.net/fix.php?id=62593&r=nozend
MySQL Configuration Error:           
https://bugs.php.net/fix.php?id=62593&r=mysqlcfg

Reply via email to