[HACKERS] convert int to bytea

2007-11-29 Thread ohp
Hi all, I'm trying to write a trigger that converts integer to bytea. My schema is like this: Create table xx ( id int, ... data bytea); the first 3 bytes of data are the binary representation of id (id is extracted from data by the application) I can occur that id change in that case

Re: [HACKERS] convert int to bytea

2007-11-29 Thread ohp
Hi Gregory On Thu, 29 Nov 2007, Gregory Stark wrote: Date: Thu, 29 Nov 2007 14:34:57 + From: Gregory Stark [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: pgsql-hackers list pgsql-hackers@postgresql.org Subject: Re: convert int to bytea [EMAIL PROTECTED] writes: select 124::bytea

Re: [HACKERS] convert int to bytea

2007-11-29 Thread Gregory Stark
[EMAIL PROTECTED] writes: select 124::bytea doesn't work Is there an other way? (preferabily simple :) This kind of question would be more appropriate on pgsql-general. What do you want the resulting bytea to look like? -- Gregory Stark EnterpriseDB http://www.enterprisedb.com

Re: [HACKERS] convert int to bytea

2007-11-29 Thread Douglas McNaught
On 11/29/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: On Thu, 29 Nov 2007, Gregory Stark wrote: What do you want the resulting bytea to look like? example : id = 9 , bytea = '\000\000\011' IIRC What do you expect to happen when server and client are differently-endian? -Doug

Re: [HACKERS] convert int to bytea

2007-11-29 Thread Usama Dar
Does it matter if you have written an explicit cast for int to bytea? On Nov 29, 2007 9:00 PM, Douglas McNaught [EMAIL PROTECTED] wrote: On 11/29/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: On Thu, 29 Nov 2007, Gregory Stark wrote: What do you want the resulting bytea to look like?

Re: [HACKERS] convert int to bytea

2007-11-29 Thread Zoltan Boszormenyi
Hi, please don't top post to someone who didn't used this convention in answering you. It's impolite. I edited the mail a bit to return sanity. On Nov 29, 2007 9:00 PM, Douglas McNaught [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: On 11/29/07, [EMAIL PROTECTED] mailto:[EMAIL

Re: [HACKERS] convert int to bytea

2007-11-29 Thread Usama Dar
On Nov 29, 2007 9:35 PM, Zoltan Boszormenyi [EMAIL PROTECTED] wrote: Hi, please don't top post to someone who didn't used this convention in answering you. It's impolite. I edited the mail a bit to return sanity. On Nov 29, 2007 9:00 PM, Douglas McNaught [EMAIL PROTECTED] mailto:[EMAIL

Re: [HACKERS] convert int to bytea

2007-11-29 Thread Andrew Dunstan
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