postgresql plugin: Added generic support for writing values to a database.

This has been implemented by requiring the user to specify an SQL statement to
be used for storing a value-list in PostgreSQL. Usually, this should be done
by creating custom functions to take care of that.

The user specified statement will then be called by collectd with eight
arguments: time, host, plugin, plugin instance (or NULL), type, type instance
(or NULL), array of value names (data source names) and an array of the
values.

Two elements have been added to the config parser: A <Writer> block may be
used to name an SQL statement (specified using the 'Statement' option) to be
used for writing data. In a <Database> block, the new option 'Writer' may be
used to apply a writer to a database connection.

The current approach has two benefits: for one, a user may chose whatever
database layout best suits her needs. Also, it is very easy to experiment with
different approaches on how to structure the data in a database without the
need to modify the plugin. This can be done in SQL, which (hopefully) is the
language that people working with PostgreSQL databases like most ;-)
If it happens to turn out that some approach is rather superior, it may still
be re-implemented in a specific plugin in later versions.
utils_time: Added cdtime_to_iso8601() function.

This function formats a cdtime_t value in ISO 8601 format (and ensures that
the string is null terminated).
postgresql plugin: Format time in ISO 8601 format when writing data.

This way, the value may directly be used as a timestamp value in PostgreSQL.
postgresql plugin: Added 'StoreRates' feature to writers.

Similar to other write plugins, this option causes counter values to be
converted to rates before submitting them to the database. The option defaults
to true.
postgresql plugin: Pass an array of data-source types to writers.

The array includes the stringified version of the data-source type, i.e.,
'gauge', 'counter', etc. This will enable the writer to treat different types
differently. However, when having 'StoreRates' enabled (the default) all types
will be 'gauge'. So, in most cases, this won't be used but it has been added
for completeness and to be safe for the future.
contrib/postgresql/collectd_insert.sql: Added sample writer setup.
postgresql plugin: Fixed a possibly uninitialized variable warning.

This was identified by 'gcc -O2'.
contrib/postgresql/collectd_insert.sql: Added values_update_childs().

This function may be used to create the child tables (for the "values" table)
for the next couple of days (if they don't exist already).
postgresql plugin: Updated copyright information.
postgresql plugin: Fixed config key check for <Writer> block.

A missing "else" caused incorrect “Ignoring unknown config key "Statement"”
warning messages.
postgresql plugin: Added 'CommitInterval' config option.

If specified, this option causes a writer to put several updates into a single
transaction. This transaction will last for the specified amount of time (in
seconds). By default, each update would be executed in a separate transaction
causing quite some overhead.
collectd_insert.sql: Added view 'collectd'.

This view provides a join of the 'identifiers' and 'values' tables plus an
additional column with the serialized collectd identifier.
collectd_insert.sql: Let values_update_childs() return table names.

The function will now return a set of the names of child tables that have been
created.
collectd.conf(5): Documented the "CommitInterval" option of 'postgresql'.
collectd.conf(5): Documented the postgresql <Database> 'Writer' option.
postgresql plugin: Restart a writer transaction if the writer's query failed.

The failed query inside the transaction causes the transaction to be aborted
and all subsequent queries to fail as well.
postgresql plugin: Don't try to restart a failed transaction when there's none.
postgresql plugin: Commit a transaction before shutting down a connection.

Also, make sure to acquire the database lock before that in order to wait for,
for example, outstanding writers.
postgresql plugin: Unregister all writers on shutdown.

This will make sure that all pending transactions will be committed. Else, the
open transactions would be rolled back by the PostgreSQL backend when closing
the connection.

In order to do so, all database connections are now stored in a plugin-global
array (this will also make further changes possible). Also, a ref-count has
been added to the database object in order to support "deleting" an object
twice when having it in use by a connection doing queries and writes.
postgresql plugin: Fixed unregistering of write callbacks.

Rather than unregistering some callback for each writer for each database,
unregister the single callback for each database only.