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.96) (envelope-from ) id 1w5ZEb-003NfJ-2i for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Mar 2026 01:10:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w5ZEa-000Ime-0P for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Mar 2026 01:10:04 +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.96) (envelope-from ) id 1w5ZEZ-000ImW-2i for pgsql-hackers@lists.postgresql.org; Thu, 26 Mar 2026 01:10:04 +0000 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w5ZEY-000000013qJ-0nPp for pgsql-hackers@postgresql.org; Thu, 26 Mar 2026 01:10:03 +0000 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-5a159c1e65aso490503e87.0 for ; Wed, 25 Mar 2026 18:10:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1774487399; cv=none; d=google.com; s=arc-20240605; b=OdNUfH/WNl041reMVrJffg9G5XQBQkfJbZDyyk1IpUVeuf8QNmP9WFYjNLfKSFQ5+H naQDn4qcWEowrEgiZ9Hq9zBKoPyL2vgzuqwTgR/yGjyH2AWEnEX5BuAqxC7nFjpB9tDT 0TR7iTbpuE/XZEtINsVj3/dRRSST7617Dp5Indrx7VwlzZXGyliaMrYemNqNctXAXrQm js5JxVrb97+Hjtj/lX5aObdr7fnzQLLg3C73D97aSMXYUZKzniC8mGKHoOjV2JaEVwmJ i6w5YY1pdcVjdohbXaxjPqxpvtbQQ54kg8DBEWNZCPIox9NqhlT4x90yvQ8pJZa0CebY oNNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Kczu3LaUWoeTWEC9Ts6HsD31w5UnxsTqmd0YZRWsq5k=; fh=iKAFMcaygt54Unh1lMg84BouMbTr92yaHiObi/y5VEY=; b=fehX7QjtlWyPfrx2k0W4gvGq99MnpJPKryewzey8a+b+niF/DKk6sq38GH/J9OwztJ I74vXcv3Vub8GLEEK3r8DWd1m8T2xzPvRi5RRYYhezg45uHjZy1koljwU45eBEhAeiXQ x8aYZmI0gDgFMbCiMz99BtGSBQucY/EEPmHHVnOQFkNaWW90Dt41FuqecT2/ZtmIgUUl AktjShpkaswsKX7bmSdrVJ5yOJAJi8CgpEbfuWqrCQwEI7RbBxMTrRnxMEEFGdYH6S5z b6AVjJoaeOPFJrrQK5Q/gdt1lk8c6k3gILNFKhO99gMx3Fbkh1QLrjESlqZM65qwzQQu zHqQ==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774487399; x=1775092199; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Kczu3LaUWoeTWEC9Ts6HsD31w5UnxsTqmd0YZRWsq5k=; b=fcWx+jw5+1SEfMnsdA5q4uBs9TRA/y26LrywwP4qtVjcxNh+j4zFb35k0ZBL8Dvmcr v0HYWd9C1MU3smQ1fUZB8xtHCnNIXLEf4pu2yeUKo7H20FQzB+MujtXf/RZsBGDY17CF 9mBHl7MbDVD7+2xhtDf3y+K4hMXuXbB3nGizOASJ9cBs+GOkw2ZaB4q/oup+Ff2w0clA ovJHMygAPtkpMxdkiEAKIhVK/YkBkcyF9P3iw6jYX9Se3pGC8uX8Pk/HxALfclEtw3yF ojnxBjVk+R3uBPBG9+mT4dTLUHvOXPZ1Gd7TTUFoHoZVufTrPQSAuWVQoxIeozlKbu9A pfoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774487399; x=1775092199; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Kczu3LaUWoeTWEC9Ts6HsD31w5UnxsTqmd0YZRWsq5k=; b=Lz9NbcqjQ9N5lILoseaXwfK/Gc+8nhxFwV9Guze1uE12hfcZe1NjzQ1XjAJACJNTZ0 g6SNrlT8uI5Z3niSUue4gPQu43X3CJFpjzxfBeyWTGuE8fZfcKg/yULOD0Oi0DqELj3q IO5LG0mz/hmVILKuTShuiIExv4QqAinXI+o/GXXdVhhlZat+25yWpM9l2LGHZgDPkVKV dIHkURBu68mnF0WQFmvdhKg29oZtZu61/773yz5OFOwVZwa0tkJS9ODm5h1eYJu+enam RjdHel/ijCBjpzUVsta1u34/R0kW5WXC8y9W8tYTc6K/TnG7Idpuht/KotuSRAGPAB9s PIlw== X-Forwarded-Encrypted: i=1; AJvYcCWY08U2mm6jbNqLC/6SH5D4US0/mxWiFQDVINzD4OWWhHyQxa1MHRJmTdH9Or+4vnH+rR6xSyKvoeg+It0k@postgresql.org X-Gm-Message-State: AOJu0Yxj8kbjJHhsAU/2CbEYORQTnilY+pT+J9aeEdM+XACPYBGS8M+y nq9y3kYVBuVWEPbz07AEHEAP3knh2YALccorIRpD7KilRRCDtooW2MNyZyABtPtcu0WH5Ee23l9 yXdAe82P+/578pFBG+UJcqq2k98ZYJKpxm6lU X-Gm-Gg: ATEYQzwZRNsvoR1mnM7VNgDkRXPcp9mcA2PoyLi1WKaGm80NmrFyeMSXO6X1G0b61gj L1Uga5MpXOlRC+bVc3rJkjJt1sX2wWtzKWXALXg8jmjZGd/SM+woj4djJNuRUpxaqSioeu3ZA9S E7NqVXlPtPbcn9u6JU/rqBaGwj0noBUihn9OSZqOJGGvgEl2roDqGBtYK4thUS0mkAsR9wDeTf2 Y0zFTcjLCWCrZmdbMf5rGtPscTBxrfoUDACCONAYfpLyiwn5xKGRW+D9rQrlB4/dBBWF8QJT9io 7Y3ohWh1ZAo4IWlFB7M= X-Received: by 2002:a05:6512:159e:b0:5a2:7868:eed2 with SMTP id 2adb3069b0e04-5a29b99b9c9mr2601630e87.39.1774487398726; Wed, 25 Mar 2026 18:09:58 -0700 (PDT) MIME-Version: 1.0 References: <1791665551.452444.1761209220211.ref@mail.yahoo.com> <878qbn51kb.fsf@wibble.ilmari.org> <1F13AF7E-B90A-40FB-B47C-DC38FBB08353@gmail.com> <01aac5bb-63b1-420f-b396-fdc2027fbb50@vondra.me> <688741.1774485357@sss.pgh.pa.us> In-Reply-To: <688741.1774485357@sss.pgh.pa.us> From: Masahiko Sawada Date: Wed, 25 Mar 2026 18:09:22 -0700 X-Gm-Features: AQROBzCRG6KuQVeE3t6uwm6oQH4Rx_rGZLZbdP4EmnfTg2YmReAndvKX_LCZUfM Message-ID: Subject: Re: Add uuid_to_base32hex() and base32hex_to_uuid() built-in functions To: Tom Lane Cc: Tomas Vondra , Aleksander Alekseev , pgsql-hackers , Chao Li , =?UTF-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= , Andrey Borodin Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Mar 25, 2026 at 5:35=E2=80=AFPM Tom Lane wrote: > > Tomas Vondra writes: > > On 3/26/26 00:40, Tom Lane wrote: > >> I believe what's happening there is that in cs_CZ locale, > >> "V" doesn't follow simple ASCII sort ordering. > > > With cs_CZ all letters sort *before* numbers, while in en_US it's the > > other way around. V is not special in any way. > > Ah, sorry, I should have researched a bit instead of relying on > fading memory. The quirk I was thinking of is that in cs_CZ, > "ch" sorts after "h": > > u8=3D# select 'h' < 'ch'::text collate "en_US"; > ?column? > ---------- > f > (1 row) > > u8=3D# select 'h' < 'ch'::text collate "cs_CZ"; > ?column? > ---------- > t > (1 row) > > Regular hex encoding isn't bitten by that because it doesn't > use 'h' in the text form ... but this base32hex thingie does. > > However, your point is also correct: > > u8=3D# select '0' < 'C'::text ; > ?column? > ---------- > t > (1 row) > > u8=3D# select '0' < 'C'::text collate "cs_CZ"; > ?column? > ---------- > f > (1 row) > > and that breaks "text ordering matches numeric ordering" > for both traditional hex and base32hex. So maybe this > is not as big a deal as I first thought. We need a fix > for the new test though. Probably adding COLLATE "C" > would be enough. Thank you for the report and the analysis. I've reproduced the issue with "cs_CZ" collation and adding COLLATE "C" to the query resolves it. It seems also a good idea to add a note in the documentation too as users might face the same issue. For example, To maintain the lexicographical sort order of the encoded data, ensure that the text is sorted using the C collation (e.g., using COLLATE "C"). Natural language collations may sort characters differently and break the ordering. Regards, --=20 Masahiko Sawada Amazon Web Services: https://aws.amazon.com