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