Re: converting from bytea to integers - Mailing list pgsql-general

From Daniel Verite
Subject Re: converting from bytea to integers
Date
Msg-id 22aeb499-b1bc-4ec9-9f3b-b9323ea27f92@mm
Whole thread Raw
In response to converting from bytea to integers  (John DeSoi <desoi@pgedit.com>)
Responses Re: converting from bytea to integers
List pgsql-general
    John DeSoi wrote:

> I'd like to convert some bytea data to an array of four byte integers

> (and vice versa). I'm probably missing something obvious, but I don't

> see an efficient way to generate a 4 byte integer from a bytea string

> (could be big endian or little endian).

get_byte()?

mailtest=> \set e '\'\12\15\107\20\'::bytea'

mailtest=> select
get_byte(:e,0),get_byte(:e,1),get_byte(:e,2),get_byte(:e,3);
 get_byte | get_byte | get_byte | get_byte
----------+----------+----------+----------
       10 |      13 |         71 |    16
(1 row)

Best regards,
--
 Daniel
 PostgreSQL-powered mail user agent and storage:
 http://www.manitou-mail.org

pgsql-general by date:

Previous
From: Mikko
Date:
Subject: trouble with to_char('L')
Next
From: Robert Morton
Date:
Subject: round behavior differs between 8.1.5 and 8.3.7