From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | Kevin Jenkins <gameprogrammer(at)rakkar(dot)org> |
Cc: | PostgreSQL General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Junk binary date? |
Date: | 2006-06-21 05:19:41 |
Message-ID: | 20060621051941.GA72186@winnie.fuhr.org |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Tue, Jun 20, 2006 at 09:12:50PM -0700, Kevin Jenkins wrote:
> I call PQexecParams with the last parameter as 1 to return binary
> data. I then get this data with:
>
> fileLengthPtr = PQgetvalue(result, rowIndex, fileLengthColumnIndex);
> memcpy(&fileLength, fileLengthPtr, sizeof(fileLength));
>
> The value being returned is of type integer.
>
> It should have the value 7237 in binary.
> It actually has the value:
> fileLengthPtr[0] 0 char
> fileLengthPtr[1] 0 char
> fileLengthPtr[2] 28 '?' char
> fileLengthPtr[3] 69 'E' char
>
> Which is not 7237, it's:
> fileLength 1159462912 int
>
> Why?
7237 decimal = 1c45 hex
28 decimal = 1c hex
69 decimal = 45 hex
The data looks correct once you recognize that it's in network byte
order (big endian). You'll need to convert it to host byte order.
--
Michael Fuhr
From | Date | Subject | |
---|---|---|---|
Next Message | Parang Saraf | 2006-06-21 05:25:09 | problem enabling postgres in php |
Previous Message | Kevin Jenkins | 2006-06-21 04:12:50 | Junk binary date? |