Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1edh6Z-0006aa-3k for pgsql-hackers@arkaria.postgresql.org; Mon, 22 Jan 2018 18:46:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1edh6Y-0008Pd-HI for pgsql-hackers@arkaria.postgresql.org; Mon, 22 Jan 2018 18:46:02 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1edh6Y-0008PT-7L for pgsql-hackers@lists.postgresql.org; Mon, 22 Jan 2018 18:46:02 +0000 Received: from mail-wm0-x230.google.com ([2a00:1450:400c:c09::230]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1edh6Q-0006QH-W3 for pgsql-hackers@postgresql.org; Mon, 22 Jan 2018 18:46:00 +0000 Received: by mail-wm0-x230.google.com with SMTP id x4so18759399wmc.0 for ; Mon, 22 Jan 2018 10:45:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=0+4us73CxrX3v3pmF3UghEx8oNi3kXEVwZ8KDhdwScM=; b=NYnK1SCPxC4ZiQ50W3fNWaEjZ22yeVk/4Z8KX8xoVHg+syJ91wbkQU6G2LUdq/Rnmd hMcg/lBVJo9AlwbdI3dLQ/5JG9DM3pG3s93KiEfVyhS0en7CYLuLwNRf760cqgUehmKk x46U3/itZ8/v20jhR8CZo9zcllSornA1nQW9/PHhvwm6+a4Z83IDcC+aaa/2qrZYwi6n as3Hoo3I5NoW9M+NvZjfEQgG+TjCGklP4znNquzOJxrp77jI2zJ7zA6v32V3IAzbaLLQ YOyMrp3vz30DHb7tFyiVj9GMPSmsOxQfgejURP2u5/HKROVMvslLTxapLV2p2z5t+NkS HpCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=0+4us73CxrX3v3pmF3UghEx8oNi3kXEVwZ8KDhdwScM=; b=riyiWfRJ8hCSTSCfc+Qo0Uz7PTyd5ioo3RyLafdTWR/PB11RnPxkXUWAnRP9l9egAM BpUubWhiRVWqYdmKuzaqPnfT5t3jxq9aZ4WM7rYVaiQD/HCT5KggRdj8+EQXYCcGQZFx 9RLPW4YMm4V3LRX8x2Y6cXdctD3bGRi03TnvZbwmLsFoIsSZIDYzKs6rXLiftnKhzX+1 2Yz/a9//PzFIEH55qhbnfe7+GqaPwD7BMD3csOnUmnS1rL8Tn/3J8mA+z17aV8f6t/5n aV9llljW2B0JVghl9/sBQXouQNT+0OWjYfrUE9Y6W4jsdCTCRkQJ3O214YRKMYBC93X8 SQbA== X-Gm-Message-State: AKwxytdr/zZCmdCGh9x9mIHQSsZWWUizfRFs5i90uVH9sAzd2HQkNNvB egl+Mq+JR2JE25WG2oDc0LTqBFzP3J0iBSI009M9Lu8sCd86NxrsNVxNn1AozOCwnMD1TDKfnA8 Tsi7HRLq3oEz6K5gIGDRtPytNlZxvFunDKGDN1Sj1SOcSgWLYsswzS5hu1RyUgHEWHEFiLdXPdw mCFZ9g96QWOnw= X-Google-Smtp-Source: AH8x224XyWas5Q3Bql6tCLPBWteiDRa/CqSppzMSG4xtxFmAb/+B7v4XNJiP38c0lBseD7MU1RENhg== X-Received: by 10.28.54.221 with SMTP id y90mr5604048wmh.156.1516646752958; Mon, 22 Jan 2018 10:45:52 -0800 (PST) Received: from [192.168.0.106] (150.123.broadband11.iol.cz. [90.178.123.150]) by smtp.gmail.com with ESMTPSA id i33sm12725243wri.70.2018.01.22.10.45.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Jan 2018 10:45:52 -0800 (PST) Subject: Re: [PATCH] Logical decoding of TRUNCATE To: Marco Nenciarini , Simon Riggs Cc: PostgreSQL-development References: <269bf0d2-6ac4-c032-6979-22aad6a9f5fb@2ndquadrant.it> <20171229195536.cdzmgllfkln6wo6t@alap3.anarazel.de> <35a1d60b-f66d-4001-499b-2336ca81fc6c@2ndquadrant.it> <1a4ace10-1997-6644-d17a-5a17bf250270@2ndquadrant.it> <28a59551-b1f5-8ed4-65cf-76d17e7ee7e6@2ndquadrant.it> From: Petr Jelinek Message-ID: <1cb9bd52-9e3a-21bf-0c0c-afa90f463629@2ndquadrant.com> Date: Mon, 22 Jan 2018 19:45:50 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 19/01/18 12:37, Marco Nenciarini wrote: > Hi All, > > Il 18/01/18 17:48, Simon Riggs ha scritto: >> On 17 January 2018 at 17:07, Petr Jelinek wrote: >> >>> Things I am less convinced about: >>> >>> The patch will cascade truncation on downstream if cascade was specified >>> on the upstream, that can potentially be dangerous and we either should >>> not do it and only truncate the tables which were truncated upstream >>> (but without restricting because of FKs), leaving the data inconsistent >>> on downstream (like we do already with DELETE or UPDATE). Or maybe make >>> it into either subscription or publication option so that user can chose >>> the behaviour here as I am sure some people will want it to cascade (but >>> the default should still IMHO be to not cascade as that's safer). >> >> I agree the default should be to NOT cascade. >> >> If someone wants cascading as a publication option, that can be added later. >> > > I agree that not replicating the CASCADE option is the best option > according to POLA principle. > >>>> + /* logicalrep_rel_close call not needed, because ExecuteTruncateGuts >>>> + * already closes the relations. Setting localrel to NULL in the map entry >>>> + * is still needed. >>>> + */ >>>> + rel->localrel = NULL; >>> >>> This is somewhat ugly. Perhaps the ExecuteTruncateGuts should track >>> which relations it opened and only close those and the rest should be >>> closed by caller? That should also remove the other ugly part which is >>> that the ExecuteTruncateGuts modifies the input list. What if caller >>> wanted to use those relations it sent as parameter later? >> >> Agreed >> > > Attached a new version of the patch addressing these issues. > Besides the small thing I wrote for the 0001 in the other thread I am pretty much happy with this now. -- Petr Jelinek http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services