Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YGrR3-0003kc-7K for pgsql-bugs@arkaria.postgresql.org; Thu, 29 Jan 2015 15:55:13 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YGrR1-0007Vl-DY for pgsql-bugs@arkaria.postgresql.org; Thu, 29 Jan 2015 15:55:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YGrR0-0007V0-AF for pgsql-bugs@postgresql.org; Thu, 29 Jan 2015 15:55:10 +0000 Received: from smtp-outbound-2.vmware.com ([208.91.2.13]) by magus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YGrQu-0006m2-5E for pgsql-bugs@postgresql.org; Thu, 29 Jan 2015 15:55:08 +0000 Received: from sc9-mailhost2.vmware.com (sc9-mailhost2.vmware.com [10.113.161.72]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id 16B4B296D6; Thu, 29 Jan 2015 07:54:59 -0800 (PST) Received: from EX13-CAS-011.vmware.com (EX13-CAS-011.vmware.com [10.113.191.63]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id 14620B0C33; Thu, 29 Jan 2015 07:54:59 -0800 (PST) Received: from [192.168.42.220] (10.113.160.246) by EX13-MBX-024.vmware.com (10.113.191.44) with Microsoft SMTP Server (TLS) id 15.0.913.22; Thu, 29 Jan 2015 07:54:54 -0800 Message-ID: <54CA57B9.3070602@vmware.com> Date: Thu, 29 Jan 2015 17:54:33 +0200 From: Heikki Linnakangas Organization: VMware User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.3.0 MIME-Version: 1.0 To: Tom Lane CC: Michael Paquier , , Subject: Re: BUG #12694: crash if the number of result rows is lower than gin_fuzzy_search_limit References: <20150128181243.2579.80775@wrigleys.postgresql.org> <54CA3EB5.3030804@vmware.com> <4773.1422545177@sss.pgh.pa.us> In-Reply-To: <4773.1422545177@sss.pgh.pa.us> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.113.160.246] X-ClientProxiedBy: EX13-CAS-013.vmware.com (10.113.191.65) To EX13-MBX-024.vmware.com (10.113.191.44) X-Pg-Spam-Score: -6.9 (------) 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 01/29/2015 05:26 PM, Tom Lane wrote: > Heikki Linnakangas writes: >> The fix is simple: make sure that startScanKey() is always called, by >> getting rid of the early return above. Attached. I'll apply this later >> today or tomorrow unless someone sees a problem with this. > > Another, even simpler fix would be to just move the startScanKey() > call loop to before the "if (GinFuzzySearchLimit > 0)" block. > Is there a particular reason why it's a good idea to do things in > the current order? It almost looks like a patch application error > as it stands. The code in startScanKey() uses the predictNumberResult estimates, which the loop modifies, so it would change how that behaves. I'm not sure if it would actually be better that way though; it's not clear to me how the fuzzy search limit should interact with the fast scan code. It won't affect correctness either way. The for()-loop sets the so->entries[i]-reduceResult fields, so it makes sense to do it right after the startScanEntry() calls. Otherwise the logic would be "1. do some initialization on entries, 2. initialize keys, 3. do more initialization on entries", which would be a bit strange. Hmm, isn't the if-check in the second loop unnecessary? The first loop checks that so->entries[i]->predictNumberResult > so->totalentries * GinFuzzySearchLimit for all entries. If there are any where that doesn't hold, it returns (which is a bad idea). There's no need to check for the same condition again in the second loop. - Heikki -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs