Better detection of duplicate rows (bug #1477500).

This commit is contained in:
Michal Čihař
2006-04-27 09:16:32 +00:00
parent 7ad007ccf8
commit 3758013766
2 changed files with 37 additions and 23 deletions

View File

@@ -11,6 +11,8 @@ $Source$
(RFE #1370874).
* sql.php: Show results of REPLACE as affected as it contains both deleted
and inserted rows count (bug #1475765).
* libraries/common.lib.php: Better detection of duplicate rows (bug
#1477500).
2006-04-26 Michal Čihař <michal@cihar.com>
* libraries/plugin_interface.lib.php:

View File

@@ -974,13 +974,24 @@ if (!defined('PMA_MINIMUM_COMMON')) {
// special characters that can become high-ascii after editing,
// depending upon which editor is used by the developer?
$error_table = array();
preg_match('@ALTER\sTABLE\s\`([^\`]+)\`@iu', $the_query, $error_table);
if (preg_match('@ALTER\s*TABLE\s*\`([^\`]+)\`@iu', $the_query, $error_table)) {
$error_table = $error_table[1];
} elseif (preg_match('@INSERT\s*INTO\s*\`([^\`]+)\`@iu', $the_query, $error_table)) {
$error_table = $error_table[1];
} elseif (preg_match('@UPDATE\s*\`([^\`]+)\`@iu', $the_query, $error_table)) {
$error_table = $error_table[1];
} elseif (preg_match('@INSERT\s*\`([^\`]+)\`@iu', $the_query, $error_table)) {
$error_table = $error_table[1];
}
// get fields
$error_fields = array();
preg_match('@\(([^\)]+)\)@i', $the_query, $error_fields);
if (preg_match('@\(([^\)]+)\)@i', $the_query, $error_fields)) {
$error_fields = explode(',', $error_fields[1]);
} elseif (preg_match('@(`[^`]+`)\s*=@i', $the_query, $error_fields)) {
$error_fields = explode(',', $error_fields[1]);
}
if (is_array($error_table) || is_array($error_fields)) {
// duplicate value
$duplicate_value = array();
@@ -1001,6 +1012,7 @@ if (!defined('PMA_MINIMUM_COMMON')) {
.' <input type="submit" name="submit" value="' . $GLOBALS['strBrowse'] . '" />' . "\n"
.' </form>' . "\n";
unset($sql);
}
} // end of show duplicate entry
echo '</div>';