我有一个使用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_size_class '转换为TEXT
没有帮助。hstore扩展存在于数据库中,我已经给了"inl-trigger"特权的hstore类型:
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操作符?
模式hstore所需的使用已安装到:
GRANT USAGE ON SCHEMA public TO "inl-trigger";