pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Volkan YAZICI <yazicivo@ttnet.net.tr>
To: Mavinakuli, Prasanna (STSD) <prasanna.b-m@hp.com>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: Convertion of date/time binary format to text format
Date: Mon, 2 Jan 2006 16:49:15 +0200
Message-ID: <20060102144915.GA589@alamut> (raw)
In-Reply-To: <E84C4F56CA80174D8834825116CF247F01C5AA08@bgeexc05.asiapacific.cpqcorp.net>
References: <E84C4F56CA80174D8834825116CF247F01C5AA08@bgeexc05.asiapacific.cpqcorp.net>

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.



view thread (3+ messages)

Message-ID: <20060102144915.GA589@alamut>
Permalink:  ../20060102144915.GA589@alamut/
Also on:    postgresql.org/message-id/20060102144915.GA589@alamut

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: yazicivo@ttnet.net.tr, prasanna.b-m@hp.com
  Subject: Re: Convertion of date/time binary format to text format
  In-Reply-To: <20060102144915.GA589@alamut>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox