Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

JavaScript in MariaDB function?

I’ve read today that MySQL can have JavaScript in a store procedure, I’ve tried the following in MariaDB:

CREATE FUNCTION `eventEngine` (bitEID BIGINT) RETURNS BIGINT
LANGUAGE JAVASCRIPT AS $$
    return biEID + 1;
$$;

I’m using HeidiSQL 12.6.0.6765, when I try to execute the script, an error dialog is displayed containing:

SQL Error (1064): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near `JAVASCRIPT AS $$ return biEID + 1` as line 2

I thought since MariaDB seems to be 100% based on MySQL that it might support this functionality or have I done something wrong?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Sorry, MariaDB 10.11 (x64)

Have just upgraded local MariaDB to latest available: 11.5 (x64), still the same error.

>Solution :

MariaDB was forked from MySQL in 2009. Things that Oracle may have added to MySQL (there’s a blog post about JS support being introduced from December 15, 2023) since may not be available in MariaDB, and of course vice versa.

In addition, the blog post says

This is available as a Preview in MySQL Enterprise Edition and can be downloaded via Oracle Technology Network (OTN). MySQL-JavaScript is also available in the MySQL Heatwave cloud service on OCI, AWS and Azure.

and I assume your MariaDB is neither MySQL EE or MySQL Heatwave.

To be clear, the MariaDB manual says, emphasis mine:

LANGUAGE SQL is a standard SQL clause, and it can be used in MariaDB for portability. However that clause has no meaning, because SQL is the only supported language for stored functions.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading