summaryrefslogtreecommitdiff
path: root/ext/pdo_oci/tests/pdo_oci_stream_2b.phpt
blob: 22ae7c6724d9d82187133cc88e5a7547bb4a4cc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
--TEST--
PDO OCI: Fetches 10K records from a table that contains 1 number and 2 LOB columns (stress test)
--SKIPIF--
<?php
if (!extension_loaded('pdo') || !extension_loaded('pdo_oci')) die('skip not loaded');
if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request');
require(dirname(__FILE__).'/../../pdo/tests/pdo_test.inc');
PDOTest::skip();
?>
--FILE--
<?php

// !! Note: uses data inserted in pdo_oci_stream_2a.phpt !!

require('ext/pdo/tests/pdo_test.inc');
$db = PDOTest::test_factory('ext/pdo_oci/tests/common.phpt');

$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);  // Let's use streams

// Since each column only has one lob descriptor, the last row is
// shown twice because the lob descriptor for each column is reused in
// the stream

$i = 0;
$j = 9;
$a_val = ord('a');
foreach($db->query("select data1 as d4_1, data2 as d4_2 from pdo_oci_stream_2 order by id") as $row) {
    $a = $row['d4_1'];
	$a1 = $row['d4_2'];
    
    $str1 = stream_get_contents($a);
	$str2 = stream_get_contents($a1);
    
    $str1len = strlen($str1);
	$str2len = strlen($str2);
    
    $b = ord($str1[0]);
	$b1 = ord($str2[0]);
    
    if (($b != ($a_val + $i)) && ($str1len != (4086 + $i)) &&
        ($b1 != ($a_val + $j)) && ($str2len != (4086 + $j))) {
        printf("There is a bug!\n");
        printf("Col1:\n");
        printf("a_val = %d\n", $a_val);
        printf("b     = %d\n", $b);
        printf("i     = %d\n", $i);
        printf("str1len = %d\n", $str1len);
        
        printf("Col2:\n");
        printf("a_val = %d\n", $a_val);
        printf("b1    = %d\n", $b1);
        printf("j     = %d\n", $j);
        printf("str2len = %d\n", $str1len);
        
    }
    $i++;
    if ($i>9)
        $i = 0;
	$j--;
	if ($j<0)
        $j = 9;
}
echo "Fetch operation done!\n";

/* Cleanup */
$db->exec("drop table pdo_oci_stream_2");

?>
--EXPECTF--
Fetch operation done!