|
|
@ -1741,33 +1741,29 @@ makepol(WORKSTATE *state) { |
|
|
|
typedef struct { |
|
|
|
typedef struct { |
|
|
|
int4 *arrb; |
|
|
|
int4 *arrb; |
|
|
|
int4 *arre; |
|
|
|
int4 *arre; |
|
|
|
int4 *ptr; |
|
|
|
|
|
|
|
} CHKVAL; |
|
|
|
} CHKVAL; |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* is there value 'val' in array or not ? |
|
|
|
* is there value 'val' in array or not ? |
|
|
|
*/
|
|
|
|
*/ |
|
|
|
static bool |
|
|
|
static bool |
|
|
|
checkcondition_arr( void *checkval, int4 val ) { |
|
|
|
checkcondition_arr( void *checkval, int4 val ) { |
|
|
|
#ifdef BS_DEBUG |
|
|
|
int4 *StopLow = ((CHKVAL*)checkval)->arrb; |
|
|
|
elog(NOTICE,"OPERAND %d", val); |
|
|
|
int4 *StopHigh = ((CHKVAL*)checkval)->arre; |
|
|
|
#endif |
|
|
|
int4 *StopMiddle; |
|
|
|
if ( val > *(((CHKVAL*)checkval)->ptr) ) { |
|
|
|
|
|
|
|
while ( ((CHKVAL*)checkval)->ptr < ((CHKVAL*)checkval)->arre ) { |
|
|
|
/* Loop invariant: StopLow <= val < StopHigh */ |
|
|
|
((CHKVAL*)checkval)->ptr++; |
|
|
|
|
|
|
|
if ( *(((CHKVAL*)checkval)->ptr) == val ) return true; |
|
|
|
while (StopLow < StopHigh) { |
|
|
|
if ( val < *(((CHKVAL*)checkval)->ptr) ) return false; |
|
|
|
StopMiddle = StopLow + (StopHigh - StopLow) / 2; |
|
|
|
} |
|
|
|
if (*StopMiddle == val) |
|
|
|
} else if ( val < *(((CHKVAL*)checkval)->ptr) ) {
|
|
|
|
return (true); |
|
|
|
while ( ((CHKVAL*)checkval)->ptr > ((CHKVAL*)checkval)->arrb ) { |
|
|
|
else if (*StopMiddle < val ) |
|
|
|
((CHKVAL*)checkval)->ptr--; |
|
|
|
StopLow = StopMiddle + 1; |
|
|
|
if ( *(((CHKVAL*)checkval)->ptr) == val ) return true; |
|
|
|
else |
|
|
|
if ( val > *(((CHKVAL*)checkval)->ptr) ) return false; |
|
|
|
StopHigh = StopMiddle; |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return false;
|
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static bool |
|
|
|
static bool |
|
|
@ -1818,8 +1814,7 @@ execconsistent( QUERYTYPE *query, ArrayType *array, bool calcnot ) { |
|
|
|
CHKVAL chkval; |
|
|
|
CHKVAL chkval; |
|
|
|
|
|
|
|
|
|
|
|
chkval.arrb = ARRPTR(array); |
|
|
|
chkval.arrb = ARRPTR(array); |
|
|
|
chkval.arre = chkval.arrb + ARRNELEMS(array) - 1; |
|
|
|
chkval.arre = chkval.arrb + ARRNELEMS(array); |
|
|
|
chkval.ptr = chkval.arrb + ARRNELEMS(array)/2; |
|
|
|
|
|
|
|
return execute(
|
|
|
|
return execute(
|
|
|
|
GETQUERY(query) + query->size-1 ,
|
|
|
|
GETQUERY(query) + query->size-1 ,
|
|
|
|
(void*)&chkval, calcnot,
|
|
|
|
(void*)&chkval, calcnot,
|
|
|
@ -1854,8 +1849,7 @@ boolop(PG_FUNCTION_ARGS) { |
|
|
|
|
|
|
|
|
|
|
|
PREPAREARR(val); |
|
|
|
PREPAREARR(val); |
|
|
|
chkval.arrb = ARRPTR(val); |
|
|
|
chkval.arrb = ARRPTR(val); |
|
|
|
chkval.arre = chkval.arrb + ARRNELEMS(val) - 1; |
|
|
|
chkval.arre = chkval.arrb + ARRNELEMS(val); |
|
|
|
chkval.ptr = chkval.arrb + ARRNELEMS(val)/2; |
|
|
|
|
|
|
|
result = execute(
|
|
|
|
result = execute(
|
|
|
|
GETQUERY(query) + query->size-1 ,
|
|
|
|
GETQUERY(query) + query->size-1 ,
|
|
|
|
&chkval, true,
|
|
|
|
&chkval, true,
|
|
|
|