Merge remote-tracking branch 'tyron/master'
This commit is contained in:
commit
65aed176dd
49
js/codemirror/mode/mysql/mysql.js
vendored
49
js/codemirror/mode/mysql/mysql.js
vendored
@ -1,11 +1,14 @@
|
||||
CodeMirror.defineMode("mysql", function(config, parserConfig) {
|
||||
var indentUnit = config.indentUnit,
|
||||
keywords = parserConfig.keywords,
|
||||
verbs = parserConfig.verbs,
|
||||
functions = parserConfig.functions,
|
||||
types = parserConfig.types,
|
||||
attributes = parserConfig.attributes,
|
||||
multiLineStrings = parserConfig.multiLineStrings;
|
||||
attributes = parserConfig.attributes,
|
||||
multiLineStrings = parserConfig.multiLineStrings,
|
||||
multiPartKeywords= parserConfig.multiPartKeywords;
|
||||
var isOperatorChar = /[+\-*&%=<>!?:\/|]/;
|
||||
|
||||
function chain(stream, state, f) {
|
||||
state.tokenize = f;
|
||||
return f(stream, state);
|
||||
@ -64,14 +67,35 @@ CodeMirror.defineMode("mysql", function(config, parserConfig) {
|
||||
else {
|
||||
// get the whole word
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
var word = stream.current().toLowerCase();
|
||||
var oldPos = stream.pos;
|
||||
// is it one of the listed verbs?
|
||||
if (verbs && verbs.propertyIsEnumerable(word)) return ret("keyword", "statement-verb");
|
||||
// is it one of the listed keywords?
|
||||
if (keywords && keywords.propertyIsEnumerable(stream.current().toLowerCase())) return ret("keyword", "keyword");
|
||||
if (keywords && keywords.propertyIsEnumerable(word)) return ret("keyword", "keyword");
|
||||
// is it one of the listed functions?
|
||||
if (functions && functions.propertyIsEnumerable(stream.current().toLowerCase())) return ret("keyword", "builtin");
|
||||
if (functions && functions.propertyIsEnumerable(word)) {
|
||||
// All functions begin with '('
|
||||
stream.eatSpace();
|
||||
if(stream.peek() == '(')
|
||||
return ret("keyword", "builtin");
|
||||
// Not func => restore old pos
|
||||
stream.pos = oldPos;
|
||||
}
|
||||
// is it one of the listed types?
|
||||
if (types && types.propertyIsEnumerable(stream.current().toLowerCase())) return ret("keyword", "variable-2");
|
||||
if (types && types.propertyIsEnumerable(word)) return ret("keyword", "variable-2");
|
||||
// is it one of the listed attributes?
|
||||
if (attributes && attributes.propertyIsEnumerable(stream.current().toLowerCase())) return ret("keyword", "variable-3");
|
||||
if (attributes && attributes.propertyIsEnumerable(word)) return ret("keyword", "variable-3");
|
||||
// is it a multipart keyword? (currently only checks 2 word parts)
|
||||
|
||||
stream.eatSpace();
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
var doubleWord = stream.current().toLowerCase();
|
||||
if (multiPartKeywords && multiPartKeywords.propertyIsEnumerable(doubleWord)) return ret("keyword", "keyword");
|
||||
|
||||
// restore old pos
|
||||
stream.pos = oldPos;
|
||||
|
||||
// default: just a "word"
|
||||
return ret("word", "mysql-word");
|
||||
}
|
||||
@ -122,11 +146,14 @@ CodeMirror.defineMode("mysql", function(config, parserConfig) {
|
||||
|
||||
(function() {
|
||||
function keywords(str) {
|
||||
var obj = {}, words = str.split(" ");
|
||||
var obj = {}, words = str;
|
||||
if(typeof str == 'string') words = str.split(" ");
|
||||
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
||||
return obj;
|
||||
}
|
||||
var cKeywords = "accessible add all alter analyze and as asc asensitive before between bigint binary blob both by call cascade case change char character check collate column condition constraint continue convert create cross current_date current_time current_timestamp current_user cursor database databases day_hour day_microsecond day_minute day_second dec decimal declare default delayed delete desc describe deterministic distinct distinctrow div double drop dual each else elseif enclosed escaped exists exit explain false fetch float float4 float8 for force foreign from fulltext grant group having high_priority hour_microsecond hour_minute hour_second if ignore in index infile inner inout insensitive insert int int1 int2 int3 int4 int8 integer interval into is iterate join key keys kill leading leave left like limit linear lines load localtime localtimestamp lock long longblob longtext loop low_priority master_ssl_verify_server_cert match maxvalue mediumblob mediumint mediumtext middleint minute_microsecond minute_second mod modifies natural not no_write_to_binlog null numeric on optimize option optionally or order out outer outfile precision primary procedure purge range read reads read_write real references regexp release rename repeat replace require resignal restrict return revoke right rlike schema schemas second_microsecond select sensitive separator set show signal smallint spatial specific sql sqlexception sqlstate sqlwarning sql_big_result sql_calc_found_rows sql_small_result ssl starting straight_join table terminated then tinyblob tinyint tinytext to trailing trigger true undo union unique unlock unsigned update usage use using utc_date utc_time utc_timestamp values varbinary varchar varcharacter varying when where while with write xor year_month zerofill";
|
||||
var cKeywords = "accessible add all and as asc asensitive before between bigint binary blob both cascade case char character collate column condition constraint continue convert cross current_date current_time current_timestamp current_user cursor database databases day_hour day_microsecond day_minute day_second dec decimal declare default delayed desc deterministic distinct distinctrow div double dual each else elseif enclosed escaped exists exit explain false fetch float float4 float8 for force foreign fulltext from having high_priority hour_microsecond hour_minute hour_second if ignore in index infile inner inout insensitive int int1 int2 int3 int4 int8 integer interval is iterate join key keys leading leave left like limit linear lines localtime localtimestamp long longblob longtext loop low_priority master_ssl_verify_server_cert match maxvalue mediumblob mediumint mediumtext middleint minute_microsecond minute_second mod modifies natural not no_write_to_binlog null numeric on option optionally or out outer outfile precision primary procedure range read reads read_write real references regexp repeat require restrict return right rlike schema schemas second_microsecond sensitive separator smallint spatial specific sql sqlexception sqlstate sqlwarning sql_big_result sql_calc_found_rows sql_small_result ssl starting straight_join table terminated then tinyblob tinyint tinytext to trailing trigger true undo union unique unsigned usage using utc_date utc_time utc_timestamp values varbinary varchar varcharacter varying when where while with write xor year_month zerofill";
|
||||
|
||||
var cVerbs = "alter analyze begin binlog call change check checksum commit create deallocate describe do drop execute flush grant handler install kill load lock optimize cache partition prepare purge release rename repair replace reset resignal revoke rollback savepoint select set signal show start truncate uninstall unlock update use xa";
|
||||
|
||||
var cFunctions = "abs acos adddate addtime aes_decrypt aes_encrypt area asbinary ascii asin astext atan atan2 avg bdmpolyfromtext bdmpolyfromwkb bdpolyfromtext bdpolyfromwkb benchmark bin bit_and bit_count bit_length bit_or bit_xor boundary buffer cast ceil ceiling centroid char character_length charset char_length coalesce coercibility collation compress concat concat_ws connection_id contains conv convert convert_tz convexhull cos cot count crc32 crosses curdate current_date current_time current_timestamp current_user curtime database date datediff date_add date_diff date_format date_sub day dayname dayofmonth dayofweek dayofyear decode default degrees des_decrypt des_encrypt difference dimension disjoint distance elt encode encrypt endpoint envelope equals exp export_set exteriorring extract extractvalue field find_in_set floor format found_rows from_days from_unixtime geomcollfromtext geomcollfromwkb geometrycollection geometrycollectionfromtext geometrycollectionfromwkb geometryfromtext geometryfromwkb geometryn geometrytype geomfromtext geomfromwkb get_format get_lock glength greatest group_concat group_unique_users hex hour if ifnull inet_aton inet_ntoa insert instr interiorringn intersection intersects interval isclosed isempty isnull isring issimple is_free_lock is_used_lock last_day last_insert_id lcase least left length linefromtext linefromwkb linestring linestringfromtext linestringfromwkb ln load_file localtime localtimestamp locate log log10 log2 lower lpad ltrim makedate maketime make_set master_pos_wait max mbrcontains mbrdisjoint mbrequal mbrintersects mbroverlaps mbrtouches mbrwithin md5 microsecond mid min minute mlinefromtext mlinefromwkb mod month monthname mpointfromtext mpointfromwkb mpolyfromtext mpolyfromwkb multilinestring multilinestringfromtext multilinestringfromwkb multipoint multipointfromtext multipointfromwkb multipolygon multipolygonfromtext multipolygonfromwkb name_const now nullif numgeometries numinteriorrings numpoints oct octet_length old_password ord overlaps password period_add period_diff pi point pointfromtext pointfromwkb pointn pointonsurface polyfromtext polyfromwkb polygon polygonfromtext polygonfromwkb position pow power quarter quote radians rand related release_lock repeat replace reverse right round row_count rpad rtrim schema second sec_to_time session_user sha sha1 sign sin sleep soundex space sqrt srid startpoint std stddev stddev_pop stddev_samp strcmp str_to_date subdate substr substring substring_index subtime sum symdifference sysdate system_user tan time timediff timestamp timestampadd timestampdiff time_format time_to_sec touches to_days trim truncate ucase uncompress uncompressed_length unhex unique_users unix_timestamp updatexml upper user utc_date utc_time utc_timestamp uuid variance var_pop var_samp version week weekday weekofyear within x y year yearweek";
|
||||
|
||||
@ -134,11 +161,15 @@ CodeMirror.defineMode("mysql", function(config, parserConfig) {
|
||||
|
||||
var cAttributes = "archive ascii auto_increment bdb berkeleydb binary blackhole csv default example federated heap innobase innodb isam maria memory merge mrg_isam mrg_myisam myisam national ndb ndbcluster precision undefined unicode unsigned varying zerofill";
|
||||
|
||||
var cmultiPartKeywords = ['insert into', 'group by', 'order by', 'delete from'];
|
||||
|
||||
CodeMirror.defineMIME("text/x-mysql", {
|
||||
name: "mysql",
|
||||
keywords: keywords(cKeywords),
|
||||
multiPartKeywords: keywords(cmultiPartKeywords),
|
||||
verbs: keywords(cVerbs),
|
||||
functions: keywords(cFunctions),
|
||||
types: keywords(cTypes),
|
||||
attributes: keywords(cAttributes)
|
||||
});
|
||||
}());
|
||||
}());
|
||||
152
js/functions.js
152
js/functions.js
@ -1617,7 +1617,13 @@ function PMA_createProfilingChart(data, options)
|
||||
},options));
|
||||
}
|
||||
|
||||
// Formats a profiling duration nicely. Used in PMA_createProfilingChart() and server_status.js
|
||||
/**
|
||||
* Formats a profiling duration nicely (in us and ms time). Used in PMA_createProfilingChart() and server_status.js
|
||||
*
|
||||
* @param integer Number to be formatted, should be in the range of microsecond to second
|
||||
* @param integer Acuracy, how many numbers right to the comma should be
|
||||
* @return string The formatted number
|
||||
*/
|
||||
function PMA_prettyProfilingNum(num, acc)
|
||||
{
|
||||
if (!acc) {
|
||||
@ -1635,6 +1641,150 @@ function PMA_prettyProfilingNum(num, acc)
|
||||
return num + 's';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Formats a SQL Query nicely with newlines and indentation. Depends on Codemirror and MySQL Mode!
|
||||
*
|
||||
* @param string Query to be formatted
|
||||
* @return string The formatted query
|
||||
*/
|
||||
function PMA_SQLPrettyPrint(string)
|
||||
{
|
||||
var mode = CodeMirror.getMode({},"text/x-mysql");
|
||||
var stream = new CodeMirror.StringStream(string);
|
||||
var state = mode.startState();
|
||||
var token, tokens = [];
|
||||
var output = '';
|
||||
var tabs = function(cnt) {
|
||||
var ret = '';
|
||||
for (var i=0; i<4*cnt; i++)
|
||||
ret += " ";
|
||||
return ret;
|
||||
};
|
||||
|
||||
// "root-level" statements
|
||||
var statements = {
|
||||
'select': ['select', 'from','on','where','having','limit','order by','group by'],
|
||||
'update': ['update', 'set','where'],
|
||||
'insert into': ['insert into', 'values']
|
||||
};
|
||||
// don't put spaces before these tokens
|
||||
var spaceExceptionsBefore = { ';':true, ',': true, '.': true, '(': true };
|
||||
// don't put spaces after these tokens
|
||||
var spaceExceptionsAfter = { '.': true };
|
||||
|
||||
// Populate tokens array
|
||||
var str='';
|
||||
while (! stream.eol()) {
|
||||
stream.start = stream.pos;
|
||||
token = mode.token(stream, state);
|
||||
if(token != null) {
|
||||
tokens.push([token, stream.current().toLowerCase()]);
|
||||
}
|
||||
}
|
||||
|
||||
var currentStatement = tokens[0][1];
|
||||
|
||||
if(! statements[currentStatement]) {
|
||||
return string;
|
||||
}
|
||||
// Holds all currently opened code blocks (statement, function or generic)
|
||||
var blockStack = [];
|
||||
// Holds the type of block from last iteration (the current is in blockStack[0])
|
||||
var previousBlock;
|
||||
// If a new code block is found, newBlock contains its type for one iteration and vice versa for endBlock
|
||||
var newBlock, endBlock;
|
||||
// How much to indent in the current line
|
||||
var indentLevel = 0;
|
||||
// Holds the "root-level" statements
|
||||
var statementPart, lastStatementPart = statements[currentStatement][0];
|
||||
|
||||
blockStack.unshift('statement');
|
||||
|
||||
// Iterate through every token and format accordingly
|
||||
for (var i = 0; i < tokens.length; i++) {
|
||||
previousBlock = blockStack[0];
|
||||
|
||||
// New block => push to stack
|
||||
if (tokens[i][1] == '(') {
|
||||
if (i < tokens.length - 1 && tokens[i+1][0] == 'statement-verb') {
|
||||
blockStack.unshift(newBlock = 'statement');
|
||||
} else if (i > 0 && tokens[i-1][0] == 'builtin') {
|
||||
blockStack.unshift(newBlock = 'function');
|
||||
} else {
|
||||
blockStack.unshift(newBlock = 'generic');
|
||||
}
|
||||
} else {
|
||||
newBlock = null;
|
||||
}
|
||||
|
||||
// Block end => pop from stack
|
||||
if (tokens[i][1] == ')') {
|
||||
endBlock = blockStack[0];
|
||||
blockStack.shift();
|
||||
} else {
|
||||
endBlock = null;
|
||||
}
|
||||
|
||||
// A subquery is starting
|
||||
if (i > 0 && newBlock == 'statement') {
|
||||
indentLevel++;
|
||||
output += "\n" + tabs(indentLevel) + tokens[i][1] + ' ' + tokens[i+1][1].toUpperCase() + "\n" + tabs(indentLevel + 1);
|
||||
currentStatement = tokens[i+1][1];
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// A subquery is ending
|
||||
if (endBlock == 'statement' && indentLevel > 0) {
|
||||
output += "\n" + tabs(indentLevel);
|
||||
indentLevel--;
|
||||
}
|
||||
|
||||
// One less indentation for statement parts (from, where, order by, etc.) and a newline
|
||||
statementPart = statements[currentStatement].indexOf(tokens[i][1]);
|
||||
if (statementPart != -1) {
|
||||
if (i > 0) output += "\n";
|
||||
output += tabs(indentLevel) + tokens[i][1].toUpperCase();
|
||||
output += "\n" + tabs(indentLevel + 1);
|
||||
lastStatementPart = tokens[i][1];
|
||||
}
|
||||
// Normal indentatin and spaces for everything else
|
||||
else {
|
||||
if (! spaceExceptionsBefore[tokens[i][1]]
|
||||
&& ! (i > 0 && spaceExceptionsAfter[tokens[i-1][1]])
|
||||
&& output.charAt(output.length -1) != ' ' ) {
|
||||
output += " ";
|
||||
}
|
||||
if (tokens[i][0] == 'keyword') {
|
||||
output += tokens[i][1].toUpperCase();
|
||||
} else {
|
||||
output += tokens[i][1];
|
||||
}
|
||||
}
|
||||
|
||||
// split columns in select and 'update set' clauses, but only inside statements blocks
|
||||
if (( lastStatementPart == 'select' || lastStatementPart == 'where' || lastStatementPart == 'set')
|
||||
&& tokens[i][1]==',' && blockStack[0] == 'statement') {
|
||||
|
||||
output += "\n" + tabs(indentLevel + 1);
|
||||
}
|
||||
|
||||
// split conditions in where clauses, but only inside statements blocks
|
||||
if (lastStatementPart == 'where'
|
||||
&& (tokens[i][1]=='and' || tokens[i][1]=='or' || tokens[i][1]=='xor')) {
|
||||
|
||||
if (blockStack[0] == 'statement') {
|
||||
output += "\n" + tabs(indentLevel + 1);
|
||||
}
|
||||
// Todo: Also split and or blocks in newlines & identation++
|
||||
//if(blockStack[0] == 'generic')
|
||||
// output += ...
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* jQuery function that uses jQueryUI's dialogs to confirm with user. Does not
|
||||
* return a jQuery object yet and hence cannot be chained
|
||||
|
||||
@ -170,7 +170,7 @@ $js_messages['strJumpToTable'] = __('Jump to Log table');
|
||||
$js_messages['strNoDataFound'] = __('Log analysed, but no data found in this time span.');
|
||||
|
||||
/* l10n: A collection of available filters */
|
||||
$js_messages['strFilters'] = __('Filters');
|
||||
$js_messages['strFiltersForLogTable'] = __('Log table filter options');
|
||||
/* l10n: Filter as in "Start Filtering" */
|
||||
$js_messages['strFilter'] = __('Filter');
|
||||
$js_messages['strFilterByWordRegexp'] = __('Filter queries by word/regexp:');
|
||||
|
||||
@ -43,6 +43,19 @@ $(function() {
|
||||
},
|
||||
type: "numeric"
|
||||
});
|
||||
|
||||
jQuery.tablesorter.addParser({
|
||||
id: "withinSpanNumber",
|
||||
is: function(s) {
|
||||
return /<span class="original"/.test(s);
|
||||
},
|
||||
format: function(s, table, html) {
|
||||
var res = html.innerHTML.match(/<span(\s*style="display:none;"\s*)?\s*class="original">(.*)?<\/span>/);
|
||||
return (res && res.length >= 3) ? res[2] : 0;
|
||||
},
|
||||
type: "numeric"
|
||||
});
|
||||
|
||||
// faster zebra widget: no row visibility check, faster css class switching, no cssChildRow check
|
||||
jQuery.tablesorter.addWidget({
|
||||
id: "fast-zebra",
|
||||
@ -394,7 +407,7 @@ $(function() {
|
||||
if (word.length == 0) {
|
||||
textFilter = null;
|
||||
}
|
||||
else textFilter = new RegExp("(^|_)" + word, 'i');
|
||||
else textFilter = new RegExp("(^| )" + word, 'i');
|
||||
|
||||
text = word;
|
||||
|
||||
@ -507,7 +520,7 @@ $(function() {
|
||||
sortList: [[0, 0]],
|
||||
widgets: ['fast-zebra'],
|
||||
headers: {
|
||||
1: { sorter: 'fancyNumber' }
|
||||
1: { sorter: 'withinSpanNumber' }
|
||||
}
|
||||
};
|
||||
break;
|
||||
|
||||
@ -9,6 +9,10 @@ $(function() {
|
||||
codemirror_editor = CodeMirror.fromTextArea(elm[0], { lineNumbers: true, matchBrackets: true, indentUnit: 4, mode: "text/x-mysql" });
|
||||
}
|
||||
}
|
||||
// Timepicker is loaded on demand so we need to initialize datetime fields from the 'load log' dialog
|
||||
$('div#logAnalyseDialog .datetimefield').each(function() {
|
||||
PMA_addDatepicker($(this));
|
||||
});
|
||||
|
||||
/**** Monitor charting implementation ****/
|
||||
/* Saves the previous ajax response for differential values */
|
||||
@ -1022,8 +1026,6 @@ $(function() {
|
||||
removeVariables: $('input#removeVariables').prop('checked'),
|
||||
limitTypes: $('input#limitTypes').prop('checked')
|
||||
});
|
||||
|
||||
$('#logAnalyseDialog').find('dateStart,dateEnd').datepicker('destroy');
|
||||
}
|
||||
|
||||
$('#logAnalyseDialog').dialog({
|
||||
@ -1388,7 +1390,7 @@ $(function() {
|
||||
if (logData.numRows > 12) {
|
||||
$('div#logTable').prepend(
|
||||
'<fieldset id="logDataFilter">' +
|
||||
' <legend>' + PMA_messages['strFilters'] + '</legend>' +
|
||||
' <legend>' + PMA_messages['strFiltersForLogTable'] + '</legend>' +
|
||||
' <div class="formelement">' +
|
||||
' <label for="filterQueryText">' + PMA_messages['strFilterByWordRegexp'] + '</label>' +
|
||||
' <input name="filterQueryText" type="text" id="filterQueryText" style="vertical-align: baseline;" />' +
|
||||
@ -1688,33 +1690,18 @@ $(function() {
|
||||
|
||||
return cols;
|
||||
}
|
||||
|
||||
|
||||
/* Opens the query analyzer dialog */
|
||||
function openQueryAnalyzer() {
|
||||
var rowData = $(this).parent().data('query');
|
||||
var query = rowData.argument || rowData.sql_text;
|
||||
|
||||
/* A very basic SQL Formatter. Totally fails in the cases of
|
||||
- Any string appearance containing a MySQL Keyword, surrounded by whitespaces, e.g. WHERE bar = "This where the formatter fails"
|
||||
- Subqueries too probably
|
||||
*/
|
||||
|
||||
// Matches the columns to be selected
|
||||
// .* selector doesn't include whitespace and we have no PCRE_DOTALL modifier, (.|\s)+ crashes Chrome (reported and confirmed),
|
||||
// [^]+ results in JS error in IE8, thus we use [^\0]+ for matching each column since the zero-byte char (hopefully) doesn't appear in column names ;)
|
||||
var sLists = query.match(/SELECT\s+[^\0]+\s+FROM\s+/gi);
|
||||
if (sLists) {
|
||||
for (var i = 0; i < sLists.length; i++) {
|
||||
query = query.replace(sLists[i], sLists[i].replace(/\s*((`|'|"|).*?\1,)\s*/gi, '$1\n\t'));
|
||||
}
|
||||
query = query
|
||||
.replace(/(\s+|^)(SELECT|FROM|WHERE|GROUP BY|HAVING|ORDER BY|LIMIT)(\s+|$)/gi, '\n$2\n\t')
|
||||
.replace(/\s+UNION\s+/gi, '\n\nUNION\n\n')
|
||||
.replace(/\s+(AND)\s+/gi, ' $1\n\t')
|
||||
.trim();
|
||||
}
|
||||
|
||||
query = PMA_SQLPrettyPrint(query);
|
||||
codemirror_editor.setValue(query);
|
||||
// Codemirror is bugged, it doesn't refresh properly sometimes. Following lines seem to fix that
|
||||
setTimeout(function() {
|
||||
codemirror_editor.refresh()
|
||||
},50);
|
||||
|
||||
var profilingChart = null;
|
||||
var dlgBtns = {};
|
||||
|
||||
@ -173,9 +173,20 @@ function editVariable(link)
|
||||
// hide original content
|
||||
$cell.html('<span class="oldContent" style="display:none;">' + $cell.html() + '</span>');
|
||||
// put edit field and save/cancel link
|
||||
$cell.prepend('<table class="serverVariableEditTable" border="0"><tr><td></td><td style="width:100%;"><input type="text" value="' + data + '"/></td></tr</table>');
|
||||
$cell.prepend('<table class="serverVariableEditTable" border="0"><tr><td></td><td style="width:100%;">' +
|
||||
'<input type="text" id="variableEditArea" value="' + data + '" /></td></tr</table>');
|
||||
$cell.find('table td:first').append(mySaveLink);
|
||||
$cell.find('table td:first').append(' ');
|
||||
$cell.find('table td:first').append(myCancelLink);
|
||||
|
||||
// Keyboard shortcuts to the rescue
|
||||
$('input#variableEditArea').focus();
|
||||
$('input#variableEditArea').keydown(function(event) {
|
||||
// Enter key
|
||||
if(event.keyCode == 13) mySaveLink.trigger('click');
|
||||
// Escape key
|
||||
if(event.keyCode == 27) myCancelLink.trigger('click');
|
||||
});
|
||||
});
|
||||
|
||||
return false;
|
||||
|
||||
@ -43,11 +43,26 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
|
||||
switch($_REQUEST['type']) {
|
||||
case 'getval':
|
||||
$varValue = PMA_DBI_fetch_single_row('SHOW GLOBAL VARIABLES WHERE Variable_name="' . PMA_sqlAddslashes($_REQUEST['varName']) . '";', 'NUM');
|
||||
if (isset($VARIABLE_DOC_LINKS[$_REQUEST['varName']][3])
|
||||
&& $VARIABLE_DOC_LINKS[$_REQUEST['varName']][3] == 'byte') {
|
||||
exit(implode(' ', PMA_formatByteDown($varValue[1],3,3)));
|
||||
}
|
||||
exit($varValue[1]);
|
||||
break;
|
||||
|
||||
case 'setval':
|
||||
$value = PMA_sqlAddslashes($_REQUEST['varValue']);
|
||||
if (!is_numeric($value)) $value="'" . $value . "'";
|
||||
$value = $_REQUEST['varValue'];
|
||||
|
||||
if (isset($VARIABLE_DOC_LINKS[$_REQUEST['varName']][3])
|
||||
&& $VARIABLE_DOC_LINKS[$_REQUEST['varName']][3] == 'byte'
|
||||
&& preg_match('/^\s*(\d+(\.\d+)?)\s*(mb|kb|mib|kib|gb|gib)\s*$/i',$value,$matches)) {
|
||||
$exp = array('kb' => 1, 'kib' => 1, 'mb' => 2, 'mib' => 2, 'gb' => 3, 'gib' => 3);
|
||||
$value = floatval($matches[1]) * pow(1024, $exp[strtolower($matches[3])]);
|
||||
} else {
|
||||
$value = PMA_sqlAddslashes($value);
|
||||
}
|
||||
|
||||
if (! is_numeric($value)) $value="'" . $value . "'";
|
||||
|
||||
if (! preg_match("/[^a-zA-Z0-9_]+/", $_REQUEST['varName']) && PMA_DBI_query('SET GLOBAL ' . $_REQUEST['varName'] . ' = ' . $value)) {
|
||||
// Some values are rounded down etc.
|
||||
|
||||
@ -2311,7 +2311,7 @@ span.CodeMirror-selected {
|
||||
.CodeMirror-matchingbracket {color: #0f0 !important;}
|
||||
.CodeMirror-nonmatchingbracket {color: #f22 !important;}
|
||||
|
||||
span.cm-keyword {
|
||||
span.cm-keyword, span.cm-statement-verb {
|
||||
color: <?php echo $GLOBALS['cfg']['SQP']['fmtColor']['alpha_reservedWord']; ?>;
|
||||
}
|
||||
span.cm-variable {
|
||||
|
||||
@ -2727,7 +2727,7 @@ span.CodeMirror-selected {
|
||||
.CodeMirror-matchingbracket {color: #0f0 !important;}
|
||||
.CodeMirror-nonmatchingbracket {color: #f22 !important;}
|
||||
|
||||
span.cm-keyword {
|
||||
span.cm-keyword, span.cm-statement-verb {
|
||||
color: <?php echo $GLOBALS['cfg']['SQP']['fmtColor']['alpha_reservedWord']; ?>;
|
||||
}
|
||||
span.cm-variable {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user