Datum HASHAPI_Hash_1_timetz(PG_FUNCTION_ARGS) { int32 num_segs; /* number of segments */ TimeTzADT *val1; /* time w/timezone value */ unsigned int targetbucket; /* 0-based */ int16 algorithm; /* hashing algorithm */ Datum d1; Oid oid; /* Get number of segments */ num_segs = PG_GETARG_INT32(0); /* Get hashing algoriithm */ algorithm = PG_GETARG_INT16(1); /* Get the value to hash */ val1 = PG_GETARG_TIMETZADT_P(2); d1 = TimeTzADTPGetDatum(val1); /* create a CdbHash for this hash test. */ h = makeCdbHash(num_segs, algorithm); /* init cdb hash */ cdbhashinit(h); oid = TIMETZOID; cdbhash(h, d1, oid); /* reduce the result hash value */ targetbucket = cdbhashreduce(h); PG_RETURN_INT32(targetbucket); /* return target bucket (segID) */ }
static Datum leftmostvalue_timetz(void) { TimeTzADT *v = palloc(sizeof(TimeTzADT)); v->time = 0; v->zone = -24 * 3600; /* XXX is that true? */ return TimeTzADTPGetDatum(v); }