is it possible in PostgreSQL 8.4 to concat multiple integers (int4) values to a bytea value?
For example:
5::int4 || 1::int4
should result in a bytea value with (0x05 0x00 0x00 0x00 0x01 0x00 0x00 0x00), assuming a little endian machine.
Well, int4send will convert an int4 to a bytea, but I suspect from the name it will always use network ordering.
that is:
steve@steve@[local] =# select int4send(3);
int4send
------------
\x00000003
event on an amd64 machine.
*send() functions are (still) undocumented!An indirect conversion can be made with select byteain(bit_out(5::bit(32) || 1::bit(32))) or select int4send(5)||int4send(1) which results in 0000000000000000000000000000010100000000000000000000000000000001.
You could also use binary string functions to convert to your desired encoding. See Maarten Foqué's answer on the pgsql-general list for a solution to a similar problem. You should be able to simple concatenate the resulting bytea values from his function or a similar function (but mark it as stable instead of volatile).