Re: BUG #12694: crash if the number of result rows is lower than gin_fuzzy_search_limit

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
Cc: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, olaf(dot)gw(at)googlemail(dot)com, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #12694: crash if the number of result rows is lower than gin_fuzzy_search_limit
Date: 2015-01-29 19:59:30
Message-ID: 25919.1422561570@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Heikki Linnakangas <hlinnakangas(at)vmware(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message satson.csc17 2015-01-30 10:50:11 BUG #12717: Slow Query
Previous Message Bruce Momjian 2015-01-29 19:07:12 Re: BUG #12670: Can't create postgis extension in single-user mode