pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedwhy schema name is same as username behaves different then others
5+ messages / 3 participants
[nested] [flat]
* why schema name is same as username behaves different then others
@ 2002-12-05 22:49 Jie Liang <jie@stbernard.com>
0 siblings, 2 replies; 5+ messages in thread
From: Jie Liang @ 2002-12-05 22:49 UTC (permalink / raw)
To: Bruce Momjian <pgman@candle.pha.pa.us>; Tom Lane <tgl@sss.pgh.pa.us>; +Cc: 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
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: why schema name is same as username behaves different then others
@ 2002-12-05 22:57 Tom Lane <tgl@sss.pgh.pa.us>
parent: Jie Liang <jie@stbernard.com>
1 sibling, 0 replies; 5+ messages in thread
From: Tom Lane @ 2002-12-05 22:57 UTC (permalink / raw)
To: Jie Liang <jie@stbernard.com>; +Cc: 'Bruce Momjian' <pgman@candle.pha.pa.us>; pgsql-admin
Jie Liang <jie@stbernard.com> writes:
> ####I expect to see something like:
You're neglecting the effects of search path. \dt only shows what's
visible in your search path. (IIRC, \dt *.* is the easiest way to
see all tables regardless of search path.)
> #### it seems if schema name is same as username then
> #### it will shadow the objects in the public schema that have same name.
That's what it's supposed to do, and yes this is documented, and yes
you can change it if you don't like it. Read about search_path.
regards, tom lane
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: why schema name is same as username behaves different
@ 2002-12-05 23:44 Joe Conway <mail@joeconway.com>
parent: Jie Liang <jie@stbernard.com>
1 sibling, 0 replies; 5+ messages in thread
From: Joe Conway @ 2002-12-05 23:44 UTC (permalink / raw)
To: Jie Liang <jie@stbernard.com>; +Cc: Bruce Momjian <pgman@candle.pha.pa.us>; Tom Lane <tgl@sss.pgh.pa.us>; pgsql-admin
Jie Liang wrote:
> ####I expect to see something like:
> List of relations
> Schema | Name | Type | Owner
> --------+------+-------+-------
> public | foo | table | robot
> t | foo | table | robot
That's because schema t is not in your search path. By default,
search path is:
regression=# show search_path ;
search_path
--------------
$user,public
(1 row)
So you are not seeing the table in schema foo. If you do:
regression=# create user robot;
CREATE USER
regression=# create schema t AUTHORIZATION robot;
CREATE SCHEMA
regression=# drop table foo;
DROP TABLE
regression=# create table foo(test text);
CREATE TABLE
regression=# create table t.foo(test text);
CREATE TABLE
regression=# \dt
List of relations
Schema | Name | Type | Owner
--------+--------+-------+----------
public | foo | table | postgres
public | table1 | table | postgres
public | table2 | table | postgres
(3 rows)
regression=# set search_path to 't','public';
SET
regression=# \dt
List of relations
Schema | Name | Type | Owner
--------+--------+-------+----------
public | table1 | table | postgres
public | table2 | table | postgres
t | foo | table | postgres
(3 rows)
The $user in the default search path allows user robot to automatically find
objects in schema robot first.
You can change the default search path for the installation in
postgresql.conf, or you can change in via ALTER DATABASE or ALTER USER to be
effective in just one database or for one user respectively.
HTH,
Joe
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: why schema name is same as username behaves different then ot
@ 2002-12-05 23:45 Jie Liang <jie@stbernard.com>
0 siblings, 0 replies; 5+ messages in thread
From: Jie Liang @ 2002-12-05 23:45 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Bruce Momjian <pgman@candle.pha.pa.us>; pgsql-admin
Got it.
Thank you.
Jie
-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
Sent: Thursday, December 05, 2002 2:58 PM
To: Jie Liang
Cc: 'Bruce Momjian'; pgsql-admin@postgresql.org
Subject: Re: why schema name is same as username behaves different then
others
Jie Liang <jie@stbernard.com> writes:
> ####I expect to see something like:
You're neglecting the effects of search path. \dt only shows what's
visible in your search path. (IIRC, \dt *.* is the easiest way to
see all tables regardless of search path.)
> #### it seems if schema name is same as username then
> #### it will shadow the objects in the public schema that have same name.
That's what it's supposed to do, and yes this is documented, and yes
you can change it if you don't like it. Read about search_path.
regards, tom lane
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: why schema name is same as username behaves different then ot
@ 2002-12-05 23:50 Jie Liang <jie@stbernard.com>
0 siblings, 0 replies; 5+ messages in thread
From: Jie Liang @ 2002-12-05 23:50 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Bruce Momjian <pgman@candle.pha.pa.us>; pgsql-admin
But why shadow happens only schema name is SAME as username??
Jie
-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
Sent: Thursday, December 05, 2002 2:58 PM
To: Jie Liang
Cc: 'Bruce Momjian'; pgsql-admin@postgresql.org
Subject: Re: why schema name is same as username behaves different then
others
Jie Liang <jie@stbernard.com> writes:
> ####I expect to see something like:
You're neglecting the effects of search path. \dt only shows what's
visible in your search path. (IIRC, \dt *.* is the easiest way to
see all tables regardless of search path.)
> #### it seems if schema name is same as username then
> #### it will shadow the objects in the public schema that have same name.
That's what it's supposed to do, and yes this is documented, and yes
you can change it if you don't like it. Read about search_path.
regards, tom lane
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2002-12-05 23:50 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-12-05 22:49 why schema name is same as username behaves different then others Jie Liang <jie@stbernard.com>
2002-12-05 22:57 ` Tom Lane <tgl@sss.pgh.pa.us>
2002-12-05 23:44 ` Re: why schema name is same as username behaves different Joe Conway <mail@joeconway.com>
2002-12-05 23:45 Re: why schema name is same as username behaves different then ot Jie Liang <jie@stbernard.com>
2002-12-05 23:50 Re: why schema name is same as username behaves different then ot Jie Liang <jie@stbernard.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox