From 176d63f10851ec2dd4331ac6aa03453ca417c8ee Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Thu, 18 Feb 2016 15:55:56 +1100 Subject: [PATCH 1/2] Fix #11979 DECLARE not accepted as valid SQL Signed-off-by: Madhura Jayaratne --- js/codemirror/addon/lint/sql-lint.js | 3 ++- js/functions.js | 10 ++++++---- js/rte.js | 10 +++++++++- lint.php | 12 ++++++++++++ 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/js/codemirror/addon/lint/sql-lint.js b/js/codemirror/addon/lint/sql-lint.js index 0a1f396f4b..92b30f2702 100644 --- a/js/codemirror/addon/lint/sql-lint.js +++ b/js/codemirror/addon/lint/sql-lint.js @@ -31,7 +31,8 @@ CodeMirror.sqlLint = function(text, updateLinting, options, cm) { data: { sql_query: text, token: PMA_commonParams.get('token'), - server: PMA_commonParams.get('server') + server: PMA_commonParams.get('server'), + options: options.lintOptions, }, success: handleResponse }); diff --git a/js/functions.js b/js/functions.js index 52c959d01f..edf8f457eb 100644 --- a/js/functions.js +++ b/js/functions.js @@ -116,11 +116,12 @@ function PMA_handleRedirectAndReload(data) { /** * Creates an SQL editor which supports auto completing etc. * - * @param $textarea jQuery object wrapping the textarea to be made the editor - * @param options optional options for CodeMirror - * @param resize optional resizing ('vertical', 'horizontal', 'both') + * @param $textarea jQuery object wrapping the textarea to be made the editor + * @param options optional options for CodeMirror + * @param resize optional resizing ('vertical', 'horizontal', 'both') + * @param lintOptions additional options for lint */ -function PMA_getSQLEditor($textarea, options, resize) { +function PMA_getSQLEditor($textarea, options, resize, lintOptions) { if ($textarea.length > 0 && typeof CodeMirror !== 'undefined') { // merge options for CodeMirror @@ -140,6 +141,7 @@ function PMA_getSQLEditor($textarea, options, resize) { lint: { "getAnnotations": CodeMirror.sqlLint, "async": true, + "lintOptions": lintOptions } }); } diff --git a/js/rte.js b/js/rte.js index fcc85d7b3f..05366a83cd 100644 --- a/js/rte.js +++ b/js/rte.js @@ -15,6 +15,8 @@ var RTE = { */ object: function (type) { $.extend(this, RTE.COMMON); + this.editorType = type; + switch (type) { case 'routine': $.extend(this, RTE.ROUTINE); @@ -58,6 +60,10 @@ RTE.COMMON = { * the jQueryUI dialog buttons */ buttonOptions: {}, + /** + * @var editorType Type of the editor + */ + editorType: null, /** * Validate editor form fields. */ @@ -360,7 +366,9 @@ RTE.COMMON = { * the Definition textarea. */ var $elm = $('textarea[name=item_definition]').last(); - that.syntaxHiglighter = PMA_getSQLEditor($elm); + var linterOptions = {}; + linterOptions[that.editorType + '_editor'] = true; + that.syntaxHiglighter = PMA_getSQLEditor($elm, {}, null, linterOptions); // Execute item-specific code that.postDialogShow(data); diff --git a/lint.php b/lint.php index 3aee35ba96..0ee1e28e7b 100644 --- a/lint.php +++ b/lint.php @@ -35,4 +35,16 @@ PMA_Response::getInstance()->disable(); PMA_headerJSON(); +if (! empty($_POST['options'])) { + $options = $_POST['options']; + + if (! empty($options['routine_editor'])) { + $sql_query = 'CREATE PROCEDURE `a`() ' . $sql_query; + } elseif (! empty($options['trigger_editor'])) { + $sql_query = 'CREATE TRIGGER `a` AFTER INSERT ON `b` FOR EACH ROW ' . $sql_query; + } elseif (! empty($options['event_editor'])) { + $sql_query = 'CREATE EVENT `a` ON SCHEDULE EVERY MINUTE DO ' . $sql_query; + } +} + echo json_encode(PMA_Linter::lint($sql_query)); From 47ff669fdc0d9b00c50c878dd85b7b27106daf94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 19 Feb 2016 13:33:14 +0100 Subject: [PATCH 2/2] Changelog entry for #11979 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Čihař --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 1a2d3b7cde..45cebabc41 100644 --- a/ChangeLog +++ b/ChangeLog @@ -36,6 +36,7 @@ phpMyAdmin - ChangeLog - issue #11967 Fix PHP error on loading invalid XML or ODS file - issue #11969 Missing confirmation while dropping a view in view_operations.php - issue #11968 Fix export of index comments in SQL +- issue #11979 DECLARE not accepted as valid SQL 4.5.4.1 (2016-01-29) - issue #11892 Error with PMA 4.4.15.3