From: f dot marquis at of2m dot fr Operating system: CentOS 6.4 PHP version: 5.4.17 Package: PDO related Bug Type: Bug Bug description:PDO/dblib not working anymore ("use dbName" not sent)
Description: ------------ All queries to our MSSQL 2008 database (PDO_dblib with freeTDS) are failing since PHP 5.4.17 (same code) setting freeTDS into debug mode seems to indicate that the SQL queries are not sent to the correct database, but to 'master' database, so queried object are not found. FreeTDS log with PHP 5.4.17 : ... (dblib.c:239):dblib_add_connection(0x7f001af738e0, 0x7f002be94540) (dblib.c:4317):dbsetopt(0x7f002be93a00, 7, 2147483647, -1) (dblib.c:4432):UNIMPLEMENTED dbsetopt(option = 7) (dblib.c:4317):dbsetopt(0x7f002be93a00, 17, 2147483647, -1) (dblib.c:4432):UNIMPLEMENTED dbsetopt(option = 17) (dblib.c:4317):dbsetopt(0x7f002be93a00, 35, 1, -1) (dblib.c:761):dbsetlname(0x7f002be93850, Emploi, 14) (dblib.c:5762):dbsetuserdata(0x7f002be93a00, 0x7f002a851fa0) (dblib.c:3196):dbcancel(0x7f002be93a00) (query.c:2155):tds_send_cancel: not in_cancel and idle (dblib.c:1312):dbcmd(0x7f002be93a00, SELECT col FROM table WHERE id = 1 ) ... FreeTDS log with PHP 5.4.11 (working) : ... (dblib.c:239):dblib_add_connection(0x7fbc5d3d68e0, 0x7fbc6ec007f0) (dblib.c:4317):dbsetopt(0x7fbc6ebffe30, 7, 2147483647, -1) (dblib.c:4432):UNIMPLEMENTED dbsetopt(option = 7) (dblib.c:4317):dbsetopt(0x7fbc6ebffe30, 17, 2147483647, -1) (dblib.c:4432):UNIMPLEMENTED dbsetopt(option = 17) (dblib.c:4317):dbsetopt(0x7fbc6ebffe30, 35, (null), -1) (dblib.c:7929):dbperror(0x7fbc6ebffe30, 20176, 0) (dblib.c:7981):20176: "Called dbsetopt with parameter 3 NULL" (dblib.c:5780):dbgetuserdata(0x7fbc6ebffe30) (dblib.c:8002):"Called dbsetopt with parameter 3 NULL", client returns 2 (INT_CANCEL) (dblib.c:1398):dbuse(0x7fbc6ebffe30, Emploi) (dblib.c:1312):dbcmd(0x7fbc6ebffe30, use [Emploi]) (dblib.c:1319):dbcmd() bufsz = 0 (dblib.c:1369):dbsqlexec(0x7fbc6ebffe30) (dblib.c:6862):dbsqlsend(0x7fbc6ebffe30) (mem.c:615):tds_free_all_results() (util.c:156):Changed query state from IDLE to QUERYING (write.c:140):tds_put_string converting 12 bytes of "use [Emploi]" (write.c:168):tds_put_string wrote 24 bytes (util.c:156):Changed query state from QUERYING to PENDING (net.c:741):Sending packet ... You can see that the "use [dbName]" is not sent with the same way. The query is executed in "master" context, and that's why it's failing. regression from https://bugs.php.net/bug.php?id=64338 "pdo_dblib can't connect to Azure SQL" Test script: --------------- $pdo = new \PDO('dblib:host=hostname;dbname=dbname', 'username', 'password'); $stmt = $pdo->query('SELECT col FROM table WHERE id = 1'); var_dump($stmt); Expected result: ---------------- PDOStatement with the matching line from existing table Actual result: -------------- false, with this error : General SQL Server error: Check messages from the SQL Server [208] (severity 16) => Invalid object name -- Edit bug report at https://bugs.php.net/bug.php?id=65219&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=65219&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=65219&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=65219&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=65219&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=65219&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=65219&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=65219&r=needscript Try newer version: https://bugs.php.net/fix.php?id=65219&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=65219&r=support Expected behavior: https://bugs.php.net/fix.php?id=65219&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=65219&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=65219&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=65219&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65219&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=65219&r=dst IIS Stability: https://bugs.php.net/fix.php?id=65219&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=65219&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=65219&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=65219&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=65219&r=mysqlcfg