1--TEST-- 2PDO_OCI: Attribute: Setting and using call timeout 3--SKIPIF-- 4<?php 5if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request'); 6if (!extension_loaded('pdo') || !extension_loaded('pdo_oci')) die('skip not loaded'); 7require(__DIR__.'/../../pdo/tests/pdo_test.inc'); 8PDOTest::skip(); 9if (strcasecmp(getenv('PDOTEST_USER'), "system") && strcasecmp(getenv('PDOTEST_USER'), "sys")) { 10 die("skip needs to be run as a user with access to DBMS_LOCK"); 11} 12 13$dbh = PDOTest::factory(); 14preg_match('/^[[:digit:]]+/', $dbh->getAttribute(PDO::ATTR_CLIENT_VERSION), $matches); 15if (!(isset($matches[0]) && $matches[0] >= 18)) { 16 die("skip works only with Oracle 18c or greater version of Oracle client libraries"); 17} 18 19?> 20--FILE-- 21<?php 22 23require(__DIR__ . '/../../pdo/tests/pdo_test.inc'); 24 25function mysleep($dbh, $t) 26{ 27 $stmt = $dbh->prepare("begin dbms_lock.sleep(:t); end;"); 28 29 if (!$stmt) { 30 $error = $dbh->errorInfo(); 31 echo "Prepare error was ", $error[2], "\n"; 32 return; 33 } 34 $stmt->bindParam(":t", $t, PDO::PARAM_INT); 35 36 $r = $stmt->execute(); 37 if ($r) { 38 echo "Execute succeeded\n"; 39 } else { 40 $error = $dbh->errorInfo(); 41 echo "Execute error was ", $error[2], "\n"; 42 } 43} 44 45$dbh = PDOTest::factory(); 46$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); 47 48echo "Test 1\n"; 49 50$dbh->setAttribute(PDO::OCI_ATTR_CALL_TIMEOUT, 4000); // milliseconds 51 52echo "call timeout:\n"; 53var_dump($dbh->getAttribute(PDO::OCI_ATTR_CALL_TIMEOUT)); 54 55$r = mysleep($dbh, 8); // seconds 56 57?> 58===DONE=== 59<?php exit(0); ?> 60--EXPECTF-- 61Test 1 62call timeout: 63int(4000) 64Execute error was OCIStmtExecute: ORA-%r(03136|03156)%r: %s 65 (%s:%d) 66===DONE=== 67