diff options
Diffstat (limited to 'ext/pgsql')
| -rw-r--r-- | ext/pgsql/config.m4 | 2 | ||||
| -rw-r--r-- | ext/pgsql/pgsql.c | 9 | ||||
| -rw-r--r-- | ext/pgsql/tests/09notice.phpt | 5 | ||||
| -rw-r--r-- | ext/pgsql/tests/80_bug32223.phpt | 6 | ||||
| -rw-r--r-- | ext/pgsql/tests/80_bug32223b.phpt | 6 | ||||
| -rw-r--r-- | ext/pgsql/tests/bug46408.phpt | 26 |
6 files changed, 47 insertions, 7 deletions
diff --git a/ext/pgsql/config.m4 b/ext/pgsql/config.m4 index bddb77a151..13837bd832 100644 --- a/ext/pgsql/config.m4 +++ b/ext/pgsql/config.m4 @@ -3,7 +3,7 @@ dnl $Id$ dnl PHP_ARG_WITH(pgsql,for PostgreSQL support, -[ --with-pgsql[=DIR] Include PostgreSQL support. DIR is the PostgreSQL +[ --with-pgsql[=DIR] Include PostgreSQL support. DIR is the PostgreSQL base install directory or the path to pg_config]) if test "$PHP_PGSQL" != "no"; then diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index f4c4cb37e7..35eb09e584 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -1815,7 +1815,7 @@ PHP_FUNCTION(pg_query_params) } else { zval tmp_val = **tmp; zval_copy_ctor(&tmp_val); - convert_to_string(&tmp_val); + convert_to_cstring(&tmp_val); if (Z_TYPE(tmp_val) != IS_STRING) { php_error_docref(NULL TSRMLS_CC, E_WARNING,"Error converting parameter"); zval_dtor(&tmp_val); @@ -4291,6 +4291,7 @@ PHP_FUNCTION(pg_unescape_bytea) to = (char *)php_pgsql_unescape_bytea((unsigned char*)from, &to_len); #endif if (!to) { + php_error_docref(NULL TSRMLS_CC, E_WARNING,"Invalid parameter"); RETURN_FALSE; } RETVAL_STRINGL(to, to_len, 0); @@ -5438,7 +5439,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con 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) { + if ((key_type = zend_hash_get_current_key_ex(Z_ARRVAL_P(values), &field, &field_len, &num_idx, 0, &pos)) == HASH_KEY_NON_EXISTENT) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to get array key type"); err = 1; } @@ -5446,7 +5447,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con php_error_docref(NULL TSRMLS_CC, E_WARNING, "Accepts only string key for values"); err = 1; } - if (!err && key_type == HASH_KEY_NON_EXISTANT) { + if (!err && key_type == HASH_KEY_NON_EXISTENT) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Accepts only string key for values"); err = 1; } @@ -6204,7 +6205,7 @@ PHP_PGSQL_API int php_pgsql_insert(PGconn *pg_link, const char *table, zval *var zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(var_array), &pos); while ((key_type = zend_hash_get_current_key_ex(Z_ARRVAL_P(var_array), &fld, - &fld_len, &num_idx, 0, &pos)) != HASH_KEY_NON_EXISTANT) { + &fld_len, &num_idx, 0, &pos)) != HASH_KEY_NON_EXISTENT) { if (key_type == HASH_KEY_IS_LONG) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Expects associative array for values to be inserted"); goto cleanup; diff --git a/ext/pgsql/tests/09notice.phpt b/ext/pgsql/tests/09notice.phpt index 67ef262fca..db671016e3 100644 --- a/ext/pgsql/tests/09notice.phpt +++ b/ext/pgsql/tests/09notice.phpt @@ -20,6 +20,9 @@ $db = pg_connect($conn_str); _set_lc_messages(); +$res = pg_query($db, 'SET client_min_messages TO NOTICE;'); +var_dump($res); + pg_query($db, "BEGIN;"); pg_query($db, "BEGIN;"); @@ -33,6 +36,8 @@ echo "pg_last_notice() is Ok\n"; ?> --EXPECTF-- +resource(%d) of type (pgsql result) + Notice: pg_query(): %s already a transaction in progress in %s on line %d %s already a transaction in progress pg_last_notice() is Ok diff --git a/ext/pgsql/tests/80_bug32223.phpt b/ext/pgsql/tests/80_bug32223.phpt index cad5fb3a12..b9bbbf86ed 100644 --- a/ext/pgsql/tests/80_bug32223.phpt +++ b/ext/pgsql/tests/80_bug32223.phpt @@ -37,8 +37,10 @@ begin end; ' LANGUAGE plpgsql;"); - +$res = pg_query($dbh, 'SET client_min_messages TO NOTICE;'); +var_dump($res); $res = pg_query($dbh, 'SELECT test_notice()'); +var_dump($res); $row = pg_fetch_row($res, 0); var_dump($row); pg_free_result($res); @@ -52,6 +54,8 @@ pg_close($dbh); ?> ===DONE=== --EXPECTF-- +resource(%d) of type (pgsql result) +resource(%d) of type (pgsql result) array(1) { [0]=> string(1) "f" diff --git a/ext/pgsql/tests/80_bug32223b.phpt b/ext/pgsql/tests/80_bug32223b.phpt index e79685c43d..418ccfc9ae 100644 --- a/ext/pgsql/tests/80_bug32223b.phpt +++ b/ext/pgsql/tests/80_bug32223b.phpt @@ -37,10 +37,13 @@ begin end; ' LANGUAGE plpgsql;"); +$res = pg_query(dbh, 'SET client_min_messages TO NOTICE;'); +var_dump($res); + function tester() { $res = pg_query(dbh, 'SELECT test_notice()'); $row = pg_fetch_row($res, 0); - var_dump($row); + var_dump($row); pg_free_result($res); if ($row[0] == 'f') { @@ -54,6 +57,7 @@ pg_close(dbh); ?> ===DONE=== --EXPECTF-- +resource(%d) of type (pgsql result) array(1) { [0]=> string(1) "f" diff --git a/ext/pgsql/tests/bug46408.phpt b/ext/pgsql/tests/bug46408.phpt new file mode 100644 index 0000000000..bf84290907 --- /dev/null +++ b/ext/pgsql/tests/bug46408.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #46408 (Locale number format settings can cause pg_query_params to break with numerics) +--SKIPIF-- +<?php +require_once('skipif.inc'); +if (false === setlocale(LC_ALL, 'hr_HR.utf-8', 'hr_HR')) { + echo "skip Locale hr_HR.utf-8 not present"; +} +?> +--FILE-- +<?php + +require_once('config.inc'); + +$dbh = pg_connect($conn_str); +setlocale(LC_ALL, 'hr_HR.utf-8', 'hr_HR'); +echo 3.5.PHP_EOL; +pg_query_params("SELECT $1::numeric", array(3.5)); +pg_close($dbh); + +echo "Done".PHP_EOL; + +?> +--EXPECTF-- +3,5 +Done |
