]> granicus.if.org Git - php/commitdiff
Fixed bug #36176 (PDO_PGSQL - PDO::exec() does not return number of rows
authorIlia Alshanetsky <iliaa@php.net>
Sun, 29 Jan 2006 17:35:54 +0000 (17:35 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Sun, 29 Jan 2006 17:35:54 +0000 (17:35 +0000)
affected by the operation).

NEWS
ext/pdo_pgsql/pgsql_driver.c

diff --git a/NEWS b/NEWS
index 5e86d36f1891d7dbc476991fef60421f3ece0484..11031d6021261767c4bee3cdd09468dcb04f97a3 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,8 @@ PHP                                                                        NEWS
 - Fixed imagecolorallocate() and imagecolorallocatelapha() to return FALSE
   on error. (Pierre)
 - Fixed bug #36185 (str_rot13(NULL) crash). (Pierre)
+- Fixed bug #36176 (PDO_PGSQL - PDO::exec() does not return number of rows 
+  affected by the operation). (Ilia)
 - Fixed bug #36152 (problems with curl+ssl and pgsql+ssl in same PHP). (Mike)
 - Fixed bug #36148 (unpack("H*hex", $data) is adding an extra character to the 
   end of the string). (Ilia)
index 18b2112c1b276c6da50e7438377195be0aceb1bd..c9fe4b174ef09dbd6292e2f214798b865ae5a539 100644 (file)
@@ -270,23 +270,26 @@ static long pgsql_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len TSRM
 {
        pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data;
        PGresult *res;
+       long ret = 1;
        
        if (!(res = PQexec(H->server, sql))) {
                /* fatal error */
                pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, NULL);
                return -1;
-       } else {
-               ExecStatusType qs = PQresultStatus(res);
-               if (qs != PGRES_COMMAND_OK && qs != PGRES_TUPLES_OK) {
-                       pdo_pgsql_error(dbh, qs, pdo_pgsql_sqlstate(res));
-                       PQclear(res);
-                       return -1;
-               }
-               H->pgoid = PQoidValue(res);
+       }
+       ExecStatusType qs = PQresultStatus(res);
+       if (qs != PGRES_COMMAND_OK && qs != PGRES_TUPLES_OK) {
+               pdo_pgsql_error(dbh, qs, pdo_pgsql_sqlstate(res));
                PQclear(res);
+               return -1;
        }
+       H->pgoid = PQoidValue(res);
+#if HAVE_PQCMDTUPLES
+       ret = atol(PQcmdTuples(res));
+#endif
+       PQclear(res);
 
-       return 1;
+       return ret;
 }
 
 static int pgsql_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquotedlen, char **quoted, int *quotedlen, enum pdo_param_type paramtype TSRMLS_DC)