Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id F30999F9A72 for ; Tue, 26 Dec 2006 00:10:45 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 39027-05 for ; Tue, 26 Dec 2006 00:10:33 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by postgresql.org (Postfix) with ESMTP id D25E59F9312 for ; Tue, 26 Dec 2006 00:10:38 -0400 (AST) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.8/8.13.8) with ESMTP id kBQ4AVlR046660 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 25 Dec 2006 21:10:33 -0700 (MST) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.8/8.13.8) with ESMTP id kBQ4AU2p061672; Mon, 25 Dec 2006 21:10:30 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.8/8.13.8/Submit) id kBQ4AU6J061671; Mon, 25 Dec 2006 21:10:30 -0700 (MST) (envelope-from mfuhr) Date: Mon, 25 Dec 2006 21:10:30 -0700 From: Michael Fuhr To: Jan Meyland Andersen Cc: pgsql-sql@postgresql.org Subject: Re: Related tables to a view Message-ID: <20061226041029.GA61490@winnie.fuhr.org> References: <1404.62.66.218.59.1167083523.squirrel@mail.agile.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1404.62.66.218.59.1167083523.squirrel@mail.agile.dk> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200612/170 X-Sequence-Number: 27126 On Mon, Dec 25, 2006 at 10:52:03PM +0100, Jan Meyland Andersen wrote: > If I have a view which is a selection from field1 and field2 from table1 > and field1 and field2 from table2. > > How can I make a selection which returns the relation for the fields in a > way so I am able to se which field belongs to which table. You could query pg_depend to find out which tables and columns the view's rewrite rule depends on but that's not as specific as what you're requesting. I'm not aware of a way to associate a particular table column with a particular view column short of parsing the view definition or rule action; doing so would have to allow for the possibility of a view column deriving its value from an arbitrarily complex expression involving multiple tables, subqueries, etc. -- Michael Fuhr