xref: /PHP-7.2/ext/oci8/tests/calltimeout1.phpt (revision e4d894ed)
1--TEST--
2oci_set_call_timeout: test timing out
3--SKIPIF--
4<?php
5if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request');
6if (!extension_loaded('oci8')) die ("skip no oci8 extension");
7$target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
8require(dirname(__FILE__).'/skipif.inc');
9if (strcasecmp($user, "system") && strcasecmp($user, "sys")) {
10    die("skip needs to be run as a user with access to DBMS_LOCK");
11}
12preg_match('/^[[:digit:]]+/', oci_client_version(), $matches);
13if (!(isset($matches[0]) && $matches[0] >= 18)) {
14    die("skip works only with Oracle 18c or greater version of Oracle client libraries");
15}
16
17?>
18--FILE--
19<?php
20
21require(dirname(__FILE__).'/connect.inc');
22
23function mysleep($c, $t)
24{
25    $s = @oci_parse($c, "begin dbms_lock.sleep(:t); end;");
26    if (!$s) {
27        $m = oci_error($c);
28        echo "Execute error was ", $m['message'], "\n";
29        return;
30    }
31    @oci_bind_by_name($s, ":t", $t);
32    $r = @oci_execute($s);
33    if ($r) {
34        echo "Execute succeeded\n";
35    } else {
36        $m = oci_error($s);
37        echo "Execute error was ", $m['message'], "\n";
38    }
39}
40
41echo "Test 1\n";
42oci_set_call_timeout($c, 4000);  // milliseconds
43$r = mysleep($c, 8);             // seconds
44
45?>
46===DONE===
47<?php exit(0); ?>
48--EXPECTF--
49Test 1
50Execute error was ORA-03136: %s
51===DONE===
52