我有一个使用hstore收集表更改的日志表。类似于:
CREATE TABLE "gt_wells"."log_edits" (
"well_gid" SERIAL
, "modified_by" TEXT
, "edit" HSTORE
);
其中“edit”是记录的前一个值和新值之间的差异。这一切都按预期工作。
我想选择编辑特定列的行,因此使用具有超级用户权限的登录角色我可以成功运行:
SELECT DISTINCT "well_gid"
FROM "gt_wells"."log_edits"
WHERE "edit" ? 'full_sized_class;
但是当我从另一个角色运行它时,我得到一个未知的运算符错误:
SET ROLE "inl-trigger";
SELECT DISTINCT "well_gid"
FROM "gt_wells"."log_edits"
WHERE "edit" ? 'full_sized_class' AND "modified_by" != 'inl-trigger';
RESET ROLE;
Error : ERROR: operator does not exist: public.hstore ? unknown
LINE 3: WHERE "edit" ? 'full_sized_class' AND "modified_by" != 'inl-...
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
将'full_sized_class'投射到TEXT
无济于事。数据库中存在hstore扩展,我给hstore类型提供了“inl-trigger”权限:
CREATE EXTENSION hstore;
Error : ERROR: extension "hstore" already exists
GRANT ALL ON TYPE hstore TO "inl-trigger";
Affected rows : 0, Time: 0.00sec
如果我使用“inl-trigger”超级用户,一切都按预期工作。那么我失去了什么特权?为什么“inl-trigger”不能使用hstore运算符?
答案 0 :(得分:0)
架构hstore上的所需用法已安装到:
GRANT USAGE ON SCHEMA public TO "inl-trigger";