|
PostgreSQL Source Code git master
|
#include "postgres.h"#include <limits.h>#include <time.h>#include "common/hashfn.h"#include "lib/hyperloglog.h"#include "libpq/pqformat.h"#include "port/pg_bswap.h"#include "utils/fmgrprotos.h"#include "utils/guc.h"#include "utils/skipsupport.h"#include "utils/sortsupport.h"#include "utils/timestamp.h"#include "utils/uuid.h"
Go to the source code of this file.
Data Structures | |
| struct | uuid_sortsupport_state |
Macros | |
| #define | NS_PER_S INT64CONST(1000000000) |
| #define | NS_PER_MS INT64CONST(1000000) |
| #define | NS_PER_US INT64CONST(1000) |
| #define | US_PER_MS INT64CONST(1000) |
| #define | PG_UNIX_EPOCH_OFFSET_US ((int64) (POSTGRES_EPOCH_JDATE - UNIX_EPOCH_JDATE) * SECS_PER_DAY * USECS_PER_SEC) |
| #define | UUIDV7_MIN_TIMESTAMP (-PG_UNIX_EPOCH_OFFSET_US) |
| #define | UUIDV7_MAX_TIMESTAMP (((INT64CONST(1) << 48) - 1) * US_PER_MS - PG_UNIX_EPOCH_OFFSET_US) |
| #define | SUBMS_MINIMAL_STEP_BITS 12 |
| #define | SUBMS_BITS 12 |
| #define | SUBMS_MINIMAL_STEP_NS ((NS_PER_MS / (1 << SUBMS_MINIMAL_STEP_BITS)) + 1) |
| #define | GREGORIAN_EPOCH_JDATE INT64CONST(2299161) |
| #define GREGORIAN_EPOCH_JDATE INT64CONST(2299161) |
| #define NS_PER_MS INT64CONST(1000000) |
| #define NS_PER_S INT64CONST(1000000000) |
| #define NS_PER_US INT64CONST(1000) |
| #define PG_UNIX_EPOCH_OFFSET_US ((int64) (POSTGRES_EPOCH_JDATE - UNIX_EPOCH_JDATE) * SECS_PER_DAY * USECS_PER_SEC) |
Definition at line 41 of file uuid.c.
| #define SUBMS_MINIMAL_STEP_NS ((NS_PER_MS / (1 << SUBMS_MINIMAL_STEP_BITS)) + 1) |
| #define US_PER_MS INT64CONST(1000) |
| #define UUIDV7_MAX_TIMESTAMP (((INT64CONST(1) << 48) - 1) * US_PER_MS - PG_UNIX_EPOCH_OFFSET_US) |
| #define UUIDV7_MIN_TIMESTAMP (-PG_UNIX_EPOCH_OFFSET_US) |
| Datum gen_random_uuid | ( | PG_FUNCTION_ARGS | ) |
Definition at line 559 of file uuid.c.
References ereport, errcode(), errmsg, ERROR, fb(), palloc(), PG_RETURN_UUID_P, pg_strong_random(), UUID_LEN, and uuid_set_version().
Referenced by pg_random_uuid().
Definition at line 636 of file uuid.c.
References ereport, errcode(), errmsg, ERROR, fb(), NS_PER_MS, palloc(), pg_strong_random(), SUBMS_BITS, UUID_LEN, and uuid_set_version().
Referenced by uuidv7(), and uuidv7_interval().
Definition at line 583 of file uuid.c.
References fb(), gettimeofday(), NS_PER_S, NS_PER_US, and SUBMS_MINIMAL_STEP_NS.
Referenced by uuidv7(), and uuidv7_interval().
Definition at line 148 of file uuid.c.
References ereturn, errcode(), errmsg, fb(), i, memcpy(), source, syntax_error(), and UUID_LEN.
Referenced by uuid_in().
|
static |
Definition at line 363 of file uuid.c.
References elog, estimateHyperLogLog(), fb(), INT64_FORMAT, LOG, SortSupportData::ssup_extra, and trace_sort.
Referenced by uuid_sortsupport().
|
static |
Definition at line 423 of file uuid.c.
References addHyperLogLog(), DatumBigEndianToNative, DatumGetUInt32(), DatumGetUInt64(), DatumGetUUIDP(), fb(), hash_uint32(), memcpy(), and SortSupportData::ssup_extra.
Referenced by uuid_sortsupport().
| Datum uuid_cmp | ( | PG_FUNCTION_ARGS | ) |
Definition at line 282 of file uuid.c.
References fb(), PG_GETARG_UUID_P, PG_RETURN_INT32, and uuid_internal_cmp().
Definition at line 455 of file uuid.c.
References DatumGetUUIDP(), fb(), i, memcpy(), palloc(), pfree(), UUID_LEN, and UUIDPGetDatum().
Referenced by uuid_skipsupport().
| Datum uuid_eq | ( | PG_FUNCTION_ARGS | ) |
Definition at line 245 of file uuid.c.
References fb(), PG_GETARG_UUID_P, PG_RETURN_BOOL, and uuid_internal_cmp().
| Datum uuid_extract_timestamp | ( | PG_FUNCTION_ARGS | ) |
Definition at line 763 of file uuid.c.
References fb(), GREGORIAN_EPOCH_JDATE, PG_GETARG_UUID_P, PG_RETURN_NULL, PG_RETURN_TIMESTAMPTZ, PG_UNIX_EPOCH_OFFSET_US, POSTGRES_EPOCH_JDATE, SECS_PER_DAY, US_PER_MS, and USECS_PER_SEC.
| Datum uuid_extract_version | ( | PG_FUNCTION_ARGS | ) |
Definition at line 818 of file uuid.c.
References fb(), PG_GETARG_UUID_P, PG_RETURN_NULL, and PG_RETURN_UINT16.
|
static |
Definition at line 348 of file uuid.c.
References DatumGetUUIDP(), fb(), uuid_internal_cmp(), x, and y.
Referenced by uuid_sortsupport().
| Datum uuid_ge | ( | PG_FUNCTION_ARGS | ) |
Definition at line 254 of file uuid.c.
References fb(), PG_GETARG_UUID_P, PG_RETURN_BOOL, and uuid_internal_cmp().
| Datum uuid_gt | ( | PG_FUNCTION_ARGS | ) |
Definition at line 263 of file uuid.c.
References fb(), PG_GETARG_UUID_P, PG_RETURN_BOOL, and uuid_internal_cmp().
| Datum uuid_hash | ( | PG_FUNCTION_ARGS | ) |
Definition at line 524 of file uuid.c.
References hash_any(), PG_GETARG_UUID_P, and UUID_LEN.
| Datum uuid_hash_extended | ( | PG_FUNCTION_ARGS | ) |
Definition at line 532 of file uuid.c.
References hash_any_extended(), PG_GETARG_INT64, PG_GETARG_UUID_P, and UUID_LEN.
| Datum uuid_in | ( | PG_FUNCTION_ARGS | ) |
Definition at line 95 of file uuid.c.
References fb(), palloc_object, PG_GETARG_CSTRING, PG_RETURN_UUID_P, and string_to_uuid().
Referenced by uuid_generate_internal().
Definition at line 480 of file uuid.c.
References DatumGetUUIDP(), fb(), i, memcpy(), palloc(), pfree(), UUID_LEN, and UUIDPGetDatum().
Referenced by uuid_skipsupport().
Definition at line 221 of file uuid.c.
References fb(), and UUID_LEN.
Referenced by uuid_cmp(), uuid_eq(), uuid_fast_cmp(), uuid_ge(), uuid_gt(), uuid_larger(), uuid_le(), uuid_lt(), uuid_ne(), and uuid_smaller().
| Datum uuid_larger | ( | PG_FUNCTION_ARGS | ) |
Definition at line 291 of file uuid.c.
References fb(), PG_GETARG_UUID_P, PG_RETURN_UUID_P, and uuid_internal_cmp().
| Datum uuid_le | ( | PG_FUNCTION_ARGS | ) |
Definition at line 236 of file uuid.c.
References fb(), PG_GETARG_UUID_P, PG_RETURN_BOOL, and uuid_internal_cmp().
Referenced by brin_minmax_multi_distance_uuid().
| Datum uuid_lt | ( | PG_FUNCTION_ARGS | ) |
Definition at line 227 of file uuid.c.
References fb(), PG_GETARG_UUID_P, PG_RETURN_BOOL, and uuid_internal_cmp().
| Datum uuid_ne | ( | PG_FUNCTION_ARGS | ) |
Definition at line 272 of file uuid.c.
References fb(), PG_GETARG_UUID_P, PG_RETURN_BOOL, and uuid_internal_cmp().
| Datum uuid_out | ( | PG_FUNCTION_ARGS | ) |
Definition at line 106 of file uuid.c.
References buf, fb(), i, palloc(), PG_GETARG_UUID_P, PG_RETURN_CSTRING, and UUID_LEN.
| Datum uuid_recv | ( | PG_FUNCTION_ARGS | ) |
Definition at line 198 of file uuid.c.
References fb(), memcpy(), palloc(), PG_GETARG_POINTER, PG_RETURN_POINTER, pq_getmsgbytes(), and UUID_LEN.
| Datum uuid_send | ( | PG_FUNCTION_ARGS | ) |
Definition at line 209 of file uuid.c.
References StringInfoData::data, fb(), PG_GETARG_UUID_P, PG_RETURN_BYTEA_P, pq_begintypsend(), pq_endtypsend(), pq_sendbytes(), and UUID_LEN.
Referenced by uuid_bytea().
Definition at line 543 of file uuid.c.
References fb().
Referenced by gen_random_uuid(), and generate_uuidv7().
| Datum uuid_skipsupport | ( | PG_FUNCTION_ARGS | ) |
Definition at line 505 of file uuid.c.
References SkipSupportData::decrement, fb(), SkipSupportData::high_elem, SkipSupportData::increment, SkipSupportData::low_elem, palloc(), PG_GETARG_POINTER, PG_RETURN_VOID, uuid_decrement(), uuid_increment(), UUID_LEN, and UUIDPGetDatum().
| Datum uuid_smaller | ( | PG_FUNCTION_ARGS | ) |
Definition at line 300 of file uuid.c.
References fb(), PG_GETARG_UUID_P, PG_RETURN_UUID_P, and uuid_internal_cmp().
| Datum uuid_sortsupport | ( | PG_FUNCTION_ARGS | ) |
Definition at line 312 of file uuid.c.
References SortSupportData::abbrev_abort, SortSupportData::abbrev_converter, SortSupportData::abbrev_full_comparator, SortSupportData::abbreviate, SortSupportData::comparator, fb(), initHyperLogLog(), MemoryContextSwitchTo(), palloc_object, PG_GETARG_POINTER, PG_RETURN_VOID, SortSupportData::ssup_cxt, ssup_datum_unsigned_cmp(), SortSupportData::ssup_extra, uuid_abbrev_abort(), uuid_abbrev_convert(), and uuid_fast_cmp().
| Datum uuidv7 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 690 of file uuid.c.
References fb(), generate_uuidv7(), get_real_time_ns_ascending(), NS_PER_MS, and PG_RETURN_UUID_P.
| Datum uuidv7_interval | ( | PG_FUNCTION_ARGS | ) |
Definition at line 702 of file uuid.c.
References DatumGetTimestampTz(), DirectFunctionCall2, ereport, errcode(), errdetail(), errmsg, ERROR, fb(), generate_uuidv7(), get_real_time_ns_ascending(), INTERVAL_NOT_FINITE, IntervalPGetDatum(), NS_PER_US, PG_GETARG_INTERVAL_P, PG_RETURN_UUID_P, PG_UNIX_EPOCH_OFFSET_US, timestamptz_pl_interval(), TimestampTzGetDatum(), US_PER_MS, and UUIDV7_MAX_TIMESTAMP.