Skip site navigation (1) Skip section navigation (2)

patch: Allow the UUID type to accept non-standard formats

From: "Robert Haas" <robertmhaas(at)gmail(dot)com>
To: "Pg Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: patch: Allow the UUID type to accept non-standard formats
Date: 2008-10-10 03:09:42
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
The attached patch allows uuid_in() to parse a wider variety of
variant input formats for the UUID data type, per the TODO named in
the subject line.

Original discussion here:

The original discussion left unresolved the question of what variant
input formats to accept.  This patch takes the approach of allowing an
optional hyphen after each group of four hex digits.  This will allow
4x-4x-4x-4x-4x-4x-4x-4x (the format that originally prompted the
discussion) as well as things like the Coldfusion format:,

...and then there's this, which seems to be using 8x-8x-8x-8x:

While we could perhaps accept only those variant formats which we
specifically know someone to be using, it seems likely that people
will keep moving those pesky dashes around, and we'll likely end up
continuing to add more formats and arguing about which ones are widely
enough used to deserve being on the list.  So my vote is - as long as
they don't put a dash in the middle of a group of four (aka a byte),
just let it go.

Somewhat to my surprise, this implementation appears to be about 2-3%
slower than the one it replaces, as measured using a trivial test
harness.  I would have thought that eliminating a call to strlen() and
an extra copy of the data would have actually picked up some speed,
but it seems not.  Any thoughts on the reason?  In any case, I don't
believe there's any possible use case where a 2-3% slowdown in
uuid_to_string is actually perceptible to the user, since I had to
call it 100 million times in a tight loop to measure it.


Attachment: uuid.patch
Description: text/x-diff (4.2 KB)


pgsql-hackers by date

Next:From: Bramandia RamadhanaDate: 2008-10-10 03:27:11
Subject: Block nested loop join
Previous:From: Emmanuel CecchetDate: 2008-10-09 23:30:17
Subject: Re: Transactions and temp tables

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group