Unix Technical Forum

Oddity with psql \d and pg_table_is_visible

This is a discussion on Oddity with psql \d and pg_table_is_visible within the pgsql Hackers forums, part of the PostgreSQL category; --> I have a database where I'd created a copy of pg_class in public. pgAdmin shows that the table exists, ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-15-2008, 09:51 PM
Decibel!
 
Posts: n/a
Default Oddity with psql \d and pg_table_is_visible

I have a database where I'd created a copy of pg_class in public.
pgAdmin shows that the table exists, but \d doesn't. This is because of
how pg_table_is_visible works, specifically this comment:

/*
* If it is in the path, it might still not be visible; it could be
* hidden by another relation of the same name earlier in the path. So
* we must do a slow check for conflicting relations.
*/

While this is correct on a per-relation level, I'm thinking that it's
not what we'd really like to have happen in psql. What I'd like \d to do
is show me everything in any schema that's in my search_path, even if
there's something higher in the search_path that would over-ride it.
ISTM that's what most people would expect out of \d.

If no one objects I'll come up with a patch for this.
--
Decibel!, aka Jim Nasby decibel@decibel.org
EnterpriseDB http://enterprisedb.com 512.569.9461 (cell)

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.3 (FreeBSD)

iD8DBQFG3tgRdO30qud8SkgRAq6KAKCZbm044rC0IGhhou6PX9 5AyfphNQCfbdH7
ySJ9d2Xsm15YYiOQswtC56s=
=/TQ5
-----END PGP SIGNATURE-----

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-15-2008, 09:51 PM
Tom Lane
 
Posts: n/a
Default Re: Oddity with psql \d and pg_table_is_visible

Decibel! <decibel@decibel.org> writes:
> While this is correct on a per-relation level, I'm thinking that it's
> not what we'd really like to have happen in psql. What I'd like \d to do
> is show me everything in any schema that's in my search_path, even if
> there's something higher in the search_path that would over-ride it.
> ISTM that's what most people would expect out of \d.


I don't agree with that reasoning in the least, particularly not if you
intend to "fix" it by redefining pg_table_is_visible() ...

What will happen if we change \d to work that way is that it will show
you a table, and you'll try to access it, and you'll get the wrong table
because the access will go to the one that really is visible.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-15-2008, 09:54 PM
Decibel!
 
Posts: n/a
Default Re: Oddity with psql \d and pg_table_is_visible

On Wed, Sep 05, 2007 at 03:27:50PM -0400, Tom Lane wrote:
> Decibel! <decibel@decibel.org> writes:
> > While this is correct on a per-relation level, I'm thinking that it's
> > not what we'd really like to have happen in psql. What I'd like \d to do
> > is show me everything in any schema that's in my search_path, even if
> > there's something higher in the search_path that would over-ride it.
> > ISTM that's what most people would expect out of \d.

>
> I don't agree with that reasoning in the least, particularly not if you
> intend to "fix" it by redefining pg_table_is_visible() ...


No, pg_table_is_visible is correct as-is.

> What will happen if we change \d to work that way is that it will show
> you a table, and you'll try to access it, and you'll get the wrong table
> because the access will go to the one that really is visible.


That's why I was suggesting that any table showing up in \d that in-fact
wasn't visible be marked somehow, either with a separate field, or by
sticking an * after it's name.

This is confusing because when using \d you generally think in terms of
what schemas are in your search path, not if an individual object has
been superseded by something further up the chain.
--
Decibel!, aka Jim Nasby decibel@decibel.org
EnterpriseDB http://enterprisedb.com 512.569.9461 (cell)

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.3 (FreeBSD)

iD8DBQFG4biydO30qud8SkgRAl/5AJwI90ZkeXcoR3JRgBWGVihWpdIYPACfWOaK
MZ+0OM8ZsIYx0vDDKIi3pX8=
=gY5o
-----END PGP SIGNATURE-----

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:51 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com