why schema name is same as username behaves different then others - Mailing list pgsql-admin

From Jie Liang
Subject why schema name is same as username behaves different then others
Date
Msg-id E7E213858379814A9AE48CA6754F5ECB1E192A@mail01.stbernard.com
Whole thread Raw
Responses Re: why schema name is same as username behaves different then others
Re: why schema name is same as username behaves different
List pgsql-admin
Note:
test=# super user postgres
test=> regular user robot
### comments


test=#create schema t AUTHORIZATION robot;
CREATE SCHEMA
test=> select * from pg_namespace ;
  nspname   | nspowner | nspacl
------------+----------+--------
 pg_catalog |        1 | {=U}
 pg_toast   |        1 | {=}
 public     |        1 | {=UC}
 pg_temp_1  |        1 |
 t          |     1045 |

test=> create table foo(test text);
CREATE TABLE
test=> \dt
       List of relations
 Schema | Name | Type  | Owner
--------+------+-------+-------
 public | foo  | table | robot
test=> create table t.foo(test text);
CREATE TABLE
test=> \dt
       List of relations
 Schema | Name | Type  | Owner
--------+------+-------+-------
 public | foo  | table | robot
(1 row)
####I expect to see something like:
       List of relations
 Schema | Name | Type  | Owner
--------+------+-------+-------
 public | foo  | table | robot
 t      | foo  | table | robot

test=> insert into foo values('zzzz');
INSERT 19868125 1
test=> insert into t.foo values('sssss');
INSERT 19868126 1
test=> select * from foo;
 test
------
 zzzz
(1 row)


test=# create schema robot AUTHORIZATION robot;
CREATE SCHEMA
test=> select * from pg_namespace ;
  nspname   | nspowner | nspacl
------------+----------+--------
 pg_catalog |        1 | {=U}
 pg_toast   |        1 | {=}
 public     |        1 | {=UC}
 pg_temp_1  |        1 |
 t          |     1045 |
 robot      |     1045 |
(6 rows)

test=> create table robot.foo(test text);
CREATE TABLE
test=> \dt
       List of relations
 Schema | Name | Type  | Owner
--------+------+-------+-------
 robot  | foo  | table | robot
(1 row)

####I expect to see something like:
       List of relations
 Schema | Name | Type  | Owner
--------+------+-------+-------
 public | foo  | table | robot
 t      | foo  | table | robot
 robot  | foo  | table | robot
#### why it's not?
test=> insert into robot.foo values('xxxxx');
INSERT 19868173 1
test=> select * from foo;
 test
-------
 xxxxx
(1 row)
#### why schema t,robot behave different???
#### it seems if schema name is same as username then
#### it will shadow the objects in the public schema that have same name.
#### I haven't documentation address this yet.

Jie Liang
Software Engineer
St. Bernard Software
16882 W. Bernardo Dr.
San Diego, CA 92127
Tel: 858-524-2134
Fax:858-676-2228
jie@stbernard.com

pgsql-admin by date:

Previous
From: Jie Liang
Date:
Subject: Re: list schema
Next
From: Tom Lane
Date:
Subject: Re: why schema name is same as username behaves different then others