[Phpmyadmin-git] [SCM] phpMyAdmin branch, master, updated. RELEASE_3_4_0BETA2-12-g45eb47f

Marc Delisle lem9 at users.sourceforge.net
Sat Jan 8 19:47:21 CET 2011


The branch, master has been updated
       via  45eb47fe145dae49cdf6d4b4ffc6a2c9ac752223 (commit)
       via  824458981388fbaad52c0e1d11db4c681bf03789 (commit)
      from  5c47f19ce88fad1687f213bfd00cee0cd391acc4 (commit)


- Log -----------------------------------------------------------------
commit 45eb47fe145dae49cdf6d4b4ffc6a2c9ac752223
Merge: 5c47f19ce88fad1687f213bfd00cee0cd391acc4 824458981388fbaad52c0e1d11db4c681bf03789
Author: Marc Delisle <marc at infomarc.info>
Date:   Sat Jan 8 13:45:40 2011 -0500

    Merge branch 'QA_3_3'

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                            |    1 +
 libraries/database_interface.lib.php |    4 ++--
 libraries/dbi/mysql.dbi.lib.php      |   24 +++++++++++++++++++++---
 libraries/dbi/mysqli.dbi.lib.php     |   17 ++++++++++++++---
 libraries/relation.lib.php           |   10 ++++++++--
 tbl_replace.php                      |    2 +-
 6 files changed, 47 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5f20f7c..2f30df3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -134,6 +134,7 @@
   thanks to erickoh75 - erickoh75
 - patch #3150164 [structure] Ordering by size gives incorrect results,
   thanks to Madhura Jayaratne - madhuracj 
+- bug #3153409 [core] 0 row(s) affected 
 
 3.3.9.0 (2011-01-03)
 - bug [doc] Fix references to MySQL doc
diff --git a/libraries/database_interface.lib.php b/libraries/database_interface.lib.php
index 0877dda..012eb7c 100644
--- a/libraries/database_interface.lib.php
+++ b/libraries/database_interface.lib.php
@@ -69,8 +69,8 @@ require_once './libraries/dbi/' . $GLOBALS['cfg']['Server']['extension'] . '.dbi
 /**
  * Common Functions
  */
