Fix #11979 DECLARE not accepted as valid SQL
Signed-off-by: Madhura Jayaratne <madhura.cj@gmail.com>
This commit is contained in:
parent
2fdd232873
commit
176d63f108
3
js/codemirror/addon/lint/sql-lint.js
vendored
3
js/codemirror/addon/lint/sql-lint.js
vendored
@ -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
|
||||
});
|
||||
|
||||
@ -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
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
10
js/rte.js
10
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);
|
||||
|
||||
12
lint.php
12
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));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user