Re: Constraint: string length must be 32 chars - Mailing list pgsql-general

From Alexander Farber
Subject Re: Constraint: string length must be 32 chars
Date
Msg-id AANLkTin6tUEt8vKizatCZGeTKMir_q3vCxSyGR_M=PSk@mail.gmail.com
Whole thread Raw
In response to Re: Constraint: string length must be 32 chars  (Rob Sargent <robjsargent@gmail.com>)
Responses Re: Constraint: string length must be 32 chars  (Rob Sargent <robjsargent@gmail.com>)
List pgsql-general
Thank you for your advices.

I actually would like to store GPS coordinates, but anonymously,
so I was going to save md5(my_secret+IMEI) coming from a mobile...

I have to lookup if uuid is supported there

Regards
Alex

On Sat, Oct 16, 2010 at 11:08 PM, Rob Sargent <robjsargent@gmail.com> wrote:
> Merlin Moncure wrote:
>> why don't you use the bytea type, and cut the key size down 50%?  You
>> can always format it going out the door if you want it displayed hex.
>> Besides being faster, you get to skip the 'is hex' regex.
>>
>> create table foo(id bytea check(length(id) = 16));
>> insert into foo values (decode(md5('a'), 'hex')); -- if not using pgcrypto
>> insert into foo values (digest('b', 'md5')); -- if using pgcrypto
>> (preferred)
>>
>> select encode(id, 'hex') from foo;
>
> Why not the support uuid type instead.  Aren't md5s only as unique as the
> source?  i.e. The same value hashed results in the same md5, no?

pgsql-general by date:

Previous
From: Rob Sargent
Date:
Subject: Re: Constraint: string length must be 32 chars
Next
From: Darren Duncan
Date:
Subject: Re: Constraint: string length must be 32 chars