converting from bigint to bit to use bitwise operators

Поиск
Список
Период
Сортировка
От Aditya
Тема converting from bigint to bit to use bitwise operators
Дата
Msg-id 20030418191123.GA44801@mighty.grot.org
обсуждение исходный текст
Список pgsql-sql
For historical reasons, I have IPv4 addresses stored as bigint and I would
like to convert them to dot-quad (ie. A.B.C.D) in a select. This is how I
would normally do it:

- remotehost is the IP address as a bigint

select ((remotehost::bit varying(32) >> 24) & 11111111) || '.' || ((remotehost::bit varying(32) & 11111100) >> 16) ||
'.'|| ((remotehost::bit varying(32) & 11110000) >>  8) || '.' || ((remotehost::bit varying(32) & 11000000)) as ip,
httpquery
fromweblogs
;

however this complains:
 ERROR:  Cannot cast type 'bigint' to 'bit varying'

hints?

Thanks,
Adi



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

Предыдущее
От: Bharath Seshadri
Дата:
Сообщение: RelationForgetRelation error in postgres 7.2.2
Следующее
От: foo2@on-spammers2.com
Дата:
Сообщение: Ok,, what about cache for SEQUENCE - where? how?