Bug #81343 [Com]: pdo_pgsql: Inconsitent boolean conversion after calling closeCursor()

From: Date: Tue, 10 Aug 2021 13:03:37 +0000
Subject: Bug #81343 [Com]: pdo_pgsql: Inconsitent boolean conversion after calling closeCursor()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-235729@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81343&edit=1

 ID:                 81343
 Comment by:         phofstetter at sensational dot ch
 Reported by:        phofstetter at sensational dot ch
 Summary:            pdo_pgsql: Inconsitent boolean conversion after
                     calling closeCursor()
 Status:             Open
 Type:               Bug
 Package:            PDO PgSQL
 Operating System:   macOS
 PHP Version:        8.1.0beta2
 Block user comment: N
 Private report:     N

 New Comment:

According to git bisect, commit caa710037e663fd78f67533b29611183090068b2 is where this broke.

> Rewrite PDO result binding

commit subject checks out :p


Previous Comments:
------------------------------------------------------------------------
[2021-08-10 12:09:17] phofstetter at sensational dot ch

Description:
------------
After calling closeCursor() on a Postgres PDO statement handle, the conversion behavior for boolean
values will change:

prior to calling closeCursor, boolean values in the database get converted to PHP boolean values.

after calling closeCursor() (and subsequently calling execute() again), boolean values will be
converted to strings 't' and 'f'

This was fine in PHP 8.0, broken in PHP 8.1b2 at least, though I'll update this bug with after
some bisecting to find the specific commit.

Test script:
---------------
$pdo = new PDO('pgsql:host=localhost;port=5432;user=someuser;dbname=somedb');
$sth = $pdo->prepare("select false where 2=?");

for ($i = 0; $i < 2; $i++) {
    $sth->execute([2]);
    var_dump($sth->fetchColumn(0));
    $sth->closeCursor();
}

Expected result:
----------------
bool(false)
bool(false)

Actual result:
--------------
bool(false)
string(1) "f"


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=81343&edit=1


Thread (5 messages)

« previous php.bugs (#235729) next »