lockd: exit when last client disconnects

This prevents leaving dangling daemons after running unit tests.

Signed-off-by: Morten Hustveit <morten.hustveit@gmail.com>
lockd: chdir to schema directory before operating

This solves several problems:

 * There's less of a risk of running out of memory while building path name
   buffers.

 * We don't run the risk of the path name being too long to fit in the socket
   address structure's path variable.

 * If the schema directory is moved or removed, we don't end up calling unlink
   on the wrong path at exit.

Signed-off-by: Morten Hustveit <morten.hustveit@gmail.com>
Added support for type casts

One use for this is to cast integer constants to TIMESTAMPTZ.  The code should
probably be expanded later to support implicit casts, to make function calls
easier.

Signed-off-by: Morten Hustveit <morten.hustveit@gmail.com>
Added support for function calls in SQL queries

We use an std::map to map function signatures to return types and LLVM function
handles.  The function signature consists of the function's name and its
parameter types.  Hence, like C++, we do not support overloading a function by
changing only its return type.

Signed-off-by: Morten Hustveit <morten.hustveit@gmail.com>
Added the TS_SAMPLE function

This functions returns a value from a TIME_FLOAT4 for a given timestamp, or NaN
if no value was found.

Signed-off-by: Morten Hustveit <morten.hustveit@gmail.com>
ts-merge.c: Removed old debug output code

Signed-off-by: Morten Hustveit <morten.hustveit@gmail.com>
Switch to %.9g for float formatting to prevent loss of precision

%.9g is guaranteed to keep all the information of a 32 bit IEEE 754 floating
point value.  %.8g is not.

Signed-off-by: Morten Hustveit <morten.hustveit@gmail.com>