Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions ext/pgsql/pgsql.c
Original file line number Diff line number Diff line change
Expand Up @@ -1923,8 +1923,7 @@ PHP_FUNCTION(pg_fetch_result)
RETURN_THROWS();
}
if (row >= PQntuples(pgsql_result)) {
php_error_docref(NULL, E_WARNING, "Unable to jump to row " ZEND_LONG_FMT " on PostgreSQL result index " ZEND_LONG_FMT,
row, Z_LVAL_P(result));
php_error_docref(NULL, E_WARNING, "Unable to jump to row " ZEND_LONG_FMT, row);
RETURN_FALSE;
}
pgsql_row = (int)row;
Expand Down Expand Up @@ -1972,8 +1971,7 @@ static bool php_pgsql_fetch_hash(zval *return_value, const zval *result, zend_lo

if (!row_is_null) {
if (row >= PQntuples(pgsql_result)) {
php_error_docref(NULL, E_WARNING, "Unable to jump to row " ZEND_LONG_FMT " on PostgreSQL result index " ZEND_LONG_FMT,
row, Z_LVAL_P(result));
php_error_docref(NULL, E_WARNING, "Unable to jump to row " ZEND_LONG_FMT, row);
return false;
}
pgsql_row = (int)row;
Expand Down Expand Up @@ -2312,8 +2310,7 @@ static void php_pgsql_data_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type, bo
RETURN_THROWS();
}
if (row >= PQntuples(pgsql_result)) {
php_error_docref(NULL, E_WARNING, "Unable to jump to row " ZEND_LONG_FMT " on PostgreSQL result index " ZEND_LONG_FMT,
row, Z_LVAL_P(result));
php_error_docref(NULL, E_WARNING, "Unable to jump to row " ZEND_LONG_FMT, row);
RETURN_FALSE;
}
pgsql_row = (int)row;
Expand Down
39 changes: 39 additions & 0 deletions ext/pgsql/tests/pg_error_message_text.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
--TEST--
The row diagnostics print no object address
--EXTENSIONS--
pgsql
--SKIPIF--
<?php include("inc/skipif.inc"); ?>
--FILE--
<?php

include('inc/config.inc');
$table_name = 'table_pg_error_message_text';

$db = pg_connect($conn_str);
pg_query($db, "CREATE TABLE {$table_name} (id INT)");
pg_query($db, "INSERT INTO {$table_name} VALUES (1)");

$result = pg_query($db, "SELECT id FROM {$table_name}");

/* the row is out of range: the warning used to append a result index read
* off the PgSql\Result object zval, which was an address, not an index */
var_dump(pg_fetch_result($result, 99, 0));
var_dump(pg_fetch_row($result, 99));
var_dump(pg_field_prtlen($result, 99, 'id'));
var_dump(pg_field_is_null($result, 99, 'id'));

pg_query($db, "DROP TABLE {$table_name}");
?>
--EXPECTF--
Warning: pg_fetch_result(): Unable to jump to row 99 in %s on line %d
bool(false)

Warning: pg_fetch_row(): Unable to jump to row 99 in %s on line %d
bool(false)

Warning: pg_field_prtlen(): Unable to jump to row 99 in %s on line %d
bool(false)

Warning: pg_field_is_null(): Unable to jump to row 99 in %s on line %d
bool(false)
Loading