问题
我试图跑\dp heroes
进去,psql
但它立即抛出了以下内容!(heroes
是表名)
ERROR: operator is not unique: unknown || "char"
LINE 16: E' (' || polcmd || E'):'
^
HINT: Could not choose a best candidate operator. You might need to add explicit type casts.
我用谷歌搜索并找到了这些,但我不清楚到底发生了什么!
参考:https://www.postgresql.org/message-id/[email protected]
我试过什么!
尝试使用架构名称访问它也不起作用
\dp public.heroes;
初读时,我认为我必须投射它,但我认为我错了。
\dp heroes::"char";
额外的东西
顺便说一句,这是一个作为 docker 容器运行的 Postgres 实例。
这是它内部生成的查询:
SELECT n.nspname as "Schema",
c.relname as "Name",
CASE c.relkind WHEN 'r' THEN 'table' WHEN 'v' THEN 'view' WHEN 'm' THEN 'materialized view' WHEN 'S' THEN 'sequence' WHEN 'f' THEN 'foreign table' WHEN 'p' THEN 'partitioned table' END as "Type",
pg_catalog.array_to_string(c.relacl, E'\n') AS "Access privileges",
pg_catalog.array_to_string(ARRAY(
SELECT attname || E':\n ' || pg_catalog.array_to_string(attacl, E'\n ')
FROM pg_catalog.pg_attribute a
WHERE attrelid = c.oid AND NOT attisdropped AND attacl IS NOT NULL
), E'\n') AS "Column privileges",
pg_catalog.array_to_string(ARRAY(
SELECT polname
|| CASE WHEN NOT polpermissive THEN
E' (RESTRICTIVE)'
ELSE '' END
|| CASE WHEN polcmd != '*' THEN
E' (' || polcmd || E'):'
ELSE E':'
END
|| CASE WHEN polqual IS NOT NULL THEN
E'\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)
ELSE E''
END
|| CASE WHEN polwithcheck IS NOT NULL THEN
E'\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)
ELSE E''
END || CASE WHEN polroles <> '{0}' THEN
E'\n to: ' || pg_catalog.array_to_string(
ARRAY(
SELECT rolname
FROM pg_catalog.pg_roles
WHERE oid = ANY (polroles)
ORDER BY 1
), E', ')
ELSE E''
END
FROM pg_catalog.pg_policy pol
WHERE polrelid = c.oid), E'\n')
AS "Policies"
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r','v','m','S','f','p')
AND c.relname OPERATOR(pg_catalog.~) '^(heroes)$' COLLATE pg_catalog.default
AND n.nspname OPERATOR(pg_catalog.~) '^(public)$' COLLATE pg_catalog.default
ORDER BY 1, 2;
问题的原因是commit 07eee5a0dc
"char"
将内部数据类型(即 的类型)的类型类别pg_policy.polcmd
从“string”更改为“internal”。因此,运算符的类型解析规则现在需要对后面的查询进行显式转换\dp
。您收到该错误是因为您使用的
psql
是 v14 或更早版本以及 v15 或更新版本的 PostgreSQL 服务器。这种问题是意料之中的;这就是开头的警告psql
: