Re: Receiving data in binary format how is it encoded?

Поиск
Список
Период
Сортировка
От Carlos Guzman Alvarez
Тема Re: Receiving data in binary format how is it encoded?
Дата
Msg-id 3F083C10.2060702@telefonica.net
обсуждение исходный текст
Ответ на Receiving data in binary format how is it encoded?  ("Francisco Figueiredo Jr." <fxjrlists@yahoo.com.br>)
Ответы Re: Receiving data in binary format how is it encoded?  ("Francisco Figueiredo Jr." <fxjrlists@yahoo.com.br>)
Список pgsql-hackers
Hello:

> while implementing the protocol 3.0 I could get the data in text mode 
> setting the format to 0. (Thanks all for helping me out with flush message)
> 
> 
> Now, I want to test the binary format. While some primitive types are 
> easy to realize, for example a int4 field will be encoded in 4 bytes,
> I don't know how other types, like date, time, timestamp, text will be 
> encoded in binary format.

Huummmmm i'm going to comment how i make in my C# implementation (stream 
is a binary reader ) for example for int4, date and time.

For int4:

int val = stream.ReadInt32();
int int4Value = IPAddress.HostToNetworkOrder(val);


For date ( not sure if i'm making this correct way but values seems to 
be correct :) )

DateTime base = new DateTime(2000, 1, 1)
int val = stream.ReadInt32();
int days = IPAddress.HostToNetworkOrder(val);

DateTime date = base.AddDays(days);


For Time:

The same as for date but reading a double and adding it to base as 
seconds instead of days.



The only basic data type i'm not handling now is numeric that seems to 
be encoded in 10 bytes but i have no seen the postgre source code yet.







-- 
Best regards

Carlos Guzmán Álvarez
Vigo-Spain


P.S.: Has you receive an email i sent to you abot little things i see on 
npgsql ?? :)



В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Francisco Figueiredo Jr."
Дата:
Сообщение: Receiving data in binary format how is it encoded?
Следующее
От: qhwt@myrealbox.com
Дата:
Сообщение: Re: PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed: Invalid argument