blob: 46c462417bb9bec2338d64ba24b31b4ce1258226 (
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
--TEST--
Bug #72294 Segmentation fault/invalid pointer in connection with pgsql_stmt_dtor
--SKIPIF--
<?php
if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not loaded');
require dirname(__FILE__) . '/config.inc';
require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
PDOTest::skip();
?>
--FILE--
<?php
require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
function handleError($errno, $errstr, $errfile, $errline)
{
if (!($errno & error_reporting())) {
return false;
}
throw new RuntimeException( $errstr, $errno );
}
abstract class PHPUnit_Framework_TestCase
{
private $name = null;
private $result;
public function run(PHPUnit_Framework_TestResult $result = null)
{
$result->run($this);
}
public function runBare()
{
$class = new ReflectionClass($this);
$method = $class->getMethod($this->name);
$method->invoke($this);
if( $x ) {
}
}
public function setName($name)
{
$this->name = $name;
}
}
class PHPUnit_Framework_TestFailure
{
private $testName;
protected $failedTest;
protected $thrownException;
public function __construct( $failedTest, $t)
{
if ($failedTest instanceof PHPUnit_Framework_SelfDescribing) {
$this->testName = $failedTest->toString();
} else {
$this->testName = get_class($failedTest);
}
$this->thrownException = $t;
}
}
class PHPUnit_Framework_TestResult
{
public function run( $test)
{
$error = false;
$oldErrorHandler = set_error_handler(
'handleError',
E_ALL | E_STRICT
);
try {
$test->runBare();
} catch (RuntimeException $e) {
$error = true;
}
restore_error_handler();
if ($error === true) {
$this->errors[] = new PHPUnit_Framework_TestFailure($test, $e);
}
}
}
$result = new PHPUnit_Framework_TestResult();
class PreparedStatementCache
{
private $cached_statements = array();
public function prepare( $pdo, $sql )
{
//return $pdo->prepare( $sql );
$this->cached_statements[$sql] = $pdo->prepare( $sql );
return $this->cached_statements[$sql];
}
}
class DatabaseTest extends PHPUnit_Framework_TestCase
{
public function testIt()
{
$pdo = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
$prepared_statement_cache = new PreparedStatementCache( $pdo );
for( $i = 1; $i <= 300; ++$i ) {
$statement = $prepared_statement_cache->prepare( $pdo, <<<SQL
SELECT $i;
SQL
);
$statement->execute();
}
}
public function test_construct()
{
$pdo = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
$pdo->exec( 'CREATE TEMPORARY TABLE temp_table ( test_column INT NOT NULL );' );
$this->cache = new PreparedStatementCache( $pdo );
$statement = $this->cache->prepare( $pdo, 'SELECT * FROM temp_table WHERE test_column > 0' );
$statement->execute();
}
}
$test = new DatabaseTest();
$test->setName( 'testIt' );
$test->run( $result );
$test->setName( 'test_construct' );
$test->run( $result );
?>
==NOCRASH==
--EXPECT--
==NOCRASH==
|