55 static const char hex_chars[] =
"0123456789abcdef";
70 if (
i == 4 ||
i == 6 ||
i == 8 ||
i == 10)
73 hi = uuid->
data[
i] >> 4;
74 lo = uuid->
data[
i] & 0x0F;
106 if (src[0] ==
'\0' || src[1] ==
'\0')
108 memcpy(str_buf, src, 2);
109 if (!isxdigit((
unsigned char) str_buf[0]) ||
110 !isxdigit((
unsigned char) str_buf[1]))
114 uuid->
data[
i] = (
unsigned char) strtoul(str_buf, NULL, 16);
116 if (src[0] ==
'-' && (
i % 2) == 1 &&
i <
UUID_LEN - 1)
134 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
135 errmsg(
"invalid input syntax for type %s: \"%s\"",
292 if (memtupcount < 10000 || uss->input_count < 10000 || !uss->estimating)
303 if (abbr_card > 100000.0)
308 "uuid_abbrev: estimation ends at cardinality %f"
322 if (abbr_card < uss->input_count / 2000.0 + 0.5)
327 "uuid_abbrev: aborting abbreviation at cardinality %f"
328 " below threshold %f after " INT64_FORMAT " values (%d rows)",
339 " values (%d rows)", abbr_card, uss->
input_count, memtupcount);
366 #if SIZEOF_DATUM == 8
383 res = DatumBigEndianToNative(
res);
412 (
errcode(ERRCODE_INTERNAL_ERROR),
413 errmsg(
"could not generate random values")));
419 uuid->
data[6] = (uuid->
data[6] & 0x0f) | 0x40;
420 uuid->
data[8] = (uuid->
data[8] & 0x3f) | 0x80;
static void PGresult * res
elog(ERROR, "%s: %s", p2, msg)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereturn(context, dummy_value,...)
#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_POINTER(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)
void initHyperLogLog(hyperLogLogState *cState, uint8 bwidth)
double estimateHyperLogLog(hyperLogLogState *cState)
void addHyperLogLog(hyperLogLogState *cState, uint32 hash)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
static rewind_source * source
void syntax_error(const char *source, int lineno, const char *line, const char *command, const char *msg, const char *more, int column)
bool pg_strong_random(void *buf, size_t len)
static uint32 DatumGetUInt32(Datum X)
struct SortSupportData * SortSupport
void appendStringInfoChar(StringInfo str, char ch)
void initStringInfo(StringInfo str)
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)
unsigned char data[UUID_LEN]
hyperLogLogState abbr_card
int ssup_datum_unsigned_cmp(Datum x, Datum y, SortSupport ssup)
Datum uuid_send(PG_FUNCTION_ARGS)
static void string_to_uuid(const char *source, pg_uuid_t *uuid, Node *escontext)
static bool uuid_abbrev_abort(int memtupcount, SortSupport ssup)
Datum uuid_lt(PG_FUNCTION_ARGS)
Datum uuid_gt(PG_FUNCTION_ARGS)
Datum gen_random_uuid(PG_FUNCTION_ARGS)
Datum uuid_recv(PG_FUNCTION_ARGS)
Datum uuid_cmp(PG_FUNCTION_ARGS)
Datum uuid_le(PG_FUNCTION_ARGS)
Datum uuid_hash(PG_FUNCTION_ARGS)
Datum uuid_hash_extended(PG_FUNCTION_ARGS)
Datum uuid_out(PG_FUNCTION_ARGS)
Datum uuid_ne(PG_FUNCTION_ARGS)
static int uuid_internal_cmp(const pg_uuid_t *arg1, const pg_uuid_t *arg2)
Datum uuid_ge(PG_FUNCTION_ARGS)
Datum uuid_eq(PG_FUNCTION_ARGS)
static int uuid_fast_cmp(Datum x, Datum y, SortSupport ssup)
Datum uuid_in(PG_FUNCTION_ARGS)
static Datum uuid_abbrev_convert(Datum original, SortSupport ssup)
Datum uuid_sortsupport(PG_FUNCTION_ARGS)
#define PG_RETURN_UUID_P(X)
static pg_uuid_t * DatumGetUUIDP(Datum X)
#define PG_GETARG_UUID_P(X)