Re: Issue with retrieving data when the column has @- in it's value

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Teju Jakkidi <teja(dot)jakkidi05(at)gmail(dot)com>, pgsql-admin <pgsql-admin(at)lists(dot)postgresql(dot)org>
Subject: Re: Issue with retrieving data when the column has @- in it's value
Date: 2025-04-05 15:18:42
Message-ID: bf0ae6506619caad2fe176f37cc08b4d370173f8.camel@cybertec.at
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Fri, 2025-04-04 at 18:41 -0700, Teju Jakkidi wrote:
> I have an issue where in the same scenario below works on my POC but is having an issue in the original db.
>
> Original db - OS : Red Hat   (postgres13)
> POC db - OS : SUSE    (postgres 14)
>
> SELECT char_length("col1"), octet_length("col1"), "col1"
> FROM "test_col" WHERE "col1" = 'test_level(at)-1';
>
> The above query returns data in POC, however, on orig db, it does not return any data.
>
> On orig db, I have to either a dd trim or COLLATE "C" for it to return data.
>
> The collation is same on both the dbs (en_US.UTF-8) and the os locate is also the same on both.
>
> Column col1 datatype is varchar.
>
> I tried checking if there are any spaces or special characters and did not see anything in the output. 
>
> SELECT char_length("col1"), octet_length("col1"), length("col1"), encode("col1"::bytea, 'escape')
> FROM "test_col" WHERE "col1" = 'test_level(at)-1';
>
> output is the same for both:
>  char_length | octet_length | length |    encode
> -------------+--------------+--------+---------------
>           13 |           13 |     13 | test_level(at)-1
>
> Can anyone guide me on what else can be checked?

Find out the primary key of the row in question and look what the bytes are:

SELECT convert_to(col1, 'UTF8') FROM test_col WHERE pkey = 42;

Compare that on both databases, and compare it with the string literal:

SELECT convert_to('test_level(at)-1', 'UTF8') FROM test_col WHERE pkey = 42;

Also, compare the collations shown in the \l output for the database.

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Scott Ribe 2025-04-05 15:27:43 Re: Issue with retrieving data when the column has @- in it's value
Previous Message David G. Johnston 2025-04-05 01:46:38 Re: Issue with retrieving data when the column has @- in it's value