Re: Storing a file hash as primary key

Поиск
Список
Период
Сортировка
От Greg Stark
Тема Re: Storing a file hash as primary key
Дата
Msg-id 87isf8rr12.fsf@stark.xeocode.com
обсуждение исходный текст
Ответ на Storing a file hash as primary key  (Eduardo Pérez Ureta <eperez@it.uc3m.es>)
Ответы Re: Storing a file hash as primary key  (Joe Conway <mail@joeconway.com>)
Список pgsql-general
Eduardo Pérez Ureta <eperez@it.uc3m.es> writes:

> I was wondering what the best way is to store a file hash (MD5 or SHA1)
> and make it primary key indexed.
> I have seen some people storing the hexadecimal encoded MD5 in a
> CHAR(32) but it may be a better idea to use a CHAR(16) without encoding
> the string, but that may cause some problems.

I would say either char(32) or bytea(16). Not char(16) since you don't want to
treat the raw binary data using any specific character encoding or sort it
according to any locale specific rules etc.

Personally I would have preferred bytea(16) but for some reason the php
drivers seem to jut drop NULL there when I try to store raw binary md5 hashes.
So for now I just declared it bytea with no length specification and store the
hex encoded hash.

If anyone knows how to get Pear::DB to store binary data in a bytea column, by
all means.

--
greg

В списке pgsql-general по дате отправления:

Предыдущее
От: Rick Gigger
Дата:
Сообщение: Re: pgFoundry Open For Business
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Interpreting vacuum verbosity