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