1--TEST--
2PDO OCI: Test to verify all implicitly created temporary LOB are cleaned up
3--EXTENSIONS--
4pdo
5pdo_oci
6--SKIPIF--
7<?php
8require(__DIR__.'/../../pdo/tests/pdo_test.inc');
9PDOTest::skip();
10?>
11--FILE--
12<?PHP
13
14require('ext/pdo/tests/pdo_test.inc');
15$db = PDOTest::test_factory('ext/pdo_oci/tests/common.phpt');
16
17$clobquery1 = "select TO_CLOB('Hello World') CLOB_DATA from dual";
18$clobquery2 = "select TO_CLOB('Hello World') CLOB_DATA from dual";
19$clobquery3 = "select TO_CLOB('Hello World') CLOB_DATA from dual";
20$clobquery4 = "select TO_CLOB('Hello World') CLOB_DATA from dual";
21$clobquery5 = "select TO_CLOB('Hello World') CLOB_DATA from dual";
22$clobquery6 = "select TO_CLOB('Hello World') CLOB_DATA from dual";
23$clobquery7 = "select TO_CLOB('Hello World') CLOB_DATA from dual";
24$clobquery8 = "select TO_CLOB('Hello World') CLOB_DATA from dual";
25$clobquery9 = "select TO_CLOB('Hello World') CLOB_DATA from dual";
26$clobquery10 = "select TO_CLOB('Hello World') CLOB_DATA from dual";
27
28$stmt= $db->prepare($clobquery1);
29$stmt->execute();
30$row = $stmt->fetch();
31$stmt= $db->prepare($clobquery2);
32$stmt->execute();
33$row = $stmt->fetch();
34$stmt= $db->prepare($clobquery3);
35$stmt->execute();
36$row = $stmt->fetch();
37$stmt= $db->prepare($clobquery4);
38$stmt->execute();
39$row = $stmt->fetch();
40$stmt= $db->prepare($clobquery5);
41$stmt->execute();
42$row = $stmt->fetch();
43$stmt= $db->prepare($clobquery6);
44$stmt->execute();
45$row = $stmt->fetch();
46$stmt= $db->prepare($clobquery7);
47$stmt->execute();
48$row = $stmt->fetch();
49$stmt= $db->prepare($clobquery8);
50$stmt->execute();
51$row = $stmt->fetch();
52$stmt= $db->prepare($clobquery9);
53$stmt->execute();
54$row = $stmt->fetch();
55$stmt= $db->prepare($clobquery10);
56$stmt->execute();
57$row = $stmt->fetch();
58
59$query1 = "SELECT SYS_CONTEXT('USERENV', 'SID') SID FROM DUAL";
60
61$stmt1 = $db->prepare($query1);
62$stmt1->execute();
63
64$row1 = $stmt1->fetch();
65$sid_value = $row1[0];
66
67$query2 = "SELECT (CACHE_LOBS+NOCACHE_LOBS+ABSTRACT_LOBS) FROM V\$TEMPORARY_LOBS WHERE SID = :SID_VALUE";
68
69$stmt2 = $db->prepare($query2);
70$stmt2->bindParam(':SID_VALUE', $sid_value);
71$stmt2->execute();
72
73$row2 = $stmt2->fetch();
74/* 1 temporary LOB still exists in V$TEMPORARY_LOBS since the destructor of $stmt is not yet called by PHP */
75if ($row2[0] > 1)
76{
77  echo "TEMP_LOB is not yet cleared!" . $row2[0] . "\n";
78}
79else
80{
81  echo "Success! All the temporary LOB in previously closed statements are properly cleaned.\n";
82}
83
84?>
85--EXPECT--
86Success! All the temporary LOB in previously closed statements are properly cleaned.
87