diff --git a/ChangeLog b/ChangeLog index 1ae36962f..6c8985926 100755 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,8 @@ $Source$ * lang/lithuanian: Updated, thanks to Vilius Zigmantas (viliusz). * lang/serbian: utf-8 translations contained no strings, regenerated. * lang/other: Added missing strings. + * libraries/display_tbl.lib.php3: Try to show sorting by indexes only if + it makes sense (bug #829594). 2003-10-20 Michal Cihar * libraries/export/sql.php3: Fix undefined variable for MySQL < 3.23.20 diff --git a/libraries/display_tbl.lib.php3 b/libraries/display_tbl.lib.php3 index 87a2cfa81..d91132a88 100644 --- a/libraries/display_tbl.lib.php3 +++ b/libraries/display_tbl.lib.php3 @@ -482,93 +482,97 @@ if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')) { $unsorted_sql_query = $sql_query; } - // sorting by indexes + // sorting by indexes, only if it makes sense + if (isset($analyzed_sql) && isset($analyzed_sql[0]) && + isset($analyzed_sql[0]['querytype']) && $analyzed_sql[0]['querytype'] == 'SELECT' && + isset($analyzed_sql[0]['table_ref']) && count($analyzed_sql[0]['table_ref']) == 1) { - // grab indexes data: - $local_query = 'SHOW KEYS FROM ' . PMA_backquote($table); - $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0); - $idx_cnt = mysql_num_rows($result); + // grab indexes data: + $local_query = 'SHOW KEYS FROM ' . PMA_backquote($table); + $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0); + $idx_cnt = mysql_num_rows($result); - $prev_index = ''; - for ($i = 0; $i < $idx_cnt; $i++) { - $row = (defined('PMA_IDX_INCLUDED') ? $ret_keys[$i] : PMA_mysql_fetch_array($result)); + $prev_index = ''; + for ($i = 0; $i < $idx_cnt; $i++) { + $row = (defined('PMA_IDX_INCLUDED') ? $ret_keys[$i] : PMA_mysql_fetch_array($result)); - if ($row['Key_name'] != $prev_index ){ - $indexes[] = $row['Key_name']; - $prev_index = $row['Key_name']; - } - $indexes_info[$row['Key_name']]['Sequences'][] = $row['Seq_in_index']; - $indexes_info[$row['Key_name']]['Non_unique'] = $row['Non_unique']; - if (isset($row['Cardinality'])) { - $indexes_info[$row['Key_name']]['Cardinality'] = $row['Cardinality']; - } - // I don't know what does following column mean.... - // $indexes_info[$row['Key_name']]['Packed'] = $row['Packed']; - $indexes_info[$row['Key_name']]['Comment'] = (isset($row['Comment'])) - ? $row['Comment'] - : ''; - $indexes_info[$row['Key_name']]['Index_type'] = (isset($row['Index_type'])) - ? $row['Index_type'] - : ''; + if ($row['Key_name'] != $prev_index ){ + $indexes[] = $row['Key_name']; + $prev_index = $row['Key_name']; + } + $indexes_info[$row['Key_name']]['Sequences'][] = $row['Seq_in_index']; + $indexes_info[$row['Key_name']]['Non_unique'] = $row['Non_unique']; + if (isset($row['Cardinality'])) { + $indexes_info[$row['Key_name']]['Cardinality'] = $row['Cardinality']; + } + // I don't know what does following column mean.... + // $indexes_info[$row['Key_name']]['Packed'] = $row['Packed']; + $indexes_info[$row['Key_name']]['Comment'] = (isset($row['Comment'])) + ? $row['Comment'] + : ''; + $indexes_info[$row['Key_name']]['Index_type'] = (isset($row['Index_type'])) + ? $row['Index_type'] + : ''; - $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Column_name'] = $row['Column_name']; - if (isset($row['Sub_part'])) { - $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Sub_part'] = $row['Sub_part']; - } - } // end while + $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Column_name'] = $row['Column_name']; + if (isset($row['Sub_part'])) { + $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Sub_part'] = $row['Sub_part']; + } + } // end while - // do we have any index? - if (isset($indexes_data)) { + // do we have any index? + if (isset($indexes_data)) { - if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') { - $span = $fields_cnt; - } else { - $span = $num_rows + floor($num_rows/$repeat_cells) + 1; - } - if ($is_display['edit_lnk'] != 'nn') $span++; - if ($is_display['del_lnk'] != 'nn') $span++; - - ?> + if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') { + $span = $fields_cnt; + } else { + $span = $num_rows + floor($num_rows/$repeat_cells) + 1; + } + if ($is_display['edit_lnk'] != 'nn') $span++; + if ($is_display['del_lnk'] != 'nn') $span++; + + ?> - ' . "\n"; - echo PMA_generate_common_hidden_inputs($db, $table, 5); - echo '' . "\n"; - echo '' . "\n"; - echo '' . "\n"; - echo '' . "\n"; - echo '' . "\n"; - echo $GLOBALS['strSortByKey'] . ': ' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo $GLOBALS['strSortByKey'] . ':  '; echo "\n"; - } - echo ''; - echo "\n"; - echo ' '; - echo "\n"; - echo ''; - echo "\n"; - echo ''; - echo "\n"; - ?> + echo ''; + echo "\n"; + echo ''; + echo "\n"; + ?> -