Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1efpOK-0001TH-KQ for pgsql-hackers@arkaria.postgresql.org; Sun, 28 Jan 2018 16:01:12 +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 1efpOJ-0007K6-Jv for pgsql-hackers@arkaria.postgresql.org; Sun, 28 Jan 2018 16:01:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1efpOJ-0007Jw-94 for pgsql-hackers@lists.postgresql.org; Sun, 28 Jan 2018 16:01:11 +0000 Received: from mail-wm0-x22f.google.com ([2a00:1450:400c:c09::22f]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1efpOF-0006OG-RX for pgsql-hackers@postgresql.org; Sun, 28 Jan 2018 16:01:10 +0000 Received: by mail-wm0-x22f.google.com with SMTP id v71so29276113wmv.2 for ; Sun, 28 Jan 2018 08:01:07 -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=u+zCVdb02alYW3Kinhg+penf43zGzWzS7EoVO5yjphg=; b=Kuepo2vbPTEXBvaBLmiriLCQZSwslHkpH5yNIwFqT6kuSZcQiKJ7QULbLeZOLn6ou0 /MWtB8jXL3SXCT86VAg2xo2/sf/sSqJOC2l5oIa6kUi9S9Da0+19UU2S5jj2eLDUpxPG R7yHj3KA9OIeH++nfAnZzQvTMnIfnqum6IJswf1DdlItcQpfVu6bUGakViSnEGUF6wjW seKByPwtIfPZOo54xxacohxez2vu1zd6W4J9+cat1z6OaGGpo+6lfPh/VSooiO1rWMkx Y0IXfXkIT73UDgnfCtA5avKEYenEyzXfdO4pcCf0653ryMDwmGyLqCq9YvZa3ksWNbaD IMZg== 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=u+zCVdb02alYW3Kinhg+penf43zGzWzS7EoVO5yjphg=; b=suX+NNp1h3RhLMcJ2OwAd3lB3SlrpXxdjrJsrVndMOSjyR+HZ42TNjwVByF6kPuxCI FMN4NbYVtY+fDSJ3AGSSZrGD+C0WDWa66SjkKIpnpcL6Zl1cqnc8YdXsFHSRyML9+vqX jlIDgNKWUtdIYFyXUcInq9n4d7Y/yE+AKwhQTp3+7VLvvcMIR9JV/oTz7CV/J+LjyS+W u6KmtUISc74d44bj/ZJz7wCRQNXLq/0I/c+WxVoZhTsHYAlZR+ApqZZJXUJZhFD9dOW/ UTbCeoCwY2oGew5YUYvh4PFv556kXgduajNhpjZaLrl4M+zi0NgNo9AxZZTqOAYofoDC Z4sg== X-Gm-Message-State: AKwxyte4WCgSr5uEp+JWSrnQth5zcNOn7RbIoZa/FEsRs3jgrS/bJzo5 SZ7pmrF5sAL+eQOxcRpbnledjuNpnT/FGgRyRguH7ucAxinOIGY/nJUYs5KrHv5psBOGpWyf0I0 nSok2zO/ns08oYUvNZbcY3plM4hhAsIP/1NaxriyQc0QqbY+gqO8Gah1wve5NMHb43KNaf5rDa5 rQCGlo/N0uNhk= X-Google-Smtp-Source: AH8x225VTjzS8B2PqwhzRZ66u8qcWhf243LbkiQA9ibbH4JhODix3/1C++UsT1d5J/9maObDeYf9Kw== X-Received: by 10.28.101.196 with SMTP id z187mr15821675wmb.29.1517155265991; Sun, 28 Jan 2018 08:01:05 -0800 (PST) Received: from [192.168.0.106] (150.123.broadband11.iol.cz. [90.178.123.150]) by smtp.gmail.com with ESMTPSA id y10sm8092958wrh.36.2018.01.28.08.01.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Jan 2018 08:01:05 -0800 (PST) Subject: Re: [PATCH] Logical decoding of TRUNCATE To: Peter Eisentraut , Marco Nenciarini , Simon Riggs Cc: PostgreSQL-development References: <269bf0d2-6ac4-c032-6979-22aad6a9f5fb@2ndquadrant.it> <1a4ace10-1997-6644-d17a-5a17bf250270@2ndquadrant.it> <28a59551-b1f5-8ed4-65cf-76d17e7ee7e6@2ndquadrant.it> <1cb9bd52-9e3a-21bf-0c0c-afa90f463629@2ndquadrant.com> <0361327b-5d59-32b0-cb13-e844acf0f0d0@2ndquadrant.it> <31773cc5-3b29-1740-e7d2-dc48e80a06ce@2ndquadrant.com> <35df4fd5-6b74-9c15-9246-ead8854cc669@2ndquadrant.com> <5462dc00-4941-167e-b287-d7bd9b2283e9@2ndquadrant.com> <3952d6e6-f438-f393-9a02-aae871d2fc3e@2ndquadrant.com> <7f0589c2-c82e-27f3-9d2c-68c0a1bb0b6e@2ndquadrant.com> From: Petr Jelinek Message-ID: Date: Sun, 28 Jan 2018 17:01:03 +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: <7f0589c2-c82e-27f3-9d2c-68c0a1bb0b6e@2ndquadrant.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 26/01/18 03:44, Peter Eisentraut wrote: > On 1/24/18 07:53, Petr Jelinek wrote: >> That depends on if we consider this to be part of sequence handling or >> truncate statement replication handling. It's true that if we had >> sequence replication, the restart would get propagated that way anyway. >> OTOH, if we'll want to add option in the future to propagate cascade (to >> any additional tables on downstream), it may need to reset sequences >> which are not even present upstream and as such would not be handled by >> sequence replication. > > Logical replication, as it currently is designed, replicates discrete > actions, not commands. A delete command that deletes five rows and > cascades to delete three more rows somewhere else ends up being > replicated as eight changes. So I think a TRUNCATE command that > cascades to four tables and resets six sequences should end up being > replicated as ten changes. (Since we currently don't handle sequences > at all, we'll omit the six sequence changes for now.) > Well, that depends, I think there are two separate problems a) decoding b) replication. I think it's useful for plugins to know if reset sequence or cascade was specified in the command so I think it should be decoded. Some plugins will definitely want to forward that info. But it's true that since we don't handle sequences in logical replication, the sequence reset does not need to be replicated there. -- Petr Jelinek http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services