1--TEST--
2PDO OCI: Fetches 10K records from a table that contains 1 number and 2 LOB columns (stress test)
3--SKIPIF--
4<?php
5if (!extension_loaded('pdo') || !extension_loaded('pdo_oci')) die('skip not loaded');
6if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request');
7require(dirname(__FILE__).'/../../pdo/tests/pdo_test.inc');
8PDOTest::skip();
9?>
10--FILE--
11<?php
12
13// !! Note: uses data inserted in pdo_oci_stream_2a.phpt !!
14
15require('ext/pdo/tests/pdo_test.inc');
16$db = PDOTest::test_factory('ext/pdo_oci/tests/common.phpt');
17
18$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);  // Let's use streams
19
20// Since each column only has one lob descriptor, the last row is
21// shown twice because the lob descriptor for each column is reused in
22// the stream
23
24$i = 0;
25$j = 9;
26$a_val = ord('a');
27foreach($db->query("select data1 as d4_1, data2 as d4_2 from pdo_oci_stream_2 order by id") as $row) {
28    $a = $row['d4_1'];
29	$a1 = $row['d4_2'];
30
31    $str1 = stream_get_contents($a);
32	$str2 = stream_get_contents($a1);
33
34    $str1len = strlen($str1);
35	$str2len = strlen($str2);
36
37    $b = ord($str1[0]);
38	$b1 = ord($str2[0]);
39
40    if (($b != ($a_val + $i)) && ($str1len != (4086 + $i)) &&
41        ($b1 != ($a_val + $j)) && ($str2len != (4086 + $j))) {
42        printf("There is a bug!\n");
43        printf("Col1:\n");
44        printf("a_val = %d\n", $a_val);
45        printf("b     = %d\n", $b);
46        printf("i     = %d\n", $i);
47        printf("str1len = %d\n", $str1len);
48
49        printf("Col2:\n");
50        printf("a_val = %d\n", $a_val);
51        printf("b1    = %d\n", $b1);
52        printf("j     = %d\n", $j);
53        printf("str2len = %d\n", $str1len);
54
55    }
56    $i++;
57    if ($i>9)
58        $i = 0;
59	$j--;
60	if ($j<0)
61        $j = 9;
62}
63echo "Fetch operation done!\n";
64
65/* Cleanup */
66$db->exec("drop table pdo_oci_stream_2");
67
68?>
69--EXPECT--
70Fetch operation done!
71