Re: BUG #12694: crash if the number of result rows is lower than gin_fuzzy_search_limit - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #12694: crash if the number of result rows is lower than gin_fuzzy_search_limit
Date
Msg-id 25919.1422561570@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #12694: crash if the number of result rows is lower than gin_fuzzy_search_limit  (Heikki Linnakangas <hlinnakangas@vmware.com>)
Responses Re: BUG #12694: crash if the number of result rows is lower than gin_fuzzy_search_limit  (Heikki Linnakangas <hlinnakangas@vmware.com>)
List pgsql-bugs
Heikki Linnakangas <hlinnakangas@vmware.com> writes:
> For master and 9.4, I'm thinking of applying the attached. It makes it
> clear that startScan() is not used to re-start a scan with existing scan
> keys, but is always called on a newly initialized scan keys.

Looks reasonable to me, but should ginFreeScanKeys() null out the pointers
after freeing them, to be sure we find any incorrect accesses?  It might
not be worth the trouble; but if you have any doubts at all about the
order of operations this seems like a good safety feature.

Also, in the department of nitpicks, I'd do this:

 {
     IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
+    GinScanOpaque so = (GinScanOpaque) scan->opaque;
     TIDBitmap  *tbm = (TIDBitmap *) PG_GETARG_POINTER(1);
     int64        ntids;

more like this:

 {
     IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
     TIDBitmap  *tbm = (TIDBitmap *) PG_GETARG_POINTER(1);
+    GinScanOpaque so = (GinScanOpaque) scan->opaque;
     int64        ntids;

I think of the PG_GETARG calls as being an ugly stepchild of a proper
function header declaration, and as such, they should come first unless
there is an unavoidable reason not to.

            regards, tom lane

pgsql-bugs by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: BUG #12670: Can't create postgis extension in single-user mode
Next
From: Emre Hasegeli
Date:
Subject: rangesel() bugs on basic comparison operators with an empty range