Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 89B6EB5F6F2 for ; Tue, 7 Jun 2011 01:13:16 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 06333-07 for ; Tue, 7 Jun 2011 04:13:09 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 485B4B5F6F9 for ; Tue, 7 Jun 2011 01:13:09 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p574BkTa002865; Tue, 7 Jun 2011 00:11:47 -0400 (EDT) To: David Fetter cc: Merlin Moncure , "Jehan-Guillaume (ioguix) de Rorthais" , pgsql-bugs@postgresql.org, Marko Tiikkaja Subject: Re: BUG #6051: wCTE query fail with wrong error text on a table with rules In-reply-to: <20110606164101.GA25901@fetter.org> References: <201106031542.p53FgDh5073991@wwwmaster.postgresql.org> <4184.1307222662@sss.pgh.pa.us> <20110606164101.GA25901@fetter.org> Comments: In-reply-to David Fetter message dated "Mon, 06 Jun 2011 09:41:01 -0700" Date: Tue, 07 Jun 2011 00:11:46 -0400 Message-ID: <2864.1307419906@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201106/56 X-Sequence-Number: 30435 David Fetter writes: > On Sat, Jun 04, 2011 at 05:24:22PM -0400, Tom Lane wrote: >> We could paste a copy of the original's cteList into the rule action, >> but there are still issues: >> >> * If there's more than one rule action, we could end up executing >> multiple copies of the same CTE query; which breaks the expectation >> of single evaluation for a CTE. >> >> * If there are CTEs attached to the rule action, as well as to the >> original query, and there is a conflict of CTE names between them, >> we can't handle that AFAICS. (The planner expects to look up entries >> in a cteList by name...) >> >> * Maybe some other things that aren't obvious yet. >> >> I don't particularly mind throwing a not-implemented error for the first >> case (ie, just say multiple rule actions don't mix with CTE queries); > Great :) >> but the second case seems seriously annoying, since there's no way >> for someone to write a CTE-containing rule action without risking a >> conflict. Ideas anybody? > Is there some way to throw "not implemented" there, too? It seems to > me that making accommodations for the user-modifiable part of our > rewrite rules isn't the right direction to go, as we're well on our > way to phasing the user-modifiable part out. Yes, we certainly can throw an error for that, it's just going to be a pain from a usability standpoint. But I agree that the number of people affected might be small, so it's not worth doing a significant rewrite for right now. I've committed a patch along these lines. regards, tom lane