PHP  
 PHP_HEAD
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

Test Failure Report for ext/oci8/tests/bug43497.phpt ('Bug #43497 (OCI8 XML/getClobVal aka temporary LOBs leak UGA memory)')

Script

1: <?php
2:
3:
require dirname(__FILE__).'/connect.inc';
4:
5: function 
sessionid($c)  // determines and returns current session ID
6:
{
7:     
$query "select sid from v\$session where audsid = userenv('sessionid')";
8:
9:     
$stmt oci_parse($c$query);
10:
11:     if (
oci_execute($stmtOCI_DEFAULT)) {
12:         
$row oci_fetch($stmt);
13:         return 
oci_result($stmt1);
14:     }
15:
16:     return 
null;
17: }
18:
19:
20: function 
templobs($c$sid)  // returns number of temporary LOBs
21:
{
22:     
$query "select abstract_lobs from v\$temporary_lobs where sid = " $sid;
23:
24:     
$stmt oci_parse($c$query);
25:
26:     if (
oci_execute($stmtOCI_DEFAULT)) {
27:         
$row oci_fetch($stmt);
28:         
$val oci_result($stmt1);
29:         
oci_free_statement($stmt);
30:         return 
$val;
31:     }
32:     return 
null;
33: }
34:
35:
36:
// Read all XML data using explicit LOB locator
37:
function readxmltab_ex($c)
38: {
39:     
$stmt oci_parse($c"select extract(xml, '/').getclobval() from bug43497_tab");
40:
41:     
$cntchk 0;
42:     if (
oci_execute($stmt)) {
43:         while (
$result oci_fetch_array($stmtOCI_NUM)) {
44:             
$result[0]->free();   // cleanup properly
45:             
++$cntchk;
46:         }
47:     }
48:     echo 
"Loop count check = $cntchk\n";
49: }
50:
51:
// Read all XML data using explicit LOB locator but without freeing the temp lobs
52:
function readxmltab_ex_nofree($c)
53: {
54:     
$stmt oci_parse($c"select extract(xml, '/').getclobval() from bug43497_tab");
55:
56:     
$cntchk 0;
57:     if (
oci_execute($stmt)) {
58:         while (
$result oci_fetch_array($stmtOCI_NUM)) {
59:             ++
$cntchk;
60:         }
61:     }
62:     echo 
"Loop count check = $cntchk\n";
63: }
64:
65:
// Read all XML data using implicit LOB locator
66:
function readxmltab_im($c)
67: {
68:     
$stmt oci_parse($c"select extract(xml, '/').getclobval() from bug43497_tab");
69:
70:     
$cntchk 0;
71:     if (
oci_execute($stmt)) {
72:         while (
$result oci_fetch_array($stmtOCI_NUM+OCI_RETURN_LOBS)) {
73:             ++
$cntchk;
74:         }
75:     }
76:     echo 
"Loop count check = $cntchk\n";
77: }
78:
79: function 
createxmltab($c)  // create table w/ field of XML type
80:
{
81:     @
dropxmltab($c);
82:     
$stmt oci_parse($c"create table bug43497_tab (id number primary key, xml xmltype)");
83:     
oci_execute($stmt);
84: }
85:
86: function 
dropxmltab($c)  // delete table
87:
{
88:     
$stmt oci_parse($c"drop table bug43497_tab");
89:     
oci_execute($stmt);
90: }
91:
92:
93: function 
fillxmltab($c)
94: {
95:     for (
$id 1$id <= 100$id++) {
96:         
97:         
// create an XML element string with random data        
98:         
$s "<data>";
99:         for (
$j 0$j 128$j++) {
100:             
$s .= rand();        
101:         }
102:         
$s .= "</data>\n";        
103:         for (
$j 0$j 4$j++) {
104:             
$s .= $s;
105:         }        
106:         
$data "<?xml version=\"1.0\"?><records>" $s "</records>";
107:         
108:         
// insert XML data into database
109:         
110:         
$stmt oci_parse($c"insert into bug43497_tab(id, xml) values (:id, sys.xmltype.createxml(:xml))");
111:         
oci_bind_by_name($stmt":id"$id);
112:         
$clob oci_new_descriptor($cOCI_D_LOB);
113:         
oci_bind_by_name($stmt":xml"$clob, -1OCI_B_CLOB);
114:         
$clob->writetemporary($data);
115:         
oci_execute($stmt);
116:         
117:         
$clob->close();
118:         
$clob->free();
119:     }
120: }
121:
122:
123:
// Initialize
124:
125:
createxmltab($c);
126:
fillxmltab($c);
127:
128:
// Run Test
129:
130:
$sid sessionid($c);
131:
132: echo 
"Explicit LOB use\n";
133: for (
$i 1$i <= 10$i++) {
134:     echo 
"\nRun              = " $i "\n";
135:     echo 
"Temporary LOBs   = " templobs($c$sid) . "\n";
136:     
readxmltab_ex($c);
137: }
138:
139: echo 
"\nImplicit LOB use\n";
140: for (
$i 1$i <= 10$i++) {
141:     echo 
"\nRun              = " $i "\n";
142:     echo 
"Temporary LOBs   = " templobs($c$sid) . "\n";
143:     
readxmltab_im($c);
144: }
145:
146: echo 
"\nExplicit LOB with no free\n";
147: for (
$i 1$i <= 10$i++) {
148:     echo 
"\nRun              = " $i "\n";
149:     echo 
"Temporary LOBs   = " templobs($c$sid) . "\n";
150:     
readxmltab_ex_nofree($c);
151: }
152:
153:
154:
155:
// Cleanup
156:
157:
dropxmltab($c);
158:
159:
oci_close($c);
160:
161: echo 
"Done\n";
162:
?>
163:

