Received: from news.tht.net (news.hub.org [216.126.91.242]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f34Nsi820880 for ; Wed, 4 Apr 2001 19:54:44 -0400 (EDT) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.1/8.11.1) id f34NZ9931789 for pgsql-sql@postgresql.org; Wed, 4 Apr 2001 19:35:09 -0400 (EDT) (envelope-from news) From: "Gordon A. Runkle" X-Newsgroups: comp.databases.postgresql.sql Subject: Re: UNION in a VIEW? Date: Wed, 04 Apr 2001 19:41:26 -0400 Organization: Integrated Dynamics, Inc. Lines: 25 Message-ID: <9agb3b$v1a$1@news.tht.net> References: <12713.986422401@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: scrappy@hub.org User-Agent: Pan/0.9.6 (Unix) X-No-Productlinks: Yes To: pgsql-sql@postgresql.org X-Archive-Number: 200104/68 X-Sequence-Number: 2408 In article <12713.986422401@sss.pgh.pa.us>, "Tom Lane" wrote: > You're correct, an outer WHERE clause will not be pushed down into the > member selects of a UNION. (This hasn't really got anything to do with > whether a VIEW is involved.) I haven't gotten round to convincing > myself about whether that transformation is always valid, or what > conditions it needs to be valid. A TODO item for some future release... Thanks, Tom. Not the answer I was hoping for... This seems to really reduce the utility of UNIONs, especially within VIEWS. What DB2 and SQL Server appear to be doing is binding the WHERE clause to the colums in the positions corresponding to the column labels in the first select. So long as that is communicated to the user, I would think that it would be valid. At the very least, it would be consistent with the other major RDBMSs. I suppose it's to late to put this in for 7.1... ;-) Gordon. -- It doesn't get any easier, you just go faster. -- Greg LeMond