]> git.wh0rd.org Git - tt-rss.git/commitdiff
rollback current transaction before trying to report SQL query errors, properly save...
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Fri, 2 Aug 2013 12:20:39 +0000 (16:20 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Fri, 2 Aug 2013 12:20:39 +0000 (16:20 +0400)
classes/db/mysql.php
classes/db/mysqli.php
classes/db/pgsql.php

index aab05aca239a13b4c0ac26c25e7a342d25a758df..d4b45b98c6034516eefb27526d8c3dc71cb55109 100644 (file)
@@ -26,9 +26,12 @@ class Db_Mysql implements IDb {
        }
 
        function query($query, $die_on_error = true) {
-               $result = mysql_query($query, $this->link);
+               $result = @mysql_query($query, $this->link);
                if (!$result) {
-                       user_error("Query $query failed: " . ($this->link ? mysql_error($this->link) : "No connection"),
+                       $error = @mysql_error($this->link);
+
+                       @mysql_query("ROLLBACK", $this->link);
+                       user_error("Query $query failed: " . ($this->link ? $error : "No connection"),
                                $die_on_error ? E_USER_ERROR : E_USER_WARNING);
                }
                return $result;
index a41ebf8ece2fbd4baf93d94e1039812923be8c68..c685b75a02c8e30db2f8d9bdd016b426861e9633 100644 (file)
@@ -24,9 +24,12 @@ class Db_Mysqli implements IDb {
        }
 
        function query($query, $die_on_error = true) {
-               $result = mysqli_query($this->link, $query);
+               $result = @mysqli_query($this->link, $query);
                if (!$result) {
-                       user_error("Query $query failed: " . ($this->link ? mysqli_error($this->link) : "No connection"),
+                       $error = @mysqli_error($this->link);
+
+                       @mysqli_query($this->link, "ROLLBACK");
+                       user_error("Query $query failed: " . ($this->link ? $error : "No connection"),
                                $die_on_error ? E_USER_ERROR : E_USER_WARNING);
                }
 
index 4d860790b1d1da4306eeaf2f125c53b12b04a6c3..ba37f83a6c09273a37d68f7a34993c2400481804 100644 (file)
@@ -35,11 +35,14 @@ class Db_Pgsql implements IDb {
        }
 
        function query($query, $die_on_error = true) {
-               $result = pg_query($query);
+               $result = @pg_query($this->link, $query);
 
                if (!$result) {
+                       $error = @pg_last_error($this->link);
+
+                       @pg_query($this->link, "ROLLBACK");
                        $query = htmlspecialchars($query); // just in case
-                       user_error("Query $query failed: " . ($this->link ? pg_last_error($this->link) : "No connection"),
+                       user_error("Query $query failed: " . ($this->link ? $error : "No connection"),
                                $die_on_error ? E_USER_ERROR : E_USER_WARNING);
                }
                return $result;