php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65219 PDO/dblib not working anymore ("use dbName" not sent)
Submitted: 2013-07-08 13:37 UTC Modified: 2013-07-12 23:29 UTC
Votes:7
Avg. Score:4.9 ± 0.3
Reproduced:7 of 7 (100.0%)
Same Version:7 (100.0%)
Same OS:2 (28.6%)
From: f dot marquis at of2m dot fr Assigned: ssufficool (profile)
Status: Closed Package: PDO related
PHP Version: 5.4.17 OS: CentOS 6.4
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: f dot marquis at of2m dot fr
New email:
PHP Version: OS:

 

 [2013-07-08 13:37 UTC] f dot marquis at of2m dot fr
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



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-07-12 23:29 UTC] felipe@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: ssufficool
 [2013-07-14 18:18 UTC] ssufficool@php.net
Automatic comment on behalf of ssufficool
Revision: http://git.php.net/?p=php-src.git;a=commit;h=d012bdca0319e225435430f89446828642b9810d
Log: Fix Bug #65219 DBSETLDBNAME should be called before login to set DBNAME in login record
 [2013-07-14 18:18 UTC] ssufficool@php.net
-Status: Assigned +Status: Closed
 [2013-07-15 00:07 UTC] stas@php.net
Automatic comment on behalf of ssufficool
Revision: http://git.php.net/?p=php-src.git;a=commit;h=d012bdca0319e225435430f89446828642b9810d
Log: Fix Bug #65219 DBSETLDBNAME should be called before login to set DBNAME in login record
 [2013-10-04 20:55 UTC] steven dot levin at sdepot dot com
Hopefully I am missing something here but I am still experiencing this issue with:

FreeBSD 9.1
PHP 5.4.20
Freetds msdblib 0.64

USE database never gets called and queries attempt to execute against the master database.

freetds.log never shows use cmd 

Is there something I can do yo troubleshoot on my end?
 [2013-10-05 16:57 UTC] ssufficool@php.net
Automatic comment on behalf of ssufficool
Revision: http://git.php.net/?p=php-src.git;a=commit;h=690bbe170d9ed4597629e4e986575fbe0a2cb796
Log: FIX BUG #65219 - USE DB not being sent for FreeTDS version < 0.92 FreeTDS <0.92 does not support DBSETLDBNAME option and therefore will not work with SQL Azure. Fallback to dbuse command in letter versions.
 [2013-10-05 17:07 UTC] ssufficool@php.net
Automatic comment on behalf of ssufficool
Revision: http://git.php.net/?p=php-src.git;a=commit;h=5ce23f39d51b1fc53a731d9fd7d419714d3de9fb
Log: FIX BUG #65219 - USE DB not being sent for FreeTDS version < 0.92 FreeTDS <0.92 does not support DBSETLDBNAME option and therefore will not work with SQL Azure. Fallback to dbuse command in letter versions.
 [2013-10-06 03:59 UTC] ssufficool@php.net
Automatic comment on behalf of ssufficool
Revision: http://git.php.net/?p=php-src.git;a=commit;h=63f242178d33fa22346d2e976b06a76455dbd6ab
Log: FIX BUG #65219 - Typo correction
 [2013-10-06 04:01 UTC] ssufficool@php.net
Automatic comment on behalf of ssufficool
Revision: http://git.php.net/?p=php-src.git;a=commit;h=fa40290fb76370c923e8f048daf1af144ff87604
Log: FIX BUG #65219 - Typo correction
 [2013-10-07 11:51 UTC] ab@php.net
Automatic comment on behalf of ssufficool
Revision: http://git.php.net/?p=php-src.git;a=commit;h=fa40290fb76370c923e8f048daf1af144ff87604
Log: FIX BUG #65219 - Typo correction
 [2013-10-07 11:51 UTC] ab@php.net
Automatic comment on behalf of ssufficool
Revision: http://git.php.net/?p=php-src.git;a=commit;h=5ce23f39d51b1fc53a731d9fd7d419714d3de9fb
Log: FIX BUG #65219 - USE DB not being sent for FreeTDS version < 0.92 FreeTDS <0.92 does not support DBSETLDBNAME option and therefore will not work with SQL Azure. Fallback to dbuse command in letter versions.
 [2013-10-09 07:19 UTC] mike@php.net
Automatic comment on behalf of ssufficool
Revision: http://git.php.net/?p=php-src.git;a=commit;h=63f242178d33fa22346d2e976b06a76455dbd6ab
Log: FIX BUG #65219 - Typo correction
 [2013-10-09 07:19 UTC] mike@php.net
Automatic comment on behalf of ssufficool
Revision: http://git.php.net/?p=php-src.git;a=commit;h=690bbe170d9ed4597629e4e986575fbe0a2cb796
Log: FIX BUG #65219 - USE DB not being sent for FreeTDS version < 0.92 FreeTDS <0.92 does not support DBSETLDBNAME option and therefore will not work with SQL Azure. Fallback to dbuse command in letter versions.
 [2013-11-17 09:30 UTC] laruence@php.net
Automatic comment on behalf of ssufficool
Revision: http://git.php.net/?p=php-src.git;a=commit;h=fa40290fb76370c923e8f048daf1af144ff87604
Log: FIX BUG #65219 - Typo correction
 [2013-11-17 09:30 UTC] laruence@php.net
Automatic comment on behalf of ssufficool
Revision: http://git.php.net/?p=php-src.git;a=commit;h=5ce23f39d51b1fc53a731d9fd7d419714d3de9fb
Log: FIX BUG #65219 - USE DB not being sent for FreeTDS version < 0.92 FreeTDS <0.92 does not support DBSETLDBNAME option and therefore will not work with SQL Azure. Fallback to dbuse command in letter versions.
 [2014-10-07 23:16 UTC] stas@php.net
Automatic comment on behalf of ssufficool
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=63f242178d33fa22346d2e976b06a76455dbd6ab
Log: FIX BUG #65219 - Typo correction
 [2014-10-07 23:16 UTC] stas@php.net
Automatic comment on behalf of ssufficool
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=690bbe170d9ed4597629e4e986575fbe0a2cb796
Log: FIX BUG #65219 - USE DB not being sent for FreeTDS version < 0.92 FreeTDS <0.92 does not support DBSETLDBNAME option and therefore will not work with SQL Azure. Fallback to dbuse command in letter versions.
 [2014-10-07 23:18 UTC] stas@php.net
Automatic comment on behalf of ssufficool
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=d012bdca0319e225435430f89446828642b9810d
Log: Fix Bug #65219 DBSETLDBNAME should be called before login to set DBNAME in login record
 [2014-10-07 23:28 UTC] stas@php.net
Automatic comment on behalf of ssufficool
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=63f242178d33fa22346d2e976b06a76455dbd6ab
Log: FIX BUG #65219 - Typo correction
 [2014-10-07 23:28 UTC] stas@php.net
Automatic comment on behalf of ssufficool
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=690bbe170d9ed4597629e4e986575fbe0a2cb796
Log: FIX BUG #65219 - USE DB not being sent for FreeTDS version < 0.92 FreeTDS <0.92 does not support DBSETLDBNAME option and therefore will not work with SQL Azure. Fallback to dbuse command in letter versions.
 [2014-10-07 23:29 UTC] stas@php.net
Automatic comment on behalf of ssufficool
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=d012bdca0319e225435430f89446828642b9810d
Log: Fix Bug #65219 DBSETLDBNAME should be called before login to set DBNAME in login record
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 12:01:29 2024 UTC