Variables with null values change to empty string after pg_query_params

Bug #36606 Variables with null values change to empty string after pg_query_params
Submitted: 2006-03-03 15:44 UTC Modified: 2006-03-05 14:35 UTC
From: everton at faccat dot br Assigned: helly (profile)
Status: Closed Package: PostgreSQL related
PHP Version: 5.1.2 OS: Linux Slackware 9.1
Private report: No CVE-ID: None

 [2006-03-03 15:44 UTC] everton at faccat dot br

Description:
------------
Variables with null values change to an empty string after pg_query_params. This is not reported in pg_query_params manual.

Reproduce code:
---------------
$a = pg_connect("dbname=saga3");
$b = null;
var_dump($b); 
pg_query_params($a, "SELECT * FROM pais WHERE idpais = $1", array($b));
var_dump($b); 
die;


Expected result:
----------------
NULL
NULL

Actual result:
--------------
NULL
string(0) ""

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports

 [2006-03-03 21:43 UTC] everton at faccat dot br

category updated

 [2006-03-05 14:02 UTC] tony2001@php.net

Marcus, please take a look at it.
From what I can see, there is no sense in converting params to string as long as we don't support OUT parameters (?).

So this extremely short patch fixes it:

@@ -1257,7 +1257,7 @@ PHP_FUNCTION(pg_query_params)
                        }

                        otype = (*tmp)->type;
-                       convert_to_string(*tmp);
+                       convert_to_string_ex(tmp);
                        if (Z_TYPE_PP(tmp) != IS_STRING) {
                                php_error_docref(NULL TSRMLS_CC, E_WARNING,"Error converting parameter");
                                _php_pgsql_free_params(params, num_params);

 [2006-03-05 14:35 UTC] tony2001@php.net

This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.