在PostreSQL中使用REASSIGN OWNED BY的错误

时间:2017-04-01 18:13:13

标签: postgresql postgresql-9.2 ownership

我在postgres 9.2中。文档https://www.postgresql.org/docs/9.2/static/sql-reassign-owned.html声明:REASSIGN OWNED only affects the objects in the current database。正是我需要的,但似乎是假的 此命令还会更改旧用户拥有的所有数据库的所有权。

这是我做的:

  

复制数据库:

$ sudo -u postgres -i
$ createdb -O faire-pp -T vozatou_db1 test_db
postgres=# \l
                              List of databases
    Name     |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
-------------+----------+----------+-------------+-------------+-----------------------
test_db      | faire-pp | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
vozatou_db1  | vozatou  | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
  

新数据库中表的权限是错误的(仍然是旧用户):

postgres=# \c test_db
You are now connected to database "test_db" as user "postgres".
test_db=# \d
                        List of relations
 Schema |                   Name                   |   Type   |  Owner  
--------+------------------------------------------+----------+---------
 public | auth_group                               | table    | vozatou
 public | auth_group_id_seq                        | sequence | vozatou
  

改变它:

test_db=# REASSIGN OWNED BY "vozatou" TO "faire-pp";
REASSIGN OWNED
test_db=# \d
                     List of relations
 Schema |                   Name                   |   Type   |  Owner   
--------+------------------------------------------+----------+----------
 public | auth_group                               | table    | faire-pp
 public | auth_group_id_seq                        | sequence | faire-pp
  

一切看起来都不错,但是:

postgres=# \l
                              List of databases
    Name     |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
-------------+----------+----------+-------------+-------------+-----------------------
test_db      | faire-pp | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
vozatou_db1  | faire-pp | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
  

为什么原始数据库的所有者发生了变化?

文档特别说明:The REASSIGN OWNED command does not affect the ownership of any databases owned by the role.

任何见解?

更新:根据下面的评论问题可能与shared objects有关,我尝试确定与SELECT * FROM pg_shdepend;有关的共享对象是什么,但它没有&# 39;告诉我一些可以利用的东西。

0 个答案:

没有答案