Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pc6sm-0002xE-Ov for pgsql-hackers@arkaria.postgresql.org; Tue, 14 Mar 2023 15:48:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pc6sk-0005Tx-0j for pgsql-hackers@arkaria.postgresql.org; Tue, 14 Mar 2023 15:48:10 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pc6sj-0005Tn-Hx for pgsql-hackers@lists.postgresql.org; Tue, 14 Mar 2023 15:48:09 +0000 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pc6se-0005xE-Qh for pgsql-hackers@postgresql.org; Tue, 14 Mar 2023 15:48:08 +0000 Received: by mail-pj1-x102a.google.com with SMTP id fy10-20020a17090b020a00b0023b4bcf0727so8115804pjb.0 for ; Tue, 14 Mar 2023 08:48:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20210112.gappssmtp.com; s=20210112; t=1678808883; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=sINgCyBhxeQ6Cv+R6DLXRSM6wOsCO3dujyTSVxXEJe4=; b=JO+nGnYTgYI9Z00I40T3h8rGy2WwNGy/G+4x+1yu7Rwhj7IPGEcrmiewDs9IhTGid/ d2Gf+lZThfptSma1PzbcimvjLo3CsNulmV/dyM4p/5gFfxXQD2GZqsNBIrgGOVDQCasd pbWMcAgX3ZyFKWn3vn9NdBEbXuWyLCx7rxrdadEUhayXXhcChushTjiwFMImRVmWf0Mx /2JYujjCSv+vIFt+K+BApJ48IsMU9j6RzAtvBUhc7/Aa2fcBGDM2zVofCq71S9dEmunb 46665LtuIAkt+u9auVYHqup5DZueHhooog5bYTkwhQh7St3ePUXcoSlDEMLFSl9aq1u7 jvDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678808883; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=sINgCyBhxeQ6Cv+R6DLXRSM6wOsCO3dujyTSVxXEJe4=; b=LQEzqUzCopRQWKSdmfZrMfzSsz4D93no9IN/ulHlgBAgZa3WSG5eBZqBNO4dUZKYmc Gfm1dlo0mg6uUDBvBFy9HMSmYZvZL+FUcdKsUJwgUOsyatWUaOTK38wywRBF0i75vB7D CWaL9x6OshXzKuaUnGd/MgUmO4/UiQFwNMhf5z0oAHtRLbIWUEdUAXV8kYGjkUyN9cMX SUxxhxc4/W/ln4bKl/gBGXxx/bxqLLIVIcPmkXjjoosCORxajII/0GLU+oHZeK3SoXnN zXU/iWwgJSTQBERep+J3eNnnPZvXDKSU+kXUgzx98hUUL7Yf/pN15bf88FGVC6qCmFPh H7qQ== X-Gm-Message-State: AO0yUKXP+z56IAlteR4C8daYSwxqL2wCK1f19xWqJReAb94pdv+QI0zO Q30ccqAGBLsW94LsJRtA2itfGH71M5JAlR++TOY= X-Google-Smtp-Source: AK7set8LhBexnmf8U0PvbnU/5wBEM3q7Q1B6oYxQSlHaRkhaXiSUL1beg59de4BTW3YMouomQOT6Xg== X-Received: by 2002:a17:903:1c1:b0:19e:72c5:34df with SMTP id e1-20020a17090301c100b0019e72c534dfmr45594807plh.52.1678808882633; Tue, 14 Mar 2023 08:48:02 -0700 (PDT) Received: from jeff-laptop.lan (c-73-231-146-4.hsd1.ca.comcast.net. [73.231.146.4]) by smtp.gmail.com with ESMTPSA id c15-20020a170903234f00b0019c922911a2sm904332plh.40.2023.03.14.08.48.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 08:48:02 -0700 (PDT) Message-ID: Subject: Re: ICU 54 and earlier are too dangerous From: Jeff Davis To: Andres Freund Cc: pgsql-hackers@postgresql.org Date: Tue, 14 Mar 2023 08:48:01 -0700 In-Reply-To: <20230314011319.5nofk5nq65in4d7f@awork3.anarazel.de> References: <20230314011319.5nofk5nq65in4d7f@awork3.anarazel.de> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4-0ubuntu1 MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2023-03-13 at 18:13 -0700, Andres Freund wrote: > What non-error code is returned in the above example? When the collator for locale "asdf" is opened, the status is set to U_USING_DEFAULT_WARNING. That seemed very promising at first, but it's the same thing returned after opening most valid locales, including "en" and "en-US". It seems to only return U_ZERO_ERROR on an exact hit, like "fr-CA" or "root". There's also U_USING_FALLBACK_WARNING, which also seemed promising, but it's returned when opening "fr-FR" or "ja-JP" (falls back to "fr" and "ja" respectively). > Can we query the returned collator and see if it matches what we were > looking > for? I tried a few variations of that in my canonicalization / validation patch, which I called "validation". The closest thing I found is: ucol_getLocaleByType(collator, ULOC_VALID_LOCALE, &status) We could strip away the attributes and compare to the result of that, and it mostly works. There are a few complications, like I think we need to preserve the "collation" attribute for things like "de@collation=3Dphonebook". Another thing to consider is that the environment might happen to open the collation you intend at the time the collation is created, but then later of course the environment can change, so we'd have to check every time it's opened. And getting an error when the collation is opened is not great, so it might need to be a WARNING or something, and it starts to get less useful. What would be *really* nice is if there was some kind of way to tell if there was no real match to a known locale, either during open or via some other API. I wasn't able to find one, though. Actually, now that I think about it, we could just search all known locales using either ucol_getAvailable() or uloc_getAvailable(), and see if there's a match. Not very clean, but it should catch most problems. I'll look into whether there's a reasonable way to match or not. >=20 > I'm a bit confused by the dates. > https://icu.unicode.org/download/55m1=C2=A0says > that version was released 2014-12-17, but the linked issue around > root locales > is from 2018: https://unicode-org.atlassian.net/browse/ICU-10823=C2=A0 - = I > guess > the issue tracker was migrated at some point or such... The dates are misleading in both git (migrated from SVN circa 2016) and JIRA (migrated circa 2018, see https://unicode-org.atlassian.net/browse/ICU-1 ). It seems 55.1 was released in either 2014 or 2015. Regards, Jeff Davis