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 1pk84I-0006Jw-7g for pgsql-bugs@arkaria.postgresql.org; Wed, 05 Apr 2023 18:41:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pk84G-0005EO-Rt for pgsql-bugs@arkaria.postgresql.org; Wed, 05 Apr 2023 18:41:12 +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 1pk84G-0005EF-Jc for pgsql-bugs@lists.postgresql.org; Wed, 05 Apr 2023 18:41:12 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pk84D-00169t-VE for pgsql-bugs@lists.postgresql.org; Wed, 05 Apr 2023 18:41:12 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 335If5P82017353; Wed, 5 Apr 2023 14:41:05 -0400 From: Tom Lane To: "Daniel Westermann (DWE)" cc: "pgsql-bugs@lists.postgresql.org" Subject: Re: Wrong results with postgres_fdw and merge anti join from RHEL 7.9 to RHEL 8.7 In-reply-to: References: Comments: In-reply-to "Daniel Westermann (DWE)" message dated "Wed, 05 Apr 2023 18:33:08 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2017351.1680720065.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 05 Apr 2023 14:41:05 -0400 Message-ID: <2017352.1680720065@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "Daniel Westermann (DWE)" writes: > I am not sure if this qualifies as bug, but anyway: > Source instance: PostgreSQL 13.7 on RHEL 7.9 > Target instance PostgreSQL 13.7 on RHEL 8.7 > This is the statement: > SELECT * FROM "rsu_adm"."data_2d_clb_global_product" f2 > LEFT OUTER JOIN "rsu_adm"."clb_global_product" f1 on f1.cprd=3Df2.cprd > WHERE f1.cprd is null; > Per default we see a merge anti join, and this gives results, which is w= rong: You didn't provide anything useful like the table schemas, but correctness of a merge join depends on the servers having the same ideas about sort ordering, and if "cprd" is a text-type column then inconsistent collations could break that. The given plan is at hazard for that because it intends to do one sort locally and the other remotely: > Merge Cond: ((f2.cprd)::text =3D (clb_global_product.cprd)::text) > -> Index Scan using data_2d_clb_global_product_pkey on rsu_adm.data_= 2d_clb_global_product f2 (cost=3D0.42..2898.56 rows=3D101426 width=3D34) > Output: f2.cprd, f2.xtc_id, f2.rprd, f2.prdgalsts_id, f2.dlz_la= st_transaction_ts > -> Foreign Scan on ro_dlz.clb_global_product (cost=3D100.42..52506.= 16 rows=3D923613 width=3D34) > Output: clb_global_product.cprd, clb_global_product.xtc_id, clb= _global_product.rprd, clb_global_product.prdgalsts_id, clb_global_product.= dlz_last_transaction_ts > Remote SQL: SELECT cprd, xtc_id, rprd, prdgalsts_id, dlz_last_t= ransaction_ts FROM ro_rsu.clb_global_product ORDER BY cprd ASC NULLS LAST > I am aware that the version of glibc is not the same between those red h= ats. Is this expected? That's certainly a hazard, but do the servers even have the same collation settings for these columns? regards, tom lane