|
| 1 | +--TEST-- |
| 2 | +PDO_DBLIB: Set query timeouts |
| 3 | +--EXTENSIONS-- |
| 4 | +pdo_dblib |
| 5 | +--SKIPIF-- |
| 6 | +<?php |
| 7 | +if (getenv("SKIP_SLOW_TESTS")) die("skip slow test"); |
| 8 | +require __DIR__ . '/config.inc'; |
| 9 | +$dsn = getenv('PDO_ODBC_TEST_DSN'); |
| 10 | +if (!$dsn || strpos($dsn, '=') === false) { |
| 11 | + die('skip'); |
| 12 | +} |
| 13 | +?> |
| 14 | +--FILE-- |
| 15 | +<?php |
| 16 | +require __DIR__ . '/config.inc'; |
| 17 | + |
| 18 | +$dsn = getenv('PDO_ODBC_TEST_DSN'); |
| 19 | +$user = getenv('PDO_ODBC_TEST_USER'); |
| 20 | +$password = getenv('PDO_ODBC_TEST_PASS'); |
| 21 | + |
| 22 | +$sql = 'WAITFOR DELAY \'00:00:02\''; |
| 23 | + |
| 24 | +// regular timeout attribute, set after instance created, will affect query timeout, causing this query to fail |
| 25 | +$db = new PDO($dsn, $user, $password); |
| 26 | +$db->setAttribute(PDO::ATTR_TIMEOUT, 1); |
| 27 | +$stmt = $db->prepare($sql); |
| 28 | +try { |
| 29 | + $stmt->execute(); |
| 30 | + echo "Shouldn't happen\n"; |
| 31 | +} catch (PDOException) { |
| 32 | + echo "OK for timeout set after\n"; |
| 33 | +} |
| 34 | + |
| 35 | +// regular timeout attribute will affect query timeout, causing this query to fail |
| 36 | +$attributes = [PDO::ATTR_TIMEOUT => 1]; |
| 37 | +$db = new PDO($dsn, $user, $password, $attributes); |
| 38 | +$stmt = $db->prepare($sql); |
| 39 | +try { |
| 40 | + $stmt->execute(); |
| 41 | + echo "Shouldn't happen\n"; |
| 42 | +} catch (PDOException) { |
| 43 | + echo "OK for timeout set on ctor\n"; |
| 44 | +} |
| 45 | + |
| 46 | +?> |
| 47 | +--EXPECT-- |
| 48 | +OK for timeout set after |
| 49 | +OK for timeout set on ctor |
0 commit comments