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