Tuesday, October 18, 2016

postgresql: Confusing piece of search_path in vcdb.


For some reason, every time I need to look at the tables vc owned, even login in with "vc", I have to perform the following to look for objects in the db. This isn't causing much problem but accessing with Python pyscopg2, it will not find the tables.


set search_path to public, vpx;



vcdb=> select usename, useconfig from pg_user
vcdb-> ;
 usename  |      useconfig
----------+----------------------
 postgres |
 vc       | {search_path=public}
(2 rows)


No matter how I changed the search_path in the postgresql.conf. A fresh login just wouldn't let me find my own tables. Finally, I decided to just let database search_path.


vcdb=> alter database vcdb set search_path to public, vpx, vc, postgres;
ALTER DATABASE
vcdb=> \d
No relations found.
vcdb=> \c vcdb
psql (9.4.9, server 9.2.9)
You are now connected to database "vcdb" as user "vc".
vcdb=> \d
                     List of relations
 Schema |              Name              |   Type   | Owner
--------+--------------------------------+----------+-------
 vpx    | vpx_access                     | table    | vc
 vpx    | vpx_access_seq                 | sequence | vc
 vpx    | vpx_alarm                      | table    | vc
 vpx    | vpx_alarm_action               | table    | vc
 vpx    | vpx_alarm_disabled_actions     | table    | vc
 vpx    | vpx_alarm_expr_comp            | table    | vc
 vpx    | vpx_alarm_expression           | table    | vc
 vpx    | vpx_alarm_repeat_action        | table    | vc
 vpx    | vpx_alarm_runtime              | table    | vc
 vpx    | vpx_alarm_seq                  | sequence | vc
 vpx    | vpx_alarm_state                | table    | vc
 vpx    | vpx_ansfile_seq                | sequence | vc
 vpx    | vpx_array_seq                  | sequence | vc
 vpx    | vpx_binary_data                | table    | vc
 vpx    | vpx_binary_data_seq            | sequence | vc
 vpx    | vpx_bulletin_operation         | table    | vc
 vpx    | vpx_change_tag                 | table    | vc
 vpx    | vpx_change_tag_seq             | sequence | vc
 vpx    | vpx_compliance_status          | table    | vc
 vpx    | vpx_compliance_status_seq      | sequence | vc
 vpx    | vpx_compute_res_failover_host  | table    | vc
 vpx    | vpx_compute_res_user_hb_ds     | table    | vc
 vpx    | vpx_compute_resource           | table    | vc
 vpx    | vpx_compute_resource_das_vm    | table    | vc
 vpx    | vpx_compute_resource_dpm_host  | table    | vc
vcdb=>


postgres=# SELECT r.rolname, d.datname, rs.setconfig
postgres-# FROM   pg_db_role_setting rs
postgres-# LEFT   JOIN pg_roles      r ON r.oid = rs.setrole
postgres-# LEFT   JOIN pg_database   d ON d.oid = rs.setdatabase;
 rolname | datname |                 setconfig
---------+---------+-------------------------------------------
 vc      |         | {"search_path=public, vpx"}
         | vcdb    | {"search_path=public, vpx, vc, postgres"}
(2 rows)




Voila, Everybody can access now!

No comments:

Post a Comment