2006-07-14 00:57:31 +08:00
|
|
|
#include <math.h>
|
|
|
|
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
#include "btree_gist.h"
|
|
|
|
#include "btree_utils_var.h"
|
2006-07-12 00:35:33 +08:00
|
|
|
#include "utils/pg_locale.h"
|
2005-07-01 21:44:56 +08:00
|
|
|
#include "utils/builtins.h"
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
|
2005-03-01 23:40:04 +08:00
|
|
|
PG_FUNCTION_INFO_V1(gbt_var_decompress);
|
2005-10-15 10:49:52 +08:00
|
|
|
Datum gbt_var_decompress(PG_FUNCTION_ARGS);
|
2005-03-01 23:40:04 +08:00
|
|
|
|
|
|
|
|
|
|
|
Datum
|
|
|
|
gbt_var_decompress(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2005-05-21 20:08:06 +08:00
|
|
|
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
|
2005-10-15 10:49:52 +08:00
|
|
|
GBT_VARKEY *key = (GBT_VARKEY *) DatumGetPointer(PG_DETOAST_DATUM(entry->key));
|
2005-03-01 23:40:04 +08:00
|
|
|
|
2005-05-21 20:08:06 +08:00
|
|
|
if (key != (GBT_VARKEY *) DatumGetPointer(entry->key))
|
|
|
|
{
|
|
|
|
GISTENTRY *retval = (GISTENTRY *) palloc(sizeof(GISTENTRY));
|
2005-03-01 23:40:04 +08:00
|
|
|
|
2005-05-21 20:08:06 +08:00
|
|
|
gistentryinit(*retval, PointerGetDatum(key),
|
|
|
|
entry->rel, entry->page,
|
2006-06-28 20:00:14 +08:00
|
|
|
entry->offset, FALSE);
|
2005-03-01 23:40:04 +08:00
|
|
|
|
2005-05-21 20:08:06 +08:00
|
|
|
PG_RETURN_POINTER(retval);
|
|
|
|
}
|
2005-03-01 23:40:04 +08:00
|
|
|
|
2005-05-21 20:08:06 +08:00
|
|
|
PG_RETURN_POINTER(entry);
|
2005-03-01 23:40:04 +08:00
|
|
|
}
|
|
|
|
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
/* Returns a better readable representaion of variable key ( sets pointer ) */
|
2005-05-12 08:39:37 +08:00
|
|
|
GBT_VARKEY_R
|
2004-08-29 13:07:03 +08:00
|
|
|
gbt_var_key_readable(const GBT_VARKEY * k)
|
|
|
|
{
|
|
|
|
|
|
|
|
GBT_VARKEY_R r;
|
|
|
|
|
|
|
|
r.lower = (bytea *) &(((char *) k)[VARHDRSZ]);
|
|
|
|
if (VARSIZE(k) > (VARHDRSZ + (VARSIZE(r.lower))))
|
|
|
|
r.upper = (bytea *) &(((char *) k)[VARHDRSZ + INTALIGN(VARSIZE(r.lower))]);
|
|
|
|
else
|
|
|
|
r.upper = r.lower;
|
|
|
|
return r;
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-05-12 08:39:37 +08:00
|
|
|
GBT_VARKEY *
|
2004-08-29 13:07:03 +08:00
|
|
|
gbt_var_key_copy(const GBT_VARKEY_R * u, bool force_node)
|
|
|
|
{
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
GBT_VARKEY *r = NULL;
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
if (u->lower == u->upper && !force_node)
|
|
|
|
{ /* leaf key mode */
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
r = (GBT_VARKEY *) palloc(VARSIZE(u->lower) + VARHDRSZ);
|
|
|
|
memcpy((void *) VARDATA(r), (void *) u->lower, VARSIZE(u->lower));
|
|
|
|
r->vl_len = VARSIZE(u->lower) + VARHDRSZ;
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ /* node key mode */
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
r = (GBT_VARKEY *) palloc(INTALIGN(VARSIZE(u->lower)) + VARSIZE(u->upper) + VARHDRSZ);
|
|
|
|
memcpy((void *) VARDATA(r), (void *) u->lower, VARSIZE(u->lower));
|
|
|
|
memcpy((void *) &(((char *) r)[VARHDRSZ + INTALIGN(VARSIZE(u->lower))]), (void *) u->upper, VARSIZE(u->upper));
|
|
|
|
r->vl_len = INTALIGN(VARSIZE(u->lower)) + VARSIZE(u->upper) + VARHDRSZ;
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
}
|
|
|
|
return r;
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
static GBT_VARKEY *
|
|
|
|
gbt_var_leaf2node(GBT_VARKEY * leaf, const gbtree_vinfo * tinfo)
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
{
|
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
GBT_VARKEY *out = leaf;
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
if (tinfo->f_l2n)
|
|
|
|
out = (*tinfo->f_l2n) (leaf);
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
return out;
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* returns the common prefix length of a node key
|
|
|
|
*/
|
2004-08-29 13:07:03 +08:00
|
|
|
static int32
|
|
|
|
gbt_var_node_cp_len(const GBT_VARKEY * node, const gbtree_vinfo * tinfo)
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
{
|
2004-08-29 13:07:03 +08:00
|
|
|
|
2005-10-15 10:49:52 +08:00
|
|
|
GBT_VARKEY_R r = gbt_var_key_readable(node);
|
|
|
|
int32 i = 0;
|
|
|
|
int32 l = 0;
|
|
|
|
int32 t1len = VARSIZE(r.lower) - VARHDRSZ;
|
|
|
|
int32 t2len = VARSIZE(r.upper) - VARHDRSZ;
|
|
|
|
int32 ml = Min(t1len, t2len);
|
2005-07-01 21:44:56 +08:00
|
|
|
|
2005-10-15 10:49:52 +08:00
|
|
|
char *p1 = VARDATA(r.lower);
|
|
|
|
char *p2 = VARDATA(r.upper);
|
2004-08-29 13:07:03 +08:00
|
|
|
|
2005-10-15 10:49:52 +08:00
|
|
|
if (ml == 0)
|
|
|
|
return 0;
|
2005-07-01 21:44:56 +08:00
|
|
|
|
2005-10-15 10:49:52 +08:00
|
|
|
while (i < ml)
|
2004-08-29 13:07:03 +08:00
|
|
|
{
|
2005-10-15 10:49:52 +08:00
|
|
|
if (tinfo->eml > 1 && l == 0)
|
|
|
|
{
|
|
|
|
|
|
|
|
if ((l = pg_mblen(p1)) != pg_mblen(p2))
|
|
|
|
{
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (*p1 != *p2)
|
|
|
|
{
|
|
|
|
if (tinfo->eml > 1)
|
|
|
|
{
|
|
|
|
return (i - l + 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
p1++;
|
|
|
|
p2++;
|
|
|
|
l--;
|
|
|
|
i++;
|
2004-08-29 13:07:03 +08:00
|
|
|
}
|
2005-10-15 10:49:52 +08:00
|
|
|
return (ml); /* lower == upper */
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2005-07-01 21:44:56 +08:00
|
|
|
* returns true, if query matches prefix ( common prefix )
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
*/
|
2004-08-29 13:07:03 +08:00
|
|
|
static bool
|
|
|
|
gbt_bytea_pf_match(const bytea *pf, const bytea *query, const gbtree_vinfo * tinfo)
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
{
|
|
|
|
|
2005-10-15 10:49:52 +08:00
|
|
|
bool out = FALSE;
|
|
|
|
int32 k = 0;
|
|
|
|
int32 qlen = VARSIZE(query) - VARHDRSZ;
|
|
|
|
int32 nlen = VARSIZE(pf) - VARHDRSZ;
|
2004-08-29 13:07:03 +08:00
|
|
|
|
|
|
|
if (nlen <= qlen)
|
|
|
|
{
|
2005-10-15 10:49:52 +08:00
|
|
|
char *q = VARDATA(query);
|
|
|
|
char *n = VARDATA(pf);
|
|
|
|
|
|
|
|
if (tinfo->eml > 1)
|
|
|
|
{
|
|
|
|
out = (varstr_cmp(q, nlen, n, nlen) == 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
out = TRUE;
|
|
|
|
for (k = 0; k < nlen; k++)
|
|
|
|
{
|
|
|
|
if (*n != *q)
|
|
|
|
{
|
|
|
|
out = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (k < (nlen - 1))
|
|
|
|
{
|
|
|
|
q++;
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-08-29 13:07:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return out;
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* returns true, if query matches node using common prefix
|
|
|
|
*/
|
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
static bool
|
|
|
|
gbt_var_node_pf_match(const GBT_VARKEY_R * node, const bytea *query, const gbtree_vinfo * tinfo)
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
{
|
|
|
|
|
2005-10-15 10:49:52 +08:00
|
|
|
return (tinfo->trnc && (
|
|
|
|
gbt_bytea_pf_match(node->lower, query, tinfo) ||
|
|
|
|
gbt_bytea_pf_match(node->upper, query, tinfo)
|
|
|
|
));
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* truncates / compresses the node key
|
2005-07-01 21:44:56 +08:00
|
|
|
* cpf_length .. common prefix length
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
*/
|
2004-08-29 13:07:03 +08:00
|
|
|
static GBT_VARKEY *
|
2005-07-01 21:44:56 +08:00
|
|
|
gbt_var_node_truncate(const GBT_VARKEY * node, int32 cpf_length, const gbtree_vinfo * tinfo)
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
{
|
2004-08-29 13:07:03 +08:00
|
|
|
GBT_VARKEY *out = NULL;
|
|
|
|
GBT_VARKEY_R r = gbt_var_key_readable(node);
|
2005-10-15 10:49:52 +08:00
|
|
|
int32 len1 = VARSIZE(r.lower) - VARHDRSZ;
|
|
|
|
int32 len2 = VARSIZE(r.upper) - VARHDRSZ;
|
|
|
|
int32 si = 0;
|
2004-08-29 13:07:03 +08:00
|
|
|
|
2005-10-15 10:49:52 +08:00
|
|
|
len1 = Min(len1, (cpf_length + 1));
|
|
|
|
len2 = Min(len2, (cpf_length + 1));
|
2004-08-29 13:07:03 +08:00
|
|
|
|
|
|
|
si = 2 * VARHDRSZ + INTALIGN(VARHDRSZ + len1) + len2;
|
|
|
|
out = (GBT_VARKEY *) palloc(si);
|
|
|
|
out->vl_len = si;
|
2005-10-15 10:49:52 +08:00
|
|
|
memcpy((void *) &(((char *) out)[VARHDRSZ]), (void *) r.lower, len1 + VARHDRSZ);
|
|
|
|
memcpy((void *) &(((char *) out)[VARHDRSZ + INTALIGN(VARHDRSZ + len1)]), (void *) r.upper, len2 + VARHDRSZ);
|
2004-08-29 13:07:03 +08:00
|
|
|
|
|
|
|
*((int32 *) &(((char *) out)[VARHDRSZ])) = len1 + VARHDRSZ;
|
|
|
|
*((int32 *) &(((char *) out)[VARHDRSZ + INTALIGN(VARHDRSZ + len1)])) = len2 + VARHDRSZ;
|
|
|
|
|
|
|
|
return out;
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-05-12 08:39:37 +08:00
|
|
|
void
|
2004-08-29 13:07:03 +08:00
|
|
|
gbt_var_bin_union(Datum *u, GBT_VARKEY * e, const gbtree_vinfo * tinfo)
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
{
|
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
GBT_VARKEY *nk = NULL;
|
|
|
|
GBT_VARKEY *tmp = NULL;
|
|
|
|
GBT_VARKEY_R nr;
|
|
|
|
GBT_VARKEY_R eo = gbt_var_key_readable(e);
|
|
|
|
|
|
|
|
if (eo.lower == eo.upper) /* leaf */
|
|
|
|
{
|
|
|
|
tmp = gbt_var_leaf2node(e, tinfo);
|
|
|
|
if (tmp != e)
|
|
|
|
eo = gbt_var_key_readable(tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (DatumGetPointer(*u))
|
|
|
|
{
|
|
|
|
|
|
|
|
GBT_VARKEY_R ro = gbt_var_key_readable((GBT_VARKEY *) DatumGetPointer(*u));
|
|
|
|
|
|
|
|
if ((*tinfo->f_cmp) ((bytea *) ro.lower, (bytea *) eo.lower) > 0)
|
|
|
|
{
|
|
|
|
nr.lower = eo.lower;
|
|
|
|
nr.upper = ro.upper;
|
|
|
|
nk = gbt_var_key_copy(&nr, TRUE);
|
|
|
|
}
|
2005-05-21 20:08:06 +08:00
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
if ((*tinfo->f_cmp) ((bytea *) ro.upper, (bytea *) eo.upper) < 0)
|
|
|
|
{
|
|
|
|
nr.upper = eo.upper;
|
|
|
|
nr.lower = ro.lower;
|
|
|
|
nk = gbt_var_key_copy(&nr, TRUE);
|
|
|
|
}
|
2005-05-21 20:08:06 +08:00
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
if (nk)
|
|
|
|
*u = PointerGetDatum(nk);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nr.lower = eo.lower;
|
|
|
|
nr.upper = eo.upper;
|
|
|
|
*u = PointerGetDatum(gbt_var_key_copy(&nr, TRUE));
|
|
|
|
}
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-05-12 08:39:37 +08:00
|
|
|
GISTENTRY *
|
2004-08-29 13:07:03 +08:00
|
|
|
gbt_var_compress(GISTENTRY *entry, const gbtree_vinfo * tinfo)
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
{
|
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
GISTENTRY *retval;
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
if (entry->leafkey)
|
|
|
|
{
|
|
|
|
GBT_VARKEY *r = NULL;
|
2005-05-21 20:08:06 +08:00
|
|
|
bytea *leaf = (bytea *) DatumGetPointer(PG_DETOAST_DATUM(entry->key));
|
2004-08-29 13:07:03 +08:00
|
|
|
GBT_VARKEY_R u;
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
u.lower = u.upper = leaf;
|
|
|
|
r = gbt_var_key_copy(&u, FALSE);
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
retval = palloc(sizeof(GISTENTRY));
|
|
|
|
gistentryinit(*retval, PointerGetDatum(r),
|
|
|
|
entry->rel, entry->page,
|
2006-06-28 20:00:14 +08:00
|
|
|
entry->offset, TRUE);
|
2004-08-29 13:07:03 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
retval = entry;
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
return (retval);
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-05-12 08:39:37 +08:00
|
|
|
GBT_VARKEY *
|
2004-08-29 13:07:03 +08:00
|
|
|
gbt_var_union(const GistEntryVector *entryvec, int32 *size, const gbtree_vinfo * tinfo)
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
{
|
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
int i = 0,
|
|
|
|
numranges = entryvec->n;
|
2005-03-01 23:40:04 +08:00
|
|
|
GBT_VARKEY *cur;
|
2004-08-29 13:07:03 +08:00
|
|
|
Datum out;
|
|
|
|
GBT_VARKEY_R rk;
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
*size = sizeof(GBT_VARKEY);
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
|
2005-03-01 23:40:04 +08:00
|
|
|
cur = (GBT_VARKEY *) DatumGetPointer(entryvec->vector[0].key);
|
2004-08-29 13:07:03 +08:00
|
|
|
rk = gbt_var_key_readable(cur);
|
|
|
|
out = PointerGetDatum(gbt_var_key_copy(&rk, TRUE));
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
for (i = 1; i < numranges; i++)
|
|
|
|
{
|
2005-03-01 23:40:04 +08:00
|
|
|
cur = (GBT_VARKEY *) DatumGetPointer(entryvec->vector[i].key);
|
2004-08-29 13:07:03 +08:00
|
|
|
gbt_var_bin_union(&out, cur, tinfo);
|
|
|
|
}
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
|
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
/* Truncate (=compress) key */
|
|
|
|
if (tinfo->trnc)
|
|
|
|
{
|
|
|
|
int32 plen;
|
|
|
|
GBT_VARKEY *trc = NULL;
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
plen = gbt_var_node_cp_len((GBT_VARKEY *) DatumGetPointer(out), tinfo);
|
|
|
|
trc = gbt_var_node_truncate((GBT_VARKEY *) DatumGetPointer(out), plen + 1, tinfo);
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
out = PointerGetDatum(trc);
|
|
|
|
}
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
return ((GBT_VARKEY *) DatumGetPointer(out));
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-05-12 08:39:37 +08:00
|
|
|
bool
|
2004-08-29 13:07:03 +08:00
|
|
|
gbt_var_same(bool *result, const Datum d1, const Datum d2, const gbtree_vinfo * tinfo)
|
|
|
|
{
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
|
2005-03-01 23:40:04 +08:00
|
|
|
GBT_VARKEY *t1 = (GBT_VARKEY *) DatumGetPointer(d1);
|
|
|
|
GBT_VARKEY *t2 = (GBT_VARKEY *) DatumGetPointer(d2);
|
2004-08-29 13:07:03 +08:00
|
|
|
GBT_VARKEY_R r1,
|
|
|
|
r2;
|
|
|
|
|
|
|
|
r1 = gbt_var_key_readable(t1);
|
|
|
|
r2 = gbt_var_key_readable(t2);
|
|
|
|
|
|
|
|
if (t1 && t2)
|
|
|
|
{
|
|
|
|
*result = (((*tinfo->f_cmp) ((bytea *) r1.lower, (bytea *) r2.lower) == 0
|
|
|
|
&& (*tinfo->f_cmp) ((bytea *) r1.upper, (bytea *) r2.upper) == 0) ? TRUE : FALSE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*result = (t1 == NULL && t2 == NULL) ? TRUE : FALSE;
|
|
|
|
|
|
|
|
PG_RETURN_POINTER(result);
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-05-12 08:39:37 +08:00
|
|
|
float *
|
2004-08-29 13:07:03 +08:00
|
|
|
gbt_var_penalty(float *res, const GISTENTRY *o, const GISTENTRY *n, const gbtree_vinfo * tinfo)
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
{
|
|
|
|
|
2005-03-01 23:40:04 +08:00
|
|
|
GBT_VARKEY *orge = (GBT_VARKEY *) DatumGetPointer(o->key);
|
|
|
|
GBT_VARKEY *newe = (GBT_VARKEY *) DatumGetPointer(n->key);
|
2004-08-29 13:07:03 +08:00
|
|
|
GBT_VARKEY_R ok,
|
|
|
|
nk;
|
|
|
|
GBT_VARKEY *tmp = NULL;
|
|
|
|
|
|
|
|
*res = 0.0;
|
|
|
|
|
|
|
|
nk = gbt_var_key_readable(newe);
|
|
|
|
if (nk.lower == nk.upper) /* leaf */
|
|
|
|
{
|
|
|
|
tmp = gbt_var_leaf2node(newe, tinfo);
|
|
|
|
if (tmp != newe)
|
|
|
|
nk = gbt_var_key_readable(tmp);
|
|
|
|
}
|
|
|
|
ok = gbt_var_key_readable(orge);
|
|
|
|
|
2005-07-01 21:44:56 +08:00
|
|
|
if ((VARSIZE(ok.lower) - VARHDRSZ) == 0 && (VARSIZE(ok.upper) - VARHDRSZ) == 0)
|
2004-08-29 13:07:03 +08:00
|
|
|
*res = 0.0;
|
|
|
|
else if (!(
|
|
|
|
(
|
|
|
|
((*tinfo->f_cmp) (nk.lower, ok.lower) >= 0 || gbt_bytea_pf_match(ok.lower, nk.lower, tinfo)) &&
|
|
|
|
((*tinfo->f_cmp) (nk.upper, ok.upper) <= 0 || gbt_bytea_pf_match(ok.upper, nk.upper, tinfo))
|
|
|
|
)
|
|
|
|
))
|
|
|
|
{
|
|
|
|
Datum d = PointerGetDatum(0);
|
|
|
|
double dres = 0.0;
|
|
|
|
int32 ol,
|
|
|
|
ul;
|
|
|
|
|
|
|
|
gbt_var_bin_union(&d, orge, tinfo);
|
|
|
|
ol = gbt_var_node_cp_len((GBT_VARKEY *) DatumGetPointer(d), tinfo);
|
|
|
|
gbt_var_bin_union(&d, newe, tinfo);
|
|
|
|
ul = gbt_var_node_cp_len((GBT_VARKEY *) DatumGetPointer(d), tinfo);
|
|
|
|
|
|
|
|
if (ul < ol)
|
|
|
|
{
|
|
|
|
dres = (ol - ul); /* lost of common prefix len */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GBT_VARKEY_R uk = gbt_var_key_readable((GBT_VARKEY *) DatumGetPointer(d));
|
|
|
|
|
2005-07-01 21:44:56 +08:00
|
|
|
char tmp[4];
|
|
|
|
|
|
|
|
tmp[0] = ((VARSIZE(ok.lower) - VARHDRSZ) == ul) ? (CHAR_MIN) : (VARDATA(ok.lower)[ul]);
|
|
|
|
tmp[1] = ((VARSIZE(uk.lower) - VARHDRSZ) == ul) ? (CHAR_MIN) : (VARDATA(uk.lower)[ul]);
|
|
|
|
tmp[2] = ((VARSIZE(ok.upper) - VARHDRSZ) == ul) ? (CHAR_MIN) : (VARDATA(ok.upper)[ul]);
|
|
|
|
tmp[3] = ((VARSIZE(uk.upper) - VARHDRSZ) == ul) ? (CHAR_MIN) : (VARDATA(uk.upper)[ul]);
|
|
|
|
dres = (tmp[0] - tmp[1]) +
|
|
|
|
(tmp[3] - tmp[2]);
|
2004-08-29 13:07:03 +08:00
|
|
|
dres /= 256.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
*res += FLT_MIN;
|
|
|
|
*res += (float) (dres / ((double) (ol + 1)));
|
|
|
|
*res *= (FLT_MAX / (o->rel->rd_att->natts + 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-21 08:09:10 +08:00
|
|
|
/*
|
2005-05-16 14:45:57 +08:00
|
|
|
* Fortunately, this sort comparison routine needn't be reentrant...
|
2004-08-21 08:09:10 +08:00
|
|
|
*/
|
2004-08-29 13:07:03 +08:00
|
|
|
static const gbtree_vinfo *gbt_vsrt_cmp_tinfo;
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
|
2004-08-21 08:09:10 +08:00
|
|
|
static int
|
|
|
|
gbt_vsrt_cmp(const void *a, const void *b)
|
|
|
|
{
|
2004-08-29 13:07:03 +08:00
|
|
|
GBT_VARKEY_R ar = gbt_var_key_readable(((const Vsrt *) a)->t);
|
|
|
|
GBT_VARKEY_R br = gbt_var_key_readable(((const Vsrt *) b)->t);
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
return (*gbt_vsrt_cmp_tinfo->f_cmp) (ar.lower, br.lower);
|
2004-08-21 08:09:10 +08:00
|
|
|
}
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
|
2005-05-12 08:39:37 +08:00
|
|
|
GIST_SPLITVEC *
|
2004-08-29 13:07:03 +08:00
|
|
|
gbt_var_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v, const gbtree_vinfo * tinfo)
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
{
|
2004-08-29 13:07:03 +08:00
|
|
|
OffsetNumber i,
|
|
|
|
maxoff = entryvec->n - 1;
|
|
|
|
Vsrt *arr;
|
2005-03-01 23:40:04 +08:00
|
|
|
int svcntr = 0,
|
2004-08-29 13:07:03 +08:00
|
|
|
nbytes;
|
2005-03-01 23:40:04 +08:00
|
|
|
char *cur;
|
2004-08-29 13:07:03 +08:00
|
|
|
GBT_VARKEY **sv = NULL;
|
|
|
|
|
|
|
|
arr = (Vsrt *) palloc((maxoff + 1) * sizeof(Vsrt));
|
|
|
|
nbytes = (maxoff + 2) * sizeof(OffsetNumber);
|
|
|
|
v->spl_left = (OffsetNumber *) palloc(nbytes);
|
|
|
|
v->spl_right = (OffsetNumber *) palloc(nbytes);
|
|
|
|
v->spl_ldatum = PointerGetDatum(0);
|
|
|
|
v->spl_rdatum = PointerGetDatum(0);
|
|
|
|
v->spl_nleft = 0;
|
|
|
|
v->spl_nright = 0;
|
|
|
|
|
|
|
|
sv = palloc(sizeof(bytea *) * (maxoff + 1));
|
|
|
|
|
|
|
|
/* Sort entries */
|
|
|
|
|
|
|
|
for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i))
|
|
|
|
{
|
|
|
|
GBT_VARKEY_R ro;
|
|
|
|
|
2005-03-01 23:40:04 +08:00
|
|
|
cur = (char *) DatumGetPointer(entryvec->vector[i].key);
|
2004-08-29 13:07:03 +08:00
|
|
|
ro = gbt_var_key_readable((GBT_VARKEY *) cur);
|
|
|
|
if (ro.lower == ro.upper) /* leaf */
|
|
|
|
{
|
|
|
|
sv[svcntr] = gbt_var_leaf2node((GBT_VARKEY *) cur, tinfo);
|
|
|
|
arr[i].t = sv[svcntr];
|
|
|
|
if (sv[svcntr] != (GBT_VARKEY *) cur)
|
|
|
|
svcntr++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
arr[i].t = (GBT_VARKEY *) cur;
|
|
|
|
arr[i].i = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* sort */
|
2004-08-21 08:09:10 +08:00
|
|
|
gbt_vsrt_cmp_tinfo = tinfo;
|
2004-08-29 13:07:03 +08:00
|
|
|
qsort((void *) &arr[FirstOffsetNumber],
|
|
|
|
maxoff - FirstOffsetNumber + 1,
|
2004-08-21 08:09:10 +08:00
|
|
|
sizeof(Vsrt),
|
|
|
|
gbt_vsrt_cmp);
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
/* We do simply create two parts */
|
|
|
|
|
|
|
|
for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i))
|
|
|
|
{
|
|
|
|
if (i <= (maxoff - FirstOffsetNumber + 1) / 2)
|
|
|
|
{
|
|
|
|
gbt_var_bin_union(&v->spl_ldatum, arr[i].t, tinfo);
|
|
|
|
v->spl_left[v->spl_nleft] = arr[i].i;
|
|
|
|
v->spl_nleft++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gbt_var_bin_union(&v->spl_rdatum, arr[i].t, tinfo);
|
|
|
|
v->spl_right[v->spl_nright] = arr[i].i;
|
|
|
|
v->spl_nright++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Truncate (=compress) key */
|
|
|
|
if (tinfo->trnc)
|
|
|
|
{
|
|
|
|
int32 ll = gbt_var_node_cp_len((GBT_VARKEY *) DatumGetPointer(v->spl_ldatum), tinfo);
|
|
|
|
int32 lr = gbt_var_node_cp_len((GBT_VARKEY *) DatumGetPointer(v->spl_rdatum), tinfo);
|
|
|
|
GBT_VARKEY *dl;
|
|
|
|
GBT_VARKEY *dr;
|
|
|
|
|
|
|
|
ll = Max(ll, lr);
|
|
|
|
ll++;
|
|
|
|
|
|
|
|
dl = gbt_var_node_truncate((GBT_VARKEY *) DatumGetPointer(v->spl_ldatum), ll, tinfo);
|
|
|
|
dr = gbt_var_node_truncate((GBT_VARKEY *) DatumGetPointer(v->spl_rdatum), ll, tinfo);
|
|
|
|
v->spl_ldatum = PointerGetDatum(dl);
|
|
|
|
v->spl_rdatum = PointerGetDatum(dr);
|
|
|
|
}
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
return v;
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2004-08-21 08:09:10 +08:00
|
|
|
* The GiST consistent method
|
|
|
|
*/
|
2005-05-12 08:39:37 +08:00
|
|
|
bool
|
2004-08-29 13:07:03 +08:00
|
|
|
gbt_var_consistent(
|
|
|
|
GBT_VARKEY_R * key,
|
|
|
|
const void *query,
|
|
|
|
const StrategyNumber *strategy,
|
|
|
|
bool is_leaf,
|
|
|
|
const gbtree_vinfo * tinfo
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
)
|
|
|
|
{
|
2004-08-29 13:07:03 +08:00
|
|
|
bool retval = FALSE;
|
|
|
|
|
|
|
|
switch (*strategy)
|
|
|
|
{
|
|
|
|
case BTLessEqualStrategyNumber:
|
|
|
|
if (is_leaf)
|
|
|
|
retval = (*tinfo->f_ge) (query, (void *) key->lower);
|
|
|
|
else
|
|
|
|
retval = (*tinfo->f_cmp) ((bytea *) query, key->lower) >= 0
|
|
|
|
|| gbt_var_node_pf_match(key, query, tinfo);
|
|
|
|
break;
|
|
|
|
case BTLessStrategyNumber:
|
|
|
|
if (is_leaf)
|
|
|
|
retval = (*tinfo->f_gt) (query, (void *) key->lower);
|
|
|
|
else
|
|
|
|
retval = (*tinfo->f_cmp) ((bytea *) query, key->lower) >= 0
|
|
|
|
|| gbt_var_node_pf_match(key, query, tinfo);
|
|
|
|
break;
|
|
|
|
case BTEqualStrategyNumber:
|
|
|
|
if (is_leaf)
|
|
|
|
retval = (*tinfo->f_eq) (query, (void *) key->lower);
|
|
|
|
else
|
|
|
|
retval = (
|
|
|
|
(
|
2005-10-15 10:49:52 +08:00
|
|
|
(*tinfo->f_cmp) (key->lower, (bytea *) query) <= 0 &&
|
|
|
|
(*tinfo->f_cmp) ((bytea *) query, (void *) key->upper) <= 0
|
2004-08-29 13:07:03 +08:00
|
|
|
) || gbt_var_node_pf_match(key, query, tinfo)
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case BTGreaterStrategyNumber:
|
|
|
|
if (is_leaf)
|
|
|
|
retval = (*tinfo->f_lt) (query, (void *) key->upper);
|
|
|
|
else
|
|
|
|
retval = (*tinfo->f_cmp) ((bytea *) query, key->upper) <= 0
|
|
|
|
|| gbt_var_node_pf_match(key, query, tinfo);
|
|
|
|
break;
|
|
|
|
case BTGreaterEqualStrategyNumber:
|
|
|
|
if (is_leaf)
|
|
|
|
retval = (*tinfo->f_le) (query, (void *) key->upper);
|
|
|
|
else
|
|
|
|
retval = (*tinfo->f_cmp) ((bytea *) query, key->upper) <= 0
|
|
|
|
|| gbt_var_node_pf_match(key, query, tinfo);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
retval = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (retval);
|
New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
}
|