2003-02-19 11:46:00 +08:00
|
|
|
#include "btree_gist.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_utils_num.h"
|
2003-02-19 11:46:00 +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
|
|
|
typedef struct
|
2003-02-19 11:46:00 +08:00
|
|
|
{
|
2004-08-29 13:07:03 +08:00
|
|
|
Timestamp lower;
|
|
|
|
Timestamp upper;
|
|
|
|
} tsKEY;
|
2003-02-19 11:46:00 +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
|
|
|
** timestamp ops
|
2003-02-19 11:46:00 +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
|
|
|
PG_FUNCTION_INFO_V1(gbt_ts_compress);
|
|
|
|
PG_FUNCTION_INFO_V1(gbt_tstz_compress);
|
|
|
|
PG_FUNCTION_INFO_V1(gbt_ts_union);
|
|
|
|
PG_FUNCTION_INFO_V1(gbt_ts_picksplit);
|
|
|
|
PG_FUNCTION_INFO_V1(gbt_ts_consistent);
|
|
|
|
PG_FUNCTION_INFO_V1(gbt_tstz_consistent);
|
|
|
|
PG_FUNCTION_INFO_V1(gbt_ts_penalty);
|
|
|
|
PG_FUNCTION_INFO_V1(gbt_ts_same);
|
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
Datum gbt_ts_compress(PG_FUNCTION_ARGS);
|
|
|
|
Datum gbt_tstz_compress(PG_FUNCTION_ARGS);
|
|
|
|
Datum gbt_ts_union(PG_FUNCTION_ARGS);
|
|
|
|
Datum gbt_ts_picksplit(PG_FUNCTION_ARGS);
|
|
|
|
Datum gbt_ts_consistent(PG_FUNCTION_ARGS);
|
|
|
|
Datum gbt_tstz_consistent(PG_FUNCTION_ARGS);
|
|
|
|
Datum gbt_ts_penalty(PG_FUNCTION_ARGS);
|
|
|
|
Datum gbt_ts_same(PG_FUNCTION_ARGS);
|
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-02-21 18:03:57 +08:00
|
|
|
#define P_TimestampGetDatum(x) PointerGetDatum( &(x) )
|
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
static bool
|
|
|
|
gbt_tsgt(const void *a, const void *b)
|
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 DatumGetBool(
|
|
|
|
DirectFunctionCall2(timestamp_gt, PointerGetDatum(a), PointerGetDatum(b))
|
|
|
|
);
|
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
|
|
|
}
|
2003-02-19 11:46:00 +08:00
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
static bool
|
|
|
|
gbt_tsge(const void *a, const void *b)
|
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 DatumGetBool(
|
|
|
|
DirectFunctionCall2(timestamp_ge, PointerGetDatum(a), PointerGetDatum(b))
|
|
|
|
);
|
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
|
|
|
}
|
2003-02-19 11:46:00 +08:00
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
static bool
|
|
|
|
gbt_tseq(const void *a, const void *b)
|
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 DatumGetBool(
|
|
|
|
DirectFunctionCall2(timestamp_eq, PointerGetDatum(a), PointerGetDatum(b))
|
|
|
|
);
|
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_tsle(const void *a, const void *b)
|
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 DatumGetBool(
|
|
|
|
DirectFunctionCall2(timestamp_le, PointerGetDatum(a), PointerGetDatum(b))
|
|
|
|
);
|
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_tslt(const void *a, const void *b)
|
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 DatumGetBool(
|
|
|
|
DirectFunctionCall2(timestamp_lt, PointerGetDatum(a), PointerGetDatum(b))
|
|
|
|
);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
gbt_tskey_cmp(const void *a, const void *b)
|
|
|
|
{
|
2004-08-29 13:07:03 +08:00
|
|
|
if (gbt_tsgt((void *) &(((Nsrt *) a)->t[0]), (void *) &(((Nsrt *) b)->t[0])))
|
|
|
|
return 1;
|
|
|
|
else if (gbt_tslt((void *) &(((Nsrt *) a)->t[0]), (void *) &(((Nsrt *) b)->t[0])))
|
|
|
|
return -1;
|
|
|
|
return 0;
|
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
|
|
|
}
|
2003-02-19 11:46:00 +08:00
|
|
|
|
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
static const gbtree_ninfo tinfo =
|
|
|
|
{
|
|
|
|
gbt_t_ts,
|
|
|
|
sizeof(Timestamp),
|
|
|
|
gbt_tsgt,
|
|
|
|
gbt_tsge,
|
|
|
|
gbt_tseq,
|
|
|
|
gbt_tsle,
|
|
|
|
gbt_tslt,
|
|
|
|
gbt_tskey_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
|
|
|
};
|
|
|
|
|
2003-02-19 11:46:00 +08:00
|
|
|
|
|
|
|
/**************************************************
|
|
|
|
* timestamp ops
|
|
|
|
**************************************************/
|
|
|
|
|
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 Timestamp *
|
|
|
|
tstz_to_ts_gmt(Timestamp *gmt, TimestampTz *ts)
|
2003-02-19 11:46:00 +08:00
|
|
|
{
|
2004-08-29 13:07:03 +08:00
|
|
|
int val,
|
|
|
|
tz;
|
|
|
|
|
|
|
|
*gmt = *ts;
|
|
|
|
DecodeSpecial(0, "gmt", &val);
|
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 (!TIMESTAMP_NOT_FINITE(*ts))
|
|
|
|
{
|
|
|
|
tz = val * 60;
|
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
|
|
|
|
|
|
|
#ifdef HAVE_INT64_TIMESTAMP
|
2004-08-29 13:07:03 +08:00
|
|
|
*gmt -= (tz * INT64CONST(1000000));
|
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
|
|
|
#else
|
2004-08-29 13:07:03 +08:00
|
|
|
*gmt -= tz;
|
|
|
|
*gmt = JROUND(*gmt);
|
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
|
|
|
#endif
|
2004-08-29 13:07:03 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
return gmt;
|
2003-02-19 11:46:00 +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
|
|
|
|
|
|
|
|
|
|
|
|
2003-02-19 11:46:00 +08:00
|
|
|
Datum
|
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
|
|
|
gbt_ts_compress(PG_FUNCTION_ARGS)
|
2003-02-19 11:46:00 +08:00
|
|
|
{
|
2004-08-29 13:07:03 +08:00
|
|
|
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
|
|
|
|
GISTENTRY *retval = NULL;
|
|
|
|
|
|
|
|
PG_RETURN_POINTER(gbt_num_compress(retval, entry, &tinfo));
|
2003-02-19 11:46:00 +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
|
|
|
|
2003-02-19 11:46:00 +08:00
|
|
|
Datum
|
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
|
|
|
gbt_tstz_compress(PG_FUNCTION_ARGS)
|
2003-02-19 11:46:00 +08:00
|
|
|
{
|
2004-08-29 13:07:03 +08:00
|
|
|
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
tsKEY *r = (tsKEY *) palloc(sizeof(tsKEY));
|
2004-06-03 20:26:10 +08:00
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
TimestampTz ts = *(TimestampTz *) DatumGetPointer(entry->key);
|
|
|
|
Timestamp gmt;
|
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
|
|
|
tstz_to_ts_gmt(&gmt, &ts);
|
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));
|
|
|
|
r->lower = r->upper = gmt;
|
|
|
|
gistentryinit(*retval, PointerGetDatum(r),
|
|
|
|
entry->rel, entry->page,
|
|
|
|
entry->offset, sizeof(tsKEY), FALSE);
|
|
|
|
}
|
|
|
|
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
|
|
|
PG_RETURN_POINTER(retval);
|
2003-02-19 11:46:00 +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
|
|
|
|
2003-02-19 11:46:00 +08:00
|
|
|
Datum
|
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
|
|
|
gbt_ts_consistent(PG_FUNCTION_ARGS)
|
2003-02-19 11:46:00 +08:00
|
|
|
{
|
2004-08-29 13:07:03 +08:00
|
|
|
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
|
|
|
|
Timestamp *query = (Timestamp *) PG_GETARG_POINTER(1);
|
|
|
|
tsKEY *kkk = (tsKEY *) DatumGetPointer(entry->key);
|
|
|
|
GBT_NUMKEY_R key;
|
|
|
|
StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
|
|
|
|
|
|
|
|
key.lower = (GBT_NUMKEY *) & kkk->lower;
|
|
|
|
key.upper = (GBT_NUMKEY *) & kkk->upper;
|
|
|
|
|
|
|
|
PG_RETURN_BOOL(
|
|
|
|
gbt_num_consistent(&key, (void *) query, &strategy, GIST_LEAF(entry), &tinfo)
|
|
|
|
);
|
2003-02-19 11:46:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
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
|
|
|
gbt_tstz_consistent(PG_FUNCTION_ARGS)
|
2003-02-19 11:46:00 +08:00
|
|
|
{
|
2004-08-29 13:07:03 +08:00
|
|
|
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
|
|
|
|
TimestampTz *query = (Timestamp *) PG_GETARG_POINTER(1);
|
|
|
|
char *kkk = (char *) DatumGetPointer(entry->key);
|
|
|
|
GBT_NUMKEY_R key;
|
|
|
|
StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
|
|
|
|
Timestamp qqq;
|
|
|
|
|
|
|
|
key.lower = (GBT_NUMKEY *) & kkk[0];
|
|
|
|
key.upper = (GBT_NUMKEY *) & kkk[MAXALIGN(tinfo.size)];
|
|
|
|
tstz_to_ts_gmt(&qqq, query);
|
|
|
|
|
|
|
|
PG_RETURN_BOOL(
|
|
|
|
gbt_num_consistent(&key, (void *) &qqq, &strategy, GIST_LEAF(entry), &tinfo)
|
|
|
|
);
|
2003-02-19 11:46:00 +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
|
|
|
|
2003-02-19 11:46:00 +08:00
|
|
|
Datum
|
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
|
|
|
gbt_ts_union(PG_FUNCTION_ARGS)
|
2003-02-19 11:46:00 +08:00
|
|
|
{
|
2004-08-29 13:07:03 +08:00
|
|
|
GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
|
|
|
|
void *out = palloc(sizeof(tsKEY));
|
|
|
|
|
|
|
|
*(int *) PG_GETARG_POINTER(1) = sizeof(tsKEY);
|
|
|
|
PG_RETURN_POINTER(gbt_num_union((void *) out, entryvec, &tinfo));
|
2003-02-19 11:46:00 +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
|
|
|
Datum
|
|
|
|
gbt_ts_penalty(PG_FUNCTION_ARGS)
|
2003-02-19 11:46:00 +08:00
|
|
|
{
|
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
tsKEY *origentry = (tsKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key);
|
|
|
|
tsKEY *newentry = (tsKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
|
|
|
|
float *result = (float *) PG_GETARG_POINTER(2);
|
|
|
|
Interval *intr;
|
|
|
|
|
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
|
|
|
#ifdef HAVE_INT64_TIMESTAMP
|
2004-08-29 13:07:03 +08:00
|
|
|
int64 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
|
|
|
#else
|
2004-08-29 13:07:03 +08:00
|
|
|
double 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
|
|
|
#endif
|
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
intr = DatumGetIntervalP(DirectFunctionCall2(
|
|
|
|
timestamp_mi,
|
2005-02-21 18:03:57 +08:00
|
|
|
P_TimestampGetDatum(newentry->upper),
|
|
|
|
P_TimestampGetDatum(origentry->upper)
|
2004-08-29 13:07:03 +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
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
/* see interval_larger */
|
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
|
|
|
res = Max(intr->time + intr->month * (30 * 86400), 0);
|
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
|
|
|
intr = DatumGetIntervalP(DirectFunctionCall2(
|
|
|
|
timestamp_mi,
|
2005-02-21 18:03:57 +08:00
|
|
|
P_TimestampGetDatum(origentry->lower),
|
|
|
|
P_TimestampGetDatum(newentry->lower)
|
2004-08-29 13:07:03 +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
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
/* see interval_larger */
|
|
|
|
res += Max(intr->time + intr->month * (30 * 86400), 0);
|
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
|
|
|
*result = 0.0;
|
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 (res > 0)
|
|
|
|
{
|
|
|
|
intr = DatumGetIntervalP(DirectFunctionCall2(
|
|
|
|
timestamp_mi,
|
2005-02-21 18:03:57 +08:00
|
|
|
P_TimestampGetDatum(origentry->upper),
|
|
|
|
P_TimestampGetDatum(origentry->lower)
|
2004-08-29 13:07:03 +08:00
|
|
|
));
|
|
|
|
*result += FLT_MIN;
|
|
|
|
*result += (float) (res / ((double) (res + intr->time + intr->month * (30 * 86400))));
|
|
|
|
*result *= (FLT_MAX / (((GISTENTRY *) PG_GETARG_POINTER(0))->rel->rd_att->natts + 1));
|
|
|
|
}
|
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
|
|
|
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
|
|
|
}
|
2003-02-19 11:46:00 +08:00
|
|
|
|
|
|
|
|
|
|
|
Datum
|
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
|
|
|
gbt_ts_picksplit(PG_FUNCTION_ARGS)
|
2003-02-19 11:46:00 +08:00
|
|
|
{
|
2004-08-29 13:07:03 +08:00
|
|
|
PG_RETURN_POINTER(gbt_num_picksplit(
|
|
|
|
(GistEntryVector *) PG_GETARG_POINTER(0),
|
|
|
|
(GIST_SPLITVEC *) PG_GETARG_POINTER(1),
|
|
|
|
&tinfo
|
|
|
|
));
|
2003-02-19 11:46:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
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
|
|
|
gbt_ts_same(PG_FUNCTION_ARGS)
|
2003-02-19 11:46:00 +08:00
|
|
|
{
|
2004-08-29 13:07:03 +08:00
|
|
|
tsKEY *b1 = (tsKEY *) PG_GETARG_POINTER(0);
|
|
|
|
tsKEY *b2 = (tsKEY *) PG_GETARG_POINTER(1);
|
|
|
|
bool *result = (bool *) PG_GETARG_POINTER(2);
|
2003-07-25 01:52:50 +08:00
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
*result = gbt_num_same((void *) b1, (void *) b2, &tinfo);
|
|
|
|
PG_RETURN_POINTER(result);
|
2003-02-19 11:46:00 +08:00
|
|
|
}
|