xref: /PHP-8.0/ext/pgsql/tests/80_bug36625.phpt (revision f8d79582)
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--CLEAN--
44<?php
45
46$tracefile = __DIR__ . '/trace.tmp';
47
48unlink($tracefile);
49
50?>
51--EXPECTF--
52bool(false)
53resource(%d) of type (pgsql result)
54bool(true)
55bool(true)
56