Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h4Jtk-0001z4-Jv for pgsql-hackers@arkaria.postgresql.org; Thu, 14 Mar 2019 06:31:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h4Jtj-00073r-9l for pgsql-hackers@arkaria.postgresql.org; Thu, 14 Mar 2019 06:31:23 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h4Jti-00072P-VE for pgsql-hackers@lists.postgresql.org; Thu, 14 Mar 2019 06:31:23 +0000 Received: from tama50.ecl.ntt.co.jp ([129.60.39.147]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h4Jtb-0007Hc-MZ for pgsql-hackers@postgresql.org; Thu, 14 Mar 2019 06:31:21 +0000 Received: from vc1.ecl.ntt.co.jp (vc1.ecl.ntt.co.jp [129.60.86.153]) by tama50.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id x2E6VCsO031020; Thu, 14 Mar 2019 15:31:12 +0900 Received: from vc1.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id B7B0DEA7678; Thu, 14 Mar 2019 15:31:12 +0900 (JST) Received: from jcms-pop21.ecl.ntt.co.jp (jcms-pop21.ecl.ntt.co.jp [129.60.87.134]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id A2F6AEA7615; Thu, 14 Mar 2019 15:31:12 +0900 (JST) Received: from [127.0.0.1] (unknown [129.60.241.61]) by jcms-pop21.ecl.ntt.co.jp (Postfix) with ESMTPSA id 610DC4003FA; Thu, 14 Mar 2019 15:31:12 +0900 (JST) Subject: Re: Fix handling of unlogged tables in FOR ALL TABLES publications References: <59e5a734-9e06-1035-385b-6267175819aa@lab.ntt.co.jp> <20190314.150328.172224727.horiguchi.kyotaro@lab.ntt.co.jp> From: Amit Langote Message-ID: <26bfa053-3fb2-ad1d-efbb-7c930b41c0fd@lab.ntt.co.jp> Date: Thu, 14 Mar 2019 15:31:03 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.3 MIME-Version: 1.0 In-Reply-To: <20190314.150328.172224727.horiguchi.kyotaro@lab.ntt.co.jp> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CC-Mail-RelayStamp: 1 To: Kyotaro HORIGUCHI Cc: peter.eisentraut@2ndquadrant.com, pgsql-hackers@postgresql.org X-TM-AS-MML: disable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2019/03/14 15:03, Kyotaro HORIGUCHI wrote: > At Thu, 14 Mar 2019 11:30:12 +0900, Amit Langote wrote in <59e5a734-9e06-1035-385b-6267175819aa@lab.ntt.co.jp> >> On 2019/03/13 21:03, Peter Eisentraut wrote: >>> If a FOR ALL TABLES publication exists, unlogged tables are ignored >>> for publishing changes. But CheckCmdReplicaIdentity() would still >>> check in that case that such a table has a replica identity set before >>> accepting updates. That is useless, so check first whether the given >>> table is publishable and skip the check if not. >>> >>> Example: >>> >>> CREATE PUBLICATION pub FOR ALL TABLES; >>> CREATE UNLOGGED TABLE logical_replication_test AS SELECT 1 AS number; >>> UPDATE logical_replication_test SET number = 2; >>> ERROR: cannot update table "logical_replication_test" because it does >>> not have a replica identity and publishes updates >>> >>> Patch attached. >> >> An email on -bugs earlier this morning complains of the same problem but >> for temporary tables. >> >> https://www.postgresql.org/message-id/CAHOFxGr%3DmqPZXbAuoR7Nbq-bU4HxqVWHbTTUy5%3DPKQut_F0%3DXA%40mail.gmail.com >> >> It seems your patch fixes their case too. > > Is it the right thing that GetRelationPublicationsActions sets > wrong rd_publicatons for the relations? Actually, after applying Peter's patch, maybe we should add an Assert(is_publishable_relation(relation)) at the top of GetRelationPublicationActions(), also adding a line in the function header comment that callers must ensure that. There's only one caller at the moment anyway, which Peter's patch is fixing to ensure that. Thanks, Amit