56 static const char hex_chars[] =
"0123456789abcdef";
71 if (i == 4 || i == 6 || i == 8 || i == 10)
74 hi = uuid->
data[
i] >> 4;
75 lo = uuid->
data[
i] & 0x0F;
107 if (src[0] ==
'\0' || src[1] ==
'\0')
109 memcpy(str_buf, src, 2);
110 if (!isxdigit((
unsigned char) str_buf[0]) ||
111 !isxdigit((
unsigned char) str_buf[1]))
115 uuid->
data[
i] = (
unsigned char) strtoul(str_buf, NULL, 16);
117 if (src[0] ==
'-' && (i % 2) == 1 && i < UUID_LEN - 1)
135 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
136 errmsg(
"invalid input syntax for type %s: \"%s\"",
307 if (memtupcount < 10000 || uss->input_count < 10000 || !uss->estimating)
318 if (abbr_card > 100000.0)
323 "uuid_abbrev: estimation ends at cardinality %f" 337 if (abbr_card < uss->input_count / 2000.0 + 0.5)
342 "uuid_abbrev: aborting abbreviation at cardinality %f" 343 " below threshold %f after " INT64_FORMAT " values (%d rows)",
354 " values (%d rows)", abbr_card, uss->
input_count, memtupcount);
374 memcpy(&res, authoritative->
data,
sizeof(
Datum));
381 #if SIZEOF_DATUM == 8 398 res = DatumBigEndianToNative(res);
427 (
errcode(ERRCODE_INTERNAL_ERROR),
428 errmsg(
"could not generate random values")));
434 uuid->
data[6] = (uuid->
data[6] & 0x0f) | 0x40;
435 uuid->
data[8] = (uuid->
data[8] & 0x3f) | 0x80;
struct SortSupportData * SortSupport
#define PG_RETURN_POINTER(x)
#define DatumGetUInt32(X)
#define PG_GETARG_UUID_P(X)
static int uuid_cmp_abbrev(Datum x, Datum y, SortSupport ssup)
unsigned char data[UUID_LEN]
Datum uuid_hash(PG_FUNCTION_ARGS)
static void string_to_uuid(const char *source, pg_uuid_t *uuid)
Datum uuid_in(PG_FUNCTION_ARGS)
StringInfoData * StringInfo
void syntax_error(const char *source, int lineno, const char *line, const char *command, const char *msg, const char *more, int column)
Datum uuid_send(PG_FUNCTION_ARGS)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
#define PG_RETURN_INT32(x)
int errcode(int sqlerrcode)
#define PG_GETARG_POINTER(n)
#define PG_RETURN_BYTEA_P(x)
static Datum hash_any_extended(const unsigned char *k, int keylen, uint64 seed)
void initHyperLogLog(hyperLogLogState *cState, uint8 bwidth)
static Datum uuid_abbrev_convert(Datum original, SortSupport ssup)
static bool uuid_abbrev_abort(int memtupcount, SortSupport ssup)
int(* comparator)(Datum x, Datum y, SortSupport ssup)
int(* abbrev_full_comparator)(Datum x, Datum y, SortSupport ssup)
Datum(* abbrev_converter)(Datum original, SortSupport ssup)
Datum uuid_hash_extended(PG_FUNCTION_ARGS)
static Datum hash_any(const unsigned char *k, int keylen)
#define PG_RETURN_UUID_P(X)
void appendStringInfoChar(StringInfo str, char ch)
void initStringInfo(StringInfo str)
hyperLogLogState abbr_card
Datum uuid_recv(PG_FUNCTION_ARGS)
#define PG_RETURN_BOOL(x)
double estimateHyperLogLog(hyperLogLogState *cState)
#define ereport(elevel,...)
Datum uuid_gt(PG_FUNCTION_ARGS)
Datum uuid_sortsupport(PG_FUNCTION_ARGS)
bool pg_strong_random(void *buf, size_t len)
static Datum hash_uint32(uint32 k)
bool(* abbrev_abort)(int memtupcount, SortSupport ssup)
#define PG_RETURN_CSTRING(x)
static rewind_source * source
static int uuid_internal_cmp(const pg_uuid_t *arg1, const pg_uuid_t *arg2)
void addHyperLogLog(hyperLogLogState *cState, uint32 hash)
Datum uuid_ge(PG_FUNCTION_ARGS)
Datum uuid_le(PG_FUNCTION_ARGS)
int errmsg(const char *fmt,...)
Datum uuid_ne(PG_FUNCTION_ARGS)
#define PG_GETARG_CSTRING(n)
Datum gen_random_uuid(PG_FUNCTION_ARGS)
Datum uuid_cmp(PG_FUNCTION_ARGS)
Datum uuid_lt(PG_FUNCTION_ARGS)
#define PG_GETARG_INT64(n)
Datum uuid_out(PG_FUNCTION_ARGS)
static int uuid_fast_cmp(Datum x, Datum y, SortSupport ssup)
Datum uuid_eq(PG_FUNCTION_ARGS)