From 7ad007ccf859d38b1f31af2d433c623ef124ecde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Thu, 27 Apr 2006 08:48:08 +0000 Subject: [PATCH] Show results of REPLACE as affected as it contains both deleted and inserted rows count (bug #1475765). --- ChangeLog | 2 ++ sql.php | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index e8d1f38b4..18f57085a 100755 --- a/ChangeLog +++ b/ChangeLog @@ -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ř * libraries/plugin_interface.lib.php: diff --git a/sql.php b/sql.php index a25dbef11..f3dfdbedb 100644 --- a/sql.php +++ b/sql.php @@ -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 . ' ' . $num_rows; } elseif ($is_insert) { - $message = $strInsertedRows . ' ' . $num_rows; + if ($is_replace) { + /* For replace we get DELETED + INSERTED row count, so we have to call it affected */ + $message = $strAffectedRows . ' ' . $num_rows; + } else { + $message = $strInsertedRows . ' ' . $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