Skip to content

Commit 0705d93

Browse files
committed
add test
1 parent 57b8e39 commit 0705d93

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

ext/pgsql/pgsql.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2151,12 +2151,12 @@ PHP_FUNCTION(pg_trace)
21512151
if (trace_mode > 0) {
21522152
#ifdef PQTRACE_REGRESS_MODE
21532153
if (trace_mode > (PQTRACE_SUPPRESS_TIMESTAMPS|PQTRACE_REGRESS_MODE)) {
2154-
zend_argument_value_error(2, "must be PGSQL_TRACE_SUPPRESS_TIMESTAMPS and/or PGSQL_TRACE_REGRESS_MODE");
2154+
zend_argument_value_error(4, "must be PGSQL_TRACE_SUPPRESS_TIMESTAMPS and/or PGSQL_TRACE_REGRESS_MODE");
21552155
} else {
21562156
PQsetTraceFlags(pgsql, trace_mode);
21572157
}
21582158
#else
2159-
zend_argument_value_error(2, "cannot set the trace mode as it's unsupported");
2159+
zend_argument_value_error(4, "cannot set as trace is unsupported");
21602160
#endif
21612161
}
21622162
RETURN_TRUE;

ext/pgsql/tests/pg_trace.phpt

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
pg_trace
3+
--EXTENSIONS--
4+
pgsql
5+
--SKIPIF--
6+
<?php include("skipif.inc"); ?>
7+
--FILE--
8+
<?php
9+
10+
include('config.inc');
11+
12+
$db = pg_connect($conn_str);
13+
$tracefile = __DIR__ . '/trace.tmp';
14+
15+
try {
16+
pg_trace($tracefile, 'w', $db, 56432);
17+
} catch (ValueError $e) {
18+
echo $e->getMessage() . PHP_EOL;
19+
}
20+
var_dump(pg_trace($tracefile, 'w', $db, 0));
21+
$res = pg_query($db, 'select 1');
22+
pg_untrace($db);
23+
24+
var_dump(gettype($rows));
25+
var_dump(count($rows) > 0);
26+
27+
?>
28+
--EXPECT--
29+
pg_trace(): Argument #4 ($trace_mode) cannot set as trace is unsupported
30+
bool(true)
31+
string(5) "array"
32+
bool(true)
33+

0 commit comments

Comments
 (0)