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 1kVymQ-00031f-09 for pgsql-general@arkaria.postgresql.org; Fri, 23 Oct 2020 15:14:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kVymO-000587-36 for pgsql-general@arkaria.postgresql.org; Fri, 23 Oct 2020 15:14:56 +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 1kVymN-00057z-Qp for pgsql-general@lists.postgresql.org; Fri, 23 Oct 2020 15:14:55 +0000 Received: from smtp-zimbra.meteo.fr ([137.129.16.22] helo=celebrian2.meteo.fr) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kVymK-0007HP-N4 for pgsql-general@postgresql.org; Fri, 23 Oct 2020 15:14:55 +0000 Received: from localhost (localhost [127.0.0.1]) by celebrian2.meteo.fr (Postfix) with ESMTP id 79260484F8 for ; Fri, 23 Oct 2020 17:14:51 +0200 (CEST) Received: from celebrian2.meteo.fr ([127.0.0.1]) by localhost (celebrian2.meteo.fr [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 8Awg08_6hMds for ; Fri, 23 Oct 2020 17:14:51 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by celebrian2.meteo.fr (Postfix) with ESMTP id 5E9E8484FB for ; Fri, 23 Oct 2020 17:14:51 +0200 (CEST) X-Virus-Scanned: amavisd-new at celebrian2.meteo.fr Received: from celebrian2.meteo.fr ([127.0.0.1]) by localhost (celebrian2.meteo.fr [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id u2GqxUgje-wH for ; Fri, 23 Oct 2020 17:14:51 +0200 (CEST) Received: from zumba5.meteo.fr (zumba5 [172.31.9.201]) by celebrian2.meteo.fr (Postfix) with ESMTP id 46E5C484F8 for ; Fri, 23 Oct 2020 17:14:51 +0200 (CEST) Date: Fri, 23 Oct 2020 17:14:50 +0200 (CEST) From: PALAYRET Jacques To: Postgres General Message-ID: <681025551.21077286.1603466090802.JavaMail.zimbra@meteo.fr> In-Reply-To: References: <1798752798.21016829.1603460088042.JavaMail.zimbra@meteo.fr> Subject: Re: Conditional column filtering with pglogical replication MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="=_e548232c-7c2a-4f9d-8c77-9b108d36ceb7" X-Originating-IP: [172.31.9.205] X-Mailer: Zimbra 8.7.11_GA_3822 (ZimbraWebClient - FF82 (Win)/8.7.11_GA_3822) Thread-Topic: Conditional column filtering with pglogical replication Thread-Index: kdRxLVQ9dv8SzbFPB55vmOaul2y7JQ== List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --=_e548232c-7c2a-4f9d-8c77-9b108d36ceb7 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable The " row_filter " filters the rows and I don=E2=80=99t want to filter the = row but only one (or several) column(s).=20 Actually, I want a column value on the provider to be filtered on subcriber= s when replicating.=20 For example, on provider :=20 a | b | c | d=20 -----+------+----+------=20 123 | 45.6 | 15 | abc=20 111 | 55.5 | 66 | def=20 on subscriber :=20 a | b | c | d=20 -----+------+----+------=20 123 | 45.6 | 15 | abc=20 111 | | 66 | def=20 -> b NULL on subscriber but the others columns are replicated.=20 De: "Fabr=C3=ADzio de Royes Mello" =20 =C3=80: "PALAYRET Jacques" =20 Cc: "Postgres General" =20 Envoy=C3=A9: Vendredi 23 Octobre 2020 16:23:19=20 Objet: Re: Conditional column filtering with pglogical replication=20 Em sex., 23 de out. de 2020 =C3=A0s 10:35, PALAYRET Jacques < [ mailto:jacq= ues.palayret@meteo.fr | jacques.palayret@meteo.fr ] > escreveu:=20 >=20 > With PgLogical extension, I have tested the possibility of column filteri= ng (columns) and row filtering (row_filter).=20 > But is there a way to do a conditional column filtering ?=20 > I mean a way to filter a column based on a predicate, with pglogical (so = the filtered values won=E2=80=99t arrive on subscribers).=20 > For example, with a replicated table t(a integer as Primary Key, b numeri= c, c integer, d text), I would like to filter the column b when c between 1= 0 and 20.=20 >=20 Hello,=20 According to the documentation [1] the row_filter is a normal PostgreSQL ex= pression with the same limitations of CHECK constraints, so you can do some= thing like: row_filter :=3D 'c between 10 and 20 and b =3D ?'=20 Regards,=20 [1] [ https://github.com/2ndQuadrant/pglogical#row-filtering | https://gith= ub.com/2ndQuadrant/pglogical#row-filtering ]=20 --=20 Fabr=C3=ADzio de Royes Mello Timbira - [ http://www.timbira.com.br/ | http:= //www.timbira.com.br/ ]=20 PostgreSQL: Consultoria, Desenvolvimento, Suporte 24x7 e Treinamento=20 --=_e548232c-7c2a-4f9d-8c77-9b108d36ceb7 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable

The " row_filter " filt= ers the rows and I don=E2=80=99t want to filter the row but only one (or se= veral) column(s).

Actually, I want a column value o= n the provider to be filtered on subcribers when replicating.


For example,= on provider :

a | b | c | d

-----+------+----+------

123 | 45.6 | 15 | a= bc

111 | 55.5 | 66 | def

on subscriber :

a |= b | c | d

-----+------+----+------

123 | 45.6 | 15 | abc

111 |  = ;      | 66 | def


-> b NULL o= n subscriber  but the others co= lumns are replicated.


De: "Fabr=C3=ADzio de Royes Mello" <fabrizio@tim= bira.com.br>
=C3=80: "PALAYRET Jacques" <jacques.palayret@m= eteo.fr>
Cc: "Postgres General" <pgsql-general@postgresql.o= rg>
Envoy=C3=A9: Vendredi 23 Octobre 2020 16:23:19
Objet= : Re: Conditional column filtering with pglogical replication
=
Em sex., 23 de ou= t. de 2020 =C3=A0s 10:35, PALAYRET Jacques <jac= ques.palayret@meteo.fr> escreveu:
>
> With PgLogical ext= ension, I have tested the possibility of column filtering (columns) and row= filtering (row_filter).
> But is there a way to do a conditional col= umn filtering ?
> I mean a way to filter a column based on a predicat= e, with pglogical (so the filtered values won=E2=80=99t arrive on subscribe= rs).
> For example, with a replicated table t(a integer as Primary Ke= y, b numeric, c integer, d text), I would like to filter the column b when = c between 10 and 20.
>

Hello,

According to = the documentation [1] the row_filter is a normal PostgreSQL expression with= the same limitations of CHECK constraints, so you can do something like: r= ow_filter :=3D 'c between 10 and 20 and b =3D ?'

Regards= ,


--
   Fabr=C3=ADzio de Royes Mello     &nb= sp;   Timbira - http://www.timbira.com.br/
&= nbsp;  PostgreSQL: Consultoria, Desenvolvimento, Suporte 24x7 e Treina= mento

--=_e548232c-7c2a-4f9d-8c77-9b108d36ceb7--