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