Skip to content

Commit 2332e4f

Browse files
author
Ilia Alshanetsky
committed
Fixed bug #37870 (pgo_pgsql tries to de-allocate unused statements).
Fixed bug #36681 (pdo_pgsql driver incorrectly ignored some errors). Fixed test for bug #38253 not to use faulty SQL that generates errors in PostgreSQL
1 parent db5dc9d commit 2332e4f

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ PHP NEWS
55
(Tony)
66
- Fixed bug #38574 (missing curl constants and improper constant detection).
77
(Ilia)
8+
- Fixed bug #37870 (pgo_pgsql tries to de-allocate unused statements).
9+
(Ilia, ce at netage dot bg)
10+
- Fixed bug #36681 (pdo_pgsql driver incorrectly ignored some errors). (Wez,
11+
Ilia)
812
- Fixed bug #34066 (recursive array_walk causes segfault). (Tony)
913

1014
14 Sep 2006, PHP 5.2.0RC4

ext/pdo/tests/bug_38253.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
1515
$pdo = PDOTest::factory();
1616

1717
$pdo->exec ("create table test (id integer primary key, n text)");
18-
$pdo->exec ("INSERT INTO test (n) VALUES ('hi')");
18+
$pdo->exec ("INSERT INTO test (id, n) VALUES (1, 'hi')");
1919

2020
$pdo->setAttribute (PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_CLASS);
2121
$stmt = $pdo->prepare ("SELECT * FROM test");
@@ -25,7 +25,7 @@ var_dump($stmt->fetchAll());
2525
$pdo = PDOTest::factory();
2626

2727
$pdo->exec ("create table test2 (id integer primary key, n text)");
28-
$pdo->exec ("INSERT INTO test2 (n) VALUES ('hi')");
28+
$pdo->exec ("INSERT INTO test2 (id, n) VALUES (1,'hi')");
2929

3030
$pdo->setAttribute (PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_FUNC);
3131
$stmt = $pdo->prepare ("SELECT * FROM test2");

ext/pdo_pgsql/pgsql_driver.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@ static int pdo_pgsql_transaction_cmd(const char *cmd, pdo_dbh_t *dbh TSRMLS_DC)
472472
res = PQexec(H->server, cmd);
473473

474474
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
475+
pdo_pgsql_error(dbh, PQresultStatus(res), pdo_pgsql_sqlstate(res));
475476
ret = 0;
476477
}
477478

ext/pdo_pgsql/pgsql_statement.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,14 @@ static int pgsql_stmt_dtor(pdo_stmt_t *stmt TSRMLS_DC)
6060
char *q = NULL;
6161
PGresult *res;
6262

63-
spprintf(&q, 0, "DEALLOCATE %s", S->stmt_name);
64-
res = PQexec(H->server, q);
65-
efree(q);
66-
if (res) PQclear(res);
63+
if (S->is_prepared) {
64+
spprintf(&q, 0, "DEALLOCATE %s", S->stmt_name);
65+
res = PQexec(H->server, q);
66+
efree(q);
67+
if (res) {
68+
PQclear(res);
69+
}
70+
}
6771
efree(S->stmt_name);
6872
S->stmt_name = NULL;
6973
}

0 commit comments

Comments
 (0)