30 #define hibits(addr) \
31 ((unsigned long)(((addr)->a<<16)|((addr)->b<<8)|((addr)->c)))
33 #define lobits(addr) \
34 ((unsigned long)(((addr)->d<<16)|((addr)->e<<8)|((addr)->f)))
70 count = sscanf(
str,
"%x:%x:%x:%x:%x:%x%1s",
71 &
a, &
b, &
c, &d, &
e, &f, junk);
73 count = sscanf(
str,
"%x-%x-%x-%x-%x-%x%1s",
74 &
a, &
b, &
c, &d, &
e, &f, junk);
76 count = sscanf(
str,
"%2x%2x%2x:%2x%2x%2x%1s",
77 &
a, &
b, &
c, &d, &
e, &f, junk);
79 count = sscanf(
str,
"%2x%2x%2x-%2x%2x%2x%1s",
80 &
a, &
b, &
c, &d, &
e, &f, junk);
82 count = sscanf(
str,
"%2x%2x.%2x%2x.%2x%2x%1s",
83 &
a, &
b, &
c, &d, &
e, &f, junk);
85 count = sscanf(
str,
"%2x%2x-%2x%2x-%2x%2x%1s",
86 &
a, &
b, &
c, &d, &
e, &f, junk);
88 count = sscanf(
str,
"%2x%2x%2x%2x%2x%2x%1s",
89 &
a, &
b, &
c, &d, &
e, &f, junk);
92 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
93 errmsg(
"invalid input syntax for type %s: \"%s\"",
"macaddr",
96 if ((
a < 0) || (
a > 255) || (
b < 0) || (
b > 255) ||
97 (
c < 0) || (
c > 255) || (d < 0) || (d > 255) ||
98 (
e < 0) || (
e > 255) || (f < 0) || (f > 255))
100 (
errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
101 errmsg(
"invalid octet value in \"macaddr\" value: \"%s\"",
str)));
125 result = (
char *)
palloc(32);
127 snprintf(result, 32,
"%02x:%02x:%02x:%02x:%02x:%02x",
128 addr->
a, addr->
b, addr->
c, addr->
d, addr->
e, addr->
f);
292 result->
a = ~addr->
a;
293 result->
b = ~addr->
b;
294 result->
c = ~addr->
c;
295 result->
d = ~addr->
d;
296 result->
e = ~addr->
e;
297 result->
f = ~addr->
f;
309 result->
a = addr1->
a & addr2->
a;
310 result->
b = addr1->
b & addr2->
b;
311 result->
c = addr1->
c & addr2->
c;
312 result->
d = addr1->
d & addr2->
d;
313 result->
e = addr1->
e & addr2->
e;
314 result->
f = addr1->
f & addr2->
f;
326 result->
a = addr1->
a | addr2->
a;
327 result->
b = addr1->
b | addr2->
b;
328 result->
c = addr1->
c | addr2->
c;
329 result->
d = addr1->
d | addr2->
d;
330 result->
e = addr1->
e | addr2->
e;
331 result->
f = addr1->
f | addr2->
f;
419 if (memtupcount < 10000 || uss->input_count < 10000 || !uss->estimating)
430 if (abbr_card > 100000.0)
435 "macaddr_abbrev: estimation ends at cardinality %f"
449 if (abbr_card < uss->input_count / 2000.0 + 0.5)
454 "macaddr_abbrev: aborting abbreviation at cardinality %f"
455 " below threshold %f after " INT64_FORMAT " values (%d rows)",
466 " values (%d rows)", abbr_card, uss->
input_count, memtupcount);
493 #if SIZEOF_DATUM == 8
511 #if SIZEOF_DATUM == 8
528 res = DatumBigEndianToNative(
res);
static void PGresult * res
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
#define PG_RETURN_BYTEA_P(x)
#define PG_GETARG_POINTER(n)
#define PG_RETURN_CSTRING(x)
#define PG_GETARG_CSTRING(n)
#define PG_GETARG_INT64(n)
#define PG_RETURN_INT32(x)
#define PG_RETURN_BOOL(x)
static Datum hash_uint32(uint32 k)
static Datum hash_any_extended(const unsigned char *k, int keylen, uint64 seed)
static Datum hash_any(const unsigned char *k, int keylen)
static const FormData_pg_attribute a1
static const FormData_pg_attribute a2
void initHyperLogLog(hyperLogLogState *cState, uint8 bwidth)
double estimateHyperLogLog(hyperLogLogState *cState)
void addHyperLogLog(hyperLogLogState *cState, uint32 hash)
Datum macaddr_lt(PG_FUNCTION_ARGS)
Datum macaddr_cmp(PG_FUNCTION_ARGS)
static int macaddr_cmp_internal(macaddr *a1, macaddr *a2)
Datum hashmacaddrextended(PG_FUNCTION_ARGS)
Datum hashmacaddr(PG_FUNCTION_ARGS)
static Datum macaddr_abbrev_convert(Datum original, SortSupport ssup)
Datum macaddr_or(PG_FUNCTION_ARGS)
Datum macaddr_recv(PG_FUNCTION_ARGS)
Datum macaddr_ne(PG_FUNCTION_ARGS)
Datum macaddr_trunc(PG_FUNCTION_ARGS)
Datum macaddr_eq(PG_FUNCTION_ARGS)
Datum macaddr_in(PG_FUNCTION_ARGS)
Datum macaddr_not(PG_FUNCTION_ARGS)
static bool macaddr_abbrev_abort(int memtupcount, SortSupport ssup)
Datum macaddr_and(PG_FUNCTION_ARGS)
Datum macaddr_send(PG_FUNCTION_ARGS)
Datum macaddr_sortsupport(PG_FUNCTION_ARGS)
Datum macaddr_ge(PG_FUNCTION_ARGS)
static int macaddr_fast_cmp(Datum x, Datum y, SortSupport ssup)
Datum macaddr_le(PG_FUNCTION_ARGS)
Datum macaddr_out(PG_FUNCTION_ARGS)
Datum macaddr_gt(PG_FUNCTION_ARGS)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
#define DatumGetUInt32(X)
struct SortSupportData * SortSupport
StringInfoData * StringInfo
int(* comparator)(Datum x, Datum y, SortSupport ssup)
Datum(* abbrev_converter)(Datum original, SortSupport ssup)
int(* abbrev_full_comparator)(Datum x, Datum y, SortSupport ssup)
bool(* abbrev_abort)(int memtupcount, SortSupport ssup)
hyperLogLogState abbr_card
int ssup_datum_unsigned_cmp(Datum x, Datum y, SortSupport ssup)
#define PG_GETARG_MACADDR_P(n)
#define PG_RETURN_MACADDR_P(x)
#define DatumGetMacaddrP(X)