-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dropped the use of LOCK TIMEOUT (#1165)
- Loading branch information
Showing
8 changed files
with
90 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
test/functional/pdo_sqlsrv/pdo_1100_query_timeout_disconnect.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
--TEST-- | ||
GitHub issue 1100 - PDO::SQLSRV_ATTR_QUERY_TIMEOUT had no effect when reconnecting | ||
--DESCRIPTION-- | ||
This test verifies that setting PDO::SQLSRV_ATTR_QUERY_TIMEOUT should work when reconnecting after disconnecting | ||
--ENV-- | ||
PHPT_EXEC=true | ||
--SKIPIF-- | ||
<?php require('skipif_mid-refactor.inc'); ?> | ||
--FILE-- | ||
<?php | ||
require_once("MsSetup.inc"); | ||
require_once("MsCommon_mid-refactor.inc"); | ||
|
||
function checkTimeElapsed($t0, $t1, $expectedDelay) | ||
{ | ||
$elapsed = $t1 - $t0; | ||
$diff = abs($elapsed - $expectedDelay); | ||
$leeway = 1.0; | ||
$missed = ($diff > $leeway); | ||
trace("$elapsed secs elapsed\n"); | ||
|
||
if ($missed) { | ||
echo "Expected $expectedDelay but $elapsed secs elapsed\n"; | ||
} | ||
} | ||
|
||
function testTimeout($conn, $timeout) | ||
{ | ||
$delay = 5; | ||
$query = "WAITFOR DELAY '00:00:$delay'; SELECT 1"; | ||
$error = '*Query timeout expired'; | ||
|
||
$t0 = microtime(true); | ||
try { | ||
$conn->exec($query); | ||
$elapsed = microtime(true) - $t0; | ||
echo "Should have failed after $timeout secs but $elapsed secs have elapsed" . PHP_EOL; | ||
} catch (PDOException $e) { | ||
$t1 = microtime(true); | ||
|
||
$message = '*Query timeout expired'; | ||
if (!fnmatch($message, $e->getMessage())) { | ||
var_dump($e->getMessage()); | ||
} | ||
checkTimeElapsed($t0, $t1, $timeout); | ||
} | ||
} | ||
|
||
try { | ||
$keywords = 'MultipleActiveResultSets=false;'; | ||
$timeout = 1; | ||
|
||
$options = array(PDO::SQLSRV_ATTR_QUERY_TIMEOUT => $timeout); | ||
$conn = connect($keywords, $options); | ||
|
||
testTimeout($conn, $timeout); | ||
unset($conn); | ||
|
||
$conn = connect($keywords); | ||
$conn->setAttribute(PDO::SQLSRV_ATTR_QUERY_TIMEOUT, $timeout); | ||
|
||
testTimeout($conn, $timeout); | ||
unset($conn); | ||
|
||
echo "Done\n"; | ||
} catch (PdoException $e) { | ||
echo $e->getMessage() . PHP_EOL; | ||
} | ||
|
||
?> | ||
--EXPECT-- | ||
Done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters