pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Momjian <bruce@momjian.us>
To: 2322370369@qq.com
To: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #18857: Abnormal string comparison results
Date: Thu, 20 Mar 2025 11:00:58 -0400
Message-ID: <Z9wtqonXuI2DL5vo@momjian.us> (raw)
In-Reply-To: <18857-a9354c81af5b800d@postgresql.org>
References: <18857-a9354c81af5b800d@postgresql.org>

On Thu, Mar 20, 2025 at 09:53:32AM +0000, PG Bug reporting form wrote:
> The following bug has been logged on the website:
> 
> Bug reference:      18857
> Logged by:          dlyixue Xu
> Email address:      2322370369@qq.com
> PostgreSQL version: 17.3
> Operating system:   Ubuntu 22.04
> Description:        
> 
> When I use a conditional query, I find that it returns results that are not
> as expected. After checking, I found that there is a problem with string
> comparison here.
> As shown in the example below, on the ASCII table ‘?’ is larger than ‘&’. I
> don't think ‘t’ should be returned here. In the MySQL database it does
> return 0.
> Is there some special consideration here?
> 
> postgres=# SELECT ('?' <= '&*CcCV5');
>  ?column? 
> ----------
>  t

I think your collation is ignoring punctuation:

	SELECT '?Z' <= '&A';
	 ?column?
	----------
	 f
	
	SELECT '?A' <= '&Z';
	 ?column?
	----------
	 t
	
	SELECT '?' <= '&*CcCV5' COLLATE "C";
	 ?column?
	----------
	 f

-- 
  Bruce Momjian  <bruce@momjian.us>        https://momjian.us
  EDB                                      https://enterprisedb.com

  Do not let urgent matters crowd out time for investment in the future.





view thread (3+ messages)

Message-ID: <Z9wtqonXuI2DL5vo@momjian.us>
Permalink:  ../Z9wtqonXuI2DL5vo@momjian.us/
Also on:    postgresql.org/message-id/Z9wtqonXuI2DL5vo@momjian.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: bruce@momjian.us, 2322370369@qq.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #18857: Abnormal string comparison results
  In-Reply-To: <Z9wtqonXuI2DL5vo@momjian.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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