Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hj5z3-00015e-4G for pgsql-bugs@arkaria.postgresql.org; Thu, 04 Jul 2019 17:57:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hj5z1-0006ov-P3 for pgsql-bugs@arkaria.postgresql.org; Thu, 04 Jul 2019 17:57:23 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hj5z1-0006o4-9m for pgsql-bugs@lists.postgresql.org; Thu, 04 Jul 2019 17:57:23 +0000 Received: from cyclops.postgrespro.ru ([93.174.131.138] helo=mail.postgrespro.ru) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hj5yy-0001mK-Nx for pgsql-bugs@lists.postgresql.org; Thu, 04 Jul 2019 17:57:22 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 8D4DF21C4372; Thu, 4 Jul 2019 20:57:19 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=x tagged_above=-99 required=4 WHITELISTED tests=[] autolearn=unavailable Received: from [192.168.27.237] (gw.postgrespro.ru [93.174.131.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id 6148F21C4316; Thu, 4 Jul 2019 20:57:19 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1562263039; bh=a85yUYJ+TsM10JcbZQPt2qXWO6To70TjScQ/xEw2QE4=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=LAbszaowQofkEoBrzLvDIKFdZZurMXm0QFLmn+Dh4kcPPCAg16HOY6VlRYIJfnwy1 ABvoYDQBlksjLvwMKcl/sBJh31EaAIYZ7YkcqaioKnHa3EZOWCAJJ1npq/M0XCNorK rTwBRD+FbLbs8rchgbO8VyJS3qEWXlE/JzIipU0M= Subject: Re: BUG #15892: URGENT: Using an ICU collation in a primary key column breaks ILIKE query To: Daniel Verite , James Inform Cc: pgsql-bugs@lists.postgresql.org References: <8be770db-3fd9-428a-968e-333fc67a50db@manitou-mail.org> From: Arthur Zakirov Message-ID: <94c64652-81f6-63b9-b86c-bfc23d5d41d9@postgrespro.ru> Date: Thu, 4 Jul 2019 20:57:19 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.1 MIME-Version: 1.0 In-Reply-To: <8be770db-3fd9-428a-968e-333fc67a50db@manitou-mail.org> Content-Type: multipart/mixed; boundary="------------D238D4C6291384E26352A94A" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------D238D4C6291384E26352A94A Content-Type: text/plain; charset=iso-8859-15; format=flowed Content-Transfer-Encoding: 7bit On 04.07.2019 19:50, Daniel Verite wrote: > Yes. It is because of the index that the code checks if the ILIKE > can be evaluated with an index lookup. Otherwise it doesn't. > > If you feel like recompiling with a temporary fix against v11.4 to do > your own tests, please try the attached patch. Also this patch works. I thinks we need to use some ICU function to check whether a char is a letter. -- Arthur Zakirov Postgres Professional: http://www.postgrespro.com Russian Postgres Company --------------D238D4C6291384E26352A94A Content-Type: text/x-patch; name="fix-selfuncs-ilike-v2.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="fix-selfuncs-ilike-v2.patch" diff --git a/src/backend/utils/adt/like_support.c b/src/backend/utils/adt/like_support.c index 26e0634833..6a8c360209 100644 --- a/src/backend/utils/adt/like_support.c +++ b/src/backend/utils/adt/like_support.c @@ -1449,7 +1449,14 @@ pattern_char_isalpha(char c, bool is_multibyte, else if (is_multibyte && IS_HIGHBIT_SET(c)) return true; else if (locale && locale->provider == COLLPROVIDER_ICU) - return IS_HIGHBIT_SET(c) ? true : false; + { +#ifdef USE_ICU + return u_isalpha(c); +#else + /* shouldn't happen */ + elog(ERROR, "unsupported collprovider: %c", locale->provider); +#endif + } #ifdef HAVE_LOCALE_T else if (locale && locale->provider == COLLPROVIDER_LIBC) return isalpha_l((unsigned char) c, locale->info.lt); --------------D238D4C6291384E26352A94A--