xref: /PHP-8.3/ext/oci8/tests/calltimeout1.phpt (revision a53e5617)
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');
8require_once 'skipifconnectfailure.inc';
9$target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
10require __DIR__.'/skipif.inc';
11if (strcasecmp($user, "system") && strcasecmp($user, "sys")) {
12    die("skip needs to be run as a user with access to DBMS_LOCK");
13}
14preg_match('/^[[:digit:]]+/', oci_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__.'/connect.inc';
24
25function mysleep($c, $t)
26{
27    $s = @oci_parse($c, "begin dbms_lock.sleep(:t); end;");
28    if (!$s) {
29        $m = oci_error($c);
30        echo "Execute error was ", $m['message'], "\n";
31        return;
32    }
33    @oci_bind_by_name($s, ":t", $t);
34    $r = @oci_execute($s);
35    if ($r) {
36        echo "Execute succeeded\n";
37    } else {
38        $m = oci_error($s);
39        echo "Execute error was ", $m['message'], "\n";
40    }
41}
42
43echo "Test 1\n";
44oci_set_call_timeout($c, 4000);  // milliseconds
45$r = mysleep($c, 8);             // seconds
46
47?>
48--EXPECTF--
49Test 1
50Execute error was ORA-%r(03136|03156)%r: %s
51