summaryrefslogtreecommitdiff
path: root/contrib/ltree/_ltree_gist.c
diff options
context:
space:
mode:
authorBruce Momjian2003-02-19 03:50:09 +0000
committerBruce Momjian2003-02-19 03:50:09 +0000
commit71e1f531d36b1fb54d0fa2568c26c4f1f44cab3f (patch)
treee32ce7ccd6279c74a073178433fc569c31733669 /contrib/ltree/_ltree_gist.c
parenta286f7321083f06e395959dffeb9b87f028defa0 (diff)
Please apply patches for contrib/ltree.
ltree_73.patch.gz - for 7.3 : Fix ~ operation bug: eg '1.1.1' ~ '*.1' ltree_74.patch.gz - for current CVS Fix ~ operation bug: eg '1.1.1' ~ '*.1' Add ? operation Optimize index storage Last change needs drop/create all ltree indexes, so only for 7.4 Teodor Sigaev
Diffstat (limited to 'contrib/ltree/_ltree_gist.c')
-rw-r--r--contrib/ltree/_ltree_gist.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/contrib/ltree/_ltree_gist.c b/contrib/ltree/_ltree_gist.c
index d8efd8096d0..1791f5bd8d4 100644
--- a/contrib/ltree/_ltree_gist.c
+++ b/contrib/ltree/_ltree_gist.c
@@ -96,7 +96,7 @@ _ltree_compress(PG_FUNCTION_ARGS)
entry->rel, entry->page,
entry->offset, key->len, FALSE);
}
- else
+ else if ( !LTG_ISALLTRUE(entry->key) )
{
int4 i,
len;
@@ -105,10 +105,9 @@ _ltree_compress(PG_FUNCTION_ARGS)
BITVECP sign = LTG_SIGN(DatumGetPointer(entry->key));
ALOOPBYTE(
- if (sign[i] != 0xff)
+ if ((sign[i]&0xff) != 0xff)
PG_RETURN_POINTER(retval);
);
-
len = LTG_HDRSIZE;
key = (ltree_gist *) palloc(len);
key->len = len;
@@ -222,7 +221,7 @@ _ltree_penalty(PG_FUNCTION_ARGS)
if (LTG_ISALLTRUE(origval))
{
- *penalty = 0.0;
+ *penalty = 0.1;
PG_RETURN_POINTER(penalty);
}
@@ -489,7 +488,7 @@ _ltree_picksplit(PG_FUNCTION_ARGS)
);
}
- if (size_alpha - size_l < size_beta - size_r + WISH_F(v->spl_nleft, v->spl_nright, 0.1))
+ if (size_alpha - size_l < size_beta - size_r + WISH_F(v->spl_nleft, v->spl_nright, 0.00001))
{
if (!LTG_ISALLTRUE(datum_l))
{
@@ -613,6 +612,22 @@ gist_qe(ltree_gist * key, lquery * query)
return true;
}
+static bool
+_arrq_cons(ltree_gist *key, ArrayType *_query) {
+ lquery *query = (lquery *) ARR_DATA_PTR(_query);
+ int num = ArrayGetNItems(ARR_NDIM(_query), ARR_DIMS(_query));
+
+ if (ARR_NDIM(_query) != 1)
+ elog(ERROR, "Dimension of array != 1");
+
+ while (num > 0) {
+ if ( gist_qe(key, query) )
+ return true;
+ num--;
+ query = (lquery*)NEXTVAL(query);
+ }
+ return false;
+}
Datum
_ltree_consistent(PG_FUNCTION_ARGS)
@@ -641,6 +656,10 @@ _ltree_consistent(PG_FUNCTION_ARGS)
case 15:
res = gist_qtxt(key, (ltxtquery *) query);
break;
+ case 16:
+ case 17:
+ res = _arrq_cons(key, (ArrayType *) query);
+ break;
default:
elog(ERROR, "Unknown StrategyNumber: %d", strategy);
}