Re: Opinion wanted on UUID/GUID datatype output formats.

From: "Dawid Kuroczko" <qnex42(at)gmail(dot)com>
To: "Gevik Babakhani" <pgdev(at)xs4all(dot)nl>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Opinion wanted on UUID/GUID datatype output formats.
Date: 2006-09-14 20:55:25
Message-ID: 758d5e7f0609141355oc43168bx912f7a74f77a498b@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 9/14/06, Gevik Babakhani <pgdev(at)xs4all(dot)nl> wrote:
> At this moment we (almost) have a uuid/guid datatype.
> As suggested in earlier discussion we provide a raw/plain output of the
> uuid type:
>
> devdb=# select * from tbluuid;
> pk |
> ----------------------------------+
> 6b13c5a1afb4dcf5ce8f8b4656b6c93c |
> 01e40a79b55b6e226bffb577e960453d |
> (2 rows)

Which is a Good Format.

> I was wondering if we want to have a formatting function to be able to
> provide other common formats of the uuid/guid?
>
> something like:
>
> select format_uuid(mypk,'format2') from tbluuid;
> and then get: 6b13c5a1-afb4-dcf5-ce8f-8b4656b6c93c

Ehm, I would strongly suggest rather something similar to to_char() family
of date-and-other-stuff formatting function, in the above example:

SELECT to_char(mypk,'NNNNNNNN-NNNN-NNNN-NNNN-NNNNNNNNNNNN') FROM tbluuid;
...or maybe some shorter syntax, like '8N-4N-4N-4N-12N').

This way it gains both flexibility (ANY format user wants is possible, say
using slashes as separator (great for hash-like filename generator) and
readability (no need to look for 'formatN' definition).

Regards,
Dawid

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Josh Berkus 2006-09-14 20:56:16 Re: New version of money type
Previous Message Bruce Momjian 2006-09-14 20:46:15 Re: Not-so-open items