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