The branch, QA_3_3 has been updated
via 824458981388fbaad52c0e1d11db4c681bf03789 (commit)
from 6135612dbb1150c6a0a6287246c8103ee637de93 (commit)
- Log -----------------------------------------------------------------
-----------------------------------------------------------------------
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 6c67957..2831d07 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,7 @@ $HeadURL:
https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyA
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 8da1035..6c321b1 100644
--- a/libraries/database_interface.lib.php
+++ b/libraries/database_interface.lib.php
@@ -79,8 +79,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 bf16114..6aa9c6a 100644
--- a/libraries/dbi/mysql.dbi.lib.php
+++ b/libraries/dbi/mysql.dbi.lib.php
@@ -155,7 +155,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'])) {
@@ -176,6 +176,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;
@@ -402,7 +406,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'])) {
@@ -411,7 +424,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 b064953..f1f037c 100644
--- a/libraries/dbi/mysqli.dbi.lib.php
+++ b/libraries/dbi/mysqli.dbi.lib.php
@@ -175,9 +175,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;
@@ -199,6 +200,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;
@@ -460,9 +466,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'])) {
@@ -471,7 +478,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 6b1ac67..b98fb6a 100644
--- a/libraries/relation.lib.php
+++ b/libraries/relation.lib.php
@@ -29,10 +29,16 @@ require_once './libraries/Table.class.php';
*/
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 a7da0bc..36e5d74 100644
--- a/tbl_replace.php
+++ b/tbl_replace.php
@@ -357,7 +357,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