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 1m3c7w-0007dT-6i for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Jul 2021 10:28:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m3c7u-0004NB-8e for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Jul 2021 10:28:26 +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 1m3c7t-0004N3-UU for pgsql-hackers@lists.postgresql.org; Wed, 14 Jul 2021 10:28:26 +0000 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1m3c7q-0003tq-Lm for pgsql-hackers@lists.postgresql.org; Wed, 14 Jul 2021 10:28:24 +0000 Received: by mail-ej1-x62c.google.com with SMTP id hc15so2540384ejc.4 for ; Wed, 14 Jul 2021 03:28:22 -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=VlPNakDviLn+KtNQ5KZ7Nj0UkTRN+U3POUMFV+IMxxk=; b=FOILvy7qNABLWeLF66GEFjHhuLqE3roRfTp9wgVhFh9739teKGkqU1KhNhKWUZVj7c +yr28UKhEd3uRkDaL8uKnO6MjTZqqxcTfd5V108nev5vYboEvOpUoaec4hvVmnihsuGd tZ3l/TbFkAsJWTdXjiB4iZnxNDkzRBiSWajsv1bCq4ZmSNtvL63WoypLnPhVf2tKgh96 tuMgXkM9fl80/KLiB+t5+Vgp0C0xl5CZCs5BSWe8ZsN8nfjXxUuxAUFGHtlIKk1NXcPK Wl3mrdBmE2HXsXeBxuXxsV3xOLE6Ob5xzzZTgWFut07cMjJ2ga61DrMwQ4M9Sh5yjPCr n9rw== 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=VlPNakDviLn+KtNQ5KZ7Nj0UkTRN+U3POUMFV+IMxxk=; b=CMDx0wUPWSBVLf1xbySk9lbwXj5Gjm4ok7iGLgxzatALhR1LvXCdaChVxyA32R4wU5 YWpkydyQdsF9ZNTnXJCwrHrOBlOQ4c0J/pQuuRHLCk/CuGisWr5CzmLeV6pkh6zaIEI9 JLWTa20jDqUduKfYiKq3fD2sVbPhBW/YB8x4/jdtb3V1N4sNGvWwhOnw3pc55inxjB4L +lyak4zcb59h4PbJKnuLq8h1qN/A1Fz8mnFWchItWU+TupZfadql7EpZv/dzEQeoc6ft pKK6rn3vhB0z+GsvFYidQe7q1DTwvJfJBogAeK+k+UoEj6WDxYLmugV29aSiGIfBLdwW 3AiA== X-Gm-Message-State: AOAM533CYt1Y8RLik6MAa6tnPPMnJ/KMz4l53noNHqezgObo/1aPvCKl TBX0jE8z+61YWAopaFauLYGmbmb5kVQM8zKL4VRJdbIMjz64OYXBOc5mJjE1O9OXBHGxnIvtM5Z UdBdACJ76DAqFCp9XaIfKbCliM640Cc2UOm/o01/h1RE5orP69Q8paPR5cqkHibuF71tfuw7XMR 1SH7C6Y8G2CXlZS78uUqNAVoi3/GDcna8+nGen+XPk4oEgG6fM87P82XvKxhlfUWmrCT9zhsQUa 4gTkCdVlWy7L1FY484/x/3HDVn87t8O6VQ7IUPE5NCBquQJctqD5Q== X-Google-Smtp-Source: ABdhPJxrI+SaENZJZ7eHUEKMj9O0t6KnsP5s5tf6/FcZ2qNZFUWmHy8QNm8C7U971PVZrJQDpr5xVw== X-Received: by 2002:a17:907:2d0e:: with SMTP id gs14mr11853676ejc.49.1626258500761; Wed, 14 Jul 2021 03:28:20 -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 n18sm609838ejl.74.2021.07.14.03.28.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 14 Jul 2021 03:28:20 -0700 (PDT) Subject: Re: row filtering for logical replication To: Amit Kapila , Euler Taveira Cc: Alvaro Herrera , Peter Smith , Rahila Syed , Peter Eisentraut , =?UTF-8?B?w5ZuZGVyIEthbGFjxLE=?= , japin , Michael Paquier , David Steele , Craig Ringer , Tomas Vondra , Amit Langote , PostgreSQL Hackers References: <202107132106.wvjgvjgcyezo@alvherre.pgsql> <48e13621-10f7-49ef-bcbe-ed530195efd2@www.fastmail.com> From: Tomas Vondra Message-ID: Date: Wed, 14 Jul 2021 12:28:16 +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: 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 7:39 AM, Amit Kapila wrote: > On Wed, Jul 14, 2021 at 6:28 AM Euler Taveira wrote: >> >> On Tue, Jul 13, 2021, at 6:06 PM, Alvaro Herrera wrote: >> >> 1. if you use REPLICA IDENTITY FULL, then the expressions would work >> even if they use any other column with DELETE. Maybe it would be >> reasonable to test for this in the code and raise an error if the >> expression requires a column that's not part of the replica identity. >> (But that could be relaxed if the publication does not publish >> updates/deletes.) >> > > +1. > >> I thought about it but came to the conclusion that it doesn't worth it. Even >> with REPLICA IDENTITY FULL expression evaluates to false if the column allows >> NULL values. Besides that REPLICA IDENTITY is changed via another DDL (ALTER >> TABLE) and you have to make sure you don't allow changing REPLICA IDENTITY >> because some row filter uses the column you want to remove from it. >> > > Yeah, that is required but is it not feasible to do so? > >> 2. For UPDATE, does the expression apply to the old tuple or to the new >> tuple? You say it's the new tuple, but from the user point of view I >> think it would make more sense that it would apply to the old tuple. >> (Of course, if you're thinking that the R.I. is the PK and the PK is >> never changed, then you don't really care which one it is, but I bet >> that some people would not like that assumption.) >> >> New tuple. The main reason is that new tuple is always there for UPDATEs. >> > > I am not sure if that is a very good reason to use a new tuple. > True. Perhaps we should look at other places with similar concept of WHERE conditions and old/new rows, and try to be consistent with those? I can think of: 1) updatable views with CHECK option 2) row-level security 3) triggers Is there some reasonable rule which of the old/new tuples (or both) to use for the WHERE condition? Or maybe it'd be handy to allow referencing OLD/NEW as in triggers? regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company