From: Oliver Elphick <olly@lfix.co.uk>
To: Jeff Boes <jboes@qtm.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: Inherited tables and new fields
Date: Wed, 21 Jul 2004 08:11:27 +0100
Message-ID: <1090393887.25749.164.camel@linda> (raw)
In-Reply-To: <D5aLc.46510$5Y.46338@cyclops.nntpserver.com>
References: <D5aLc.46510$5Y.46338@cyclops.nntpserver.com>
On Tue, 2004-07-20 at 15:36, Jeff Boes wrote:
...
> Of course, had we used table inheritance, we'd do something like ...
>
> select * from draft_template ...
>
> but it wouldn't do exactly what we are doing now: that is,
> fn_all_drafts() returns not only the contents of every row in the tables
> draft_XXXXX, but also an extra column indicating which table that row
> came from.
You can do that with an inheritance hierarchy like this:
select tableoid::regclass as tablename, * from my_table;
> create table all_drafts (editor_id integer) inherits draft_template;
>
> What frustrates me from time to time is that if "draft_template" is
> altered to add a new column, then the function breaks because the new
> column appears in "all_drafts" as *following* editor_id. The column
> order messes up the code in the function, because it's expecting
> all_drafts to look like draft_template, with editor_id added at the end.
>
> Is this a mis-feature?
New columns get added at the end of each table; that is standard.
--
Oliver Elphick olly@lfix.co.uk
Isle of Wight http://www.lfix.co.uk/oliver
GPG: 1024D/A54310EA 92C8 39E7 280E 3631 3F0E 1EC0 5664 7A2F A543 10EA
========================================
"Greater love hath no man than this, that a man lay
down his life for his friends." John 15:13
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: olly@lfix.co.uk, jboes@qtm.net
Subject: Re: Inherited tables and new fields
In-Reply-To: <1090393887.25749.164.camel@linda>
* 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