20 #include "utils/fmgrprotos.h"
55 static const char hex_chars[] =
"0123456789abcdef";
73 if (
i == 4 ||
i == 6 ||
i == 8 ||
i == 10)
76 hi = uuid->
data[
i] >> 4;
77 lo = uuid->
data[
i] & 0x0F;
110 if (src[0] ==
'\0' || src[1] ==
'\0')
112 memcpy(str_buf, src, 2);
113 if (!isxdigit((
unsigned char) str_buf[0]) ||
114 !isxdigit((
unsigned char) str_buf[1]))
118 uuid->
data[
i] = (
unsigned char) strtoul(str_buf, NULL, 16);
120 if (src[0] ==
'-' && (
i % 2) == 1 &&
i <
UUID_LEN - 1)
138 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
139 errmsg(
"invalid input syntax for type %s: \"%s\"",
296 if (memtupcount < 10000 || uss->input_count < 10000 || !uss->estimating)
307 if (abbr_card > 100000.0)
312 "uuid_abbrev: estimation ends at cardinality %f"
326 if (abbr_card < uss->input_count / 2000.0 + 0.5)
331 "uuid_abbrev: aborting abbreviation at cardinality %f"
332 " below threshold %f after " INT64_FORMAT " values (%d rows)",
343 " values (%d rows)", abbr_card, uss->
input_count, memtupcount);
370 #if SIZEOF_DATUM == 8
387 res = DatumBigEndianToNative(
res);
416 (
errcode(ERRCODE_INTERNAL_ERROR),
417 errmsg(
"could not generate random values")));
423 uuid->
data[6] = (uuid->
data[6] & 0x0f) | 0x40;
424 uuid->
data[8] = (uuid->
data[8] & 0x3f) | 0x80;
static void PGresult * res
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
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)