Re: Junk binary date?

Поиск
Список
Период
Сортировка
Искать
От
Michael Fuhr
Тема
Re: Junk binary date?
Дата
Msg-id
20060621051941.GA72186@winnie.fuhr.org
Ответ на
Junk binary date? (Kevin Jenkins)
Список
Дерево обсуждения
multiple statement 'instead of' rule "Merlin Moncure" <mmoncure@gmail.com>
Junk binary date? Kevin Jenkins <gameprogrammer@rakkar.org>
Re: Junk binary date? Michael Fuhr <mike@fuhr.org>
Re: multiple statement 'instead of' rule Tom Lane <tgl@sss.pgh.pa.us>
Re: multiple statement 'instead of' rule "Merlin Moncure" <mmoncure@gmail.com>
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
В списке pgsql-general по дате отправления
От: Kevin Jenkins
Дата:
Сообщение: Junk binary date?
От: Parang Saraf
Дата:
FAQ