X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 0D9559DC893 for ; Mon, 2 Jan 2006 10:53:16 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 22005-05 for ; Mon, 2 Jan 2006 10:53:17 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from fep01.ttnet.net.tr (mail.ttnet.net.tr [212.175.13.129]) by postgresql.org (Postfix) with ESMTP id B49689DC835 for ; Mon, 2 Jan 2006 10:52:45 -0400 (AST) Received: from (192.168.8.101) by AVGW-I-1.ttnet.net.tr via smtp id 108d_97c52b82_7b75_11da_9858_001422175f0e; Mon, 02 Jan 2006 11:53:19 +0200 Received: from alamut ([85.97.162.227]) by fep01.ttnet.net.tr with ESMTP id <20060102144859.QSFD1771.fep01.ttnet.net.tr@alamut>; Mon, 2 Jan 2006 16:48:59 +0200 Date: Mon, 2 Jan 2006 16:49:15 +0200 From: Volkan YAZICI To: "Mavinakuli, Prasanna (STSD)" Cc: pgsql-interfaces@postgresql.org Subject: Re: Convertion of date/time binary format to text format Message-ID: <20060102144915.GA589@alamut> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.1i X-NAI-Spam-Rules: 1 Rules triggered BAYES_00=-2.5 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=2.226 required=5 tests=[AWL=-0.573, DNS_FROM_RFC_ABUSE=0.479, DNS_FROM_RFC_POST=1.44, DNS_FROM_RFC_WHOIS=0.879, UNPARSEABLE_RELAY=0.001] X-Spam-Score: 2.226 X-Spam-Level: ** X-Archive-Number: 200601/1 X-Sequence-Number: 5917 On Jan 02 09:26, Mavinakuli, Prasanna (STSD) wrote: > Could u give me one more favour.. > That is can u please elobarate on bytea order conversion...? You can find lots of information about "byte order coersion" on the internet. I'd suggest reading these links: http://www.cs.umass.edu/~verts/cs32/endian.html http://www.netrino.com/Publications/Glossary/Endianness.html But for a "quick & dirty" answer: o. You don't have to make any byte order coersion on types smaller than 0xFF = 256 bytes - like char. o. You _should_ make byte order coersion on types bigger than 256 bytes - like int. From PostgreSQL documentation's libpq-example.html: char *iptr; int ival; iptr = PQgetvalue(res, i, i_fnum); /* * The binary representation of INT4 is in network byte order, * which we'd better coerce to the local byte order. */ ival = ntohl(*((uint32_t *) iptr)); Otherwise, you'll encounter different results in data transfers on different architectures with different endianness. Regards.