On 2015-08-13 14:28:58 +0300, Heikki Linnakangas wrote:
> On 08/12/2015 03:46 PM, Stephen Frost wrote:
> >* Andres Freund (and...@anarazel.de) wrote:
> >>On 2015-08-12 08:16:09 -0400, Stephen Frost wrote:
> >>>>1) gin stores/queries some bools as GinTernaryValue.
> >>>>
> >>>>    Part of this is easy to fix, just adjust GinScanKeyData->entryRes to
> >>>>    be a GinTernaryValue (it's actually is compared against
> >>>>    MAYBE).

That bit looks sane to you? That appears to be an actual misdeclaration
to me.

> >>>>    What I find slightly worrysome is that in gin_tsquery_consistent()
> >>>>    checkcondition_gin (returning GinTernaryValue) is passed as a
> >>>>    callback that's expected to return bool. And the field
> >>>>    checkcondition_gin is returning (GinChkVal->check[i]) actually is a
> >>>>    ternary.
> >>>
> >>>Is there a potential corruption issue from that..?
> >>
> >>I honestly don't understand the gin code well enough to answer that.
> >
> >Yeah, neither do I, so I've added Heikki.  Heikki, any idea as to the
> >impact of this?
> 
> It's harmless. gin_tsquery_consistent() places a boolean array as the
> 'check' array, and therefore checkcondition_gin will also only return TRUEs
> and FALSEs, never MAYBEs. A comment to explain why that's OK would probably
> be in order though.

Ok. As I get warnings here it seems best to add a cast when passing the
function (i.e. (bool (*) (void *, QueryOperand *)) checkcondition_gin))
and adding a comment to checkcondition_gin() explaining that it better
only return booleans?

For reference, those are the warnings.

/home/andres/src/postgresql/src/backend/access/gin/ginlogic.c: In function 
‘shimTriConsistentFn’:
/home/andres/src/postgresql/src/backend/access/gin/ginlogic.c:171:24: warning: 
comparison of constant ‘2’ with boolean expression is always false 
[-Wbool-compare]
   if (key->entryRes[i] == GIN_MAYBE)
                        ^
/home/andres/src/postgresql/src/backend/utils/adt/tsginidx.c: In function 
‘gin_tsquery_consistent’:
/home/andres/src/postgresql/src/backend/utils/adt/tsginidx.c:287:13: warning: 
assignment from incompatible pointer type [-Wincompatible-pointer-types]
   gcv.check = check;
             ^
/home/andres/src/postgresql/src/backend/utils/adt/tsginidx.c:294:8: warning: 
passing argument 4 of ‘TS_execute’ from incompatible pointer type 
[-Wincompatible-pointer-types]
        checkcondition_gin);
        ^
In file included from 
/home/andres/src/postgresql/src/backend/utils/adt/tsginidx.c:20:0:
/home/andres/src/postgresql/src/include/tsearch/ts_utils.h:107:13: note: 
expected ‘_Bool (*)(void *, QueryOperand *) {aka _Bool (*)(void *, struct 
<anonymous> *)}’ but argument is of type ‘GinTernaryValue (*)(void *, 
QueryOperand *) {aka char (*)(void *, struct <anonymous> *)}’
 extern bool TS_execute(QueryItem *curitem, void *checkval, bool calcnot,
             ^

Greetings,

Andres Freund


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to