pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #14578: Tables with same name in different schema are not shown with \dt
5+ messages / 5 participants
[nested] [flat]

* BUG #14578: Tables with same name in different schema are not shown with \dt
@ 2017-03-04 14:51 francois@teksol.info
  2017-03-04 15:10 ` Re: BUG #14578: Tables with same name in different schema are not shown with \dt Euler Taveira <euler@timbira.com.br>
  2017-03-04 15:20 ` Re: BUG #14578: Tables with same name in different schema are not shown with \dt Fabien COELHO <coelho@cri.ensmp.fr>
  0 siblings, 2 replies; 5+ messages in thread

From: francois@teksol.info @ 2017-03-04 14:51 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      14578
Logged by:          François Beausoleil
Email address:      francois@teksol.info
PostgreSQL version: 9.6.2
Operating system:   Mac OS 10.11.6
Description:        

In my schema, I happen to have two tables in different schemas with the same
name. PG supports that no problem, but when I listed the tables using \dt
and the search path set to both schemas, I expected to see the two tables.
Sadly, that wasn't the case.

https://gist.github.com/francois/2db220bd197492d02e0b60224a7576ac

-- repro.sql
create schema mybank;
create table public.a();
create table mybank.a();
set search_path to public;
\dt
set search_path to mybank;
\dt
set search_path to mybank, public;
\dt
set search_path to public, mybank;
\dt


-- run
$ psql --no-psqlrc --quiet repro -f b.sql
        List of relations
 Schema | Name | Type  |  Owner
--------+------+-------+----------
 public | a    | table | francois
(1 row)

        List of relations
 Schema | Name | Type  |  Owner
--------+------+-------+----------
 mybank | a    | table | francois
(1 row)

        List of relations
 Schema | Name | Type  |  Owner
--------+------+-------+----------
 mybank | a    | table | francois
(1 row)

        List of relations
 Schema | Name | Type  |  Owner
--------+------+-------+----------
 public | a    | table | francois
(1 row)


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs


^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #14578: Tables with same name in different schema are not shown with \dt
  2017-03-04 14:51 BUG #14578: Tables with same name in different schema are not shown with \dt francois@teksol.info
@ 2017-03-04 15:10 ` Euler Taveira <euler@timbira.com.br>
  2017-03-04 15:17   ` Re: BUG #14578: Tables with same name in different schema are not shown with \dt Tom Lane <tgl@sss.pgh.pa.us>
  2017-03-04 16:33   ` Re: BUG #14578: Tables with same name in different schema are not shown with \dt François Beausoleil <francois@teksol.info>
  1 sibling, 2 replies; 5+ messages in thread

From: Euler Taveira @ 2017-03-04 15:10 UTC (permalink / raw)
  To: francois@teksol.info; pgsql-bugs

On 04-03-2017 11:51, francois@teksol.info wrote:
> In my schema, I happen to have two tables in different schemas with the same
> name. PG supports that no problem, but when I listed the tables using \dt
> and the search path set to both schemas, I expected to see the two tables.
> Sadly, that wasn't the case.
> 
It is not a bug. It is a documented behavior [1].

"An object is said to be visible if its containing schema is in the
search path and no object of the same kind and name appears earlier in
the search path."


[1] https://www.postgresql.org/docs/9.6/static/app-psql.html


-- 
   Euler Taveira                   Timbira - http://www.timbira.com.br/
   PostgreSQL: Consultoria, Desenvolvimento, Suporte 24x7 e Treinamento


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #14578: Tables with same name in different schema are not shown with \dt
  2017-03-04 14:51 BUG #14578: Tables with same name in different schema are not shown with \dt francois@teksol.info
  2017-03-04 15:10 ` Re: BUG #14578: Tables with same name in different schema are not shown with \dt Euler Taveira <euler@timbira.com.br>
@ 2017-03-04 15:17   ` Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 0 replies; 5+ messages in thread

From: Tom Lane @ 2017-03-04 15:17 UTC (permalink / raw)
  To: Euler Taveira <euler@timbira.com.br>; +Cc: francois@teksol.info; pgsql-bugs

Euler Taveira <euler@timbira.com.br> writes:
> On 04-03-2017 11:51, francois@teksol.info wrote:
>> In my schema, I happen to have two tables in different schemas with the same
>> name. PG supports that no problem, but when I listed the tables using \dt
>> and the search path set to both schemas, I expected to see the two tables.
>> Sadly, that wasn't the case.

> It is not a bug. It is a documented behavior [1].

Indeed.  See the last discussion of this,
https://www.postgresql.org/message-id/flat/20170208113300.1411.83851%40wrigleys.postgresql.org

An approximation to what you want can be had with "\dt *.tablename"
or perhaps "\dt *.*".

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #14578: Tables with same name in different schema are not shown with \dt
  2017-03-04 14:51 BUG #14578: Tables with same name in different schema are not shown with \dt francois@teksol.info
  2017-03-04 15:10 ` Re: BUG #14578: Tables with same name in different schema are not shown with \dt Euler Taveira <euler@timbira.com.br>
@ 2017-03-04 16:33   ` François Beausoleil <francois@teksol.info>
  1 sibling, 0 replies; 5+ messages in thread

From: François Beausoleil @ 2017-03-04 16:33 UTC (permalink / raw)
  To: Euler Taveira <euler@timbira.com.br>; +Cc: pgsql-bugs


> Le 4 mars 2017 à 10:10, Euler Taveira <euler@timbira.com.br> a écrit :
> 
> On 04-03-2017 11:51, francois@teksol.info wrote:
>> In my schema, I happen to have two tables in different schemas with the same
>> name. PG supports that no problem, but when I listed the tables using \dt
>> and the search path set to both schemas, I expected to see the two tables.
>> Sadly, that wasn't the case.
>> 
> It is not a bug. It is a documented behavior [1].
> 
> "An object is said to be visible if its containing schema is in the
> search path and no object of the same kind and name appears earlier in
> the search path."
> 
> 
> [1] https://www.postgresql.org/docs/9.6/static/app-psql.html

Oh, OK. That was surprising. I don't usually have tables with the same name in different schemas.

Thanks for the quick replies!
François



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #14578: Tables with same name in different schema are not shown with \dt
  2017-03-04 14:51 BUG #14578: Tables with same name in different schema are not shown with \dt francois@teksol.info
@ 2017-03-04 15:20 ` Fabien COELHO <coelho@cri.ensmp.fr>
  1 sibling, 0 replies; 5+ messages in thread

From: Fabien COELHO @ 2017-03-04 15:20 UTC (permalink / raw)
  To: francois@teksol.info; +Cc: pgsql-bugs


Hello François,

> name. PG supports that no problem, but when I listed the tables using \dt
> and the search path set to both schemas, I expected to see the two tables.



^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2017-03-04 16:33 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-03-04 14:51 BUG #14578: Tables with same name in different schema are not shown with \dt francois@teksol.info
2017-03-04 15:10 ` Euler Taveira <euler@timbira.com.br>
2017-03-04 15:17   ` Tom Lane <tgl@sss.pgh.pa.us>
2017-03-04 16:33   ` François Beausoleil <francois@teksol.info>
2017-03-04 15:20 ` Fabien COELHO <coelho@cri.ensmp.fr>

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