代码之家  ›  专栏  ›  技术社区  ›  Héctor

无法删除角色,因为即使REVOKE语句成功,它的权限也不会被撤销

  •  0
  • Héctor  · 技术社区  · 8 月前

    我无法从postgres数据库中删除角色。运行DROP ROLE语句会输出以下错误:

    DROP ROLE read_only;
    
    
    SQL Error [2BP01]: ERROR: role "read_only" cannot be dropped because some objects depend on it
      Detail: privileges for table orgs.client
    

    当我尝试从表中撤销这些特权时,revoke语句成功(完全没有错误):

    REVOKE ALL PRIVILEGES ON TABLE orgs.client FROM read_only;
    

    但是,如果我再次尝试删除该角色,我会得到上面相同的错误。

    我不知道为什么REVOKE声明没有按预期工作。或者,它可能正在发挥作用,但问题是另一回事。对如何解决这个问题有什么想法吗?


    输出 \z orgs.client :

                                                               Access privileges
     Schema |  Name  | Type  |                                Access privileges                                | Column privileges | Policies 
    --------+--------+-------+---------------------------------------------------------------------------------+-------------------+----------
     orgs   | client | table | "prisma-beta-gsa@REDACTED"=arwdDxt/"[email protected]"         +|                   | 
            |        |       | REDACTED_dev=arwdDxt/"[email protected]"                       +|                   | 
            |        |       | landlord=a*r*w*d*D*x*t*/"[email protected]"                    +|                   | 
            |        |       | read_only=r/landlord                                                           +|                   | 
            |        |       | read_write=arwd/landlord                                                       +|                   | 
            |        |       | landlord=a*r*w*d*D*x*t*/costa                                                  +|                   | 
            |        |       | landlord=arwdDxt/landlord                                                      +|                   | 
            |        |       | REDACTED_read_only=r/"[email protected]"                       +|                   | 
            |        |       | REDACTED_read_write=arwdD/"[email protected]"                  +|                   | 
            |        |       | REDACTED_admin=arwdDxt/"[email protected]"                      |                   | 
    
    

    注意:我正在使用托管在Google Cloud SQL实例中的postgres 11。因此,我无法访问超级用户角色。我确实可以访问 postgres 最接近超级用户的用户( docs ).

    1 回复  |  直到 8 月前
        1
  •  1
  •   Laurenz Albe    8 月前

    由于特权是由用户授予的 landlord ,您还应该使用该角色来撤销特权:

    REVOKE SELECT ON orgs.client FROM read_only;