Bug #80586 [Opn->Fbk]: PDO constructor overrides dblib timeout

From: Date: Sun, 10 Jan 2021 21:47:36 +0000
Subject: Bug #80586 [Opn->Fbk]: PDO constructor overrides dblib timeout
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-231480@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80586&edit=1 ID: 80586 Updated by: adambaratz@php.net Reported by: jeremys at ha dot com Summary: PDO constructor overrides dblib timeout -Status: Open +Status: Feedback Type: Bug Package: PDO DBlib Operating System: RHEL 7.8 PHP Version: 7.3.25 Block user comment: N Private report: N Previous Comments: ------------------------------------------------------------------------ [2021-01-10 21:47:19] adambaratz@php.net This behavior is certainly awkward, but it was intended as a compromise between PDO's generic timeout attribute and the two timeouts that dblib can set. We could certainly come up with new logic for getting to the values to send to dbsetlogintime and dbsettime, but it would require some thought (and likely break a fair bit of existing code in the wild). Is it an option for you to set a timeout value in your PHP userland code instead of relying on freetds.conf? ------------------------------------------------------------------------ [2021-01-04 15:21:40] jeremys at ha dot com Description: ------------ When instantiating a new PDO instance with dblib as the driver, passing a non-null value to $options causes PDO_DBLIB to override the configured timeout and default it to 30 seconds for both connects and queries. For example, when using FreeTDS with a defined query timeout of 300 seconds in freetds.conf ("timeout = 300"), passing an empty array or an array with options that have nothing to do with timeouts sets the query timeout to 30 seconds. The gist is, passing $options to PDO::__construct() should only set the driver options specifically defined in $options, not every driver option. https://github.com/php/php-src/blob/caa710037e663fd78f67533b29611183090068b2/ext/pdo_dblib/dblib_driver.c#L481 Test script: --------------- test-1.php: <?php $pdo = new PDO( 'dblib:dbname=northwinds;host=contoso', 'username', 'password' ); try { $pdo->query( "WAITFOR DELAY '00:00:35'" ); var_dump( $pdo->query( "SELECT 'output' AS Output" )->fetch()['Output'] ); } catch( Throwable $e ) { var_dump( stripos( $pdo->errorInfo()[2], 'DBPROCESS is dead or not enabled' ) === 0 ); } ?> test-2.php: <?php $pdo = new PDO( 'dblib:dbname=northwinds;host=contoso', 'username', 'password', [] ); try { $pdo->query( "WAITFOR DELAY '00:00:35'" ); var_dump( $pdo->query( "SELECT 'output' AS Output" )->fetch()['Output'] ); } catch( Throwable $e ) { var_dump( stripos( $pdo->errorInfo()[2], 'DBPROCESS is dead or not enabled' ) === 0 ); } Expected result: ---------------- test-1.php: string(6) "output" test-2.php: string(6) "output" Actual result: -------------- test-1.php: string(6) "output" test-2.php: bool(true) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80586&edit=1

« previous php.bugs (#231480) next »