]> granicus.if.org Git - php/commitdiff
- Fixed #36625 pg_trace() does not work
authorMarcus Boerger <helly@php.net>
Mon, 6 Mar 2006 20:16:34 +0000 (20:16 +0000)
committerMarcus Boerger <helly@php.net>
Mon, 6 Mar 2006 20:16:34 +0000 (20:16 +0000)
ext/pgsql/pgsql.c
ext/pgsql/tests/80_bug36625.phpt [new file with mode: 0755]

index 2f179b426e83de020c2eaf6d4ce5d148ccd48837..d52d2b451934ca901fdf46ef473c7bb7c7775bcf 100644 (file)
@@ -2360,7 +2360,7 @@ PHP_FUNCTION(pg_trace)
                RETURN_FALSE;
        }
 
-       if (FAILURE == php_stream_cast(stream, PHP_STREAM_AS_STDIO, (void**)fp, REPORT_ERRORS)) {
+       if (FAILURE == php_stream_cast(stream, PHP_STREAM_AS_STDIO, (void**)&fp, REPORT_ERRORS))        {
                php_stream_close(stream);
                RETURN_FALSE;
        }
diff --git a/ext/pgsql/tests/80_bug36625.phpt b/ext/pgsql/tests/80_bug36625.phpt
new file mode 100755 (executable)
index 0000000..a95cea7
--- /dev/null
@@ -0,0 +1,49 @@
+--TEST--
+Bug #36625 (pg_trace() does not work)
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+?>
+--FILE--
+<?php
+
+require_once('config.inc');
+       
+$dbh = @pg_connect($conn_str);
+if (!$dbh) {
+       die ('Could not connect to the server');
+}
+
+$tracefile = dirname(__FILE__) . '/trace.tmp';
+
+@unlink($tracefile);
+var_dump(file_exists($tracefile));
+
+pg_trace($tracefile, 'w', $dbh);
+$res = pg_query($dbh, 'select 1');
+var_dump($res);
+pg_close($dbh);
+
+$found = 0;
+function search_trace_file($line)
+{
+       if (strpos($line, '"select 1"') !== false || strpos($line, "'select 1'") !== false) {
+               $GLOBALS['found']++;
+       }
+}
+
+$trace = file($tracefile);
+array_walk($trace, 'search_trace_file');
+var_dump($found > 0);
+var_dump(file_exists($tracefile));
+
+?>
+===DONE===
+--CLEAN--
+<?php unlink($tracefile); ?>
+--EXPECTF--
+bool(false)
+resource(%d) of type (pgsql result)
+bool(true)
+bool(true)
+===DONE===