SHOW CREATE LIBRARY [database_name.]library_nameReturns 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:
With the
SHOW_ROUTINEprivilege or the globalSELECTprivilege, the account can see all library properties, including its definition. This means thatSHOW CREATE LIBRARYprints the source code of the library, and all libraries in the Information Schemalibrariestable are visible to this account.With the
CREATE ROUTINE,ALTER ROUTINE, orEXECUTEprivilege granted at a scope that includes the library, the account can see all routine properties except its definition. This means that the associated row inINFORMATION_SCHEMA.LIBRARIESis visible but,SHOW CREATE LIBRARYdoes not print the library's source code.
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”.