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 1nlyNg-0004e9-Dq for pgsql-hackers@arkaria.postgresql.org; Tue, 03 May 2022 19:40:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nlyNe-0001kI-4m for pgsql-hackers@arkaria.postgresql.org; Tue, 03 May 2022 19:40:18 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nlyNd-0001k9-DZ for pgsql-hackers@lists.postgresql.org; Tue, 03 May 2022 19:40:17 +0000 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nlyNV-0008Hf-26 for pgsql-hackers@lists.postgresql.org; Tue, 03 May 2022 19:40:16 +0000 Received: by mail-wr1-x42a.google.com with SMTP id e24so24677306wrc.9 for ; Tue, 03 May 2022 12:40:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=vb03erSdDS/NcJIa1ULdKcWbcn+5by1IZUCzLZiT9sA=; b=kNoHXvbKxbBCAlnXszemJg7C5vHmKvZOiHwJSlHVOSWxU/1ApKp1Fbm08MBniwUTSD 2U4VLSYnSa9jPbmtmeK2FiY2AKYJQ0NdY+dk6jBf2V8gVZKCy1kEbG1lBGrnF//vAcgP Ysjy1biMlzMGLDFTccduROZcanQeW7PIdg20aaCtr4f5Cg8wAn9x1QGcI/56lm/CN7qV hNhsBZe+s/dM7vgsIyn2EyncfIGUi6bidFaO1TK2SRgohxIq4kjacz3WxPfTgFdoU3jI qnTSLbH2Wksny5yZ1Ws9SUnYupdDVF3NNyNGHxfKMCc0RanyE31Cc9mdfKdsmNYbkm63 XXxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=vb03erSdDS/NcJIa1ULdKcWbcn+5by1IZUCzLZiT9sA=; b=8SZASqIT5ZCTsiSgTO31S5HBXbM+JuNUfu7yoOVhhHRamLM4PZntSykjtzOjsuheJJ Rgy9mpxKBcHtBdia5me6vIqMkpb5ydXuReqW0JCYURYVsqwZ5JjEd0WZJtyIaUzRI1D5 pImt71kepkgngBovFa6Y+s05Cbkk1yD+WJwpEcjoPYtxBoGUuv3MIVFEWPPKuL9AN0Xw 5MGj0PQoFiZ0FdyVDWRN11ovgmDsm7QQx0iDk/d/nd/mRVyj8QQa1OBDZuKoz0IbZvqK og5NIpIRHO884b9wGCr7Wx6Gu++m4niMCck7DpSZS9lClCEoRm6y9TH/gQDe49ykNdqL RqIQ== X-Gm-Message-State: AOAM533ZamDuvWNCxyBS3JFlIHkNkUSnO//R+zhQR5RH9H/Fv7VRavAc Gv0U2I88vVKqx4xebpg+QtytzVCStQCqlbwOdCcJJXD9ioQMA07ic5kAV3P32tS/YGa7LdIZy2n 9DWvMKcW5ue88wlalXhD+hDvkHfCze7nfjebkiQVcNNr4aFE4SE2kBa3XMwtoIwJbumqAE5iXBC oLbWGdBrxvcAGaUiFQ85QGMA2rlaPVPGvIze+w5RSiiA2GWgrjnSVV X-Google-Smtp-Source: ABdhPJwuoVw1TKkDKSyI+/kV8hSEn0NxUI/YE5ewfipNCGrghXCIcgL5Az9vDKqPm1XuengLffASjQ== X-Received: by 2002:adf:cc82:0:b0:20a:cf3b:4624 with SMTP id p2-20020adfcc82000000b0020acf3b4624mr13707942wrj.573.1651606807899; Tue, 03 May 2022 12:40:07 -0700 (PDT) Received: from [10.137.0.17] (ip-86-49-250-165.net.upcbroadband.cz. [86.49.250.165]) by smtp.gmail.com with ESMTPSA id l12-20020adfbd8c000000b0020c5253d8edsm10219412wrh.57.2022.05.03.12.40.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 03 May 2022 12:40:07 -0700 (PDT) Message-ID: Date: Tue, 3 May 2022 21:40:04 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: bogus: logical replication rows/cols combinations Content-Language: en-US To: Peter Eisentraut , Amit Kapila Cc: Alvaro Herrera , Pg Hackers References: <006d5ffc-1e7a-5cf2-c507-88eee6e0c14d@enterprisedb.com> <202204270943.4ol7indtwv3i@alvherre.pgsql> <39077967-c327-eddb-ac4b-7d64117944fb@enterprisedb.com> <338e719c-4bc8-f40a-f701-e29543a264e4@enterprisedb.com> <47dd2cb9-4e96-169f-15ac-f9407fb54d43@enterprisedb.com> From: Tomas Vondra In-Reply-To: <47dd2cb9-4e96-169f-15ac-f9407fb54d43@enterprisedb.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 5/2/22 22:34, Peter Eisentraut wrote: > On 01.05.22 23:42, Tomas Vondra wrote: >> Imagine have a table with customers from different regions, and you want >> to replicate the data somewhere else, but for some reason you can only >> replicate details for one particular region, and subset of columns for >> everyone else. So you'd do something like this: >> >> CREATE PUBLICATION p1 FOR TABLE customers (... all columns ...) >>   WHERE region = 'USA'; >> >> CREATE PUBLICATION p1 FOR TABLE customers (... subset of columns ...) >>   WHERE region != 'USA'; >> >> I think ignoring the row filters and just merging the column lists makes >> no sense for this use case. > > I'm thinking now the underlying problem is that we shouldn't combine > column lists at all.  Examples like the above where you want to redact > values somehow are better addressed with something like triggers or an > actual "column filter" that works dynamically or some other mechanism. > So what's wrong with merging the column lists as implemented in the v2 patch, posted a couple days ago? I don't think triggers are a suitable alternative, as it executes on the subscriber node. So you have to first copy the data to the remote node, where it gets filtered. With column filters the data gets redacted on the publisher. > The main purpose, in my mind, of column lists is if the tables > statically have different shapes on publisher and subscriber.  Perhaps > for space reasons or regulatory reasons you don't want to replicate > everything.  But then it doesn't make sense to combine column lists.  If > you decide over here that the subscriber table has this shape and over > there that the subscriber table has that other shape, then the > combination of the two will be a table that has neither shape and so > will not work for anything. > Yeah. If we intend to use column lists only to adapt to a different schema on the subscriber node, then maybe it'd be fine to not merge column lists. It'd probably be reasonable to allow at least cases with multiple publications using the same column list, though. In that case there's no ambiguity. > I think in general we should be much more restrictive in how we combine > publications.  Unless we are really sure it makes sense, we should > disallow it.  Users can always make a new publication with different > settings and subscribe to that directly. I agree with that in principle - correct first, flexibility second. If the behavior is not correct, it doesn't matter how flexible it is. I still think the data redaction use case is valid/interesting, but if we want to impose some restrictions I'm OK with that, as long as it's done in a way that we can relax in the future to allow that use case (that is, without introducing any incompatibilities). However, what's the definition of "correctness" in this context? Without that it's hard to say if the restrictions make the behavior any more correct. It'd be unfortunate to impose restritions, which will prevent some use cases, only to discover we haven't actually made it correct. For example, is it enough to restrict column lists, or does it need to restrict e.g. row filters too? And does it need to consider other stuff, like publications replicating different actions? For example, if we allow different column lists (or row filters) for different actions (one publication for insert, another one for update), we still have the strange behavior described before. And if we force users to use separate subscriptions, I'm not sure that really improves the situation for users who actually need that. They'll do that, and aside from all the problems they'll also face issues with timing between the two concurrent subscriptions, having to decode stuff multiple times, etc. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company