xref: /PHP-7.4/ext/pgsql/tests/80_bug36625.phpt (revision 26dfce7f)
1--TEST--
2Bug #36625 (8.0+) (pg_trace() does not work)
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6?>
7--FILE--
8<?php
9
10require_once('config.inc');
11
12$dbh = @pg_connect($conn_str);
13if (!$dbh) {
14	die ('Could not connect to the server');
15}
16
17$tracefile = __DIR__ . '/trace.tmp';
18
19@unlink($tracefile);
20var_dump(file_exists($tracefile));
21
22pg_trace($tracefile, 'w', $dbh);
23$res = pg_query($dbh, 'select 1');
24var_dump($res);
25pg_close($dbh);
26
27$found = 0;
28function search_trace_file($line)
29{
30	if (strpos($line, '"select 1"') !== false || strpos($line, "'select 1'") !== false) {
31		$GLOBALS['found']++;
32	}
33}
34
35$trace = file($tracefile);
36array_walk($trace, 'search_trace_file');
37var_dump($found > 0);
38var_dump(file_exists($tracefile));
39
40@unlink($tracefile);
41
42?>
43===DONE===
44--CLEAN--
45<?php
46
47$tracefile = __DIR__ . '/trace.tmp';
48
49unlink($tracefile);
50
51?>
52--EXPECTF--
53bool(false)
54resource(%d) of type (pgsql result)
55bool(true)
56bool(true)
57===DONE===
58