Bug #68156 [NEW]: pg_query_params Sets Booleans to Blank Strings
| From: | nexisentertainment at gmail dot com | Date: | Sun, 05 Oct 2014 07:45:37 +0000 |
| Subject: | Bug #68156 [NEW]: pg_query_params Sets Booleans to Blank Strings | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-187854@lists.php.net to get a copy of this message | ||
From: nexisentertainment at gmail dot com
Operating system: Debian Linux (Jessie)
PHP version: 5.6.1
Package: PostgreSQL related
Bug Type: Bug
Bug description:pg_query_params Sets Booleans to Blank Strings
Description:
------------
pg_query_params somehow converts (boolean)false (as a parameter) to a
blank string before sending it to postgres.
Note, behavior has not been documented, but has been mentioned by a user
comment: http://php.net/manual/en/function.pg-query-params.php#115063
I therefore conclude I am not crazy and imagining things.
May be related to #19575.
Test script:
---------------
<?php
// NOTE: General layout unabashedly stolen from [FILE] of
https://github.com/php/php-src/blob/master/ext/pgsql/tests/bug64609.phpt
$conn_str='user=test password=test host=localhost dbname=test';
error_reporting(E_ALL);
$db = pg_connect($conn_str);
foreach(array(TRUE,FALSE) as $bool) {
echo "Inserting ".($bool?'true':'false');
pg_query("BEGIN");
pg_query("CREATE TABLE test_bool_table (a boolean)");
$values = array($bool);
pg_query_params($db,'INSERT INTO test_bool_table (a) VALUES
($1)',$values);
pg_query("ROLLBACK");
}
Expected result:
----------------
No errors, output of:
Inserting true
Inserting false
Actual result:
--------------
Inserting true
Inserting false
Warning: pg_query_params(): Query failed: ERROR: invalid input syntax
for type boolean: "" in /host/[NOPE]/htdocs/testpgbug.php on line 13
--
Edit bug report at https://bugs.php.net/bug.php?id=68156&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=68156&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=68156&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=68156&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=68156&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=68156&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=68156&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=68156&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=68156&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=68156&r=support
Expected behavior: https://bugs.php.net/fix.php?id=68156&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=68156&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=68156&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=68156&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=68156&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=68156&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=68156&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=68156&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=68156&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=68156&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=68156&r=mysqlcfg