X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 15F8DD1B25F for ; Wed, 21 Jul 2004 04:11:57 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 58056-05 for ; Wed, 21 Jul 2004 07:11:34 +0000 (GMT) Received: from anchor-post-32.mail.demon.net (anchor-post-32.mail.demon.net [194.217.242.90]) by svr1.postgresql.org (Postfix) with ESMTP id 58A69D1B1D1 for ; Wed, 21 Jul 2004 04:11:31 -0300 (ADT) Received: from lfix.demon.co.uk ([80.177.205.209] helo=cerberus.lfix.co.uk) by anchor-post-32.mail.demon.net with esmtp (Exim 3.35 #1) id 1BnBGF-000Mni-0W; Wed, 21 Jul 2004 08:11:31 +0100 Received: from linda.lfix.co.uk ([192.168.1.1]) by cerberus.lfix.co.uk with esmtp (Exim 4.34) id 1BnBGB-0005TQ-C8; Wed, 21 Jul 2004 08:11:27 +0100 Subject: Re: Inherited tables and new fields From: Oliver Elphick Reply-To: olly@lfix.co.uk To: Jeff Boes Cc: pgsql-sql@postgresql.org In-Reply-To: References: Content-Type: text/plain Organization: LFIX Limited Message-Id: <1090393887.25749.164.camel@linda> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Wed, 21 Jul 2004 08:11:27 +0100 Content-Transfer-Encoding: 7bit X-LFIX-MailScanner: Found to be clean X-MailScanner-From: olly@lfix.co.uk X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/141 X-Sequence-Number: 18393 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