gpt4 book ai didi

postgresql - 如何检查函数是否不可变?

转载 作者:行者123 更新时间:2023-11-29 11:58:04 25 4
gpt4 key购买 nike

我在 PostgreSQL 文档中没有找到关于 translate() 函数分类的任何信息。它是否被归类为不可变函数?

最佳答案

查询系统目录pg_proc :

provolatile tells whether the function's result depends only on its input arguments, or is affected by outside factors. It is i for “immutable” functions, which always deliver the same result for the same inputs. It is s for “stable” functions, whose results (for fixed inputs) do not change within a scan. It is v for “volatile” functions, whose results might change at any time.

select proname, pronamespace::regnamespace, provolatile
from pg_proc
where proname = 'translate'

proname | pronamespace | provolatile
-----------+--------------+-------------
translate | pg_catalog | i
(1 row)

或者,使用函数 pg_get_functiondef():

select pg_get_functiondef('pg_catalog.translate'::regproc)

pg_get_functiondef
-------------------------------------------------------------------
CREATE OR REPLACE FUNCTION pg_catalog.translate(text, text, text)+
RETURNS text +
LANGUAGE internal +
IMMUTABLE STRICT +
AS $function$translate$function$ +

(1 row)

关于postgresql - 如何检查函数是否不可变?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54452415/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com