Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WLbOk-0007Zg-8b for pgsql-bugs@arkaria.postgresql.org; Thu, 06 Mar 2014 16:43:54 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WLbOj-0003pD-Jo for pgsql-bugs@arkaria.postgresql.org; Thu, 06 Mar 2014 16:43:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WLbOi-0003p6-MX for pgsql-bugs@postgresql.org; Thu, 06 Mar 2014 16:43:52 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WLbOc-0005GP-AN for pgsql-bugs@postgresql.org; Thu, 06 Mar 2014 16:43:52 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id s26Ghi3R026900; Thu, 6 Mar 2014 11:43:44 -0500 From: Tom Lane To: Michael Paquier cc: pgsql-bugs@postgresql.org, Kevin Grittner Subject: Re: BUG #9398: DELETE refering to a materialized view produces "cannot lock rows in materialized view" error In-reply-to: References: <20140301095125.11734.87903@wrigleys.postgresql.org> <22267.1394063204@sss.pgh.pa.us> Comments: In-reply-to Michael Paquier message dated "Thu, 06 Mar 2014 15:25:11 +0900" Date: Thu, 06 Mar 2014 11:43:44 -0500 Message-ID: <26899.1394124224@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Michael Paquier writes: > On Thu, Mar 6, 2014 at 8:46 AM, Tom Lane wrote: >> 2. We could remove the error complaint in CheckValidRowMarkRel(), >> allowing a matview row to be marked the same as a regular-table row. >> >> Since matview rows do in fact have TIDs and the same >> visibility/vacuumability rules as regular-table rows (no?), I see no >> reason that #2 wouldn't work, though I admit I've not actually tried it. > After digging into #2, I finished with the attached patch that passes > regression tests. The idea is simply to allow a matview to use > ROW_MARK_REFERENCE and ROW_MARK_COPY when its rows are referenced. I > added a regression test as well in the patch. The ROW_MARK_COPY test is unnecessary since control will never reach this function for that case. (If it did, most of the other case branches would need to be checking it; checking only here is inconsistent.) Also, after comparing this to the code in CheckValidResultRel, I wonder why we aren't allowing SELECT FOR UPDATE in maintenance mode; that is, shouldn't the test go like this: if (markType != ROW_MARK_REFERENCE && !MatViewIncrementalMaintenanceIsEnabled()) However, that smells less like a bug fix and more like a feature addition, so I'll leave it to Kevin to decide whether that's appropriate. In the meantime, I committed the clear bug fix with some cosmetic adjustments. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs