Re: BUG #18887: Inner join returns non-existent data.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: fabernal(at)gmail(dot)com
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18887: Inner join returns non-existent data.
Date: 2025-04-10 17:51:54
Message-ID: 535955.1744307514@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)org> 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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2025-04-10 18:02:22 Re: BUG #18890: /src/timezone/localtime.c condition always false
Previous Message PG Bug reporting form 2025-04-10 16:47:44 BUG #18891: /src/include/lib/simplehash.h possible palloc0 problems