pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Pavel Stehule <pavel.stehule@gmail.com>
To: Steve Midgley <public@misuse.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: System catalog future changes
Date: Tue, 18 Dec 2007 18:36:36 +0100
Message-ID: <162867790712180936x7792d302pb3ed9f533339ee67@mail.gmail.com> (raw)
In-Reply-To: <20071218165836.4EFD42E004C@postgresql.org>
References: <20071218165836.4EFD42E004C@postgresql.org>

Hello

use information schema instead:
   SELECT * FROM information_schema.tables;
   SELECT * FROM information_schema.columns ;

Structure of these tables is specified in ANSI SQL. But nobody can be
sure so all these table are stable forever. System catalog isn't fixed
and can be changed every mayor release.  Or better, use own wrapper
views:

CREATE myTables AS SELECT * FROM pg_tables
CREATE myColumns AS SELECT * FROM pg_....

you can fix all future changes only with change these views. and views
have not any overhead in PostgreSQL.

Regards
Pavel Stehule

On 18/12/2007, Steve Midgley <public@misuse.org> wrote:
> Hello again,
>
> Reading a previous recent post and answers called "Describe Table" got
> me thinking about a little piece of SQL I use in an application to get
> a list of all the tables for a specific namespace:
>
> select pg_class.relname as table_name
> from pg_class
>   join pg_namespace on pg_namespace.oid = relnamespace
> where pg_class.relkind = 'r' and pg_namespace.nspname = 'public'
> order by pg_class.relname
>
> I have assumed that this sort of query would be relatively "durable" -
> that future system catalog changes are unlikely to make this query stop
> working? Does anyone have any knowledge of how "fixed" the columns and
> values of this query are (i.e. are there a lot of internal and external
> dependencies that make future Pg versiosn unlikely to break the above
> code)?
>
> Any other input on the above SQL - should I be doing this in another
> way?
>
> Thanks for any thoughts or advice,
>
> Steve
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
>        choose an index scan if your joining column's datatypes do not
>        match
>



view thread (4+ messages)  latest in thread

Message-ID: <162867790712180936x7792d302pb3ed9f533339ee67@mail.gmail.com>
Permalink:  ../162867790712180936x7792d302pb3ed9f533339ee67@mail.gmail.com/
Also on:    postgresql.org/message-id/162867790712180936x7792d302pb3ed9f533339ee67@mail.gmail.com

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: pavel.stehule@gmail.com, public@misuse.org
  Subject: Re: System catalog future changes
  In-Reply-To: <162867790712180936x7792d302pb3ed9f533339ee67@mail.gmail.com>

* 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