From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Philip Warner <pjw(at)rhyme(dot)com(dot)au> |
Cc: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Giles Lean <giles(at)nemeton(dot)com(dot)au>, PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: pg_dump and large files - is this a problem? |
Date: | 2002-10-21 13:47:10 |
Message-ID: | 16708.1035208030@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Philip Warner <pjw(at)rhyme(dot)com(dot)au> writes:
> It might be good if someone who knows a little more than me about
> endianness etc has a look at the patch - specifically this bit of code:
> #if __BYTE_ORDER == __LITTLE_ENDIAN
Well, the main problem with that is there's no such symbol as
__BYTE_ORDER ...
I'd prefer not to introduce one, either, if we can possibly avoid it.
I know that we have BYTE_ORDER defined in the port header files, but
I think it's quite untrustworthy, since there is no other place in the
main distribution that uses it anymore (AFAICS only contrib/pgcrypto
uses it at all).
The easiest way to write and reassemble an arithmetic value in a
platform-independent order is via shifting. For instance,
// write, LSB first
for (i = 0; i < sizeof(off_t); i++)
{
writebyte(val & 0xFF);
val >>= 8;
}
// read, LSB first
val = 0;
shift = 0;
for (i = 0; i < sizeof(off_t); i++)
{
val |= (readbyte() << shift);
shift += 8;
}
(This assumes readbyte delivers an unsigned byte, else you might need to
mask it with 0xFF before shifting.)
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Meskes | 2002-10-21 13:59:12 | ECPG |
Previous Message | Olivier PRENANT | 2002-10-21 13:42:39 | Please help |