diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml index 37ec3cb4e5..44c60223ee 100644 --- a/doc/src/sgml/libpq.sgml +++ b/doc/src/sgml/libpq.sgml @@ -8874,6 +8874,109 @@ int PQisthreadsafe(); + + Binary Format + + Various libpq functions support sending or + receiving data in binary format. Data in binary format requires the + application to be handle any differences between the system and the network + byte order. + + + + demonstrates how to write a complete + program that uses libpq functions that request + data in binary foramt. This example shows how to handle only a few data + types. This section will detail the handling of as many of the data types + as possible. See for descriptions of each of the + built-in data types. + + + + <type>boolean</type> + + A boolean is transmitted as single byte that, when cast to + an int, will be 0 for + false and 1 for + true. + + + + + + + + <type>real</type> + + A real is composed of 4 bytes and needs to be handled + correctly for byte order. + + + + + + + + <type>timestamp without time zone</type> + + A timestamp without time zone is a 64-bit data type + representing the number of microseconds since January 1, 2000. It can be + converted into a broken-down time representation by converting the time + into seconds and saving the microseconds elsewhere. + + + Note that in C time is counted from January 1, 1970 so this discrepency + needs to be accounted for in addition to handling the network byte order. + + +tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, + tm->tm_min, tm->tm_sec, mantissa); +]]> + + + + Building <application>libpq</application> Programs