database_doc: Postgresql data types

Next: Connection functions, Up: Postgresql [Index]

### 7.1 Representation in Octave of types specific to Postgresql

For the general types, defined by SQL and potentially available in each database implementation, see SQL data types.

The last column indicates whether the SQL type is automatically deduced by this packages functions from the representation of the data in Octave. If not, the correct SQL type must be specified by the user if the data is sent from Octave to the database.

Postgresql | Octave | auto
--- | --- | ---
oid | uint32 scalar | yes
text | string | yes
name | string of length < `NAMEDATALEN` (often 64) | no
money | int64 scalar, which is 100 times the currency value to enable storing the ’small currency’ (e.g. Cent) fraction in the last two digits | no
point | geometric point data for one point (see below) | yes
lseg | geometric point data for two points (see below) | yes
line (not yet implemented by postgresql-9.2.4) | as lseg | no
box | as lseg | no
circle | real vector (but the restrictions for type uint8 as in geometric element type apply, as explained below) with 3 elements, no. 1 and 2 centre coordinates, no. 3 radius | yes
polygon | geometric point data (see below) | no
path | structure with fields `closed` (boolean, is path closed?) and `path` (geometric point data, see below). | no
inet | uint8 array of 4 or 5 elements for IPv4 or uint16 array of 8 or 9 elements for IPv6. 5th or 9th element, respectively, contain number of set bits in network mask, the default (if there are only 4 or 8 elements, respectively) is all bits set. | no
cidr | as inet | no
macaddr | uint8 array of 6 elements | no
uuid | uint8 array of 16 elements | no
any enum type | string | no

The 8-byte-time value (see time types in SQL data types) can be an int64 scalar, representing microseconds, if the Postgresql server is configured for integer date/time, or a double scalar, representing seconds, if the server is configured for float date/time (deprecated). One can use pq_conninfo to query the respective server configuration.

Geometric point data: if converting from Octave data, any real array (but if of type uint8, the geometric type name must always be specified, for otherwise uint8 would be considered as bytea) with even number of elements. Two adjacent elements (adjacent if indexed with a single index) define a pair of 2D point coordinates. In converting from Postgresql data, dimensions of Octave geometric point data will be chosen to be (2, n_points) and elements will be of format double.

Next: Connection functions, Up: Postgresql [Index]