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 1paYId-0003vm-4n for pgsql-bugs@arkaria.postgresql.org; Fri, 10 Mar 2023 08:40:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1paYIc-00071Q-0e for pgsql-bugs@arkaria.postgresql.org; Fri, 10 Mar 2023 08:40:26 +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 1paYIb-00071H-Nx for pgsql-bugs@lists.postgresql.org; Fri, 10 Mar 2023 08:40:25 +0000 Received: from new1-smtp.messagingengine.com ([66.111.4.221]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1paYIY-0005Wu-TZ for pgsql-bugs@postgresql.org; Fri, 10 Mar 2023 08:40:25 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.nyi.internal (Postfix) with ESMTP id 19F1E582187; Fri, 10 Mar 2023 03:40:21 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Fri, 10 Mar 2023 03:40:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1678437621; x= 1678444821; bh=GQiJ9M9/TuvOLGxvtLDeGfwsDQ3/lHDt9gAbNeUFexQ=; b=k TmGkwoUM/6oTA8po+8JmW3MyxoEUcMpDPyPcbrLKHVz6ZnTBoTSDagjw881hc/mX PHSiQtyrZQySJ4bcObs2uUXXxDJyNG9kWSlKiomsWUW4yXrucz6rvELmHzb2/OvX WnVMiq+QUMP0+L/PvONTq65Ho1hFoYweRmARTCOvUBxE7xZYBeCBdZA8xEzKxa9s 52+wK4Mkal58EPVNvaIKC/4c/4oag2feykDBNbaoVHirJ000n0/noGxlBIqvK7Je IYJ5EagbtWwlO8sJxo7il4eRrH+c9F8e+z1OdkJTpZIXEF+xByNiU7U5JpRqP6Fs WLcq3bCZV3wpUuB9haycQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvddujedguddvudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepkfffgggfuffvfhfhjggtgfesth ekredttdefjeenucfhrhhomheprfgvthgvrhcugfhishgvnhhtrhgruhhtuceophgvthgv rhdrvghishgvnhhtrhgruhhtsegvnhhtvghrphhrihhsvggusgdrtghomheqnecuggftrf grthhtvghrnheplefgteefiedtleelgeegjeevhfeuteefvddtjeehveeuieefgedvhfeu leduteeunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epphgvthgvrhdrvghishgvnhhtrhgruhhtsegvnhhtvghrphhrihhsvggusgdrtghomh X-ME-Proxy: Feedback-ID: i131946ab:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 10 Mar 2023 03:40:20 -0500 (EST) Message-ID: <314313bd-9cec-75d2-97fe-9172ef0a593b@enterprisedb.com> Date: Fri, 10 Mar 2023 09:40:19 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: unaccent fails when datlocprovider=i and datctype=C Content-Language: en-US To: Jeff Davis , pgsql-bugs@postgresql.org References: <79e4354d9eccfdb00483146a6b9f6295202e7890.camel@j-davis.com> From: Peter Eisentraut In-Reply-To: <79e4354d9eccfdb00483146a6b9f6295202e7890.camel@j-davis.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 08.03.23 06:49, Jeff Davis wrote: > $ initdb -D data -N --locale-provider=icu --icu-locale=en --locale=C Is it even worth supporting that? What is the point of this kind of setup? > =# create extension unaccent; > ERROR: invalid multibyte character for locale > HINT: The server's LC_CTYPE locale is probably incompatible with the > database encoding. > CONTEXT: line 1 of configuration file > ".../share/tsearch_data/unaccent.rules": "ยก ! > " > > Cause: t_isspace() implementation is incomplete (notice "TODO" > comments): > > Oid collation = DEFAULT_COLLATION_OID; /* TODO */ > pg_locale_t mylocale = 0; /* TODO */ > > if (clen == 1 || lc_ctype_is_c(collation)) > return isspace(TOUCHAR(ptr)); > > char2wchar(character, WC_BUF_LEN, ptr, clen, mylocale); > > return iswspace((wint_t) character[0]); > > If using datlocprovider=c, then the earlier branch goes straight to > isspace(). But if datlocprovider=i, then > lc_ctype_is_c(DEFAULT_COLLATION_OID) returns false, and it goes into > char2wchar(). char2wchar() is essentially a wrapper around mbstowcs(), > which does not work on multibyte input when LC_CTYPE=C. > > Quick fix (attached): check whether datctype is C rather than the > default collation. This seems right. It's unfortunate that we would now have the possibilty that lc_ctype_is_c(DEFAULT_COLLATION_OID) != database_ctype_is_c but that seems to be the nature of things. Maybe a comment somewhere?