MySQL 9.3 Reference Manual Including MySQL NDB Cluster 9.3

15.7.7.10 SHOW CREATE LIBRARY Statement

SHOW CREATE LIBRARY [database_name.]library_name

Returns the text that can be used to re-create the named JavaScript library in the named database; the database defaults to the current database if one is not specified. See Section 15.1.17, “CREATE LIBRARY Statement”, for more information.

For an account other than the account which created the library, access to routine properties depends on the privileges granted to the account, as described here:

Library code may contain SQL statements (known as a JavaScript SQL callout). The statements are restricted, based on the INVOKER and DEFINER security contexts of the stored program using that library. Such SQL statements follow the usual restrictions applying to stored functions and stored procedures (see Section 27.9, “Restrictions on Stored Programs”).

mysql> SHOW CREATE LIBRARY jslib.lib1\G
*************************** 1. row ***************************
       Library: lib1
      sql_mode: ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,
NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
Create Library: CREATE LIBRARY `lib1`
    LANGUAGE JAVASCRIPT COMMENT "This is lib1"
AS $$
      export function f(n) {
        return n
      }
    $$
1 row in set (0.00 sec)

mysql> SHOW CREATE LIBRARY jslib.lib2\G
*************************** 1. row ***************************
       Library: lib2
      sql_mode: ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,
NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
Create Library: CREATE LIBRARY `lib2`
    LANGUAGE JAVASCRIPT COMMENT "This is lib2"
AS $$
      export function g(n) {
        return n * 2
      }
    $$
1 row in set (0.00 sec)

For further information and examples, see Section 27.3.8, “Using JavaScript Libraries”.