diff options
author | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:35:28 -0400 |
---|---|---|
committer | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:35:28 -0400 |
commit | ba50031707469046407a35b77a3cd81351e951b3 (patch) | |
tree | 5c03e723bdbfabae09d41a3ab1253dff41eeed4a /ext/pgsql | |
parent | 0a36161e13484a99ccf69bb38f206462d27cc6d6 (diff) | |
download | php-ba50031707469046407a35b77a3cd81351e951b3.tar.gz |
Imported Upstream version 5.1.5upstream/5.1.5
Diffstat (limited to 'ext/pgsql')
-rw-r--r-- | ext/pgsql/pgsql.c | 11 | ||||
-rwxr-xr-x | ext/pgsql/tests/80_bug36625.phpt | 49 |
2 files changed, 55 insertions, 5 deletions
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index 92a20ad1c..df233118e 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pgsql.c,v 1.331.2.8 2006/01/01 12:50:12 sniper Exp $ */ +/* $Id: pgsql.c,v 1.331.2.13 2006/04/10 19:51:55 helly Exp $ */ #include <stdlib.h> @@ -257,7 +257,7 @@ ZEND_GET_MODULE(pgsql) static int le_link, le_plink, le_result, le_lofp, le_string; -ZEND_DECLARE_MODULE_GLOBALS(pgsql); +ZEND_DECLARE_MODULE_GLOBALS(pgsql) /* {{{ _php_pgsql_trim_message */ static char * _php_pgsql_trim_message(const char *message, int *len) @@ -1257,7 +1257,7 @@ PHP_FUNCTION(pg_query_params) } otype = (*tmp)->type; - convert_to_string(*tmp); + convert_to_string_ex(tmp); if (Z_TYPE_PP(tmp) != IS_STRING) { php_error_docref(NULL TSRMLS_CC, E_WARNING,"Error converting parameter"); _php_pgsql_free_params(params, num_params); @@ -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; } @@ -4531,6 +4531,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con zend_hash_get_current_data_ex(Z_ARRVAL_P(values), (void **)&val, &pos) == SUCCESS; zend_hash_move_forward_ex(Z_ARRVAL_P(values), &pos)) { skip_field = 0; + new_val = NULL; if ((key_type = zend_hash_get_current_key_ex(Z_ARRVAL_P(values), &field, &field_len, &num_idx, 0, &pos)) == HASH_KEY_NON_EXISTANT) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to get array key type"); @@ -4569,7 +4570,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con if (err) { break; /* break out for() */ } - MAKE_STD_ZVAL(new_val); + ALLOC_INIT_ZVAL(new_val); switch(php_pgsql_get_data_type(Z_STRVAL_PP(type), Z_STRLEN_PP(type))) { case PG_BOOL: diff --git a/ext/pgsql/tests/80_bug36625.phpt b/ext/pgsql/tests/80_bug36625.phpt new file mode 100755 index 000000000..a95cea711 --- /dev/null +++ b/ext/pgsql/tests/80_bug36625.phpt @@ -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=== |