#include "postgres.h"#include "fmgr.h"#include "utils/builtins.h"#include "utils/uuid.h"
Go to the source code of this file.
Functions | |
| Datum | uuid_nil (PG_FUNCTION_ARGS) |
| Datum | uuid_ns_dns (PG_FUNCTION_ARGS) |
| Datum | uuid_ns_url (PG_FUNCTION_ARGS) |
| Datum | uuid_ns_oid (PG_FUNCTION_ARGS) |
| Datum | uuid_ns_x500 (PG_FUNCTION_ARGS) |
| Datum | uuid_generate_v1 (PG_FUNCTION_ARGS) |
| Datum | uuid_generate_v1mc (PG_FUNCTION_ARGS) |
| Datum | uuid_generate_v3 (PG_FUNCTION_ARGS) |
| Datum | uuid_generate_v4 (PG_FUNCTION_ARGS) |
| Datum | uuid_generate_v5 (PG_FUNCTION_ARGS) |
| PG_FUNCTION_INFO_V1 (uuid_nil) | |
| PG_FUNCTION_INFO_V1 (uuid_ns_dns) | |
| PG_FUNCTION_INFO_V1 (uuid_ns_url) | |
| PG_FUNCTION_INFO_V1 (uuid_ns_oid) | |
| PG_FUNCTION_INFO_V1 (uuid_ns_x500) | |
| PG_FUNCTION_INFO_V1 (uuid_generate_v1) | |
| PG_FUNCTION_INFO_V1 (uuid_generate_v1mc) | |
| PG_FUNCTION_INFO_V1 (uuid_generate_v3) | |
| PG_FUNCTION_INFO_V1 (uuid_generate_v4) | |
| PG_FUNCTION_INFO_V1 (uuid_generate_v5) | |
| static void | pguuid_complain (uuid_rc_t rc) |
| static char * | uuid_to_string (const uuid_t *uuid) |
| static void | string_to_uuid (const char *str, uuid_t *uuid) |
| static Datum | special_uuid_value (const char *name) |
| static Datum | uuid_generate_internal (int mode, const uuid_t *ns, const char *name) |
| static Datum | uuid_generate_v35_internal (int mode, pg_uuid_t *ns, text *name) |
Variables | |
| PG_MODULE_MAGIC | |
| PG_FUNCTION_INFO_V1 | ( | uuid_nil | ) |
| PG_FUNCTION_INFO_V1 | ( | uuid_generate_v1 | ) |
| PG_FUNCTION_INFO_V1 | ( | uuid_generate_v1mc | ) |
| PG_FUNCTION_INFO_V1 | ( | uuid_generate_v3 | ) |
| PG_FUNCTION_INFO_V1 | ( | uuid_generate_v4 | ) |
| PG_FUNCTION_INFO_V1 | ( | uuid_generate_v5 | ) |
| PG_FUNCTION_INFO_V1 | ( | uuid_ns_dns | ) |
| PG_FUNCTION_INFO_V1 | ( | uuid_ns_url | ) |
| PG_FUNCTION_INFO_V1 | ( | uuid_ns_oid | ) |
| PG_FUNCTION_INFO_V1 | ( | uuid_ns_x500 | ) |
| static void pguuid_complain | ( | uuid_rc_t | rc | ) | [static] |
Definition at line 68 of file uuid-ossp.c.
References ereport, errcode(), errmsg(), ERROR, and NULL.
Referenced by special_uuid_value(), string_to_uuid(), uuid_generate_internal(), uuid_generate_v35_internal(), and uuid_to_string().
| static Datum special_uuid_value | ( | const char * | name | ) | [static] |
Definition at line 110 of file uuid-ossp.c.
References CStringGetDatum, DirectFunctionCall1, pguuid_complain(), uuid_in(), and uuid_to_string().
Referenced by uuid_nil(), uuid_ns_dns(), uuid_ns_oid(), uuid_ns_url(), and uuid_ns_x500().
{
uuid_t *uuid;
char *str;
uuid_rc_t rc;
rc = uuid_create(&uuid);
if (rc != UUID_RC_OK)
pguuid_complain(rc);
rc = uuid_load(uuid, name);
if (rc != UUID_RC_OK)
pguuid_complain(rc);
str = uuid_to_string(uuid);
rc = uuid_destroy(uuid);
if (rc != UUID_RC_OK)
pguuid_complain(rc);
return DirectFunctionCall1(uuid_in, CStringGetDatum(str));
}
| static void string_to_uuid | ( | const char * | str, | |
| uuid_t * | uuid | |||
| ) | [static] |
Definition at line 99 of file uuid-ossp.c.
References pguuid_complain().
Referenced by uuid_generate_v35_internal().
{
uuid_rc_t rc;
rc = uuid_import(uuid, UUID_FMT_STR, str, UUID_LEN_STR + 1);
if (rc != UUID_RC_OK)
pguuid_complain(rc);
}
| static Datum uuid_generate_internal | ( | int | mode, | |
| const uuid_t * | ns, | |||
| const char * | name | |||
| ) | [static] |
Definition at line 167 of file uuid-ossp.c.
References CStringGetDatum, DirectFunctionCall1, pguuid_complain(), uuid_in(), and uuid_to_string().
Referenced by uuid_generate_v1(), uuid_generate_v1mc(), uuid_generate_v35_internal(), and uuid_generate_v4().
{
uuid_t *uuid;
char *str;
uuid_rc_t rc;
rc = uuid_create(&uuid);
if (rc != UUID_RC_OK)
pguuid_complain(rc);
rc = uuid_make(uuid, mode, ns, name);
if (rc != UUID_RC_OK)
pguuid_complain(rc);
str = uuid_to_string(uuid);
rc = uuid_destroy(uuid);
if (rc != UUID_RC_OK)
pguuid_complain(rc);
return DirectFunctionCall1(uuid_in, CStringGetDatum(str));
}
| Datum uuid_generate_v1 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 189 of file uuid-ossp.c.
References NULL, and uuid_generate_internal().
{
return uuid_generate_internal(UUID_MAKE_V1, NULL, NULL);
}
| Datum uuid_generate_v1mc | ( | PG_FUNCTION_ARGS | ) |
Definition at line 196 of file uuid-ossp.c.
References NULL, and uuid_generate_internal().
{
return uuid_generate_internal(UUID_MAKE_V1 | UUID_MAKE_MC, NULL, NULL);
}
| Datum uuid_generate_v3 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 228 of file uuid-ossp.c.
References name, PG_GETARG_TEXT_P, PG_GETARG_UUID_P, and uuid_generate_v35_internal().
{
pg_uuid_t *ns = PG_GETARG_UUID_P(0);
text *name = PG_GETARG_TEXT_P(1);
return uuid_generate_v35_internal(UUID_MAKE_V3, ns, name);
}
Definition at line 203 of file uuid-ossp.c.
References DatumGetCString, DirectFunctionCall1, pguuid_complain(), string_to_uuid(), text_to_cstring(), uuid_generate_internal(), uuid_out(), and UUIDPGetDatum.
Referenced by uuid_generate_v3(), and uuid_generate_v5().
{
uuid_t *ns_uuid;
Datum result;
uuid_rc_t rc;
rc = uuid_create(&ns_uuid);
if (rc != UUID_RC_OK)
pguuid_complain(rc);
string_to_uuid(DatumGetCString(DirectFunctionCall1(uuid_out, UUIDPGetDatum(ns))),
ns_uuid);
result = uuid_generate_internal(mode,
ns_uuid,
text_to_cstring(name));
rc = uuid_destroy(ns_uuid);
if (rc != UUID_RC_OK)
pguuid_complain(rc);
return result;
}
| Datum uuid_generate_v4 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 238 of file uuid-ossp.c.
References NULL, and uuid_generate_internal().
{
return uuid_generate_internal(UUID_MAKE_V4, NULL, NULL);
}
| Datum uuid_generate_v5 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 245 of file uuid-ossp.c.
References name, PG_GETARG_TEXT_P, PG_GETARG_UUID_P, and uuid_generate_v35_internal().
{
pg_uuid_t *ns = PG_GETARG_UUID_P(0);
text *name = PG_GETARG_TEXT_P(1);
return uuid_generate_v35_internal(UUID_MAKE_V5, ns, name);
}
| Datum uuid_nil | ( | PG_FUNCTION_ARGS | ) |
Definition at line 132 of file uuid-ossp.c.
References special_uuid_value().
{
return special_uuid_value("nil");
}
| Datum uuid_ns_dns | ( | PG_FUNCTION_ARGS | ) |
Definition at line 139 of file uuid-ossp.c.
References special_uuid_value().
{
return special_uuid_value("ns:DNS");
}
| Datum uuid_ns_oid | ( | PG_FUNCTION_ARGS | ) |
Definition at line 153 of file uuid-ossp.c.
References special_uuid_value().
{
return special_uuid_value("ns:OID");
}
| Datum uuid_ns_url | ( | PG_FUNCTION_ARGS | ) |
Definition at line 146 of file uuid-ossp.c.
References special_uuid_value().
{
return special_uuid_value("ns:URL");
}
| Datum uuid_ns_x500 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 160 of file uuid-ossp.c.
References special_uuid_value().
{
return special_uuid_value("ns:X500");
}
| static char* uuid_to_string | ( | const uuid_t * | uuid | ) | [static] |
Definition at line 83 of file uuid-ossp.c.
References buf, palloc(), and pguuid_complain().
Referenced by special_uuid_value(), and uuid_generate_internal().
{
char *buf = palloc(UUID_LEN_STR + 1);
void *ptr = buf;
size_t len = UUID_LEN_STR + 1;
uuid_rc_t rc;
rc = uuid_export(uuid, UUID_FMT_STR, &ptr, &len);
if (rc != UUID_RC_OK)
pguuid_complain(rc);
return buf;
}
Definition at line 39 of file uuid-ossp.c.
1.7.1