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 1m3KaZ-0003tG-S7 for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Jul 2021 15:44:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m3KaY-0000cz-MI for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Jul 2021 15:44:50 +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 1m3KaY-0000cr-Aw for pgsql-hackers@lists.postgresql.org; Tue, 13 Jul 2021 15:44:50 +0000 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1m3KaV-0003ap-Sh for pgsql-hackers@lists.postgresql.org; Tue, 13 Jul 2021 15:44:49 +0000 Received: by mail-pg1-x533.google.com with SMTP id s18so6676133pgq.3 for ; Tue, 13 Jul 2021 08:44:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:cc:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=g2tVGyMwWdVrfFs2/YdKcoktawqhh+74qMBpHpB7psc=; b=T65ouFlFbzGCCOTIBLpfxe7ZYqCidOhfnDJDEnlh88NcO7PK/f9HsQ1Yl3Gs2UJzir P604eg/QaZSsKUjctcRdNhwQSmeijWlVRs7kAjscwV/b3swTUCNXBAfboz6UV8QjsDCR Xo7/3lQRnj02oN+Vg6znPpSRW3hW3oiMA9LoBOdYHs/PZxGrRDHm+cmen/jUaAKJ8Sq8 SvgMaYFQqiRhy67Zh7Gps6HuE7c++uSQWgo0FpL4pi5YH8wfru4hRg6uOufBzqTcmsF6 IINDQ29gCxBPDnryM6DtTsvxLtBMHCKwRF3Fcr8cGvD50JXDVRoZctaZyTH9FlFB+4BF BZeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=g2tVGyMwWdVrfFs2/YdKcoktawqhh+74qMBpHpB7psc=; b=QTMU4xS1ZSUorJuGpUlKwUlbvTXXSBIut1mkEDM7QmgZs/oMzgg6UZotJF9uT0TuzT N7E70gonT6GgIJqmWgsTMFHmDDwOkRWzhXExH4dlOlpXFixlp8muYr8u8FI+GxPTGlQ+ ork/2pYkJ9D3PKUujaPHqcDTcoH8RIif/mXJRYdu8QKA3tjpfNMqhMrullY8qzGtHF5m /WBgcbLHlQQkAKQOICgwytrTdIAw73HM5oK7Nyvg/rqumGmVqnVpZKKRLRlwxwYWIjF1 0nCZ6VpskwHZ15WEVmI9jVoTMHtumh9sjZYzms86kkE4hsXS+YslOiSvrls30bedhdSH k1gg== X-Gm-Message-State: AOAM532013l0SI+iArASNI/IyEZ6VHDrpU9Em8nwlhrK9cHjSLLU176n lFwkU0qozoOxqu3qZT2gBPyjkw== X-Google-Smtp-Source: ABdhPJxC/w9266TkInMntHQR0wsBXHJxgHsdAzuFaLcLA1v/tpgpPqM8T2suqLlNZvLkyiBfvgbA+A== X-Received: by 2002:a62:f84d:0:b029:30f:a9a8:b8c0 with SMTP id c13-20020a62f84d0000b029030fa9a8b8c0mr5448613pfm.52.1626191086880; Tue, 13 Jul 2021 08:44:46 -0700 (PDT) Received: from jdavis.lan (c-73-231-146-4.hsd1.ca.comcast.net. [73.231.146.4]) by smtp.gmail.com with ESMTPSA id h5sm15879611pfv.145.2021.07.13.08.44.44 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Jul 2021 08:44:46 -0700 (PDT) Message-ID: <15cdb1b63669b6e6d7a3dcd9a21f156aa1bea8fd.camel@j-davis.com> Subject: Re: row filtering for logical replication From: Jeff Davis To: Amit Kapila , Tomas Vondra Cc: Alvaro Herrera , Euler Taveira , Greg Nancarrow , Peter Smith , Rahila Syed , Peter Eisentraut , =?UTF-8?Q?=C3=96nder_Kalac=C4=B1?= , japin , Michael Paquier , David Steele , Craig Ringer , Tomas Vondra , Amit Langote , PostgreSQL Hackers Date: Tue, 13 Jul 2021 08:44:43 -0700 In-Reply-To: References: <849ee491-bba3-c0ae-cc25-4fce1c03f105@enterprisedb.com> <202107120148.l4nueeibgynb@alvherre.pgsql> <33c033f7-be44-e241-5fdf-da1b328c288d@enterprisedb.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 2021-07-13 at 10:24 +0530, Amit Kapila wrote: > to do. AFAIU, the main things we want to prohibit in the filter are: > (a) it doesn't refer to any relation other than catalog in where > clause, Right, because the walsender is using a historical snapshot. > (b) it doesn't use UDFs in any way (in expressions, in > user-defined operators, user-defined types, etc.), Is this a reasonable requirement? Postgres has a long history of allowing UDFs nearly everywhere that a built-in is allowed. It feels wrong to make built-ins special for this feature. > (c) the columns > referred to in the filter should be part of PK or Replica Identity. Why? Also: * Andres also mentioned that the function should not leak memory. * One use case for this feature is when sharding a table, so the expression should allow things like "hashint8(x) between ...". I'd really like to see this problem solved, as well. > I think in the long run one idea to allow UDFs is probably by > explicitly allowing users to specify whether the function is > publication predicate safe and if so, then we can allow such > functions > in the filter clause. This sounds like a better direction. We probably need some kind of catalog information here to say what functions/operators are "safe" for this kind of purpose. There are a couple questions: 1. Should this notion of safety be specific to this feature, or should we try to generalize it so that other areas of the system might benefit as well? 2. Should this marking be superuser-only, or user-specified? 3. Should it be related to the IMMUTABLE/STABLE/VOLATILE designation, or completely separate? Regards, Jeff Davis