MySQL 支持可加载函数,也就是说,这些函数不是内置的,但可以在运行时加载(无论是在启动期间还是之后)以扩展服务器功能,或者卸载以移除功能。有关可用可加载函数的表格,请参见 第 14.2 节,“可加载函数参考”。可加载函数与内置(本地)函数形成对比,内置函数是作为服务器的一部分实现的,并且始终可用;有关表格,请参见 第 14.1 节,“内置函数和操作符参考”。MySQL supports loadable functions, that is, functions that are not built in but can be loaded at runtime (either during startup or later) to extend server capabilities, or unloaded to remove capabilities. For a table describing the available loadable functions, see Section 14.2, “Loadable Function Reference”. Loadable functions contrast with built-in (native) functions, which are implemented as part of the server and are always available; for a table, see Section 14.1, “Built-In Function and Operator Reference”.
可加载函数以前被称为用户自定义函数(UDF)。这个术语有些不准确,因为“用户自定义”也可以适用于其他类型的函数,例如存储函数(使用 SQL 编写的一种存储对象类型)以及通过修改服务器源代码添加的本地函数。Loadable functions previously were known as user-defined functions (UDFs). That terminology was something of a misnomer because “user-defined” also can apply to other types of functions, such as stored functions (a type of stored object written using SQL) and native functions added by modifying the server source code.
MySQL 发行版包括可加载函数,这些函数全部或部分实现了这些服务器功能:MySQL distributions include loadable functions that implement, in whole or in part, these server capabilities:
组复制使您能够在一组 MySQL 服务器实例之间创建高度可用的分布式 MySQL 服务,内置数据一致性、冲突检测与解决以及组成员管理服务。参见第 20 章,组复制。Group Replication enables you to create a highly available distributed MySQL service across a group of MySQL server instances, with data consistency, conflict detection and resolution, and group membership services all built-in. See Chapter 20, Group Replication.
MySQL 企业版包含基于 OpenSSL 库执行加密操作的功能。参见第 8.6 节,“MySQL 企业加密”。MySQL Enterprise Edition includes functions that perform encryption operations based on the OpenSSL library. See Section 8.6, “MySQL Enterprise Encryption”.
MySQL 企业版包含提供 SQL 级接口以执行掩码和去标识化操作的功能。参见第 8.5 节,“MySQL 企业数据掩码和去标识化”。MySQL Enterprise Edition includes functions that provide an SQL-level API for masking and de-identification operations. See Section 8.5, “MySQL Enterprise Data Masking and De-Identification”.
MySQL 企业版包括审计日志功能,用于监控和记录连接及查询活动。请参见 第 8.4.5 节,“MySQL 企业审计”,以及 第 8.4.6 节,“审计消息组件”。MySQL Enterprise Edition includes audit logging for monitoring and logging of connection and query activity. See Section 8.4.5, “MySQL Enterprise Audit”, and Section 8.4.6, “The Audit Message Component”.
MySQL 企业版包括防火墙功能,实现了应用层防火墙,使数据库管理员能够根据与接受语句模式的匹配来允许或拒绝 SQL 语句的执行。请参见 第 8.4.7 节,“MySQL 企业防火墙”。MySQL Enterprise Edition includes a firewall capability that implements an application-level firewall to enable database administrators to permit or deny SQL statement execution based on matching against patterns for accepted statement. See Section 8.4.7, “MySQL Enterprise Firewall”.
查询重写器会检查 MySQL 服务器接收的语句,并可能在服务器执行之前重写它们。参见 第 7.6.4 节,“重写器查询重写插件”A query rewriter examines statements received by MySQL Server and possibly rewrites them before the server executes them. See Section 7.6.4, “The Rewriter Query Rewrite Plugin”
版本令牌允许创建和同步服务器令牌,应用程序可以使用这些令牌防止访问不正确或过时的数据。参见 第 7.6.6 节,“版本令牌”。Version Tokens enables creation of and synchronization around server tokens that applications can use to prevent accessing incorrect or out-of-date data. See Section 7.6.6, “Version Tokens”.
MySQL Keyring 提供敏感信息的安全存储。参见 第 8.4.4 节,“MySQL Keyring”。The MySQL Keyring provides secure storage for sensitive information. See Section 8.4.4, “The MySQL Keyring”.
锁定服务为应用程序使用提供锁定接口。参见 第 7.6.9.1 节,“锁定服务”。A locking service provides a locking interface for application use. See Section 7.6.9.1, “The Locking Service”.
一个函数提供访问查询属性的功能。参见 第 11.6 节,“查询属性”。A function provides access to query attributes. See Section 11.6, “Query Attributes”.
以下各节介绍了如何安装和卸载可加载函数,以及如何在运行时确定已安装的可加载函数并获取有关它们的信息。The following sections describe how to install and uninstall loadable functions, and how to determine at runtime which loadable functions are installed and obtain information about them.
在某些情况下,可加载函数是通过安装实现该函数的组件来加载的,而不是通过直接加载函数来实现的。有关特定可加载函数的详细信息,请参阅包含该函数的服务器功能的安装说明。In some cases, a loadable function is loaded by installing the component that implements the function, rather than by loading the function directly. For details about a particular loadable function, see the installation instructions for the server feature that includes it.
有关编写可加载函数的信息,请参见 向 MySQL 添加函数。For information about writing loadable functions, see Adding Functions to MySQL.