Summary
MySQL 9.0 added JavaScript stored programs: CREATE FUNCTION ... LANGUAGE JAVASCRIPT AS $$ ... $$ (and same for CREATE PROCEDURE). Marino does not recognise the LANGUAGE characteristic or the $$ ... $$ body delimiter.
MySQL version
Introduced in MySQL 9.0 (community parses the syntax; the language component itself ships in MySQL Enterprise / HeatWave).
Current state in marino
grep -in 'LANGUAGE JAVASCRIPT\|JAVASCRIPT' parser/parser.y parser/keywords.go returns no matches. The current routine-characteristics list does not accept LANGUAGE other than the SQL/2003-standard LANGUAGE SQL (if at all).
Example SQL
CREATE FUNCTION js_add(a INT, b INT) RETURNS INT
LANGUAGE JAVASCRIPT
DETERMINISTIC
NO SQL
AS $$
return a + b;
$$;
CREATE PROCEDURE js_log(IN msg VARCHAR(255))
LANGUAGE JAVASCRIPT
AS $$
console.log(msg);
$$;
The body delimiter can be any matching $tag$ ... $tag$ pair:
CREATE FUNCTION js_q(s VARCHAR(64)) RETURNS VARCHAR(128)
LANGUAGE JAVASCRIPT
DETERMINISTIC
NO SQL
AS $body$
return "got: " + s.replace(/'/g, "''");
$body$;
Validation
CREATE FUNCTION ... LANGUAGE JAVASCRIPT ... AS $$ ... $$; parses against MySQL 9.2.0 Community. (The community build returns ER_LANGUAGE_COMPONENT_NOT_AVAILABLE when the function is invoked; that is the runtime, not the parser, rejecting it.)
Notes for the implementer
- Add
LANGUAGE (already a keyword in some grammars), JAVASCRIPT as keywords.
- Lexer changes: recognise
$tag$ ... $tag$ dollar-quoted strings as the routine body when preceded by AS in a CREATE FUNCTION/PROCEDURE with LANGUAGE JAVASCRIPT. The opening tag may be empty ($$) or alphanumeric ($body$).
- Routine AST: add a
Language characteristic (SQL / JAVASCRIPT) and a raw-body string for non-SQL bodies.
- Also enables PREPARE/EXECUTE of event DDL (preparable as of MySQL 9.0).
- Reference: https://dev.mysql.com/doc/refman/9.2/en/create-procedure.html
Summary
MySQL 9.0 added JavaScript stored programs:
CREATE FUNCTION ... LANGUAGE JAVASCRIPT AS $$ ... $$(and same forCREATE PROCEDURE). Marino does not recognise theLANGUAGEcharacteristic or the$$ ... $$body delimiter.MySQL version
Introduced in MySQL 9.0 (community parses the syntax; the language component itself ships in MySQL Enterprise / HeatWave).
Current state in marino
grep -in 'LANGUAGE JAVASCRIPT\|JAVASCRIPT' parser/parser.y parser/keywords.goreturns no matches. The current routine-characteristics list does not acceptLANGUAGEother than the SQL/2003-standardLANGUAGE SQL(if at all).Example SQL
The body delimiter can be any matching
$tag$ ... $tag$pair:Validation
CREATE FUNCTION ... LANGUAGE JAVASCRIPT ... AS $$ ... $$;parses against MySQL 9.2.0 Community. (The community build returnsER_LANGUAGE_COMPONENT_NOT_AVAILABLEwhen the function is invoked; that is the runtime, not the parser, rejecting it.)Notes for the implementer
LANGUAGE(already a keyword in some grammars),JAVASCRIPTas keywords.$tag$ ... $tag$dollar-quoted strings as the routine body when preceded byASin aCREATE FUNCTION/PROCEDUREwithLANGUAGE JAVASCRIPT. The opening tag may be empty ($$) or alphanumeric ($body$).Languagecharacteristic (SQL/JAVASCRIPT) and a raw-body string for non-SQL bodies.