{
gbt_t_cash,
sizeof(Cash),
+ 16, /* sizeof(gbtreekey16) */
gbt_cashgt,
gbt_cashge,
gbt_casheq,
{
gbt_t_date,
sizeof(DateADT),
+ 8, /* sizeof(gbtreekey8) */
gbt_dategt,
gbt_datege,
gbt_dateeq,
{
gbt_t_float4,
sizeof(float4),
+ 8, /* sizeof(gbtreekey8) */
gbt_float4gt,
gbt_float4ge,
gbt_float4eq,
{
gbt_t_float8,
sizeof(float8),
+ 16, /* sizeof(gbtreekey16) */
gbt_float8gt,
gbt_float8ge,
gbt_float8eq,
{
gbt_t_inet,
sizeof(double),
+ 16, /* sizeof(gbtreekey16) */
gbt_inetgt,
gbt_inetge,
gbt_ineteq,
{
gbt_t_int2,
sizeof(int16),
+ 4, /* sizeof(gbtreekey4) */
gbt_int2gt,
gbt_int2ge,
gbt_int2eq,
{
gbt_t_int4,
sizeof(int32),
+ 8, /* sizeof(gbtreekey8) */
gbt_int4gt,
gbt_int4ge,
gbt_int4eq,
{
gbt_t_int8,
sizeof(int64),
+ 16, /* sizeof(gbtreekey16) */
gbt_int8gt,
gbt_int8ge,
gbt_int8eq,
/*
* INTERVALSIZE should be the actual size-on-disk of an Interval, as shown
* in pg_type. This might be less than sizeof(Interval) if the compiler
- * insists on adding alignment padding at the end of the struct.
+ * insists on adding alignment padding at the end of the struct. (Note:
+ * this concern is obsolete with the current definition of Interval, but
+ * was real before a separate "day" field was added to it.)
*/
#define INTERVALSIZE 16
{
gbt_t_intv,
sizeof(Interval),
+ 32, /* sizeof(gbtreekey32) */
gbt_intvgt,
gbt_intvge,
gbt_intveq,
{
gbt_t_macad,
sizeof(macaddr),
+ 16, /* sizeof(gbtreekey16) */
gbt_macadgt,
gbt_macadge,
gbt_macadeq,
{
gbt_t_oid,
sizeof(Oid),
+ 8, /* sizeof(gbtreekey8) */
gbt_oidgt,
gbt_oidge,
gbt_oideq,
{
gbt_t_time,
sizeof(TimeADT),
+ 16, /* sizeof(gbtreekey16) */
gbt_timegt,
gbt_timege,
gbt_timeeq,
{
gbt_t_ts,
sizeof(Timestamp),
+ 16, /* sizeof(gbtreekey16) */
gbt_tsgt,
gbt_tsge,
gbt_tseq,
Cash ch;
} v;
- GBT_NUMKEY *r = (GBT_NUMKEY *) palloc0(2 * tinfo->size);
+ GBT_NUMKEY *r = (GBT_NUMKEY *) palloc0(tinfo->indexsize);
void *leaf = NULL;
switch (tinfo->t)
leaf = DatumGetPointer(entry->key);
}
+ Assert(tinfo->indexsize >= 2 * tinfo->size);
+
memcpy((void *) &r[0], leaf, tinfo->size);
memcpy((void *) &r[tinfo->size], leaf, tinfo->size);
retval = palloc(sizeof(GISTENTRY));
if (!DatumGetPointer(*u))
{
- *u = PointerGetDatum(palloc(2 * tinfo->size));
+ *u = PointerGetDatum(palloc0(tinfo->indexsize));
memcpy((void *) &(((GBT_NUMKEY *) DatumGetPointer(*u))[0]), (void *) rd.lower, tinfo->size);
memcpy((void *) &(((GBT_NUMKEY *) DatumGetPointer(*u))[tinfo->size]), (void *) rd.upper, tinfo->size);
}
/* Attribs */
enum gbtree_type t; /* data type */
- int32 size; /* size of type , 0 means variable */
+ int32 size; /* size of type, 0 means variable */
+ int32 indexsize; /* size of datums stored in index */
/* Methods */