Postgresql 中文操作指南

38.9. Internal Functions #

内部函数是用 C 编写的函数,已经被静态链接到 PostgreSQL 服务器中。函数定义的“主体”指定函数的 C 语言名称,该名称不必与为 SQL 使用而声明的名称相同。(出于向后兼容性的原因,空主体被接受为意味着 C 语言函数名称与 SQL 名称相同。)

Internal functions are functions written in C that have been statically linked into the PostgreSQL server. The “body” of the function definition specifies the C-language name of the function, which need not be the same as the name being declared for SQL use. (For reasons of backward compatibility, an empty body is accepted as meaning that the C-language function name is the same as the SQL name.)

通常,在数据库集群初始化期间声明服务器中存在的所有内部函数(请参见 Section 19.2),但用户可以使用 _CREATE FUNCTION_为内部函数创建其他别名。内部函数在声明为 _CREATE FUNCTION_语言名称 _internal_中。例如,为 _sqrt_函数创建别名:

Normally, all internal functions present in the server are declared during the initialization of the database cluster (see Section 19.2), but a user could use CREATE FUNCTION to create additional alias names for an internal function. Internal functions are declared in CREATE FUNCTION with language name internal. For instance, to create an alias for the sqrt function:

CREATE FUNCTION square_root(double precision) RETURNS double precision
    AS 'dsqrt'
    LANGUAGE internal
    STRICT;

(大多数内部函数都希望能被声明为“严格的”。)

(Most internal functions expect to be declared “strict”.)

Note

并非所有“预定义”函数在这层意义上都属于“内部”函数。一些预定义函数使用 SQL 编写。

Not all “predefined” functions are “internal” in the above sense. Some predefined functions are written in SQL.