Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1deokH-0002IB-1k for pgsql-bugs@arkaria.postgresql.org; Mon, 07 Aug 2017 20:35:25 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1deokG-0003jp-GB for pgsql-bugs@arkaria.postgresql.org; Mon, 07 Aug 2017 20:35:24 +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 1deojY-0002Qd-VZ for pgsql-bugs@postgresql.org; Mon, 07 Aug 2017 20:34:41 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1deojS-00041s-8w for pgsql-bugs@postgresql.org; Mon, 07 Aug 2017 20:34:39 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 6E3A120C6A; Mon, 7 Aug 2017 16:34:33 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute5.internal (MEProxy); Mon, 07 Aug 2017 16:34:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=fm1; bh=/1zfSNikuxgb0YDPaN UYVKT3inIZ0QZaZ3F7fpujHeI=; b=WJ3cXsecRrYoSEXNq0EnZTbAOwV6DW7zPI 0lTvUnjS5zbKceYiNzacNc7Of2ycEK+K4Jjt70HfFVTJnnID6qXRxgVqjlsyw3Yf FGVrxcjyUDMwXWLflS1LclWO9rTkATvPh2No2njZZ1Icg4zMdsNb6Nm11EWLx6D2 mXIDlHEk9FrHAQHufW2NLDhMDgtAheKp4EJtChFuYmtEhoagIQmKzsndm29IZN3s 0Y7uEmABTQbBHB0ce9hpNbq8vNhk0fEJCt7wyw+A4S2Q5rqY9p9PmZSv2bmSsN4G kgVE1RQ18ETa3Hk8Dhuolj/3V1ANgiDX79Bc+gsKQee8JUiTIu1Q== X-ME-Sender: X-Sasl-enc: 3kjrf+Gn0d3bie03pvTKTYht0oBvn3yS08vdBU46aUZl 1502138073 Received: from intern.anarazel.de (unknown [208.72.138.107]) by mail.messagingengine.com (Postfix) with ESMTPA id 397BD7E8D5; Mon, 7 Aug 2017 16:34:33 -0400 (EDT) Date: Mon, 7 Aug 2017 13:34:32 -0700 From: Andres Freund To: hillel.eilat@attunity.com Cc: pgsql-bugs@postgresql.org Subject: Re: BUG #14771: "Logical decoding" does not cover the impact of "TRUNCATE TABLE" command Message-ID: <20170807203432.zb4wv2hr34s2mya2@alap3.anarazel.de> References: <20170807122030.8422.9419@wrigleys.postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170807122030.8422.9419@wrigleys.postgresql.org> 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 Hi, On 2017-08-07 12:20:30 +0000, hillel.eilat@attunity.com wrote: > From "Logical Decoding" perspective - "TRUNCATE TABLE" is logically > equivalent to "DELETE FROM TABLE". It's absolutely not. A DELETE FROM TABLE has to include all the deleted rows (think of concurrency and servers that don't match), whereas a truncate doesn't include that. So changing TRUNCATE wouldn't be appropriate. > Both affect the contents of the PostgreSQL database identically. > However - "DELETE FROM TABLE" will be reflected at the target database > properly - as expected - while "TRUNCATE" will NOT!!. > "Logical Decoding" aims to cover ALL changes made onto data in a coherent > fashion. > "TRUNCATE" stands for a case where change in data contents at PostgreSQL are > not handled by "Logical Decoding", hence synchronization is not achieved. > Did I miss something? > Is it the only case? Others remarked on this. > How can one cope with this deficiency? The best solution imo is to have a TRUNCATE trigger that leads to the truncation being logged. Either by having a 'ddl commands' table, or by using wal messages. Greetings, Andres Freund -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs