calltimeout1.phpt 1.2 KB

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