Substract 2 hstore,您可能需要添加显式类型转换

use*_*443 0 postgresql post postgresql-9.1 psql

postgres的文档有hstore - hstore,它从左操作数中删除匹配的对.安装了postgres扩展.

当我尝试

select public.hstore('"x"=>"30", "y"=>"c"') - 
       public.hstore('"x"=>"30","y"=>"fred"')
Run Code Online (Sandbox Code Playgroud)

正在跟随错误

ERROR:  operator does not exist: public.hstore - public.hstore
LINE 3:  select public.hstore('"x"=>"30", "y"=>"c"') - public.hstore...
                                                     ^
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
Run Code Online (Sandbox Code Playgroud)

Cra*_*ger 5

您已将hstore扩展安装到public架构中,而不在您的架构上search_path.要查找类型,您可以对其进行模式限定,但是您没有限定适用于这些类型的- 运算符.

这意味着hstore将找不到运算符定义.你必须:

  • 使用模式验证运营商的资格OPERATOR(public.-);
  • publicsearch_path; 要么
  • 卸载hstore,然后安装到自己的专用模式,它search_path.

模式限定的运算符语法的示例是:

SELECT 1 OPERATOR(pg_catalog.-) 2;
Run Code Online (Sandbox Code Playgroud)