Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u2w4G-0080u7-FD for pgsql-bugs@arkaria.postgresql.org; Thu, 10 Apr 2025 17:52:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1u2w4E-00FVha-PP for pgsql-bugs@arkaria.postgresql.org; Thu, 10 Apr 2025 17:51:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u2w4E-00FVhS-Gm for pgsql-bugs@lists.postgresql.org; Thu, 10 Apr 2025 17:51:58 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1u2w4C-004Yug-1O for pgsql-bugs@lists.postgresql.org; Thu, 10 Apr 2025 17:51:58 +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 53AHpshL535956; Thu, 10 Apr 2025 13:51:54 -0400 From: Tom Lane To: fabernal@gmail.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18887: Inner join returns non-existent data. In-reply-to: <18887-6681d7157d178b70@postgresql.org> References: <18887-6681d7157d178b70@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Thu, 10 Apr 2025 15:50:50 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <535954.1744307514.1@sss.pgh.pa.us> Date: Thu, 10 Apr 2025 13:51:54 -0400 Message-ID: <535955.1744307514@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > I have two tables that share the same primary key composed of three fields. > When I perform an inner join using all the key fields in the statement, it > returns non-existent values. The inner join shouldn't return any rows, but > instead it returns a row with a non-existent value. > Select rp.codactividadeconomica > from p_contratos pc > inner join remuner.remunerp_contratos rp > on pc.codigoempresa = rp.codigoempresa > and pc.concoanio = rp.concoanio > and pc.concosecue = rp.concosecue > where pc.codigoempresa = 2 and pc.concoanio = 16 and pc.concosecue = > '017'; I'm inclined to guess that this is a symptom of a corrupted index; does REINDEX help? Since one of the columns in question is text (well, char(N)), a plausible theory about what caused the corruption is an update of the underlying system that resulted in a collation change. See https://wiki.postgresql.org/wiki/Locale_data_changes regards, tom lane