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