Re: Analogue to SQL Server UniqueIdentifier?

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Dave Page <dpage(at)pgadmin(dot)org>
Cc: Bill Moran <wmoran(at)potentialtech(dot)com>, "jerry(dot)evans(at)chordia" <jerry(dot)evans(at)chordia(dot)co(dot)uk>, pgsql-general(at)postgresql(dot)org
Subject: Re: Analogue to SQL Server UniqueIdentifier?
Date: 2008-02-19 11:49:15
Message-ID: 20080219114915.GF3091@svr2.hagander.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Feb 18, 2008 at 05:01:22PM +0000, Dave Page wrote:
> On Feb 18, 2008 4:52 PM, Bill Moran <wmoran(at)potentialtech(dot)com> wrote:
> > In response to "jerry(dot)evans(at)chordia" <jerry(dot)evans(at)chordia(dot)co(dot)uk>:
> >
> >
> > > Hi
> > >
> > > My porting experiment has encountered the SQL Server UniqueIdentifier problem. I can see one or two suggestions about this have been made over the years but I'd like to try and stay close to the original. So:
> > >
> > > I'm wondering if I can use a combination of a domain 'hack' for syntatic compatibillity and an externally implemented function to handle generation.
> > >
> > > More specifically, given a table defined thus:
> > >
> > > CREATE TABLE jazz(
> > > UUID UniqueIdentifier DEFAULT newIdentifier(),
> > > rootname VARCHAR(255),
> > > data_source VARCHAR(1024),
> > > date_created DATETIME DEFAULT GETDATE())
> > >
> > > 1. Can I handle the UniqueIdentifier datatype via a domain that aliases UniqueIdentifier to char(X) (for example) ? This seems to work fine for the DATETIME datatype.
> > > 2. Implement newIdentifier() in some extension DLL that simply calls CoCreateGUID() ?
> > >
> > > or does uuid-ossp do this for me?
> >
> > I'm no expert on this topic, but since nobody else has responded ...
> >
> > I'm unsure why you would do anything other than install uuid-ossp.
> > Anything else is going to be a hack, and uuid-ossp was created specifically
> > to address this requirement.
>
> Lack of support for Windows, which it sounds like the OP might be running?

That's something that's been on my agenda for a while. There are certainly
UUID generation functions available on Windows - at least for some of the
cases supported by uuid-ossp. If I were to write the same functions for
that one, where would people prefer that to go - in the uuid-ossp module
even though that's actually not correct (since it wouldn't be using ossp)
or a separate module uuid-win32?

//Magnus

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ashish Karalkar 2008-02-19 11:57:28 shared buffer hash table corrupted
Previous Message Richard Huxton 2008-02-19 10:59:22 Re: out-of-line (TOAST) storage ineffective when loading from dump?