diff --git a/ChangeLog b/ChangeLog
index f7c9eabc0..35992c683 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,7 @@ $HeadURL$
+ [import] support handling of DELIMITER to mimic mysql CLI, thanks to fb1
- bug #1674914 [structure] changing definition of a TIMESTAMP field
- bug #1615530 [upload] added more specific error message if field upload fails
+- bug #1627210, #1083301, #1482401 [data] warning on duplicate indexes
- [gui] avoid displaying a wide selector in server selection
+ [core] added PMA_fatalError() and made use of it
. [i18n] use generic $strOptions
diff --git a/libraries/tbl_indexes.lib.php b/libraries/tbl_indexes.lib.php
index 93449b8b1..65d1be38d 100644
--- a/libraries/tbl_indexes.lib.php
+++ b/libraries/tbl_indexes.lib.php
@@ -1,8 +1,9 @@
$w_count) {
- if (isset($idx_collection['PRIMARY'][$w_keyname]) && (isset($idx_collection['INDEX'][$w_keyname]) || isset($idx_collection['UNIQUE'][$w_keyname]))) {
- $output .= PMA_index_warning(sprintf($GLOBALS['strIndexWarningPrimary'], htmlspecialchars($w_keyname)), $table);
- } elseif (isset($idx_collection['UNIQUE'][$w_keyname]) && isset($idx_collection['INDEX'][$w_keyname])) {
- $output .= PMA_index_warning(sprintf($GLOBALS['strIndexWarningUnique'], htmlspecialchars($w_keyname)), $table);
- }
+ // count($idx_collection) < 2:
+ // there is no need to check if there less than two indexes
+ if (! is_array($idx_collection) || count($idx_collection) < 2) {
+ return false;
+ }
- foreach ($index_types AS $index_type) {
- if (isset($idx_collection[$index_type][$w_keyname]) && $idx_collection[$index_type][$w_keyname] > 1) {
- $output .= PMA_index_warning(sprintf($GLOBALS['strIndexWarningMultiple'], $index_type, htmlspecialchars($w_keyname)), $table);
+ $indexes = array();
+ foreach ($idx_collection as $index_field) {
+ $indexes[$index_field['Key_name']][$index_field['Column_name']]
+ = $index_field;
+ }
+
+ $output = '';
+
+ // remove last index from stack and ...
+ while ($while_index = array_pop($indexes)) {
+ // ... compare with every remaining index in stack
+ foreach ($indexes as $each_index_name => $each_index) {
+ if (count($while_index) !== count($each_index)) {
+ // number of fields are not equal
+ continue;
}
+
+ // compare some key elements of every column in this two indexes
+ foreach ($each_index as $col_name => $each_index_column) {
+ if (! isset($while_index[$col_name])
+ // the position
+ || $while_index[$col_name]['Seq_in_index'] !== $each_index_column['Seq_in_index']
+ // the order, ASC or DESC
+ || $while_index[$col_name]['Collation'] !== $each_index_column['Collation']
+ // the length
+ || $while_index[$col_name]['Sub_part'] !== $each_index_column['Sub_part']
+ // BTREE or HASH
+ || $while_index[$col_name]['Index_type'] !== $each_index_column['Index_type']) {
+ continue 2;
+ }
+ }
+
+ // did not find any difference
+ // so it makes no sense to have this two equal indexes
+
+ // use first column from index to fetch index name
+ reset($while_index);
+ $first_column = current($while_index);
+
+ $output .= '
';
+
+ // there is no need to check any further indexes if we have already
+ // found that this one has a duplicate
+ continue 2;
}
}
+ if ($output) {
+ $output = '