Re: Add uuid_to_base32hex() and base32hex_to_uuid() built-in functions

From: Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: Aleksander Alekseev <aleksander(at)tigerdata(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
Subject: Re: Add uuid_to_base32hex() and base32hex_to_uuid() built-in functions
Date: 2026-03-19 14:36:04
Message-ID: 878qbn51kb.fsf@wibble.ilmari.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> writes:

> I've made some minor changes to both patches (e.g., rewording the
> documentation changes and commit messages etc), and attached the
> updated patches.
>
> I'm going to push these patches unless there is no further comment.

Just one minor nitpick on my patch, which is that it should use
palloc_object(), which I wasn't aware of when I wrote it originally.

> diff --git a/src/backend/utils/adt/bytea.c b/src/backend/utils/adt/bytea.c
> index fd7662d41ee..4dc83671aa5 100644
> --- a/src/backend/utils/adt/bytea.c
> +++ b/src/backend/utils/adt/bytea.c
[...]
> + if (len != UUID_LEN)
> + ereport(ERROR,
> + (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
> + errmsg("invalid input length for type %s", "uuid"),
> + errdetail("Expected %d bytes, got %d.", UUID_LEN, len)));
> +
> + uuid = (pg_uuid_t *) palloc(sizeof(pg_uuid_t));

this should be:

+ uuid = palloc_object(pg_uuid_t);

> + memcpy(uuid->data, VARDATA_ANY(v), UUID_LEN);
> + PG_RETURN_UUID_P(uuid);
> +}
> +

- ilmari

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Nathan Bossart 2026-03-19 14:47:26 Re: remove bits* types
Previous Message Heikki Linnakangas 2026-03-19 14:34:11 Re: Better shared data structure management and resizable shared data structures