Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m3gVE-0001ON-Dq for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Jul 2021 15:08:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m3gVD-0007S8-Dw for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Jul 2021 15:08:47 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m3gVD-0007S0-1O for pgsql-hackers@lists.postgresql.org; Wed, 14 Jul 2021 15:08:47 +0000 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1m3gV6-00065Z-Q7 for pgsql-hackers@lists.postgresql.org; Wed, 14 Jul 2021 15:08:44 +0000 Received: by mail-wr1-x432.google.com with SMTP id l7so3634952wrv.7 for ; Wed, 14 Jul 2021 08:08:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb-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=qQ1JtW+zA2BUzSOE8QMkj1suTqXRl0iZ4X7nmevDTBE=; b=eX2psRFe00do8yhTfpDt1QJpmqmuFD1eZtL/fcZ3kj+6IvUubpD2XmoLqMZIufL8Mm txVmegehuUrb1E/VqQAXvH4BRaTXiRRL0MouHbR5nmkXyK4cJO/wJ5cTn8eNiPW9+Gkj 6Zsek2UdjIFmRmDQinhVwwKbmoAPYRkGEwk7OI9cXtrEioBsn6IZGDuWS1gdQRktn+mx LuOQqFLRhbEj7DpUmjF7d6VHKa4d5Ltpr89S+euv/taHQbZWXjtnD3XGRpBep/SMMFly 7pnW7If81fkQqtnUzbC5Tnaz8m5VdVVgaz4NY7pNhcCDwRpmh8BrA6MMImAanu4kim/y w3Fw== 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=qQ1JtW+zA2BUzSOE8QMkj1suTqXRl0iZ4X7nmevDTBE=; b=XWrhTR2JDi1mvhX7k7A5IxdE1ISZvl2ozUtpzO5W3hD/YeChvtAW7VWza7vBM5nzL0 cMJ5ykXhZZHa+IlrXxPkyapNiDyGQi3/SswsvDDJX0hjWc27WgBgxucg5v5FHyUhJelU ZPpskBHdPFMcbaLWaL0iVt839pGoPQOiirbFX33NVKifqjXcF6xUgtGH9jCZok1aqEv5 PfoQPQNEh+TTjmbIf/HrZOaZeliuM4BgLLhsOysaiJqd84RGAonAVYme+Rv7pdAtxFzw mlc9RBswJ+LkQYYlsQfOAyKUIuOi8OCjoIYI79nWVtTIGmHJviXsvTahYfTmLDah+hJ/ Nujg== X-Gm-Message-State: AOAM530lI10DN3QfFZVlD7x9gMBWPMNotgbKTv7U4RjgNMl8Vdn3niat URuoLz0JMTX8ahFs0SUGIGxo0kr6KwKM879cGSIFLVCbziojo/hVUMFvej5+hiaK9aKpkbIWpl4 5Jf2PlPpiSQp12A3J/cAQWJSfCAL6l09hT8BiI2A2U1ttVj79G+Vqt++JnQMChH4MdUS03IX+0y 66nSt9xaVghVQqK+rEXBICxpeDJvodE0Omciw5k3KsjxH13Tap/SX6AbkRWOb4ViARJbC2In5bp GVSy/Jk7+fplHuCds1/4UNaE4d7//8RyH+cI9swIOLnh7cafkjp5w== X-Google-Smtp-Source: ABdhPJw72jeTRqTr9h126OUI0NDEKDu/I7fkUWupOp/JVp+brWLab4gTrlpa7VIp5PNm4Az7/i+LSA== X-Received: by 2002:adf:ed46:: with SMTP id u6mr13763141wro.252.1626275318241; Wed, 14 Jul 2021 08:08:38 -0700 (PDT) Received: from [10.137.0.18] (ip-86-49-254-183.net.upcbroadband.cz. [86.49.254.183]) by smtp.gmail.com with ESMTPSA id s17sm2967593wrv.2.2021.07.14.08.08.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 14 Jul 2021 08:08:37 -0700 (PDT) Subject: Re: row filtering for logical replication To: Alvaro Herrera Cc: Dilip Kumar , Amit Kapila , Euler Taveira , Peter Smith , Rahila Syed , Peter Eisentraut , =?UTF-8?B?w5ZuZGVyIEthbGFjxLE=?= , japin , Michael Paquier , David Steele , Craig Ringer , Tomas Vondra , Amit Langote , PostgreSQL Hackers References: <202107141452.edncq4ot5zkg@alvherre.pgsql> From: Tomas Vondra Message-ID: <4da2b027-4f80-f31f-1d06-6498e9760c2e@enterprisedb.com> Date: Wed, 14 Jul 2021 17:08:34 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <202107141452.edncq4ot5zkg@alvherre.pgsql> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 7/14/21 4:52 PM, Alvaro Herrera wrote: > On 2021-Jul-14, Tomas Vondra wrote: > >> The way I'm thinking about this is that for INSERT and DELETE it's clear >> which row version should be used (because there's just one). And for UPDATE >> we could see that as DELETE + INSERT, and apply the same rule to each >> action. >> >> On the other hand, I can imagine cases where it'd be useful to send the >> UPDATE when the old row matches the condition and new row does not. > > In any case, it seems to me that the condition expression should be > scanned to see which columns are used in Vars (pull_varattnos?), and > verify if those columns are in the REPLICA IDENTITY; and if they are > not, raise an error. Most of the time the REPLICA IDENTITY is going to > be the primary key; but if the user wants to use other columns in the > expression, we can HINT that they can set REPLICA IDENTITY FULL. > Yeah, but AFAIK that's needed only when replicating DELETEs, so perhaps we could ignore this for subscriptions without DELETE. The other question is when to check/enforce this. I guess we'll have to do that during decoding, not just when the publication is being created, because the user can do ALTER TABLE later. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company