-function PMA_DBI_query($query, $link = null, $options = 0) {
-    $res = PMA_DBI_try_query($query, $link, $options)
+function PMA_DBI_query($query, $link = null, $options = 0, $cache_affected_rows = true) {
+    $res = PMA_DBI_try_query($query, $link, $options, $cache_affected_rows)
         or PMA_mysqlDie(PMA_DBI_getError($link), $query);
     return $res;
 }
diff --git a/libraries/dbi/mysql.dbi.lib.php b/libraries/dbi/mysql.dbi.lib.php
index c5ff26f..1db4f1e 100644
--- a/libraries/dbi/mysql.dbi.lib.php
+++ b/libraries/dbi/mysql.dbi.lib.php
@@ -154,7 +154,7 @@ function PMA_DBI_select_db($dbname, $link = null)
  * @param integer $options
  * @return mixed
  */
-function PMA_DBI_try_query($query, $link = null, $options = 0)
+function PMA_DBI_try_query($query, $link = null, $options = 0, $cache_affected_rows = true)
 {
     if (empty($link)) {
         if (isset($GLOBALS['userlink'])) {
@@ -175,6 +175,10 @@ function PMA_DBI_try_query($query, $link = null, $options = 0)
         $r = mysql_query($query, $link);
     }
 
+    if ($cache_affected_rows) { 
+       $GLOBALS['cached_affected_rows'] = PMA_DBI_affected_rows($link, $get_from_cache = false); 
+    }
+
     if ($GLOBALS['cfg']['DBG']['sql']) {
         $time = microtime(true) - $time;
 
@@ -398,7 +402,16 @@ function PMA_DBI_insert_id($link = null)
     return PMA_DBI_fetch_value('SELECT LAST_INSERT_ID();', 0, 0, $link);
 }
 
-function PMA_DBI_affected_rows($link = null)
+/**
+ * returns the number of rows affected by last query
+ *
+ * @uses    $GLOBALS['userlink']
+ * @uses    mysql_affected_rows()
+ * @param   object mysql   $link   the mysql object
+ * @param   boolean        $get_from_cache 
+ * @return  string integer
+ */
+function PMA_DBI_affected_rows($link = null, $get_from_cache = true)
 {
     if (empty($link)) {
         if (isset($GLOBALS['userlink'])) {
@@ -407,7 +420,12 @@ function PMA_DBI_affected_rows($link = null)
             return false;
         }
     }
-    return mysql_affected_rows($link);
+
+    if ($get_from_cache) {
+        return $GLOBALS['cached_affected_rows'];
+    } else {
+        return mysql_affected_rows($link);
+    }
 }
 
 /**
diff --git a/libraries/dbi/mysqli.dbi.lib.php b/libraries/dbi/mysqli.dbi.lib.php
index e027f23..8022c77 100644
--- a/libraries/dbi/mysqli.dbi.lib.php
+++ b/libraries/dbi/mysqli.dbi.lib.php
@@ -172,9 +172,10 @@ function PMA_DBI_select_db($dbname, $link = null)
  * @param   string          $query      query to execute
  * @param   object mysqli   $link       mysqli object
  * @param   integer         $options
+ * @param   boolean         $cache_affected_rows
  * @return  mixed           true, false or result object
  */
-function PMA_DBI_try_query($query, $link = null, $options = 0)
+function PMA_DBI_try_query($query, $link = null, $options = 0, $cache_affected_rows = true)
 {
     if ($options == ($options | PMA_DBI_QUERY_STORE)) {
         $method = MYSQLI_STORE_RESULT;
@@ -196,6 +197,11 @@ function PMA_DBI_try_query($query, $link = null, $options = 0)
         $time = microtime(true);
     }
     $r = mysqli_query($link, $query, $method);
+
+    if ($cache_affected_rows) { 
+       $GLOBALS['cached_affected_rows'] = PMA_DBI_affected_rows($link, $get_from_cache = false); 
+    }
+
     if ($GLOBALS['cfg']['DBG']['sql']) {
         $time = microtime(true) - $time;
 
@@ -455,9 +461,10 @@ function PMA_DBI_insert_id($link = '')
  * @uses    $GLOBALS['userlink']
  * @uses    mysqli_affected_rows()
  * @param   object mysqli   $link   the mysqli object
+ * @param   boolean         $get_from_cache 
  * @return  string integer
  */
-function PMA_DBI_affected_rows($link = null)
+function PMA_DBI_affected_rows($link = null, $get_from_cache = true)
 {
     if (empty($link)) {
         if (isset($GLOBALS['userlink'])) {
@@ -466,7 +473,11 @@ function PMA_DBI_affected_rows($link = null)
             return false;
         }
     }
-    return mysqli_affected_rows($link);
+    if ($get_from_cache) {
+        return $GLOBALS['cached_affected_rows'];
+    } else {
+        return mysqli_affected_rows($link);
+    }
 }
 
 /**
diff --git a/libraries/relation.lib.php b/libraries/relation.lib.php
index 960e890..18504e2 100644
--- a/libraries/relation.lib.php
+++ b/libraries/relation.lib.php
@@ -22,10 +22,16 @@ if (! defined('PHPMYADMIN')) {
  */
 function PMA_query_as_controluser($sql, $show_error = true, $options = 0)
 {
+    // Avoid caching of the number of rows affected; for example, this function 
+    // is called for tracking purposes but we want to display the correct number
+    // of rows affected by the original query, not by the query generated for
+    // tracking.
+    $cache_affected_rows = false;
+
     if ($show_error) {
-        $result = PMA_DBI_query($sql, $GLOBALS['controllink'], $options);
+        $result = PMA_DBI_query($sql, $GLOBALS['controllink'], $options, $cache_affected_rows);
     } else {
-        $result = @PMA_DBI_try_query($sql, $GLOBALS['controllink'], $options);
+        $result = @PMA_DBI_try_query($sql, $GLOBALS['controllink'], $options, $cache_affected_rows);
     } // end if... else...
 
     if ($result) {
diff --git a/tbl_replace.php b/tbl_replace.php
index f7371ec..7a60ddb 100644
--- a/tbl_replace.php
+++ b/tbl_replace.php
@@ -363,7 +363,7 @@ foreach ($query as $single_query) {
     if (! $result) {
         $error_messages[] = PMA_DBI_getError();
     } else {
-        // the following is a real assignment:
+        // The next line contains a real assignment, it's not a typo
         if ($tmp = @PMA_DBI_affected_rows()) {
             $total_affected_rows += $tmp;
         }


hooks/post-receive
-- 
phpMyAdmin




More information about the Git mailing list