xref: /PHP-8.1/ext/oci8/tests/lob_043.phpt (revision b5a14e6c)
1--TEST--
2Bug #49560 (LOB resource destructor and refcount test)
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7$target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
8require(__DIR__.'/skipif.inc');
9if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request');
10?>
11--FILE--
12<?php
13
14require(__DIR__.'/connect.inc');
15
16// Initialization
17
18$stmtarray = array(
19    "drop table lob_043_tab",
20    "create table lob_043_tab(id number, c1 clob)",
21    "begin
22       for i in 1..50000 loop
23         insert into lob_043_tab (id, c1) values (i, i || ' abcdefghijklmnopq');
24      end loop;
25     end;",
26);
27
28oci8_test_sql_execute($c, $stmtarray);
29
30// Run Test
31
32function f1($c)
33{
34    $s = oci_parse($c, 'select id, c1 from lob_043_tab order by id');
35    oci_execute($s);
36    $r = array();
37    while (($row = oci_fetch_array($s, OCI_RETURN_NULLS+OCI_ASSOC+OCI_RETURN_LOBS)) !== false) {
38        $r[] = $row['C1'];
39    }
40    echo "f1 ended\n";
41    return $r;
42}
43
44function f2($c)
45{
46    $s = oci_parse($c, 'select id, c1 from lob_043_tab order by id');
47    oci_execute($s);
48    $r = array();
49    while (($row = oci_fetch_array($s, OCI_RETURN_NULLS+OCI_ASSOC)) !== false) {
50        $r[] = $row['C1'];
51    }
52    echo "f2 ended\n";
53    return $r;
54}
55
56echo "Test 1\n";
57$r = f1($c);
58/*
59  foreach ($r as $v) {
60  echo $v, "\n";
61  }
62*/
63
64echo "Test 2\n";
65$r = f2($c);
66/*
67  foreach ($r as $v) {
68  echo $v->load(), "\n";
69  }
70*/
71
72// Clean up
73
74$stmtarray = array(
75    "drop table lob_043_tab"
76);
77
78oci8_test_sql_execute($c, $stmtarray);
79
80oci_close($c);
81
82?>
83--EXPECT--
84Test 1
85f1 ended
86Test 2
87f2 ended
88