diff options
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/access/gin/ginarrayproc.c | 41 | ||||
-rw-r--r-- | src/backend/access/gin/ginget.c | 67 | ||||
-rw-r--r-- | src/backend/access/gist/gistget.c | 33 | ||||
-rw-r--r-- | src/backend/access/gist/gistproc.c | 21 | ||||
-rw-r--r-- | src/backend/commands/opclasscmds.c | 6 | ||||
-rw-r--r-- | src/backend/nodes/copyfuncs.c | 3 | ||||
-rw-r--r-- | src/backend/nodes/equalfuncs.c | 3 | ||||
-rw-r--r-- | src/backend/parser/gram.y | 13 | ||||
-rw-r--r-- | src/backend/utils/adt/tsginidx.c | 20 | ||||
-rw-r--r-- | src/backend/utils/adt/tsgistidx.c | 13 | ||||
-rw-r--r-- | src/backend/utils/adt/tsquery_gist.c | 9 |
11 files changed, 156 insertions, 73 deletions
diff --git a/src/backend/access/gin/ginarrayproc.c b/src/backend/access/gin/ginarrayproc.c index c453cda525c..c85399d632f 100644 --- a/src/backend/access/gin/ginarrayproc.c +++ b/src/backend/access/gin/ginarrayproc.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/gin/ginarrayproc.c,v 1.12 2008/01/01 19:45:46 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/gin/ginarrayproc.c,v 1.13 2008/04/14 17:05:33 tgl Exp $ *------------------------------------------------------------------------- */ #include "postgres.h" @@ -95,8 +95,9 @@ ginarrayconsistent(PG_FUNCTION_ARGS) bool *check = (bool *) PG_GETARG_POINTER(0); StrategyNumber strategy = PG_GETARG_UINT16(1); ArrayType *query = PG_GETARG_ARRAYTYPE_P(2); - int res, - i, + bool *recheck = (bool *) PG_GETARG_POINTER(3); + bool res; + int i, nentries; /* ARRAYCHECK was already done by previous ginarrayextract call */ @@ -104,25 +105,51 @@ ginarrayconsistent(PG_FUNCTION_ARGS) switch (strategy) { case GinOverlapStrategy: + /* result is not lossy */ + *recheck = false; + /* at least one element in check[] is true, so result = true */ + res = true; + break; case GinContainedStrategy: + /* we will need recheck */ + *recheck = true; /* at least one element in check[] is true, so result = true */ - res = TRUE; + res = true; break; case GinContainsStrategy: + /* result is not lossy */ + *recheck = false; + /* must have all elements in check[] true */ + nentries = ArrayGetNItems(ARR_NDIM(query), ARR_DIMS(query)); + res = true; + for (i = 0; i < nentries; i++) + { + if (!check[i]) + { + res = false; + break; + } + } + break; case GinEqualStrategy: + /* we will need recheck */ + *recheck = true; + /* must have all elements in check[] true */ nentries = ArrayGetNItems(ARR_NDIM(query), ARR_DIMS(query)); - res = TRUE; + res = true; for (i = 0; i < nentries; i++) + { if (!check[i]) { - res = FALSE; + res = false; break; } + } break; default: elog(ERROR, "ginarrayconsistent: unknown strategy number: %d", strategy); - res = FALSE; + res = false; } PG_RETURN_BOOL(res); diff --git a/src/backend/access/gin/ginget.c b/src/backend/access/gin/ginget.c index af38717340a..26abaa76afa 100644 --- a/src/backend/access/gin/ginget.c +++ b/src/backend/access/gin/ginget.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/gin/ginget.c,v 1.12 2008/04/13 19:18:13 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/gin/ginget.c,v 1.13 2008/04/14 17:05:33 tgl Exp $ *------------------------------------------------------------------------- */ @@ -343,10 +343,12 @@ entryGetItem(Relation index, GinScanEntry entry) /* * Sets key->curItem to new found heap item pointer for one scan key - * returns isFinished! + * Returns isFinished, ie TRUE means we did NOT get a new item pointer! + * Also, *keyrecheck is set true if recheck is needed for this scan key. */ static bool -keyGetItem(Relation index, GinState *ginstate, MemoryContext tempCtx, GinScanKey key) +keyGetItem(Relation index, GinState *ginstate, MemoryContext tempCtx, + GinScanKey key, bool *keyrecheck) { uint32 i; GinScanEntry entry; @@ -391,31 +393,36 @@ keyGetItem(Relation index, GinState *ginstate, MemoryContext tempCtx, GinScanKey return TRUE; } - if (key->nentries == 1) - { - /* we can do not call consistentFn !! */ - key->entryRes[0] = TRUE; - return FALSE; - } + /* + * if key->nentries == 1 then the consistentFn should always succeed, + * but we must call it anyway to find out the recheck status. + */ /* setting up array for consistentFn */ for (i = 0; i < key->nentries; i++) { entry = key->scanEntry + i; - if (entry->isFinished == FALSE && compareItemPointers(&entry->curItem, &key->curItem) == 0) + if (entry->isFinished == FALSE && + compareItemPointers(&entry->curItem, &key->curItem) == 0) key->entryRes[i] = TRUE; else key->entryRes[i] = FALSE; } + /* + * Initialize *keyrecheck in case the consistentFn doesn't know it + * should set it. The safe assumption in that case is to force + * recheck. + */ + *keyrecheck = true; + oldCtx = MemoryContextSwitchTo(tempCtx); - res = DatumGetBool(FunctionCall3( - &ginstate->consistentFn, + res = DatumGetBool(FunctionCall4(&ginstate->consistentFn, PointerGetDatum(key->entryRes), UInt16GetDatum(key->strategy), - key->query - )); + key->query, + PointerGetDatum(keyrecheck))); MemoryContextSwitchTo(oldCtx); MemoryContextReset(tempCtx); } while (!res); @@ -430,24 +437,32 @@ keyGetItem(Relation index, GinState *ginstate, MemoryContext tempCtx, GinScanKey static bool scanGetItem(IndexScanDesc scan, ItemPointerData *item, bool *recheck) { - uint32 i; GinScanOpaque so = (GinScanOpaque) scan->opaque; - - /* XXX for the moment, treat all GIN operators as lossy */ - *recheck = true; + uint32 i; + bool keyrecheck; + + /* + * We return recheck = true if any of the keyGetItem calls return + * keyrecheck = true. Note that because the second loop might advance + * some keys, this could theoretically be too conservative. In practice + * though, we expect that a consistentFn's recheck result will depend + * only on the operator and the query, so for any one key it should + * stay the same regardless of advancing to new items. So it's not + * worth working harder. + */ + *recheck = false; ItemPointerSetMin(item); for (i = 0; i < so->nkeys; i++) { GinScanKey key = so->keys + i; - if (keyGetItem(scan->indexRelation, &so->ginstate, so->tempCtx, key) == FALSE) - { - if (compareItemPointers(item, &key->curItem) < 0) - *item = key->curItem; - } - else + if (keyGetItem(scan->indexRelation, &so->ginstate, so->tempCtx, + key, &keyrecheck)) return FALSE; /* finished one of keys */ + if (compareItemPointers(item, &key->curItem) < 0) + *item = key->curItem; + *recheck |= keyrecheck; } for (i = 1; i <= so->nkeys; i++) @@ -462,8 +477,10 @@ scanGetItem(IndexScanDesc scan, ItemPointerData *item, bool *recheck) break; else if (cmp > 0) { - if (keyGetItem(scan->indexRelation, &so->ginstate, so->tempCtx, key) == TRUE) + if (keyGetItem(scan->indexRelation, &so->ginstate, so->tempCtx, + key, &keyrecheck)) return FALSE; /* finished one of keys */ + *recheck |= keyrecheck; } else { /* returns to begin */ diff --git a/src/backend/access/gist/gistget.c b/src/backend/access/gist/gistget.c index 8e921395825..7a5177218e5 100644 --- a/src/backend/access/gist/gistget.c +++ b/src/backend/access/gist/gistget.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.71 2008/04/13 19:18:14 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.72 2008/04/14 17:05:33 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -151,7 +151,6 @@ gistnext(IndexScanDesc scan, ScanDirection dir, TIDBitmap *tbm) GISTScanOpaque so; GISTSearchStack *stk; IndexTuple it; - bool recheck; GISTPageOpaque opaque; bool resetoffset = false; int64 ntids = 0; @@ -257,8 +256,6 @@ gistnext(IndexScanDesc scan, ScanDirection dir, TIDBitmap *tbm) for (;;) { n = gistfindnext(scan, n, dir); - /* XXX for the moment, treat all GIST operators as lossy */ - recheck = true; if (!OffsetNumberIsValid(n)) { @@ -304,11 +301,11 @@ gistnext(IndexScanDesc scan, ScanDirection dir, TIDBitmap *tbm) it = (IndexTuple) PageGetItem(p, PageGetItemId(p, n)); ntids++; if (tbm != NULL) - tbm_add_tuples(tbm, &it->t_tid, 1, recheck); + tbm_add_tuples(tbm, &it->t_tid, 1, scan->xs_recheck); else { scan->xs_ctup.t_self = it->t_tid; - scan->xs_recheck = recheck; + /* scan->xs_recheck is already set */ LockBuffer(so->curbuf, GIST_UNLOCK); return ntids; /* always 1 */ @@ -345,6 +342,10 @@ gistnext(IndexScanDesc scan, ScanDirection dir, TIDBitmap *tbm) /* * gistindex_keytest() -- does this index tuple satisfy the scan key(s)? * + * On success return for a leaf tuple, scan->xs_recheck is set to indicate + * whether recheck is needed. We recheck if any of the consistent() functions + * request it. + * * We must decompress the key in the IndexTuple before passing it to the * sk_func (and we have previously overwritten the sk_func to use the * user-defined Consistent method, so we actually are invoking that). @@ -371,6 +372,8 @@ gistindex_keytest(IndexTuple tuple, IncrIndexProcessed(); + scan->xs_recheck = false; + /* * Tuple doesn't restore after crash recovery because of incomplete insert */ @@ -382,6 +385,7 @@ gistindex_keytest(IndexTuple tuple, Datum datum; bool isNull; Datum test; + bool recheck; GISTENTRY de; datum = index_getattr(tuple, @@ -408,7 +412,6 @@ gistindex_keytest(IndexTuple tuple, } else { - gistdentryinit(giststate, key->sk_attno - 1, &de, datum, r, p, offset, FALSE, isNull); @@ -416,21 +419,28 @@ gistindex_keytest(IndexTuple tuple, /* * Call the Consistent function to evaluate the test. The * arguments are the index datum (as a GISTENTRY*), the comparison - * datum, and the comparison operator's strategy number and - * subtype from pg_amop. + * datum, the comparison operator's strategy number and + * subtype from pg_amop, and the recheck flag. * * (Presently there's no need to pass the subtype since it'll * always be zero, but might as well pass it for possible future * use.) + * + * We initialize the recheck flag to true (the safest assumption) + * in case the Consistent function forgets to set it. */ - test = FunctionCall4(&key->sk_func, + recheck = true; + + test = FunctionCall5(&key->sk_func, PointerGetDatum(&de), key->sk_argument, Int32GetDatum(key->sk_strategy), - ObjectIdGetDatum(key->sk_subtype)); + ObjectIdGetDatum(key->sk_subtype), + PointerGetDatum(&recheck)); if (!DatumGetBool(test)) return false; + scan->xs_recheck |= recheck; } keySize--; @@ -444,6 +454,7 @@ gistindex_keytest(IndexTuple tuple, * Return the offset of the first index entry that is consistent with * the search key after offset 'n' in the current page. If there are * no more consistent entries, return InvalidOffsetNumber. + * On success, scan->xs_recheck is set correctly, too. * Page should be locked.... */ static OffsetNumber diff --git a/src/backend/access/gist/gistproc.c b/src/backend/access/gist/gistproc.c index 7653776c365..ec23385f5c9 100644 --- a/src/backend/access/gist/gistproc.c +++ b/src/backend/access/gist/gistproc.c @@ -10,7 +10,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/gist/gistproc.c,v 1.13 2008/01/01 19:45:46 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/gist/gistproc.c,v 1.14 2008/04/14 17:05:33 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -86,6 +86,11 @@ gist_box_consistent(PG_FUNCTION_ARGS) GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); BOX *query = PG_GETARG_BOX_P(1); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ + bool *recheck = (bool *) PG_GETARG_POINTER(4); + + /* All cases served by this function are exact */ + *recheck = false; if (DatumGetBoxP(entry->key) == NULL || query == NULL) PG_RETURN_BOOL(FALSE); @@ -723,13 +728,18 @@ gist_poly_consistent(PG_FUNCTION_ARGS) GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); POLYGON *query = PG_GETARG_POLYGON_P(1); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ + bool *recheck = (bool *) PG_GETARG_POINTER(4); bool result; + /* All cases served by this function are inexact */ + *recheck = true; + if (DatumGetBoxP(entry->key) == NULL || query == NULL) PG_RETURN_BOOL(FALSE); /* - * Since the operators are marked lossy anyway, we can just use + * Since the operators require recheck anyway, we can just use * rtree_internal_consistent even at leaf nodes. (This works in part * because the index entries are bounding boxes not polygons.) */ @@ -794,14 +804,19 @@ gist_circle_consistent(PG_FUNCTION_ARGS) GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); CIRCLE *query = PG_GETARG_CIRCLE_P(1); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ + bool *recheck = (bool *) PG_GETARG_POINTER(4); BOX bbox; bool result; + /* All cases served by this function are inexact */ + *recheck = true; + if (DatumGetBoxP(entry->key) == NULL || query == NULL) PG_RETURN_BOOL(FALSE); /* - * Since the operators are marked lossy anyway, we can just use + * Since the operators require recheck anyway, we can just use * rtree_internal_consistent even at leaf nodes. (This works in part * because the index entries are bounding boxes not circles.) */ diff --git a/src/backend/commands/opclasscmds.c b/src/backend/commands/opclasscmds.c index 648488a04ae..08bb97288d4 100644 --- a/src/backend/commands/opclasscmds.c +++ b/src/backend/commands/opclasscmds.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/opclasscmds.c,v 1.59 2008/03/26 21:10:37 alvherre Exp $ + * $PostgreSQL: pgsql/src/backend/commands/opclasscmds.c,v 1.60 2008/04/14 17:05:33 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -52,7 +52,6 @@ typedef struct int number; /* strategy or support proc number */ Oid lefttype; /* lefttype */ Oid righttype; /* righttype */ - bool recheck; /* oper recheck flag (unused for proc) */ } OpFamilyMember; @@ -445,7 +444,6 @@ DefineOpClass(CreateOpClassStmt *stmt) member = (OpFamilyMember *) palloc0(sizeof(OpFamilyMember)); member->object = operOid; member->number = item->number; - member->recheck = item->recheck; assignOperTypes(member, amoid, typeoid); addFamilyMember(&operators, member, false); break; @@ -898,7 +896,6 @@ AlterOpFamilyAdd(List *opfamilyname, Oid amoid, Oid opfamilyoid, member = (OpFamilyMember *) palloc0(sizeof(OpFamilyMember)); member->object = operOid; member->number = item->number; - member->recheck = item->recheck; assignOperTypes(member, amoid, InvalidOid); addFamilyMember(&operators, member, false); break; @@ -1266,7 +1263,6 @@ storeOperators(List *opfamilyname, Oid amoid, values[Anum_pg_amop_amoplefttype - 1] = ObjectIdGetDatum(op->lefttype); values[Anum_pg_amop_amoprighttype - 1] = ObjectIdGetDatum(op->righttype); values[Anum_pg_amop_amopstrategy - 1] = Int16GetDatum(op->number); - values[Anum_pg_amop_amopreqcheck - 1] = BoolGetDatum(op->recheck); values[Anum_pg_amop_amopopr - 1] = ObjectIdGetDatum(op->object); values[Anum_pg_amop_amopmethod - 1] = ObjectIdGetDatum(amoid); diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c index e1e8957efd7..87a04bcd64c 100644 --- a/src/backend/nodes/copyfuncs.c +++ b/src/backend/nodes/copyfuncs.c @@ -15,7 +15,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.391 2008/04/13 20:51:20 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.392 2008/04/14 17:05:33 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -2471,7 +2471,6 @@ _copyCreateOpClassItem(CreateOpClassItem *from) COPY_NODE_FIELD(name); COPY_NODE_FIELD(args); COPY_SCALAR_FIELD(number); - COPY_SCALAR_FIELD(recheck); COPY_NODE_FIELD(class_args); COPY_NODE_FIELD(storedtype); diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c index fd453fabd23..161e8f06dcf 100644 --- a/src/backend/nodes/equalfuncs.c +++ b/src/backend/nodes/equalfuncs.c @@ -18,7 +18,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.320 2008/03/21 22:41:48 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.321 2008/04/14 17:05:33 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1275,7 +1275,6 @@ _equalCreateOpClassItem(CreateOpClassItem *a, CreateOpClassItem *b) COMPARE_NODE_FIELD(name); COMPARE_NODE_FIELD(args); COMPARE_SCALAR_FIELD(number); - COMPARE_SCALAR_FIELD(recheck); COMPARE_NODE_FIELD(class_args); COMPARE_NODE_FIELD(storedtype); diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index 21fff239c70..e17842231d9 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.611 2008/03/28 00:21:55 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.612 2008/04/14 17:05:33 tgl Exp $ * * HISTORY * AUTHOR DATE MAJOR EVENT @@ -3107,7 +3107,6 @@ opclass_item: n->name = $3; n->args = NIL; n->number = $2; - n->recheck = $4; $$ = (Node *) n; } | OPERATOR Iconst any_operator '(' oper_argtypes ')' opt_recheck @@ -3117,7 +3116,6 @@ opclass_item: n->name = $3; n->args = $5; n->number = $2; - n->recheck = $7; $$ = (Node *) n; } | FUNCTION Iconst func_name func_args @@ -3156,7 +3154,14 @@ opt_opfamily: FAMILY any_name { $$ = $2; } | /*EMPTY*/ { $$ = NIL; } ; -opt_recheck: RECHECK { $$ = TRUE; } +opt_recheck: RECHECK + { + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("RECHECK is no longer supported"), + errhint("Update your data type."))); + $$ = TRUE; + } | /*EMPTY*/ { $$ = FALSE; } ; diff --git a/src/backend/utils/adt/tsginidx.c b/src/backend/utils/adt/tsginidx.c index add1fc1910c..55518834ae9 100644 --- a/src/backend/utils/adt/tsginidx.c +++ b/src/backend/utils/adt/tsginidx.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/tsginidx.c,v 1.10 2008/03/25 22:42:44 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/tsginidx.c,v 1.11 2008/04/14 17:05:33 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -54,7 +54,7 @@ gin_extract_tsquery(PG_FUNCTION_ARGS) { TSQuery query = PG_GETARG_TSQUERY(0); int32 *nentries = (int32 *) PG_GETARG_POINTER(1); - StrategyNumber strategy = PG_GETARG_UINT16(2); + /* StrategyNumber strategy = PG_GETARG_UINT16(2); */ Datum *entries = NULL; *nentries = 0; @@ -89,12 +89,6 @@ gin_extract_tsquery(PG_FUNCTION_ARGS) txt = cstring_to_text_with_len(GETOPERAND(query) + val->distance, val->length); entries[j++] = PointerGetDatum(txt); - - if (strategy != TSearchWithClassStrategyNumber && val->weight != 0) - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("@@ operator does not support lexeme weight restrictions in GIN index searches"), - errhint("Use the @@@ operator instead."))); } } else @@ -109,6 +103,7 @@ typedef struct { QueryItem *frst; bool *mapped_check; + bool *need_recheck; } GinChkVal; static bool @@ -116,6 +111,10 @@ checkcondition_gin(void *checkval, QueryOperand *val) { GinChkVal *gcv = (GinChkVal *) checkval; + /* if any val requiring a weight is used, set recheck flag */ + if (val->weight != 0) + *(gcv->need_recheck) = true; + return gcv->mapped_check[((QueryItem *) val) - gcv->frst]; } @@ -125,8 +124,12 @@ gin_tsquery_consistent(PG_FUNCTION_ARGS) bool *check = (bool *) PG_GETARG_POINTER(0); /* StrategyNumber strategy = PG_GETARG_UINT16(1); */ TSQuery query = PG_GETARG_TSQUERY(2); + bool *recheck = (bool *) PG_GETARG_POINTER(3); bool res = FALSE; + /* The query requires recheck only if it involves weights */ + *recheck = false; + if (query->size > 0) { int i, @@ -144,6 +147,7 @@ gin_tsquery_consistent(PG_FUNCTION_ARGS) gcv.frst = item = GETQUERY(query); gcv.mapped_check = (bool *) palloc(sizeof(bool) * query->size); + gcv.need_recheck = recheck; for (i = 0; i < query->size; i++) if (item[i].type == QI_VAL) diff --git a/src/backend/utils/adt/tsgistidx.c b/src/backend/utils/adt/tsgistidx.c index f3a98ba6f8d..ecbac7b40f2 100644 --- a/src/backend/utils/adt/tsgistidx.c +++ b/src/backend/utils/adt/tsgistidx.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/tsgistidx.c,v 1.7 2008/01/01 19:45:52 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/tsgistidx.c,v 1.8 2008/04/14 17:05:33 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -330,10 +330,15 @@ checkcondition_bit(void *checkval, QueryOperand *val) Datum gtsvector_consistent(PG_FUNCTION_ARGS) { + GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); TSQuery query = PG_GETARG_TSQUERY(1); - SignTSVector *key = (SignTSVector *) DatumGetPointer( - ((GISTENTRY *) PG_GETARG_POINTER(0))->key - ); + /* StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); */ + /* Oid subtype = PG_GETARG_OID(3); */ + bool *recheck = (bool *) PG_GETARG_POINTER(4); + SignTSVector *key = (SignTSVector *) DatumGetPointer(entry->key); + + /* All cases served by this function are inexact */ + *recheck = true; if (!query->size) PG_RETURN_BOOL(false); diff --git a/src/backend/utils/adt/tsquery_gist.c b/src/backend/utils/adt/tsquery_gist.c index fdefd92bae2..df813b59223 100644 --- a/src/backend/utils/adt/tsquery_gist.c +++ b/src/backend/utils/adt/tsquery_gist.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_gist.c,v 1.4 2008/01/01 19:45:53 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_gist.c,v 1.5 2008/04/14 17:05:33 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -52,12 +52,17 @@ Datum gtsquery_consistent(PG_FUNCTION_ARGS) { GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); - TSQuerySign *key = (TSQuerySign *) DatumGetPointer(entry->key); TSQuery query = PG_GETARG_TSQUERY(1); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ + bool *recheck = (bool *) PG_GETARG_POINTER(4); + TSQuerySign *key = (TSQuerySign *) DatumGetPointer(entry->key); TSQuerySign sq = makeTSQuerySign(query); bool retval; + /* All cases served by this function are inexact */ + *recheck = true; + switch (strategy) { case RTContainsStrategyNumber: |