Re: [Q] string to int hash function for small range

Поиск
Список
Период
Сортировка
От V S P
Тема Re: [Q] string to int hash function for small range
Дата
Msg-id 1236538244.10584.1304281453@webmail.messagingengine.com
обсуждение исходный текст
Ответ на Re: [Q] string to int hash function for small range  (Scott Marlowe <scott.marlowe@gmail.com>)
Список pgsql-general
Ok, thank you

using   \df *hash*  from psql prompt
I can see that is how I have to access this function

select pg_catalog.hashtext('myusername')

I will also play with other suggestions of get_byte
of the MD5 result casted to a string.

thanks again for all the replies,
Vlad





On Sat, 07 Mar 2009 21:17 -0700, "Scott Marlowe"
<scott.marlowe@gmail.com> wrote:
> On Sat, Mar 7, 2009 at 7:33 PM, V S P <toreason@fastmail.fm> wrote:
> > I would like to have a function
> > given a user id varchar(64) to get a hash number between 0 and 255.
> >
> > I first tried md5 but the number it returns is very big and cannot
> > be converted to an INT
> >
> > there is likely a way to simply add ascii values of the userId together
> > to get a small integer, but wanted to know if there are any other
> > 'built-in' ways
> >
> > this is to get the database id based on user id.
>
> In psql type this:
>
> \df *hash*
--
  V S P
  toreason@fastmail.fm

--
http://www.fastmail.fm - The professional email service


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

Предыдущее
От: Carl Sopchak
Дата:
Сообщение: Re: Newbie questions relating to transactions
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Newbie questions relating to transactions