diff --git a/ChangeLog b/ChangeLog index c45fb47b00..7772061e7f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -83,6 +83,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 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 275466cc60..ddcfc5636b 100644 --- a/js/functions.js +++ b/js/functions.js @@ -213,11 +213,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 @@ -237,6 +238,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 ce3a696a71..ca2f6d4d6c 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 93aae29cd2..73a3b289df 100644 --- a/lint.php +++ b/lint.php @@ -31,4 +31,16 @@ PMA\libraries\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(Linter::lint($sql_query));