pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <hlinnakangas@vmware.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Michael Paquier <michael.paquier@gmail.com>
Cc: olaf.gw@googlemail.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #12694: crash if the number of result rows is lower than gin_fuzzy_search_limit
Date: Thu, 29 Jan 2015 17:54:33 +0200
Message-ID: <54CA57B9.3070602@vmware.com> (raw)
In-Reply-To: <4773.1422545177@sss.pgh.pa.us>
References: <20150128181243.2579.80775@wrigleys.postgresql.org>
	<CAB7nPqQGmwBDzX42NJPdOJ4Sgdx2PT6p8ymcTEH-+1KDiYBtCg@mail.gmail.com>
	<54CA3EB5.3030804@vmware.com>
	<4773.1422545177@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

On 01/29/2015 05:26 PM, Tom Lane wrote:
> Heikki Linnakangas <hlinnakangas@vmware.com> 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.

<looks at the loop a bit more>

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



view thread (10+ messages)  latest in thread

Message-ID: <54CA57B9.3070602@vmware.com>
Permalink:  ../54CA57B9.3070602@vmware.com/
Also on:    postgresql.org/message-id/54CA57B9.3070602@vmware.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: hlinnakangas@vmware.com, tgl@sss.pgh.pa.us, michael.paquier@gmail.com, olaf.gw@googlemail.com
  Subject: Re: BUG #12694: crash if the number of result rows is lower than gin_fuzzy_search_limit
  In-Reply-To: <54CA57B9.3070602@vmware.com>
  References: <20150128181243.2579.80775@wrigleys.postgresql.org> <CAB7nPqQGmwBDzX42NJPdOJ4Sgdx2PT6p8ymcTEH-+1KDiYBtCg@mail.gmail.com> <54CA3EB5.3030804@vmware.com> <4773.1422545177@sss.pgh.pa.us> <54CA57B9.3070602@vmware.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox