libpq 7.4 and binary cursor
От | Stephane Raimbault |
---|---|
Тема | libpq 7.4 and binary cursor |
Дата | |
Msg-id | 1086877827.4646.22.camel@picasso.lan обсуждение исходный текст |
Ответы |
Re: libpq 7.4 and binary cursor
Re: libpq 7.4 and binary cursor |
Список | pgsql-interfaces |
Hi, It seems some changes occured in network protocol between 7.3 and 7.4. In my simple libray above libpq, I used this call to extract float8 with a binary cursor (on x86) : ----------------------------------------------- memcpy(&float8, PQgetvalue(pg_res, tup_num, field_num), PQfsize(pg_res, field_num)); ----------------------------------------------- Now with PostgreSQL 7.4, I replaced this memcpy by theses lines : ----------------------------------------------- union {double d; int64_t i64; } swap; uint32_t tab_uint32[2]; /* Read two uint32 */ memcpy(tab_uint32, PQgetvalue(pg_res, tup_num, field_num), 8); /* Swap MSB -> LSB */ tab_uint32[0] = ntohl(tab_uint32[0]); tab_uint32[1] = ntohl(tab_uint32[1]); /* Fusion */ swap.i64 = tab_uint32[0]; swap.i64 <<= 32; swap.i64 |= tab_uint32[1]; /* Cast */ return swap.d; ------------------------------------------------ Is it the right method to extract binary data ? Don't exist a easiest method ? Thank you. Stephane
В списке pgsql-interfaces по дате отправления: