Re: convert int to bytea

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Usama Dar <munir(dot)usama(at)gmail(dot)com>
Cc: Zoltan Boszormenyi <zb(at)cybertec(dot)at>, Douglas McNaught <doug(at)mcnaught(dot)org>, ohp(at)pyrenet(dot)fr, Gregory Stark <stark(at)enterprisedb(dot)com>, pgsql-hackers list <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: convert int to bytea
Date: 2007-11-29 16:55:50
Message-ID: 474EEF16.5000705@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Usama Dar wrote:
>
>
>
> 2) i know what a byte order is , i just thought your interface i.e.
> libpq would convert it to the local byte order.
>

You haven't thought this through. Data traveling over libpq is still
text, not binary, in most cases, so byte order is irrelevant at that
time. The translation to a bytea (if possible) would be done after the
data was already on the server and the int was in its native,
architecture dependent form.

The short answer is thus still that there is no sane consistent cast
from int to bytea.

If you want a bytea then it's really up to you to contruct the byte array.

cheers

andrew

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2007-11-29 17:18:20 Re: pgwin32_open returning EINVAL
Previous Message Bruce Momjian 2007-11-29 16:53:10 Re: Time to update list of contributors