Merge remote-tracking branch 'origin/QA_4_4' into QA_4_4

This commit is contained in:
Weblate 2015-03-20 17:47:28 +01:00
commit c29f7305b8
3 changed files with 54 additions and 17 deletions

View File

@ -175,6 +175,9 @@ function PMA_addColumnToIndex(source_array, array_index, index_choice, col_index
PMA_removeColumnFromIndex(col_index);
var index_name = $('input[name="index[Key_name]"]').val();
var index_comment = $('input[name="index[Index_comment]"]').val();
var key_block_size = $('input[name="index[Key_block_size]"]').val();
var parser = $('input[name="index[Parser]"]').val();
var index_type = $('select[name="index[Index_type]"]').val();
var columns = [];
$('#index_columns tbody').find('tr').each(function () {
// Get columns in particular order.
@ -191,6 +194,9 @@ function PMA_addColumnToIndex(source_array, array_index, index_choice, col_index
'Key_name': index_name,
'Index_comment': index_comment,
'Index_choice': index_choice.toUpperCase(),
'Key_block_size': key_block_size,
'Parser': parser,
'Index_type': index_type,
'columns': columns
};
@ -631,7 +637,7 @@ AJAX.registerOnload('indexes.js', function () {
*/
$('body').on('change', 'select[name*="field_key"]', function () {
// Index of column on Table edit and create page.
var col_index = /\d/.exec($(this).attr('name'));
var col_index = /\d+/.exec($(this).attr('name'));
col_index = col_index[0];
// Choice of selected index.
var index_choice = /[a-z]+/.exec($(this).val());

View File

@ -136,21 +136,51 @@ function PMA_buildIndexStatements($index, $index_choice,
return $statement;
}
$fields = array();
foreach ($index['columns'] as $field) {
$fields[]
= PMA_Util::backquote($_REQUEST['field_name'][$field['col_index']])
. (! empty($field['size']) ? '(' . $field['size'] . ')' : '');
$sql_query = PMA_getStatementPrefix($is_create_tbl)
. ' ' . $index_choice;
if (! empty($index['Key_name']) && $index['Key_name'] != 'PRIMARY') {
$sql_query .= ' ' . PMA_Util::backquote($index['Key_name']);
}
$statement[] = PMA_getStatementPrefix($is_create_tbl)
. ' ' . $index_choice
. (! empty($index['Key_name']) && $index['Key_name'] != 'PRIMARY' ?
PMA_Util::backquote($index['Key_name'])
: '')
. ' (' . implode(', ', $fields) . ') '
. (! empty($index['Index_comment']) ? 'COMMENT '
. "'" . $index['Index_comment'] . "' " : '');
unset($fields);
$index_fields = array();
foreach ($index['columns'] as $key => $column) {
$index_fields[$key] = PMA_Util::backquote(
$_REQUEST['field_name'][$column['col_index']]
);
if ($column['size']) {
$index_fields[$key] .= '(' . $column['size'] . ')';
}
} // end while
$sql_query .= ' (' . implode(', ', $index_fields) . ')';
$keyBlockSizes = $index['Key_block_size'];
if (! empty($keyBlockSizes)) {
$sql_query .= " KEY_BLOCK_SIZE = "
. PMA_Util::sqlAddSlashes($keyBlockSizes);
}
// specifying index type is allowed only for primary, unique and index only
$type = $index['Index_type'];
if ($index['Index_choice'] != 'SPATIAL'
&& $index['Index_choice'] != 'FULLTEXT'
&& in_array($type, PMA_Index::getIndexTypes())
) {
$sql_query .= ' USING ' . $type;
}
$parser = $index['Parser'];
if ($index['Index_choice'] == 'FULLTEXT' && ! empty($parser)) {
$sql_query .= " WITH PARSER " . PMA_Util::sqlAddSlashes($parser);
}
$comment = $index['Index_comment'];
if (! empty($comment)) {
$sql_query .= " COMMENT '" . PMA_Util::sqlAddSlashes($comment) . "'";
}
$statement[] = $sql_query;
return $statement;
}

View File

@ -323,7 +323,8 @@ function PMA_getHtmlForIndexForm($fields, $index, $form_params, $add_fields)
. '</strong>'
. '</div>'
. '<input type="text" name="index[Key_block_size]" '
. 'id="input_key_block_size" size="30" value="" />'
. 'id="input_key_block_size" size="30" value="'
. htmlspecialchars($index->getKeyBlockSize()) . '" />'
. '</div>';
$html .= '<div>'
@ -347,7 +348,7 @@ function PMA_getHtmlForIndexForm($fields, $index, $form_params, $add_fields)
. '</strong>'
. '</div>'
. '<input type="text" name="index[Parser]" '
. 'id="input_parse" size="30" value="" />'
. 'id="input_parse" size="30" value="' . htmlspecialchars($index->getParser()) . '" />'
. '</div>';
$html .= '<div>'