pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
String comparison fails for some cases after migration
4+ messages / 3 participants
[nested] [flat]

* String comparison fails for some cases after migration
@ 2021-10-27 06:11  Jayadevan M <maymala.jayadevan@gmail.com>
  0 siblings, 2 replies; 4+ messages in thread

From: Jayadevan M @ 2021-10-27 06:11 UTC (permalink / raw)
  To: pgsql-general

Hello all,

We moved our PostgreSQL database from one hosting provider to another using
pgbackrest.  In the new environment, some comparison operations  were
failing.  The issue was fixed by running an update. But I am trying to find
out what would have happened.

select * from accounts where email = 'someemail@gmail.com'; -- failed for
some email ids even though there were records.

select * from accounts where lower(trim(email)) <> email; -- fetched no
records.

select * from accounts where email::bytea = 'someemail@gmail.com'::bytea; -
worked for those records where comparison was failing.

update accounts set email = trim(lower(email)); -- fixed the issue.

Source database was PG 13.2, target 13.3.

Any suggestions will be appreciated - not sure if other tables/columns are
affected.

Best Regards,
Jayadevan

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: String comparison fails for some cases after migration
@ 2021-10-27 06:19  Julien Rouhaud <rjuju123@gmail.com>
  parent: Jayadevan M <maymala.jayadevan@gmail.com>
  1 sibling, 1 reply; 4+ messages in thread

From: Julien Rouhaud @ 2021-10-27 06:19 UTC (permalink / raw)
  To: Jayadevan M <maymala.jayadevan@gmail.com>; +Cc: pgsql-general

Hi,

On Wed, Oct 27, 2021 at 2:12 PM Jayadevan M <maymala.jayadevan@gmail.com> wrote:
>
> We moved our PostgreSQL database from one hosting provider to another using pgbackrest.  In the new environment, some comparison operations  were failing.  The issue was fixed by running an update. But I am trying to find out what would have happened.
>
> select * from accounts where email = 'someemail@gmail.com'; -- failed for some email ids even though there were records.
>
> select * from accounts where lower(trim(email)) <> email; -- fetched no records.
>
> select * from accounts where email::bytea = 'someemail@gmail.com'::bytea; - worked for those records where comparison was failing.
>
> update accounts set email = trim(lower(email)); -- fixed the issue.
>
> Source database was PG 13.2, target 13.3.
>
> Any suggestions will be appreciated - not sure if other tables/columns are affected.

Most likely you had a different version of the glibc or ICU libraries
on the new system, which lead to your indexes on collatable datatypes
partially corrupted.  See https://wiki.postgresql.org/wiki/Collations
for more details.

You can issue a REINDEX for each impacted index, or a database-wide REINDEX.





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: String comparison fails for some cases after migration
@ 2021-10-27 06:19  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Jayadevan M <maymala.jayadevan@gmail.com>
  1 sibling, 0 replies; 4+ messages in thread

From: Tom Lane @ 2021-10-27 06:19 UTC (permalink / raw)
  To: Jayadevan M <maymala.jayadevan@gmail.com>; +Cc: pgsql-general

Jayadevan M <maymala.jayadevan@gmail.com> writes:
> We moved our PostgreSQL database from one hosting provider to another using
> pgbackrest.  In the new environment, some comparison operations  were
> failing.  The issue was fixed by running an update. But I am trying to find
> out what would have happened.

Did the underlying OS version change?  If so, see

https://wiki.postgresql.org/wiki/Locale_data_changes

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: String comparison fails for some cases after migration
@ 2021-10-27 10:48  Jayadevan M <maymala.jayadevan@gmail.com>
  parent: Julien Rouhaud <rjuju123@gmail.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Jayadevan M @ 2021-10-27 10:48 UTC (permalink / raw)
  To: Julien Rouhaud <rjuju123@gmail.com>; +Cc: pgsql-general

On Wed, Oct 27, 2021 at 11:49 AM Julien Rouhaud <rjuju123@gmail.com> wrote:

>
>
> Most likely you had a different version of the glibc or ICU libraries
> on the new system, which lead to your indexes on collatable datatypes
> partially corrupted.  See https://wiki.postgresql.org/wiki/Collations
> for more details.
>
> You can issue a REINDEX for each impacted index, or a database-wide
> REINDEX.
>

Tried creating  a new env with the same approach - just reindexing solved
the problem. Thanks a lot.

Regards,
Jayadevan

^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2021-10-27 10:48 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-10-27 06:11 String comparison fails for some cases after migration Jayadevan M <maymala.jayadevan@gmail.com>
2021-10-27 06:19 ` Julien Rouhaud <rjuju123@gmail.com>
2021-10-27 10:48   ` Jayadevan M <maymala.jayadevan@gmail.com>
2021-10-27 06:19 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox