[Phpmyadmin-git] [SCM] phpMyAdmin branch, master, updated. RELEASE_3_4_3_2-15828-g65aed17

Michal Čihař nijel at users.sourceforge.net
Fri Aug 19 06:45:43 CEST 2011


The branch, master has been updated
       via  65aed176dd3e2dcb379af23a574b7bce3f412585 (commit)
       via  cfa5ec283fe4993fa8dbcb031a218f43d6cadff8 (commit)
       via  1ca6ea0af2155b1188b0742ac67e49a061ee86ee (commit)
       via  ba21b5f3a24c893506debeb2acffe472c92547ea (commit)
       via  67f396a7b69f06a0c756ed5212470890082a317a (commit)
       via  dd36db9ca9b60da5196303e8a4aaaa0a50e2f177 (commit)
       via  a6638a3c088632e85939afa5681dc79c23cf3725 (commit)
       via  ea96d945265e482bf4cb34fdd3f25117634eada0 (commit)
       via  917aa3e1825e4f86466a3c48c8c27f6cf4eb90ad (commit)
       via  de98961029477e1680805bb82d5d375d87420ebc (commit)
      from  fd60f78d3bfc0822c7a0c13330e9375ab2abfbb9 (commit)


- Log -----------------------------------------------------------------
commit 65aed176dd3e2dcb379af23a574b7bce3f412585
Merge: fd60f78 cfa5ec2
Author: Michal Čihař <michal at cihar.com>
Date:   Fri Aug 19 06:45:07 2011 +0200

    Merge remote-tracking branch 'tyron/master'

commit cfa5ec283fe4993fa8dbcb031a218f43d6cadff8
Author: Tyron Madlener <tyronx at gmail.com>
Date:   Thu Aug 18 22:05:22 2011 +0300

    - Easy editing of byte values using kb,mb,gb
    - Keyboard shortcuts: Enter to save, Escape to cancel

commit 1ca6ea0af2155b1188b0742ac67e49a061ee86ee
Author: Tyron Madlener <tyronx at gmail.com>
Date:   Thu Aug 18 19:21:04 2011 +0300

    Better wording

commit ba21b5f3a24c893506debeb2acffe472c92547ea
Author: Tyron Madlener <tyronx at gmail.com>
Date:   Thu Aug 18 19:11:00 2011 +0300

    Commit 84cc7837f5da69c588f7503da0acc9512ff29619 broke the datetime picker for the monitor loading log dialog

commit 67f396a7b69f06a0c756ed5212470890082a317a
Author: Tyron Madlener <tyronx at gmail.com>
Date:   Thu Aug 18 17:46:40 2011 +0300

    Fix: Correct sorting for status variable values

commit dd36db9ca9b60da5196303e8a4aaaa0a50e2f177
Author: Tyron Madlener <tyronx at gmail.com>
Date:   Thu Aug 18 17:31:27 2011 +0300

    Fix: Incorrect word filter regex for status variables

commit a6638a3c088632e85939afa5681dc79c23cf3725
Merge: ea96d94 676b0cc
Author: Tyron Madlener <tyronx at gmail.com>
Date:   Thu Aug 18 17:22:17 2011 +0300

    Merge remote-tracking branch 'origin/master'

commit ea96d945265e482bf4cb34fdd3f25117634eada0
Merge: 917aa3e 9f476c8
Author: Tyron Madlener <tyronx at gmail.com>
Date:   Thu Aug 18 16:50:45 2011 +0300

    Merge remote-tracking branch 'origin/master'

commit 917aa3e1825e4f86466a3c48c8c27f6cf4eb90ad
Author: Tyron Madlener <tyronx at gmail.com>
Date:   Thu Aug 18 13:37:01 2011 +0300

    SQL Pretty printer: Uppercase for keywords

commit de98961029477e1680805bb82d5d375d87420ebc
Author: Tyron Madlener <tyronx at gmail.com>
Date:   Thu Aug 18 13:16:03 2011 +0300

    SQL pretty printer feature using the codemirror tokenizer. Replaced this with old pretty-printer regexp collection in query analyzer dialog.

-----------------------------------------------------------------------

Summary of changes:
 js/codemirror/mode/mysql/mysql.js       |   49 ++++++++--
 js/functions.js                         |  152 ++++++++++++++++++++++++++++++-
 js/messages.php                         |    2 +-
 js/server_status.js                     |   17 +++-
 js/server_status_monitor.js             |   35 ++-----
 js/server_variables.js                  |   13 +++-
 server_variables.php                    |   19 ++++-
 themes/original/css/theme_right.css.php |    2 +-
 themes/pmahomme/css/theme_right.css.php |    2 +-
 9 files changed, 249 insertions(+), 42 deletions(-)

diff --git a/js/codemirror/mode/mysql/mysql.js b/js/codemirror/mode/mysql/mysql.js
index 657942d..755e3ec 100644
--- a/js/codemirror/mode/mysql/mysql.js
+++ b/js/codemirror/mode/mysql/mysql.js
@@ -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 p eriod_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)
   });
-}());
+}());
\ No newline at end of file
diff --git a/js/functions.js b/js/functions.js
index 54a08d5..92c4caf 100644
--- a/js/functions.js
+++ b/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
diff --git a/js/messages.php b/js/messages.php
index 10beb0a..7bb7bd3 100644
--- a/js/messages.php
+++ b/js/messages.php
@@ -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:');
diff --git a/js/server_status.js b/js/server_status.js
index 08d7679..594e8d9 100644
--- a/js/server_status.js
+++ b/js/server_status.js
@@ -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;
diff --git a/js/server_status_monitor.js b/js/server_status_monitor.js
index fa0f28e..e89f048 100644
--- a/js/server_status_monitor.js
+++ b/js/server_status_monitor.js
@@ -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 = {};
diff --git a/js/server_variables.js b/js/server_variables.js
index 0ca5304..cb4f8c3 100644
--- a/js/server_variables.js
+++ b/js/server_variables.js
@@ -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;
diff --git a/server_variables.php b/server_variables.php
index ca39a5e..4c2086a 100644
--- a/server_variables.php
+++ b/server_variables.php
@@ -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.
diff --git a/themes/original/css/theme_right.css.php b/themes/original/css/theme_right.css.php
index e97b1e9..8f64772 100644
--- a/themes/original/css/theme_right.css.php
+++ b/themes/original/css/theme_right.css.php
@@ -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 {
diff --git a/themes/pmahomme/css/theme_right.css.php b/themes/pmahomme/css/theme_right.css.php
index 914ef0b..25aeadc 100644
--- a/themes/pmahomme/css/theme_right.css.php
+++ b/themes/pmahomme/css/theme_right.css.php
@@ -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 {


hooks/post-receive
-- 
phpMyAdmin




More information about the Git mailing list