Skip to content

fix bug 81343: inconsistent type conversion after closeCursor #7355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
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
10 changes: 2 additions & 8 deletions ext/pdo_pgsql/pgsql_statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ static int pgsql_stmt_execute(pdo_stmt_t *stmt)
return 0;
}

if (!stmt->executed && (!stmt->column_count || S->cols == NULL)) {
stmt->column_count = (int) PQnfields(S->result);
stmt->column_count = (int) PQnfields(S->result);
if (S->cols == NULL) {
S->cols = ecalloc(stmt->column_count, sizeof(pdo_pgsql_column));
}

Expand Down Expand Up @@ -674,12 +674,6 @@ static int pgsql_stmt_get_column_meta(pdo_stmt_t *stmt, zend_long colno, zval *r

static int pdo_pgsql_stmt_cursor_closer(pdo_stmt_t *stmt)
{
pdo_pgsql_stmt *S = (pdo_pgsql_stmt*)stmt->driver_data;

if (S->cols != NULL){
efree(S->cols);
S->cols = NULL;
}
return 1;
}

Expand Down
27 changes: 27 additions & 0 deletions ext/pdo_pgsql/tests/bug81343.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
--TEST--
Bug #81343 pdo_pgsql: Inconsitent boolean conversion after calling closeCursor()
--EXTENSIONS--
pdo
pdo_pgsql
--SKIPIF--
<?php
require __DIR__ . '/config.inc';
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
PDOTest::skip();
?>
--FILE--
<?php
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
$pdo = PDOTest::test_factory(__DIR__ . '/common.phpt');
$pdo->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);
$sth = $pdo->prepare("select false where 2=?");

for ($i = 0; $i < 2; $i++) {
$sth->execute([2]);
var_dump($sth->fetchColumn(0));
$sth->closeCursor();
}
?>
--EXPECT--
bool(false)
bool(false)