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 1tvHON-0032zY-JZ for pgsql-bugs@arkaria.postgresql.org; Thu, 20 Mar 2025 15:01:08 +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 1tvHOM-002wFx-9N for pgsql-bugs@arkaria.postgresql.org; Thu, 20 Mar 2025 15:01:06 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tvHOM-002wFj-0t for pgsql-bugs@lists.postgresql.org; Thu, 20 Mar 2025 15:01:06 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tvHOH-00094R-1n for pgsql-bugs@lists.postgresql.org; Thu, 20 Mar 2025 15:01:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=momjian.us; s=2025010100; h=In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Message-ID:Subject:To:From:Date:Sender:Reply-To:Cc: Content-ID:Content-Description; bh=HUw0Hhn898+JeUkOI3hPHo7LC3sjlayFyrSVuBt9OOY=; b=R/OqcyLuHBZ94lSb2kIqI3VgOt Frx6k2MilOoOKxU1jhP57Okz7S6DpRKHY80GQ/XrTY/pwl8x4BQh/JIHQWEOaTKZu/xN5LOwC/tTG d+uD+n3Rq6JQ0MQLMyn4el+CTrehkSB9W2eaAxCoQl37tJm8vJ/3K50r/JIKvTq8Q3xkz076I8EDe HKkBOrC5OQ+yvgHHMC6QChybAXZDtSHmNbqMwWf5kfJfw323hgXYbYeh4XHb8SMZsbT82F8Dxj2BM RiTTji5OeBYJIzxk5DVj4oEzFdXN6cZDQucf9e9uNzhVcyp+nQcXGMhs1bh4qFNtGgJlEcg1VyTqh bD51ZZUg==; Received: from bruce by momjian.us with local (Exim 4.96) (envelope-from ) id 1tvHOE-009WoX-13; Thu, 20 Mar 2025 11:00:58 -0400 Date: Thu, 20 Mar 2025 11:00:58 -0400 From: Bruce Momjian To: 2322370369@qq.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18857: Abnormal string comparison results Message-ID: References: <18857-a9354c81af5b800d@postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <18857-a9354c81af5b800d@postgresql.org> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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 https://momjian.us EDB https://enterprisedb.com Do not let urgent matters crowd out time for investment in the future.