postgresql-运行子查询不显示用户的结果

发布于 2025-01-31 18:51:50 字数 1341 浏览 1 评论 0原文

我在数据库中有这个用户,此用户只需要读取权限,这里的权限现在拥有的权限:

GRANT USAGE ON SCHEMA myschema TO "user";
GRANT SELECT ON TABLES TO "user";
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA myschema to "user";

如果该查询未显示结果,但是如果我使用admin-user-user向我显示结果:

SELECT "tableA"."tableA_id", "tableA"."first_name", "tableA"."last_name", "brands"."brand_id" AS "brands.brand_id",
"brands->tableB"."door_id" AS "brands.tableB.door_id", "brands->tableB"."agent_id" AS "brands.tableB.agent_id",
"brands->tableB"."tableA_id" AS "brands.tableB.tableA_id", "brands->tableB"."brand_id" AS "brands.tableB.brand_id",
"brands->tableB"."relationship_type" AS "brands.tableB.relationship_type", "agents"."agent_id" AS "agents.agent_id", 
"agents"."relationship_type" AS "agents.relationship_type" 
FROM "myschema"."tableA" AS "tableA" 
INNER JOIN ( "myschema"."tableB" AS "brands->tableB" INNER JOIN "myschema"."brand" AS "brands" ON "brands"."brand_id" = "brands->tableB"."brand_id") ON "tableA"."tableA_id" = "brands->tableB"."tableA_id" AND "brands"."brand_id" = 1 
INNER JOIN "myschema"."tableB" AS "agents" ON "tableA"."tableA_id" = "agents"."tableA_id" AND "agents"."relationship_type" = 'Employee' 
WHERE "tableA"."active" = true ORDER BY "tableA"."first_name" ASC;

任何想法哪个特权需要检查这些数据吗?

问候

i have this user in the database, this user only needs read permissions, here the permissions that has right now:

GRANT USAGE ON SCHEMA myschema TO "user";
GRANT SELECT ON TABLES TO "user";
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA myschema to "user";

If the runs this query didn't show results, but if I use an admin-user show me results:

SELECT "tableA"."tableA_id", "tableA"."first_name", "tableA"."last_name", "brands"."brand_id" AS "brands.brand_id",
"brands->tableB"."door_id" AS "brands.tableB.door_id", "brands->tableB"."agent_id" AS "brands.tableB.agent_id",
"brands->tableB"."tableA_id" AS "brands.tableB.tableA_id", "brands->tableB"."brand_id" AS "brands.tableB.brand_id",
"brands->tableB"."relationship_type" AS "brands.tableB.relationship_type", "agents"."agent_id" AS "agents.agent_id", 
"agents"."relationship_type" AS "agents.relationship_type" 
FROM "myschema"."tableA" AS "tableA" 
INNER JOIN ( "myschema"."tableB" AS "brands->tableB" INNER JOIN "myschema"."brand" AS "brands" ON "brands"."brand_id" = "brands->tableB"."brand_id") ON "tableA"."tableA_id" = "brands->tableB"."tableA_id" AND "brands"."brand_id" = 1 
INNER JOIN "myschema"."tableB" AS "agents" ON "tableA"."tableA_id" = "agents"."tableA_id" AND "agents"."relationship_type" = 'Employee' 
WHERE "tableA"."active" = true ORDER BY "tableA"."first_name" ASC;

Any idea which privileges are need it to check this data?

Regards

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

允世 2025-02-07 18:51:50

缺少权限不会影响查询结果,而是导致“允许拒绝”错误。我知道的例外是

  • 查询inovery_schema视图,仅显示您拥有权限的对象

  • 行级安全

如果有的话,您的问题表明,行级安全性在此处发挥作用。

如果您需要更详细的答案,则必须在问题中添加详细信息。

Missing permissions don't influence the query result, they cause "permission denied" errors. The exceptions I know are

  • queries on information_schema views, which only show objects on which you have permissions

  • row-level security

If anything, your question suggests that row-level security is at play here.

If you need a more detailed answer, you have to add details to the question.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文