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 1nXuJN-0004oQ-Ew for pgsql-hackers@arkaria.postgresql.org; Sat, 26 Mar 2022 00:29:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nXuJM-0008Rp-3f for pgsql-hackers@arkaria.postgresql.org; Sat, 26 Mar 2022 00:29:44 +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 1nXuJL-0008Rf-54 for pgsql-hackers@lists.postgresql.org; Sat, 26 Mar 2022 00:29:43 +0000 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nXuJH-0006PH-Fw for pgsql-hackers@postgresql.org; Sat, 26 Mar 2022 00:29:41 +0000 Received: by mail-ej1-x633.google.com with SMTP id bg10so18336823ejb.4 for ; Fri, 25 Mar 2022 17:29:39 -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=HQNEWjRvKjn0QYel2D3y4ysd4igWQ7km+DnS/DjlfT8=; b=eolGOz9ou8YWtGBm78A5ssnKeQXm36TkmlqfcWxPQeiB0UBiym1mPELC8JiN+y6r/Y eWh+EUVxZPFCkwmgh/28gx1wgdLAnXid06BRoUDxOIj0SwqgDtd26XWUqOtqwClrL7y6 gIEUUC5BOj5JirQn8BdGMqmVdGmh/jjGjZ+9eIrl4GGqFx4qh8Fwpuqd2JCML7Wob5TT LyRZC4E9wFnE8b7Q3BQ6ZbiizOL3Ovy2VWEUcSMOZC5TLnQ326fj/7mr4CdUcq84nIIf Fxipb0YFu8oHGQh4if8ItilOBd2H1Y2rxhpfuraLiDj9xdLm5CYXKZ0Qwa57rPoSEb/L xi8Q== 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=HQNEWjRvKjn0QYel2D3y4ysd4igWQ7km+DnS/DjlfT8=; b=ODxxHCTpfGHhOsBrB+lAFFkhX7+NRAmQ512YjTa3HEXq/ZxCLdNGHUosPk5pfbtaNo 4wJ7mw4U4V7nodGCvC8pHz/njRCz/WqBkZ+awado4rzU9p4Ul8ONkrWHEyX0n32rC7VM oRlLZv5UAsQdv7J0SxN3wdq9CC38QNQC/aJYjKjlWYOV+MJYWCGP6kgrkg9ATD+ZkhOD upt0Svv6ZrvmP/d7rMl75RsbjWz0lP3GJnCXIXyPSWAoLqf7FvnOHyyoQpz9s87LMwAl ZpWGowbr6IlF8SAqcGVi5KZHPGtTBWKyAD1UGeXcEqsFJPfCUaKlA4NhaPxZEsh2K3Jq enlw== X-Gm-Message-State: AOAM5314YwAhKKv8p4kSuRCLlyAvoxDdtOGZ6gKxd8WiEynYPfxsiC8z wgjkZ9sIkRQwUTC7M28xRnNsJXp+P6YFNH5ZbpywZaOCvFOzHd+/ur/cElkPRf6UzHiZ+gJXAcf 7Yp+XGgBqsTzEft+z7/P6g9HHTec4ymLEaJLcfWXjBFGFZn7IGKUzLw4Su+PRWVPF0Jkb4pSuo3 3NJnYm61jI4JILXh/KRJiaWBqMIGkgVRnbvBXAx0p58ivO X-Google-Smtp-Source: ABdhPJzdR21MDmHXygqsWJt734NpKpW83kyE5tq27twnQ2MnK661HoHHu7RjIEIh2psDGWwIkv0iIw== X-Received: by 2002:a17:906:9b89:b0:6da:ac6b:e785 with SMTP id dd9-20020a1709069b8900b006daac6be785mr14960358ejc.295.1648254578019; Fri, 25 Mar 2022 17:29:38 -0700 (PDT) Received: from [10.137.0.17] (ip-86-49-251-241.net.upcbroadband.cz. [86.49.251.241]) by smtp.gmail.com with ESMTPSA id j8-20020aa7c0c8000000b0041934547989sm3408398edp.55.2022.03.25.17.29.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 25 Mar 2022 17:29:37 -0700 (PDT) Message-ID: <05353cce-2da8-74cc-5419-d0a398212f12@enterprisedb.com> Date: Sat, 26 Mar 2022 01:29:35 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: Column Filtering in Logical Replication Content-Language: en-US To: Amit Kapila Cc: "houzj.fnst@fujitsu.com" , Peter Eisentraut , Alvaro Herrera , Justin Pryzby , Rahila Syed , Peter Smith , pgsql-hackers , "shiy.fnst@fujitsu.com" References: <202201120041.p24wvsfcsope@alvherre.pgsql> <2b8471f9-3849-c91f-ef82-9181d4bca0a7@enterprisedb.com> <16e83ce3-8415-b732-37b2-c3329a2c13a1@enterprisedb.com> <3162f7f0-86ac-e3a9-dc55-0a660cb9bab1@enterprisedb.com> <9f551740-1395-f73d-a792-9d487f8074db@enterprisedb.com> <566a06cd-fcb5-3e78-b2f0-8d21d92e5b87@enterprisedb.com> From: Tomas Vondra In-Reply-To: Content-Type: text/plain; charset=UTF-8 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 3/21/22 15:12, Amit Kapila wrote: > On Sat, Mar 19, 2022 at 11:11 PM Tomas Vondra > wrote: >> >> On 3/19/22 18:11, Tomas Vondra wrote: >>> Fix a compiler warning reported by cfbot. >> >> Apologies, I failed to actually commit the fix. So here we go again. >> > > Few comments: > =============== > 1. > +/* > + * Gets a list of OIDs of all partial-column publications of the given > + * relation, that is, those that specify a column list. > + */ > +List * > +GetRelationColumnPartialPublications(Oid relid) > { > ... > } > > ... > +/* > + * For a relation in a publication that is known to have a non-null column > + * list, return the list of attribute numbers that are in it. > + */ > +List * > +GetRelationColumnListInPublication(Oid relid, Oid pubid) > { > ... > } > > Both these functions are not required now. So, we can remove them. > Good catch, removed. > 2. > @@ -464,11 +478,11 @@ logicalrep_write_update(StringInfo out, > TransactionId xid, Relation rel, > pq_sendbyte(out, 'O'); /* old tuple follows */ > else > pq_sendbyte(out, 'K'); /* old key follows */ > - logicalrep_write_tuple(out, rel, oldslot, binary); > + logicalrep_write_tuple(out, rel, oldslot, binary, columns); > } > > As mentioned previously, here, we should pass NULL similar to > logicalrep_write_delete as we don't need to use column list for old > tuples. > Fixed. > 3. > + * XXX The name is a bit misleading, because we don't really transform > + * anything here - we merely check the column list is compatible with the > + * definition of the publication (with publish_via_partition_root=false) > + * we only allow column lists on the leaf relations. So maybe rename it? > + */ > +static void > +TransformPubColumnList(List *tables, const char *queryString, > + bool pubviaroot) > > The second parameter is not used in this function. As noted in the > comments, I also think it is better to rename this. How about > ValidatePubColumnList? > > 4. > @@ -821,6 +942,9 @@ fetch_remote_table_info(char *nspname, char *relname, > * > * 3) one of the subscribed publications is declared as ALL TABLES IN > * SCHEMA that includes this relation > + * > + * XXX Does this actually handle puballtables and schema publications > + * correctly? > */ > if (walrcv_server_version(LogRepWorkerWalRcvConn) >= 150000) > > Why is this comment added in the row filter code? Now, both row filter > and column list are fetched in the same way, so not sure what exactly > this comment is referring to. > I added that comment as a note to myself while learning about how the code works, forgot to remove that. > 5. > +/* qsort comparator for attnums */ > +static int > +compare_int16(const void *a, const void *b) > +{ > + int av = *(const int16 *) a; > + int bv = *(const int16 *) b; > + > + /* this can't overflow if int is wider than int16 */ > + return (av - bv); > +} > > The exact same code exists in statscmds.c. Do we need a second copy of the same? > Yeah, I thought about moving it to some common header, but I think it's not really worth it at this point. > 6. > static void pgoutput_row_filter_init(PGOutputData *data, > List *publications, > RelationSyncEntry *entry); > + > static bool pgoutput_row_filter_exec_expr(ExprState *state, > > Spurious line addition. > Fixed. > 7. The tests in 030_column_list.pl take a long time as compared to all > other similar individual tests in the subscription folder. I haven't > checked whether there is any need to reduce some tests but it seems > worth checking. > On my machine, 'make check' in src/test/subscription takes ~150 seconds (with asserts and -O0), and the new script takes ~14 seconds, while most other tests have 3-6 seconds. AFAICS that's simply due to the number of tests in the script, and I don't think there are any unnecessary ones. I was actually adding them in response to issues reported during development, or to test various important cases. So I don't think we can remove some of them easily :-( And it's not like the tests are using massive amounts of data either. We could split the test, but that obviously won't reduce the duration, of course. So I decided to keep the test as is, for now, and maybe we can try reducing the test after a couple buildfarm runs. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company