Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aiqQz-0007cg-QE for pgsql-bugs@arkaria.postgresql.org; Wed, 23 Mar 2016 21:35:21 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1aiqQy-0003sL-Pd for pgsql-bugs@arkaria.postgresql.org; Wed, 23 Mar 2016 21:35:20 +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_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1aiqQK-00035R-DP for pgsql-bugs@postgresql.org; Wed, 23 Mar 2016 21:34:40 +0000 Received: from mail-vk0-x230.google.com ([2607:f8b0:400c:c05::230]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1aiqQF-0003Aa-JP for pgsql-bugs@postgresql.org; Wed, 23 Mar 2016 21:34:39 +0000 Received: by mail-vk0-x230.google.com with SMTP id k1so35978289vkb.0 for ; Wed, 23 Mar 2016 14:34:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heroku-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=ambgnCUS7tDQvTLT3JdN9FF6vWhm63AjX6Kvnyi1v5M=; b=boKUuERlix9jTDTDHanfxiO0xjcAe4Gw3jGguNnM2kiWpv9zPqtq4Xvu+EwKK7WinZ DOrqHJdaaQcmImjFIW2LRpVOvhHiQ0oisq/dEv8loZI96LO7XJTcqYsmbcvABKGT8PSs ZQCA66+ntm/ecWoz/luRou55v3KVWsZ2fuwrpLtOUG+6P1ylTcTKNTEgajnv6X6JDYnh p3up90sn7DAapOldsk7+Be2KjzIJNu6F5G9OfiOxfV6e2NMX12eNyDPN6yn+CbSna3lF Mfc9vVy2ygB40K4iTmkRbm9hwu1aK6mEEJxWiAfDrDMr/SfTCB/Ykzc43OQonwQxJ2XW qggQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=ambgnCUS7tDQvTLT3JdN9FF6vWhm63AjX6Kvnyi1v5M=; b=SPB+gV9cTRxQ9oX+drilmaoRMaplMNFaGSnnxxT7G4Igf67KPp07IqMJND9g0tIb9s Yn00NDACc2pk+qjbvqhAI11/kaRIJpBBzA/WoT9X/xI8/h00ct6/OvPzcZ9gQh0/vm5j k5UzNpT6LCkp38w0l/5YWhjAiEe3sAYcHeHRUrla6+MMhscjjpyZKUOmxRBEBuAASbAw GpWZo7gOgEHxJH/YZYbCbra7mpLHEmiQON+1kBWInA3VTnvTGQ2mIsPl4X/9USdjEJSJ w+pXAM8Eh0yckbbuztLzNRoCSXOqEqTu1+KpeqvxuMTtg37vjPNeS86ACq9ZAR8bmg3o RCrQ== X-Gm-Message-State: AD7BkJIDGIris9ULxhG6LwryGBCrWIdpeVvr0kp9GEtP3hGIGTJBlWoxyQIwMFTswpjcLa/lXnPDrS4vP7Q4guik MIME-Version: 1.0 X-Received: by 10.31.156.129 with SMTP id f123mr2722044vke.40.1458768873899; Wed, 23 Mar 2016 14:34:33 -0700 (PDT) Received: by 10.31.154.145 with HTTP; Wed, 23 Mar 2016 14:34:33 -0700 (PDT) In-Reply-To: <28182.1458700903@sss.pgh.pa.us> References: <111D0E27-A8F3-4A84-A4E0-B0FB703863DF@s24.com> <9688.1458605021@sss.pgh.pa.us> <16214.1458615257@sss.pgh.pa.us> <28182.1458700903@sss.pgh.pa.us> Date: Wed, 23 Mar 2016 14:34:33 -0700 Message-ID: Subject: Re: Missing rows with index scan when collation is not "C" (PostgreSQL 9.5) From: Peter Geoghegan To: Tom Lane Cc: Robert Haas , Marc-Olaf Jaschke , Postgres-Bugs Content-Type: text/plain; charset=UTF-8 X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On Tue, Mar 22, 2016 at 7:41 PM, Tom Lane wrote: > Peter Geoghegan writes: >> My concern was not merely "academic" (i.e. it was not limited in scope >> to things that don't make B-Tree indexes corrupt). Pretty sure that we >> need to start thinking of this as a problem with strcoll() that >> strxfrm() does not have for more fundamental reasons, because >> strcoll() says that the first string in the de_DE sorted list is >> *greater* than the third string. > > [ squint... ] I was looking specifically for that sort of misbehavior > in my test program, and I haven't seen it. Sorry, I was in too much of a hurry to get to the bottom of this with that example. I failed to notice that LC_COLLATE for sort was "de_DE", not "de_DE.UTF-8". For my simple case it would not have mattered if "de_DE" was specified instead of "de_DE.UTF-8" on a non-broken system. But, this was a broken system. Anyway, what prompted the misguided example was this: [vagrant@localhost ~]$ ./strxfrm-binary de_DE.UTF-8 'x xx"' 'xxx"' "x xx"" -> 2323230108080801020202010235034b (16 bytes) "xxx"" -> 232323010808080102020201044b (14 bytes) strcmp(arg1, arg2) result: -2 strcoll(arg1, arg2) result: -6 [vagrant@localhost ~]$ ./strxfrm-binary de_DE.UTF-8 'x xxf' 'xxxf' "x xxf" -> 2323231101080808080102020202010235 (17 bytes) "xxxf" -> 2323231101080808080102020202 (14 bytes) strcmp(arg1, arg2) result: 1 strcoll(arg1, arg2) result: -6 Notice that case where a double-quote is used makes strxfrm() and strcoll() agree. Whereas if that character is a character from the Latin Alphabet instead, they disagree. My intuition is that this is significant from the point of view of fixing the glibc strcoll() bug. It feels like there is an incorrectly applied optimization here, that occurs for strcoll() but not the separate transformation process that strxfrm() does. There seems to be at least a few instances of over-optimizing strcoll() in the past few years. For example: https://github.com/bminor/glibc/commit/87701a58e291bd7ac3b407d10a829dac52c9c16e This bug looks like a possible candidate, given that complaints were about de_DE: https://github.com/bminor/glibc/commit/33a667def79c42e0befed1a4070798c58488170f Is this bug of the right vintage? Seems like it might be a bit too early for RHEL 6 to be affected, but I'm no expert. -- Peter Geoghegan -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs