@@ -232,7 +232,7 @@ typedef struct
232
232
* is there value 'val' in array or not ?
233
233
*/
234
234
static bool
235
- checkcondition_arr (void * checkval , int4 val )
235
+ checkcondition_arr (void * checkval , ITEM * item )
236
236
{
237
237
int4 * StopLow = ((CHKVAL * ) checkval )-> arrb ;
238
238
int4 * StopHigh = ((CHKVAL * ) checkval )-> arre ;
@@ -243,9 +243,9 @@ checkcondition_arr(void *checkval, int4 val)
243
243
while (StopLow < StopHigh )
244
244
{
245
245
StopMiddle = StopLow + (StopHigh - StopLow ) / 2 ;
246
- if (* StopMiddle == val )
246
+ if (* StopMiddle == item -> val )
247
247
return (true);
248
- else if (* StopMiddle < val )
248
+ else if (* StopMiddle < item -> val )
249
249
StopLow = StopMiddle + 1 ;
250
250
else
251
251
StopHigh = StopMiddle ;
@@ -254,20 +254,20 @@ checkcondition_arr(void *checkval, int4 val)
254
254
}
255
255
256
256
static bool
257
- checkcondition_bit (void * checkval , int4 val )
257
+ checkcondition_bit (void * checkval , ITEM * item )
258
258
{
259
- return GETBIT (checkval , HASHVAL (val ));
259
+ return GETBIT (checkval , HASHVAL (item -> val ));
260
260
}
261
261
262
262
/*
263
263
* check for boolean condition
264
264
*/
265
265
static bool
266
- execute (ITEM * curitem , void * checkval , bool calcnot , bool (* chkcond ) (void * checkval , int4 val ))
266
+ execute (ITEM * curitem , void * checkval , bool calcnot , bool (* chkcond ) (void * checkval , ITEM * item ))
267
267
{
268
268
269
269
if (curitem -> type == VAL )
270
- return (* chkcond ) (checkval , curitem -> val );
270
+ return (* chkcond ) (checkval , curitem );
271
271
else if (curitem -> val == (int4 ) '!' )
272
272
{
273
273
return (calcnot ) ?
@@ -319,6 +319,40 @@ execconsistent(QUERYTYPE * query, ArrayType *array, bool calcnot)
319
319
);
320
320
}
321
321
322
+ typedef struct {
323
+ ITEM * first ;
324
+ bool * mapped_check ;
325
+ } GinChkVal ;
326
+
327
+ static bool
328
+ checkcondition_gin (void * checkval , ITEM * item ) {
329
+ GinChkVal * gcv = (GinChkVal * )checkval ;
330
+
331
+ return gcv -> mapped_check [ item - gcv -> first ];
332
+ }
333
+
334
+ bool
335
+ ginconsistent (QUERYTYPE * query , bool * check ) {
336
+ GinChkVal gcv ;
337
+ ITEM * items = GETQUERY (query );
338
+ int i , j = 0 ;
339
+
340
+ if ( query -> size < 0 )
341
+ return FALSE;
342
+
343
+ gcv .first = items ;
344
+ gcv .mapped_check = (bool * )palloc ( sizeof (bool )* query -> size );
345
+ for (i = 0 ; i < query -> size ; i ++ )
346
+ if ( items [i ].type == VAL )
347
+ gcv .mapped_check [ i ] = check [ j ++ ];
348
+
349
+ return execute (
350
+ GETQUERY (query ) + query -> size - 1 ,
351
+ (void * ) & gcv , true,
352
+ checkcondition_gin
353
+ );
354
+ }
355
+
322
356
/*
323
357
* boolean operations
324
358
*/
@@ -588,7 +622,7 @@ countdroptree(ITEM * q, int4 pos)
588
622
* result of all '!' will be = 'true', so
589
623
* we can modify query tree for clearing
590
624
*/
591
- static int4
625
+ int4
592
626
shorterquery (ITEM * q , int4 len )
593
627
{
594
628
int4 index ,
0 commit comments