xref: /PHP-7.3/ext/oci8/tests/bug71600.phpt (revision 37652336)
1--TEST--
2Bug #71600 (oci_fetch_all result in segfault when select more than 8 columns)
3--SKIPIF--
4<?php
5$target_dbs = array('oracledb' => true, 'timesten' => true);  // test runs on these DBs
6require(dirname(__FILE__).'/skipif.inc');
7?>
8--FILE--
9<?php
10
11require(dirname(__FILE__).'/connect.inc');
12
13// Initialize
14
15$stmtarray = array(
16         "create table bug71600_tab (col1 number, col2 number, col3 number,
17                                     col4 number, col5 number, col6 number,
18                                     col7 number, col8 number, col9 number)",
19         "insert into bug71600_tab values(1, 2, 3, 4, 5, 6, 7, 8, 9)",
20         "insert into bug71600_tab values(11, 12, 13, 14, 15, 16, 17, 18, 19)"
21);
22
23oci8_test_sql_execute($c, $stmtarray);
24
25// Run test
26
27$sql = "select col1,col2,col3,col4,col5,col6,col7,col8,col9 from bug71600_tab";
28
29echo "Test 1\n";
30$stmt = oci_parse($c, $sql);
31
32echo "Executing SELECT statament...\n";
33oci_execute($stmt,OCI_DEFAULT);
34
35echo "Fetching data by columns...\n";
36oci_fetch_all($stmt, $result);
37oci_free_statement($stmt);
38
39$rsRows=(count($result,1)/($rows = count($result,0)))-1;
40echo "$rsRows Records Found\n";
41$rsCount=0;
42while($rsCount < $rsRows)
43{
44  $col1   =$result['COL1'][$rsCount];
45  $col9   =$result['COL9'][$rsCount];
46  echo "$rsCount|$col1|$col9\n";
47  $rsCount++;
48}
49
50echo "Test 2\n";
51$stmt = oci_parse($c, $sql);
52
53echo "Re-executing SELECT statament...\n";
54oci_execute($stmt,OCI_DEFAULT);
55
56echo "Fetching data by rows...\n";
57oci_fetch_all($stmt, $result, 0, -1, OCI_FETCHSTATEMENT_BY_ROW);
58oci_free_statement($stmt);
59
60$rsRows=count($result,0);
61echo "$rsRows Records Found\n";
62$rsCount=0;
63while($rsCount < $rsRows)
64{
65  $col1 = $result[$rsCount]['COL1'];
66  $col9 = $result[$rsCount]['COL9'];
67  echo "$rsCount|$col1|$col9\n";
68  $rsCount++;
69}
70
71
72// Cleanup
73
74$stmtarray = array(
75    "drop table bug71600_tab"
76);
77
78oci8_test_sql_execute($c, $stmtarray);
79
80?>
81===DONE===
82<?php exit(0); ?>
83--EXPECT--
84Test 1
85Executing SELECT statament...
86Fetching data by columns...
872 Records Found
880|1|9
891|11|19
90Test 2
91Re-executing SELECT statament...
92Fetching data by rows...
932 Records Found
940|1|9
951|11|19
96===DONE===
97