]> granicus.if.org Git - php/commitdiff
MFB:
authorIlia Alshanetsky <iliaa@php.net>
Tue, 19 Sep 2006 15:46:25 +0000 (15:46 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Tue, 19 Sep 2006 15:46:25 +0000 (15:46 +0000)
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

ext/pdo/tests/bug_38253.phpt
ext/pdo_pgsql/pgsql_driver.c
ext/pdo_pgsql/pgsql_statement.c

index 713eefb701f103a73851874088b4e7a161f8fb18..6dfdab8df1146099bc39ef66d9a7dbf5becaea80 100644 (file)
@@ -15,7 +15,7 @@ require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
 $pdo = PDOTest::factory();
 
 $pdo->exec ("create table test (id integer primary key, n text)");
-$pdo->exec ("INSERT INTO test (n) VALUES ('hi')");
+$pdo->exec ("INSERT INTO test (id, n) VALUES (1, 'hi')");
 
 $pdo->setAttribute (PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_CLASS);
 $stmt = $pdo->prepare ("SELECT * FROM test");
@@ -25,7 +25,7 @@ var_dump($stmt->fetchAll());
 $pdo = PDOTest::factory();
 
 $pdo->exec ("create table test2 (id integer primary key, n text)");
-$pdo->exec ("INSERT INTO test2 (n) VALUES ('hi')");
+$pdo->exec ("INSERT INTO test2 (id, n) VALUES (1,'hi')");
 
 $pdo->setAttribute (PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_FUNC);
 $stmt = $pdo->prepare ("SELECT * FROM test2");
index 37c8e67144542344773bfbd54c615b9eeca5caac..08edc81f92407976a758cc9940050df40de487bc 100644 (file)
@@ -414,6 +414,7 @@ static int pdo_pgsql_transaction_cmd(const char *cmd, pdo_dbh_t *dbh TSRMLS_DC)
        res = PQexec(H->server, cmd);
 
        if (PQresultStatus(res) != PGRES_COMMAND_OK) {
+               pdo_pgsql_error(dbh, PQresultStatus(res), pdo_pgsql_sqlstate(res));
                ret = 0;
        }
 
index 4a8d4e11764f807a03ce1d19810af716f4fda39c..5d5e4723a09a08dcfdd536d11b80d1bbc63ed0b6 100644 (file)
@@ -55,10 +55,14 @@ static int pgsql_stmt_dtor(pdo_stmt_t *stmt TSRMLS_DC)
                char *q = NULL;
                PGresult *res;
 
-               spprintf(&q, 0, "DEALLOCATE %s", S->stmt_name);
-               res = PQexec(H->server, q);
-               efree(q);
-               if (res) PQclear(res);
+               if (S->is_prepared) {
+                       spprintf(&q, 0, "DEALLOCATE %s", S->stmt_name);
+                       res = PQexec(H->server, q);
+                       efree(q);
+                       if (res) {
+                               PQclear(res);
+                       }
+               }
                efree(S->stmt_name);
                S->stmt_name = NULL;
        }