pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: lucian.ciufudean@gmail.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #14317: psql \dt not working as expected
Date: Thu, 08 Sep 2016 11:52:57 -0400
Message-ID: <4557.1473349977@sss.pgh.pa.us> (raw)
In-Reply-To: <20160908154003.1410.72854@wrigleys.postgresql.org>
References: <20160908154003.1410.72854@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

lucian.ciufudean@gmail.com writes:
> If one creates a table with the same name as one of the pg_catalog tables
> then \dt will not show it:

This is expected, if you are using the default search_path, because
pg_catalog will be in front of public and will mask your version of
pg_tables.

> Expectations: \dt shows all tables in the public schema.

Nope, \dt shows *visible* tables, ie those that can be referenced without
schema qualification.  See this bit in the psql documentation:

       Whenever the pattern parameter is omitted completely, the \d
       commands display all objects that are visible in the current schema
       search path — this is equivalent to using * as the pattern. (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. This is equivalent to the statement that the
       object can be referenced by name without explicit schema
       qualification.) To see all objects in the database regardless of
       visibility, use *.* as the pattern.

> Note that it is also unexpected that this query:
> select * from pg_tables;
> goes to pg_catalog.pg_tables instead of public.pg_tables.

Again, you are confused about how the search path works.

If you really want to, you can put public in front of pg_catalog
in your search path, but it's not recommendable --- it's a security
hazard, for one thing.

			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



view thread (3+ messages)

Message-ID: <4557.1473349977@sss.pgh.pa.us>
Permalink:  ../4557.1473349977@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/4557.1473349977@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, lucian.ciufudean@gmail.com
  Subject: Re: BUG #14317: psql \dt not working as expected
  In-Reply-To: <4557.1473349977@sss.pgh.pa.us>
  References: <20160908154003.1410.72854@wrigleys.postgresql.org> <4557.1473349977@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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