Re: UUID data format 4x-4x-4x-4x-4x-4x-4x-4x

From: "Tom Dunstan" <pgsql(at)tomd(dot)cc>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Andrew Sullivan" <ajs(at)crankycanuck(dot)ca>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: UUID data format 4x-4x-4x-4x-4x-4x-4x-4x
Date: 2008-02-29 05:40:39
Message-ID: ca33c0a30802282140h4102658bi5202f28a6b79d812@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Feb 29, 2008 at 9:26 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Andrew Sullivan <ajs(at)crankycanuck(dot)ca> writes:
> > "Be conservative in what you send, and liberal in what you accept."
>
> Yeah, I was about to quote that same maxim myself. I don't have a big
> problem with allowing uuid_in to accept known format variants. (I'm
> not sure about allowing a hyphen *anywhere*, because that could lead to
> accepting things that weren't meant to be a UUID at all, but this HP
> format seems regular enough that that's not a serious objection to it.)

This seems like a good enough opportunity to mention an idea that I
had while/after doing the enum patch. The patch was fairly intrusive
for something that was just adding a type because postgresql isn't
really set up for parameterized types other than core types. The idea
would be to extend the enum mechanism to allow UDTs etc to be
parameterized, and enums would just become one use of the mechanism.
Other obvious examples that I had in mind were allowing variable
lengths for that binary data type with hex IO for e.g. differently
sized checksums that people want, and allowing different formats for
uuids.

So the idea as applied to this case would be to do the enum-style
typesafe thing, ie:

create type coldfusion_uuid as generic_uuid('xxxx-xxxx-xxxx-xxxx');

...then just use that. I had some thoughts about whether it would be
worth allowing inline declarations of such types inside table creation
statements as well, and there are various related issues and thoughts
on implementation which I won't go into in this email. Do people think
the idea has legs, though?

> What I was really complaining about was Josh's suggestion that we invent
> a function to let users *output* UUIDs in random-format-of-the-week.
> I can't imagine much good coming of that. I think we should keep
> uuid_out emitting only the RFC-standardized format.

Well, if the application is handing them to us in that format, it
might be a bit surprised if it gets back a "fixed" one. The custom
type approach wouldn't have that side effect.

Cheers

Tom

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2008-02-29 06:09:26 Re: UUID data format 4x-4x-4x-4x-4x-4x-4x-4x
Previous Message Mark Mielke 2008-02-29 05:24:59 Re: UUID data format 4x-4x-4x-4x-4x-4x-4x-4x