Expected

Explicit LOB use

Run              = 1
Temporary LOBs   = 0
Loop count check = 100

Run              = 2
Temporary LOBs   = 0
Loop count check = 100

Run              = 3
Temporary LOBs   = 0
Loop count check = 100

Run              = 4
Temporary LOBs   = 0
Loop count check = 100

Run              = 5
Temporary LOBs   = 0
Loop count check = 100

Run              = 6
Temporary LOBs   = 0
Loop count check = 100

Run              = 7
Temporary LOBs   = 0
Loop count check = 100

Run              = 8
Temporary LOBs   = 0
Loop count check = 100

Run              = 9
Temporary LOBs   = 0
Loop count check = 100

Run              = 10
Temporary LOBs   = 0
Loop count check = 100

Implicit LOB use

Run              = 1
Temporary LOBs   = 0
Loop count check = 100

Run              = 2
Temporary LOBs   = 0
Loop count check = 100

Run              = 3
Temporary LOBs   = 0
Loop count check = 100

Run              = 4
Temporary LOBs   = 0
Loop count check = 100

Run              = 5
Temporary LOBs   = 0
Loop count check = 100

Run              = 6
Temporary LOBs   = 0
Loop count check = 100

Run              = 7
Temporary LOBs   = 0
Loop count check = 100

Run              = 8
Temporary LOBs   = 0
Loop count check = 100

Run              = 9
Temporary LOBs   = 0
Loop count check = 100

Run              = 10
Temporary LOBs   = 0
Loop count check = 100

Explicit LOB with no free

Run              = 1
Temporary LOBs   = 0
Loop count check = 100

Run              = 2
Temporary LOBs   = 0
Loop count check = 100

Run              = 3
Temporary LOBs   = 0
Loop count check = 100

Run              = 4
Temporary LOBs   = 0
Loop count check = 100

Run              = 5
Temporary LOBs   = 0
Loop count check = 100

Run              = 6
Temporary LOBs   = 0
Loop count check = 100

Run              = 7
Temporary LOBs   = 0
Loop count check = 100

Run              = 8
Temporary LOBs   = 0
Loop count check = 100

Run              = 9
Temporary LOBs   = 0
Loop count check = 100

Run              = 10
Temporary LOBs   = 0
Loop count check = 100
Done

Output

***********************************************************************
Fatal NI connect error 12541, connecting to:
 (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=XE)(CID=(PROGRAM=php)(HOST=nex2.php.net)(USER=nlopess)))(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521)))

  VERSION INFORMATION:
	TNS for Linux: Version 11.2.0.2.0 - Beta
	TCP/IP NT Protocol Adapter for Linux: Version 11.2.0.2.0 - Beta
  Time: 17-JUN-2018 05:04:21
  Tracing not turned on.
  Tns error struct:
    ns main err code: 12541
    TNS-12541: TNS:no listener
    ns secondary err code: 12560
    nt main err code: 511
    TNS-00511: No listener

