Bug #78534 [NEW]: Query that contains '?' and 'string\' returns less records than must be

From: Date: Fri, 13 Sep 2019 12:54:30 +0000
Subject: Bug #78534 [NEW]: Query that contains '?' and 'string\' returns less records than must be
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-222734@lists.php.net to get a copy of this message
From: mnvx at yandex dot ru Operating system: Ubuntu 18.04 PHP version: 7.3.9 Package: PDO PgSQL Bug Type: Bug Bug description:Query that contains '?' and 'string\' returns less records than must be Description: ------------ Script below returns one record (incorrect) instead of two (expected). This script executed directly in PostgreSQL console returns two rows (correct). For thinking. After replacing 'CHACTECHNOLOGICO\\' to 'CHACTECHNOLOGICO' OR "?" to "-" in both places script returns two records (it is correct). Discussion on stackoverflow: https://stackoverflow.com/questions/57858915 Test script: --------------- <?php $pdo = new \PDO('pgsql:host=localhost;dbname=postgres', 'postgres', 'postgres'); $sql = <<<SQL SELECT * FROM ( SELECT 'CHAC TECHNOLOG*' as alias UNION SELECT 'KINDERY LIGHTING SALES DE?T*' ) m JOIN ( SELECT 'CHACTECHNOLOGICO\\' as ie_clean UNION SELECT 'KINDERYLIGHTINGSALESDEPT' as ie_clean ) t ON t.ie_clean ILIKE REPLACE(REPLACE(REPLACE(m.alias, '*', '%'), '?', '_'), ' ', '') ORDER BY ie_clean; SQL; echo $sql . PHP_EOL . PHP_EOL; $stmt = $pdo->query($sql); print_r($stmt->fetchAll(PDO::FETCH_ASSOC)); Expected result: ---------------- Array ( [0] => Array ( [alias] => CHAC TECHNOLOG* [ie_clean] => CHACTECHNOLOGICO\ ) [1] => Array ( [alias] => KINDERY LIGHTING SALES DE?T* [ie_clean] => KINDERYLIGHTINGSALESDEPT ) ) Actual result: -------------- Array ( [0] => Array ( [alias] => CHAC TECHNOLOG* [ie_clean] => CHACTECHNOLOGICO\ ) ) -- Edit bug report at https://bugs.php.net/bug.php?id=78534&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=78534&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=78534&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=78534&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=78534&r=needscript Try newer version: https://bugs.php.net/fix.php?id=78534&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=78534&r=support Expected behavior: https://bugs.php.net/fix.php?id=78534&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=78534&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=78534&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=78534&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=78534&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=78534&r=dst IIS Stability: https://bugs.php.net/fix.php?id=78534&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=78534&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=78534&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=78534&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=78534&r=mysqlcfg

« previous php.bugs (#222734) next »