Skip to content
Roland edited this page Jul 5, 2013 · 5 revisions

The jserr UDF can be used to check for javascript syntax errors. The signature of the UDF is:

string jserr(string script)

The jserr UDF attempts to compile the argument. It then returns a message string indicating success or failure.

If the argument script could be compiled, the message is Ok. Otherwise, the return value indicates the line and column number as well as a message indicating the type of error.

Example:

mysql> SELECT script, jserr(script) 
     > FROM (
     >       SELECT    'var a = arguments[0];' AS script 
     >       UNION ALL 
     >       SELECT    'var;'
     > ) scripts;
+-----------------------+--------------------------------------------------------+
| script                | jserr(script)                                          |
+-----------------------+--------------------------------------------------------+
| var a = arguments[0]; | Ok.                                                    |
| var;                  | Line 1, columns 3 - 4: SyntaxError: Unexpected token ; |
+-----------------------+--------------------------------------------------------+
2 rows in set (0.02 sec)