20#include "utils/fmgrprotos.h"
31 ((unsigned long)(((addr)->a<<16)|((addr)->b<<8)|((addr)->c)))
34 ((unsigned long)(((addr)->d<<16)|((addr)->e<<8)|((addr)->f)))
58 Node *escontext = fcinfo->context;
71 count =
sscanf(
str,
"%x:%x:%x:%x:%x:%x%1s",
74 count =
sscanf(
str,
"%x-%x-%x-%x-%x-%x%1s",
77 count =
sscanf(
str,
"%2x%2x%2x:%2x%2x%2x%1s",
80 count =
sscanf(
str,
"%2x%2x%2x-%2x%2x%2x%1s",
83 count =
sscanf(
str,
"%2x%2x.%2x%2x.%2x%2x%1s",
86 count =
sscanf(
str,
"%2x%2x-%2x%2x-%2x%2x%1s",
89 count =
sscanf(
str,
"%2x%2x%2x%2x%2x%2x%1s",
94 errmsg(
"invalid input syntax for type %s: \"%s\"",
"macaddr",
97 if ((
a < 0) || (
a > 255) || (
b < 0) || (
b > 255) ||
98 (
c < 0) || (
c > 255) || (d < 0) || (d > 255) ||
99 (
e < 0) || (
e > 255) || (f < 0) || (f > 255))
102 errmsg(
"invalid octet value in \"macaddr\" value: \"%s\"",
str)));
126 result = (
char *)
palloc(32);
128 snprintf(result, 32,
"%02x:%02x:%02x:%02x:%02x:%02x",
129 addr->
a, addr->
b, addr->
c, addr->
d, addr->
e, addr->
f);
378 uss->input_count = 0;
379 uss->estimating =
true;
431 if (abbr_card > 100000.0)
435 "macaddr_abbrev: estimation ends at cardinality %f"
437 abbr_card,
uss->input_count, memtupcount);
438 uss->estimating =
false;
452 "macaddr_abbrev: aborting abbreviation at cardinality %f"
453 " below threshold %f after " INT64_FORMAT " values (%d rows)",
454 abbr_card,
uss->input_count / 2000.0 + 0.5,
uss->input_count,
462 " values (%d rows)", abbr_card,
uss->input_count, memtupcount);
489 "Datum is too small for macaddr");
490 memset(&res, 0,
sizeof(res));
492 uss->input_count += 1;
#define StaticAssertDecl(condition, errmessage)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereturn(context, dummy_value,...)
#define palloc_object(type)
#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 DatumBigEndianToNative(x)
static char buf[DEFAULT_XLOG_SEG_SIZE]
static uint32 DatumGetUInt32(Datum X)
static uint64 DatumGetUInt64(Datum X)
struct SortSupportData * SortSupport
struct 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)
static macaddr * DatumGetMacaddrP(Datum X)