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