9.6 版中的 to_regclass 参数数据类型是什么?
What is to_regclass argument data type in version 9.6?
我用这篇文章检查 table 存在于版本 9.5
中,它工作正常:
do $$
declare v text;
begin
SELECT to_regclass(('some'||'table')::cstring) into v;
raise notice '%', v;
end;
$$ language plpgsql
现在我使用版本 9.6
的另一个(远程)数据库,此代码产生错误:
function to_regclass(cstring) does not exist
那么,postgres 9.6 中 to_regclass()
函数的参数数据类型是什么?
在 Postgres 9.6 中,to_regclass()
的参数是 text
(在早期版本中是 cstring
)。
Make the to_reg*() functions accept type text not cstring (Petr Korobeinikov)
This avoids the need to write an explicit cast in most cases where the argument is not a simple literal constant.
将文本表达式简单转换为 regclass 应该适用于两个版本:
SELECT ('some'||'table')::regclass into v;
我用这篇文章检查 table 存在于版本 9.5
中,它工作正常:
do $$
declare v text;
begin
SELECT to_regclass(('some'||'table')::cstring) into v;
raise notice '%', v;
end;
$$ language plpgsql
现在我使用版本 9.6
的另一个(远程)数据库,此代码产生错误:
function to_regclass(cstring) does not exist
那么,postgres 9.6 中 to_regclass()
函数的参数数据类型是什么?
在 Postgres 9.6 中,to_regclass()
的参数是 text
(在早期版本中是 cstring
)。
Make the to_reg*() functions accept type text not cstring (Petr Korobeinikov)
This avoids the need to write an explicit cast in most cases where the argument is not a simple literal constant.
将文本表达式简单转换为 regclass 应该适用于两个版本:
SELECT ('some'||'table')::regclass into v;