xref: /PHP-8.3/ext/oci8/tests/bug41069.phpt (revision a53e5617)
1--TEST--
2Bug #41069 (Oracle crash with certain data over a DB-link when prefetch memory limit used - Oracle bug 6039623)
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8$target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
9require __DIR__.'/skipif.inc';
10if (empty($dbase)) die ("skip requires network connection alias for DB link loopback");
11if ($test_drcp) die("skip DRCP does not support shared database links");
12?>
13--INI--
14oci8.default_prefetch=5
15--FILE--
16    <?php
17
18    require __DIR__.'/connect.inc';
19
20// Initialization
21
22$stmtarray = array(
23    "alter session set nls_date_format = 'MM/DD/YYYY'",
24
25    "drop database link bug41069_dblink",
26
27    "drop table bug41069_tab",
28
29    "create shared database link bug41069_dblink authenticated by $user identified by $password using '$dbase'",
30
31    "create table bug41069_tab
32    (
33        c1  number(20),
34        c2  varchar2(60 byte),
35        c3  varchar2(1000 byte),
36        c4  varchar2(255 byte),
37        c5  varchar2(2 byte),
38        c6  varchar2(1 byte),
39        c7  varchar2(255 byte),
40        c8  varchar2(50 byte),
41        c9  date,
42        c10 date,
43        c12 number(20),
44        c13 varchar2(20 byte),
45        c15 varchar2(50 byte)
46     )",
47
48    "insert into bug41069_tab (c1, c2, c5, c6, c9, c10, c12, c15)	values
49    (111, 'aaaaaaa', 'b', 'c', '01/17/2008', '01/07/2017', 2222, 'zzzzzzzzzz')",
50
51    "insert into bug41069_tab (c1, c2, c3, c4, c5, c6, c7, c9, c10, c12, c13, c15) values
52    (112, 'aaaaaaa', 'bbbbbbbb', 'ccccccc', 'd', 'e', 'rrrrrrr', '04/16/2007', '04/16/2007', 2223, 'xxxxxxxx', 'zzzzzzzz')",
53
54    "insert into bug41069_tab (c1, c2, c3, c4, c5, c6, c7, c9, c10, c12, c15)	values
55    (113, 'aaaaaaa', 'bbbbbbbbbb', 'cccccc', 'e', 'f', 'dddd', '12/04/2006', '12/04/2006', 2224, 'zzzzzzz')"
56);
57
58oci8_test_sql_execute($c, $stmtarray);
59
60
61// Run Tests
62
63echo "Test 1: non-DB link case that always worked\n";
64$stid = oci_parse($c, 'select * from bug41069_tab order by c1');
65oci_execute($stid, OCI_DEFAULT);
66oci_fetch_all($stid, $results, 0, -1, OCI_ASSOC+OCI_FETCHSTATEMENT_BY_ROW);
67var_dump($results);
68
69echo "Test 2: Should not crash\n";
70$stid = oci_parse($c, 'select * from bug41069_tab@bug41069_dblink order by c1');
71oci_execute($stid, OCI_DEFAULT);
72oci_fetch_all($stid, $results, 0, -1, OCI_ASSOC+OCI_FETCHSTATEMENT_BY_ROW);
73var_dump($results);
74
75// Cleanup
76
77$c = oci_new_connect($user, $password, $dbase);
78
79$stmtarray = array(
80    "drop database link bug41069_dblink",
81    "drop table bug41069_tab"
82);
83
84oci8_test_sql_execute($c, $stmtarray);
85
86echo "Done\n";
87
88?>
89--EXPECT--
90Test 1: non-DB link case that always worked
91array(3) {
92  [0]=>
93  array(13) {
94    ["C1"]=>
95    string(3) "111"
96    ["C2"]=>
97    string(7) "aaaaaaa"
98    ["C3"]=>
99    NULL
100    ["C4"]=>
101    NULL
102    ["C5"]=>
103    string(1) "b"
104    ["C6"]=>
105    string(1) "c"
106    ["C7"]=>
107    NULL
108    ["C8"]=>
109    NULL
110    ["C9"]=>
111    string(10) "01/17/2008"
112    ["C10"]=>
113    string(10) "01/07/2017"
114    ["C12"]=>
115    string(4) "2222"
116    ["C13"]=>
117    NULL
118    ["C15"]=>
119    string(10) "zzzzzzzzzz"
120  }
121  [1]=>
122  array(13) {
123    ["C1"]=>
124    string(3) "112"
125    ["C2"]=>
126    string(7) "aaaaaaa"
127    ["C3"]=>
128    string(8) "bbbbbbbb"
129    ["C4"]=>
130    string(7) "ccccccc"
131    ["C5"]=>
132    string(1) "d"
133    ["C6"]=>
134    string(1) "e"
135    ["C7"]=>
136    string(7) "rrrrrrr"
137    ["C8"]=>
138    NULL
139    ["C9"]=>
140    string(10) "04/16/2007"
141    ["C10"]=>
142    string(10) "04/16/2007"
143    ["C12"]=>
144    string(4) "2223"
145    ["C13"]=>
146    string(8) "xxxxxxxx"
147    ["C15"]=>
148    string(8) "zzzzzzzz"
149  }
150  [2]=>
151  array(13) {
152    ["C1"]=>
153    string(3) "113"
154    ["C2"]=>
155    string(7) "aaaaaaa"
156    ["C3"]=>
157    string(10) "bbbbbbbbbb"
158    ["C4"]=>
159    string(6) "cccccc"
160    ["C5"]=>
161    string(1) "e"
162    ["C6"]=>
163    string(1) "f"
164    ["C7"]=>
165    string(4) "dddd"
166    ["C8"]=>
167    NULL
168    ["C9"]=>
169    string(10) "12/04/2006"
170    ["C10"]=>
171    string(10) "12/04/2006"
172    ["C12"]=>
173    string(4) "2224"
174    ["C13"]=>
175    NULL
176    ["C15"]=>
177    string(7) "zzzzzzz"
178  }
179}
180Test 2: Should not crash
181array(3) {
182  [0]=>
183  array(13) {
184    ["C1"]=>
185    string(3) "111"
186    ["C2"]=>
187    string(7) "aaaaaaa"
188    ["C3"]=>
189    NULL
190    ["C4"]=>
191    NULL
192    ["C5"]=>
193    string(1) "b"
194    ["C6"]=>
195    string(1) "c"
196    ["C7"]=>
197    NULL
198    ["C8"]=>
199    NULL
200    ["C9"]=>
201    string(10) "01/17/2008"
202    ["C10"]=>
203    string(10) "01/07/2017"
204    ["C12"]=>
205    string(4) "2222"
206    ["C13"]=>
207    NULL
208    ["C15"]=>
209    string(10) "zzzzzzzzzz"
210  }
211  [1]=>
212  array(13) {
213    ["C1"]=>
214    string(3) "112"
215    ["C2"]=>
216    string(7) "aaaaaaa"
217    ["C3"]=>
218    string(8) "bbbbbbbb"
219    ["C4"]=>
220    string(7) "ccccccc"
221    ["C5"]=>
222    string(1) "d"
223    ["C6"]=>
224    string(1) "e"
225    ["C7"]=>
226    string(7) "rrrrrrr"
227    ["C8"]=>
228    NULL
229    ["C9"]=>
230    string(10) "04/16/2007"
231    ["C10"]=>
232    string(10) "04/16/2007"
233    ["C12"]=>
234    string(4) "2223"
235    ["C13"]=>
236    string(8) "xxxxxxxx"
237    ["C15"]=>
238    string(8) "zzzzzzzz"
239  }
240  [2]=>
241  array(13) {
242    ["C1"]=>
243    string(3) "113"
244    ["C2"]=>
245    string(7) "aaaaaaa"
246    ["C3"]=>
247    string(10) "bbbbbbbbbb"
248    ["C4"]=>
249    string(6) "cccccc"
250    ["C5"]=>
251    string(1) "e"
252    ["C6"]=>
253    string(1) "f"
254    ["C7"]=>
255    string(4) "dddd"
256    ["C8"]=>
257    NULL
258    ["C9"]=>
259    string(10) "12/04/2006"
260    ["C10"]=>
261    string(10) "12/04/2006"
262    ["C12"]=>
263    string(4) "2224"
264    ["C13"]=>
265    NULL
266    ["C15"]=>
267    string(7) "zzzzzzz"
268  }
269}
270Done
271