Show results of REPLACE as affected as it contains both deleted and inserted rows count (bug #1475765).

This commit is contained in:
Michal Čihař
2006-04-27 08:48:08 +00:00
parent 15eb10076c
commit 7ad007ccf8
2 changed files with 12 additions and 2 deletions

View File

@@ -9,6 +9,8 @@ $Source$
* Documentation.html, libraries/config.default.php,
libraries/auth/cookie.auth.lib.php: Logout from all servers by default
(RFE #1370874).
* sql.php: Show results of REPLACE as affected as it contains both deleted
and inserted rows count (bug #1475765).
2006-04-26 Michal Čihař <michal@cihar.com>
* libraries/plugin_interface.lib.php:

12
sql.php
View File

@@ -315,7 +315,7 @@ else {
// TODO: detect all this with the parser, to avoid problems finding
// those strings in comments or backquoted identifiers
$is_explain = $is_count = $is_export = $is_delete = $is_insert = $is_affected = $is_show = $is_maint = $is_analyse = $is_group = $is_func = false;
$is_explain = $is_count = $is_export = $is_delete = $is_insert = $is_affected = $is_show = $is_maint = $is_analyse = $is_group = $is_func = $is_replace = false;
if ($is_select) { // see line 141
$is_group = preg_match('@(GROUP[[:space:]]+BY|HAVING|SELECT[[:space:]]+DISTINCT)[[:space:]]+@i', $sql_query);
$is_func = !$is_group && (preg_match('@[[:space:]]+(SUM|AVG|STD|STDDEV|MIN|MAX|BIT_OR|BIT_AND)\s*\(@i', $sql_query));
@@ -330,6 +330,9 @@ else {
} elseif (preg_match('@^(INSERT|LOAD[[:space:]]+DATA|REPLACE)[[:space:]]+@i', $sql_query)) {
$is_insert = true;
$is_affected = true;
if (preg_match('@^(REPLACE)[[:space:]]+@i', $sql_query)) {
$is_replace = true;
}
} elseif (preg_match('@^UPDATE[[:space:]]+@i', $sql_query)) {
$is_affected = true;
} elseif (preg_match('@^SHOW[[:space:]]+@i', $sql_query)) {
@@ -620,7 +623,12 @@ else {
if ($is_delete) {
$message = $strDeletedRows . '&nbsp;' . $num_rows;
} elseif ($is_insert) {
$message = $strInsertedRows . '&nbsp;' . $num_rows;
if ($is_replace) {
/* For replace we get DELETED + INSERTED row count, so we have to call it affected */
$message = $strAffectedRows . '&nbsp;' . $num_rows;
} else {
$message = $strInsertedRows . '&nbsp;' . $num_rows;
}
$insert_id = PMA_DBI_insert_id();
if ($insert_id != 0) {
// insert_id is id of FIRST record inserted in one insert, so if we inserted multiple rows, we had to increment this