Fatal error: connect.inc: Failed to connect as 'system' to 'localhost/XE': ORA-12541: TNS:no listener in /var/php_gcov/PHP_HEAD/ext/oci8/tests/connect.inc on line 14
    nt secondary err code: 111
    nt OS err code: 0

Diff

001+ ***********************************************************************
002+ Fatal NI connect error 12541, connecting to:
003+  (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=XE)(CID=(PROGRAM=php)(HOST=nex2.php.net)(USER=nlopess)))(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521)))
001- Explicit LOB use
003- Run              = 1
004- Temporary LOBs   = 0
005- Loop count check = 100
005+   VERSION INFORMATION:
006+ 	TNS for Linux: Version 11.2.0.2.0 - Beta
007+ 	TCP/IP NT Protocol Adapter for Linux: Version 11.2.0.2.0 - Beta
008+   Time: 17-JUN-2018 05:04:21
009+   Tracing not turned on.
010+   Tns error struct:
011+     ns main err code: 12541
012+     TNS-12541: TNS:no listener
013+     ns secondary err code: 12560
014+     nt main err code: 511
015+     TNS-00511: No listener
007- Run              = 2
008- Temporary LOBs   = 0
009- Loop count check = 100
017+ Fatal error: connect.inc: Failed to connect as 'system' to 'localhost/XE': ORA-12541: TNS:no listener in /var/php_gcov/PHP_HEAD/ext/oci8/tests/connect.inc on line 14
018+     nt secondary err code: 111
019+     nt OS err code: 0
010- 
011- Run              = 3
012- Temporary LOBs   = 0
013- Loop count check = 100
014- 
015- Run              = 4
016- Temporary LOBs   = 0
017- Loop count check = 100
018- 
019- Run              = 5
020- Temporary LOBs   = 0
021- Loop count check = 100
022- 
023- Run              = 6
024- Temporary LOBs   = 0
025- Loop count check = 100
026- 
027- Run              = 7
028- Temporary LOBs   = 0
029- Loop count check = 100
030- 
031- Run              = 8
032- Temporary LOBs   = 0
033- Loop count check = 100
034- 
035- Run              = 9
036- Temporary LOBs   = 0
037- Loop count check = 100
038- 
039- Run              = 10
040- Temporary LOBs   = 0
041- Loop count check = 100
042- 
043- Implicit LOB use
044- 
045- Run              = 1
046- Temporary LOBs   = 0
047- Loop count check = 100
048- 
049- Run              = 2
050- Temporary LOBs   = 0
051- Loop count check = 100
052- 
053- Run              = 3
054- Temporary LOBs   = 0
055- Loop count check = 100
056- 
057- Run              = 4
058- Temporary LOBs   = 0
059- Loop count check = 100
060- 
061- Run              = 5
062- Temporary LOBs   = 0
063- Loop count check = 100
064- 
065- Run              = 6
066- Temporary LOBs   = 0
067- Loop count check = 100
068- 
069- Run              = 7
070- Temporary LOBs   = 0
071- Loop count check = 100
072- 
073- Run              = 8
074- Temporary LOBs   = 0
075- Loop count check = 100
076- 
077- Run              = 9
078- Temporary LOBs   = 0
079- Loop count check = 100
080- 
081- Run              = 10
082- Temporary LOBs   = 0
083- Loop count check = 100
084- 
085- Explicit LOB with no free
086- 
087- Run              = 1
088- Temporary LOBs   = 0
089- Loop count check = 100
090- 
091- Run              = 2
092- Temporary LOBs   = 0
093- Loop count check = 100
094- 
095- Run              = 3
096- Temporary LOBs   = 0
097- Loop count check = 100
098- 
099- Run              = 4
100- Temporary LOBs   = 0
101- Loop count check = 100
102- 
103- Run              = 5
104- Temporary LOBs   = 0
105- Loop count check = 100
106- 
107- Run              = 6
108- Temporary LOBs   = 0
109- Loop count check = 100
110- 
111- Run              = 7
112- Temporary LOBs   = 0
113- Loop count check = 100
114- 
115- Run              = 8
116- Temporary LOBs   = 0
117- Loop count check = 100
118- 
119- Run              = 9
120- Temporary LOBs   = 0
121- Loop count check = 100
122- 
123- Run              = 10
124- Temporary LOBs   = 0
125- Loop count check = 100
126- Done

 

Generated at Mon, 18 Jun 2018 17:33:50 +0000 (24 hours ago)

Copyright © 2005-2018 The PHP Group
All rights reserved.