diff --git a/ChangeLog b/ChangeLog index e170864cbd..5f04bbb474 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24,6 +24,7 @@ phpMyAdmin - ChangeLog + rfe #1597 Fast filter improvement: remove "x other results found" - bug #4720 No error message on Missing extension mbstring + rfe #801 Builtin transformations and relations ++ rfe #767 USING BTREE support for HEAP/MEMORY tables 4.3.9.0 (not yet released) - bug #4728 Incorrect headings in routine editor diff --git a/js/functions.js b/js/functions.js index df9697df7d..4091ecefac 100644 --- a/js/functions.js +++ b/js/functions.js @@ -3219,10 +3219,10 @@ function checkIndexName(form_id) // Gets the elements pointers var $the_idx_name = $("#input_index_name"); - var $the_idx_type = $("#select_index_type"); + var $the_idx_choice = $("#select_index_choice"); // Index is a primary key - if ($the_idx_type.find("option:selected").val() == 'PRIMARY') { + if ($the_idx_choice.find("option:selected").val() == 'PRIMARY') { $the_idx_name.val('PRIMARY'); $the_idx_name.prop("disabled", true); } diff --git a/js/indexes.js b/js/indexes.js index fbca67e9ac..b1040a7f28 100644 --- a/js/indexes.js +++ b/js/indexes.js @@ -14,6 +14,10 @@ */ function checkIndexType() { + /** + * @var Object Dropdown to select the index choice. + */ + $select_index_choice = $('#select_index_choice'); /** * @var Object Dropdown to select the index type. */ @@ -35,7 +39,7 @@ function checkIndexType() */ $add_more = $('#index_frm .tblFooters'); - if ($select_index_type.val() == 'SPATIAL') { + if ($select_index_choice.val() == 'SPATIAL') { // Disable and hide the size column $size_header.hide(); $size_inputs.each(function () { @@ -78,22 +82,29 @@ function checkIndexType() // Show controllers to add more columns $add_more.show(); } + + if ($select_index_choice.val() == 'SPATIAL' || + $select_index_choice.val() == 'FULLTEXT') { + $select_index_type.val('').prop('disabled', true); + } else { + $select_index_type.prop('disabled', false) + } } /** * Sets current index information into form parameters. * * @param array source_array Array containing index columns - * @param string index_type Type of index + * @param string index_choice Choice of index * * @return void */ -function PMA_setIndexFormParameters(source_array, index_type) +function PMA_setIndexFormParameters(source_array, index_choice) { - if (index_type == 'index') { + if (index_choice == 'index') { $('input[name="indexes"]').val(JSON.stringify(source_array)); } else { - $('input[name="' + index_type + '_indexes"]').val(JSON.stringify(source_array)); + $('input[name="' + index_choice + '_indexes"]').val(JSON.stringify(source_array)); } } @@ -153,12 +164,12 @@ function PMA_removeColumnFromIndex(col_index) * * @param array source_array Array holding corresponding indexes * @param string array_index Index of an INDEX in array - * @param string index_type Type of Index + * @param string index_choice Choice of Index * @param string col_index Index of column on form * * @return void */ -function PMA_addColumnToIndex(source_array, array_index, index_type, col_index) +function PMA_addColumnToIndex(source_array, array_index, index_choice, col_index) { // Remove column from other indexes (if any). PMA_removeColumnFromIndex(col_index); @@ -179,20 +190,20 @@ function PMA_addColumnToIndex(source_array, array_index, index_type, col_index) source_array[array_index] = { 'Key_name': index_name, 'Index_comment': index_comment, - 'Index_type': index_type.toUpperCase(), + 'Index_choice': index_choice.toUpperCase(), 'columns': columns }; // Update index details on form. $('select[name="field_key[' + col_index + ']"]') - .attr('data-index', index_type + ',' + array_index); - PMA_setIndexFormParameters(source_array, index_type.toLowerCase()); + .attr('data-index', index_choice + ',' + array_index); + PMA_setIndexFormParameters(source_array, index_choice.toLowerCase()); } /** * Get choices list for a column to create a composite index with. * - * @param string index_type Type of index + * @param string index_choice Choice of index * @param array source_array Array hodling columns for particular index * * @return jQuery Object @@ -288,7 +299,7 @@ function PMA_showAddIndexDialog(source_array, array_index, target_columns, col_i PMA_addColumnToIndex( source_array, array_index, - index.Index_type, + index.Index_choice, col_index ); } else { @@ -354,21 +365,21 @@ function PMA_showAddIndexDialog(source_array, array_index, target_columns, col_i * Creates a advanced index type selection dialog. * * @param array source_array Array holding a particular type of indexes - * @param string index_type Type of index + * @param string index_choice Choice of index * @param string col_index Index of new column on form * * @return void */ -function PMA_indexTypeSelectionDialog(source_array, index_type, col_index) +function PMA_indexTypeSelectionDialog(source_array, index_choice, col_index) { - var $single_column_radio = $('' + ''); var $composite_index_radio = $('' + + ' name="index_choice">' + ''); var $dialog_content = $('
'); - $dialog_content.append('' + index_type.toUpperCase() + ''); + $dialog_content.append('' + index_choice.toUpperCase() + ''); // For UNIQUE/INDEX type, show choice for single-column and composite index. @@ -380,8 +391,8 @@ function PMA_indexTypeSelectionDialog(source_array, index_type, col_index) button_options[PMA_messages.strGo] = function () { if ($('#single_column').is(':checked')) { var index = { - 'Key_name': (index_type == 'primary' ? 'PRIMARY' : ''), - 'Index_type': index_type.toUpperCase() + 'Key_name': (index_choice == 'primary' ? 'PRIMARY' : ''), + 'Index_choice': index_choice.toUpperCase() }; PMA_showAddIndexDialog(source_array, (source_array.length), [col_index], col_index, index); } @@ -458,7 +469,7 @@ function PMA_indexTypeSelectionDialog(source_array, index_type, col_index) * Unbind all event handlers before tearing down a page */ AJAX.registerTeardown('indexes.js', function () { - $(document).off('change', '#select_index_type'); + $(document).off('change', '#select_index_choice'); $(document).off('click', 'a.drop_primary_key_index_anchor.ajax'); $(document).off('click', "#table_index tbody tr td.edit_index.ajax, #indexes .add_index.ajax"); $(document).off('click', '#index_frm input[type=submit]'); @@ -483,7 +494,7 @@ AJAX.registerOnload('indexes.js', function () { checkIndexType(); checkIndexName("index_frm"); - $(document).on('change', '#select_index_type', function (event) { + $(document).on('change', '#select_index_choice', function (event) { event.preventDefault(); checkIndexType(); checkIndexName("index_frm"); @@ -596,19 +607,19 @@ AJAX.registerOnload('indexes.js', function () { // Index of column on Table edit and create page. var col_index = /\d/.exec($(this).attr('name')); col_index = col_index[0]; - // Type of selected index. - var index_type = /[a-z]+/.exec($(this).val()); - index_type = index_type[0]; + // Choice of selected index. + var index_choice = /[a-z]+/.exec($(this).val()); + index_choice = index_choice[0]; // Array containing corresponding indexes. var source_array = null; - if (index_type == 'none') { + if (index_choice == 'none') { PMA_removeColumnFromIndex(col_index); return false; } // Select a source array. - switch (index_type) { + switch (index_choice) { case 'primary': source_array = primary_indexes; break; @@ -625,12 +636,12 @@ AJAX.registerOnload('indexes.js', function () { if (source_array.length === 0) { var index = { - 'Key_name': (index_type == 'primary' ? 'PRIMARY' : ''), - 'Index_type': index_type.toUpperCase() + 'Key_name': (index_choice == 'primary' ? 'PRIMARY' : ''), + 'Index_choice': index_choice.toUpperCase() }; PMA_showAddIndexDialog(source_array, 0, [col_index], col_index, index); } else { - if (index_type == 'primary') { + if (index_choice == 'primary') { var array_index = 0; var source_length = source_array[array_index].columns.length; var target_columns = []; @@ -643,7 +654,7 @@ AJAX.registerOnload('indexes.js', function () { source_array[array_index]); } else { // If there are multiple columns selected for an index, show advanced dialog. - PMA_indexTypeSelectionDialog(source_array, index_type, col_index); + PMA_indexTypeSelectionDialog(source_array, index_choice, col_index); } } }); diff --git a/libraries/Index.class.php b/libraries/Index.class.php index 9917473750..e4b366d4c7 100644 --- a/libraries/Index.class.php +++ b/libraries/Index.class.php @@ -47,7 +47,7 @@ class PMA_Index private $_columns = array(); /** - * The index method used (BTREE, SPATIAL, FULLTEXT, HASH, RTREE). + * The index method used (BTREE, HASH, RTREE). * * @var string */ @@ -290,16 +290,22 @@ class PMA_Index if (isset($params['Packed'])) { $this->_packed = $params['Packed']; } - if ('PRIMARY' == $this->_name) { - $this->_choice = 'PRIMARY'; - } elseif ('FULLTEXT' == $this->_type) { - $this->_choice = 'FULLTEXT'; - } elseif ('SPATIAL' == $this->_type) { - $this->_choice = 'SPATIAL'; - } elseif ('0' == $this->_non_unique) { - $this->_choice = 'UNIQUE'; + if (isset($params['Index_choice'])) { + $this->_choice = $params['Index_choice']; } else { - $this->_choice = 'INDEX'; + if ('PRIMARY' == $this->_name) { + $this->_choice = 'PRIMARY'; + } elseif ('FULLTEXT' == $this->_type) { + $this->_choice = 'FULLTEXT'; + $this->_type = ''; + } elseif ('SPATIAL' == $this->_type) { + $this->_choice = 'SPATIAL'; + $this->_type = ''; + } elseif ('0' == $this->_non_unique) { + $this->_choice = 'UNIQUE'; + } else { + $this->_choice = 'INDEX'; + } } } @@ -350,7 +356,7 @@ class PMA_Index } /** - * Returns index type ((BTREE, SPATIAL, FULLTEXT, HASH, RTREE) + * Returns index type (BTREE, HASH, RTREE) * * @return string index type */ @@ -385,14 +391,31 @@ class PMA_Index ); } + /** + * Returns a lit of all index types + * + * @return string[] index types + */ + static public function getIndexTypes() + { + return array( + 'BTREE', + 'HASH' + ); + } + /** * Returns HTML for the index choice selector * + * @param boolean $edit_table whether this is table editing + * * @return string HTML for the index choice selector */ - public function generateIndexSelector() + public function generateIndexChoiceSelector($edit_table) { - $html_options = ''; + $html_options = ''; return $html_options; } + /** + * Returns HTML for the index type selector + * + * @return string HTML for the index type selector + */ + public function generateIndexTypeSelector() + { + $types = array("" => "--"); + foreach (PMA_Index::getIndexTypes() as $type) { + $types[$type] = $type; + } + + return PMA_Util::getDropdown( + "index[Index_type]", $types, + $this->_type, "select_index_type" + ); + } + /** * Returns how the index is packed * @@ -637,9 +679,13 @@ class PMA_Index . htmlspecialchars($index->getName()) . ''; } - $r .= '' - . htmlspecialchars($index->getType()) - . ''; + $r .= ''; + if (! empty($index->getType())) { + $r .= htmlspecialchars($index->getType()); + } else { + $r .= htmlspecialchars($index->getChoice()); + } + $r .= ''; $r .= '' . $index->isUnique(true) . ''; $r .= '' . $index->isPacked(true) . ''; @@ -691,7 +737,7 @@ class PMA_Index $data = array( // 'Non_unique' => $this->_non_unique, 'Packed' => $this->_packed, - 'Index_type' => $this->_type, + 'Index_choice' => $this->_choice, ); foreach ($this->_columns as $column) { diff --git a/libraries/create_addfield.lib.php b/libraries/create_addfield.lib.php index 25ee55f9da..d40376caa8 100644 --- a/libraries/create_addfield.lib.php +++ b/libraries/create_addfield.lib.php @@ -121,14 +121,14 @@ function PMA_setColumnCreationStatementSuffix($current_field_num, * Create relevant index statements * * @param array $index an array of index columns - * @param string $index_type index type that which represents + * @param string $index_choice index choice that which represents * the index type of $indexed_fields * @param boolean $is_create_tbl true if requirement is to get the statement * for table creation * * @return array an array of sql statements for indexes */ -function PMA_buildIndexStatements($index, $index_type, +function PMA_buildIndexStatements($index, $index_choice, $is_create_tbl = true ) { $statement = array(); @@ -143,7 +143,7 @@ function PMA_buildIndexStatements($index, $index_type, . (! empty($field['size']) ? '(' . $field['size'] . ')' : ''); } $statement[] = PMA_getStatementPrefix($is_create_tbl) - . ' ' . $index_type + . ' ' . $index_choice . (! empty($index['Key_name']) && $index['Key_name'] != 'PRIMARY' ? PMA_Util::backquote($index['Key_name']) : '') diff --git a/libraries/tbl_indexes.lib.php b/libraries/tbl_indexes.lib.php index 7b11e1e27f..5ab354d4b2 100644 --- a/libraries/tbl_indexes.lib.php +++ b/libraries/tbl_indexes.lib.php @@ -109,7 +109,7 @@ function PMA_getSqlQueryForIndexCreateOrEdit($db, $table, $index, &$error) } // end if // Builds the new one - switch ($index->getType()) { + switch ($index->getChoice()) { case 'PRIMARY': if ($index->getName() == '') { $index->setName('PRIMARY'); @@ -127,7 +127,7 @@ function PMA_getSqlQueryForIndexCreateOrEdit($db, $table, $index, &$error) if ($index->getName() == 'PRIMARY') { $error = PMA_Message::error(__('Can\'t rename index to PRIMARY!')); } - $sql_query .= ' ADD ' . $index->getType() . ' ' + $sql_query .= ' ADD ' . $index->getChoice() . ' ' . ($index->getName() ? PMA_Util::backquote($index->getName()) : ''); break; } // end switch @@ -146,6 +146,14 @@ function PMA_getSqlQueryForIndexCreateOrEdit($db, $table, $index, &$error) $sql_query .= ' (' . implode(', ', $index_fields) . ')'; } + // specifying index type is allowed only for primary, unique and index only + if ($index->getChoice() != 'SPATIAL' + && $index->getChoice() != 'FULLTEXT' + && in_array($index->getType(), PMA_Index::getIndexTypes()) + ) { + $sql_query .= ' USING ' . $index->getType(); + } + $sql_query .= " COMMENT '" . PMA_Util::sqlAddSlashes($index->getComment()) . "'"; @@ -292,6 +300,18 @@ function PMA_getHtmlForIndexForm($fields, $index, $form_params, $add_fields) . 'onfocus="this.select()" />' . ''; + $html .= '
' + . '
' + . '' + . '' + . '' + . '
' + . $index->generateIndexChoiceSelector(isset($_REQUEST['create_edit_table'])) + . '
'; + $html .= '
' . '
' . '' @@ -301,10 +321,7 @@ function PMA_getHtmlForIndexForm($fields, $index, $form_params, $add_fields) . '' . '' . '
' - . '' + . $index->generateIndexTypeSelector() . '
'; $html .= '
'; @@ -336,9 +353,9 @@ function PMA_getHtmlForIndexForm($fields, $index, $form_params, $add_fields) $html .= '