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

From: Date: Tue, 10 Aug 2021 12:09:17 +0000
Subject: Bug #81343 [NEW]: pdo_pgsql: Inconsitent boolean conversion after calling closeCursor()
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-235725@lists.php.net to get a copy of this message
From:             phofstetter at sensational dot ch
Operating system: macOS
PHP version:      8.1.0beta2
Package:          PDO PgSQL
Bug Type:         Bug
Bug description:pdo_pgsql: Inconsitent boolean conversion after calling closeCursor()

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 bug report at https://bugs.php.net/bug.php?id=81343&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=81343&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=81343&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=81343&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=81343&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=81343&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=81343&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=81343&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=81343&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=81343&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=81343&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81343&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=81343&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=81343&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=81343&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=81343&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=81343&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=81343&r=mysqlcfg


Thread (5 messages)

« previous php.bugs (#235725) next »