ts-merge: Corrected data sanity check asserts

Previously, pointers to different heap blocks were compared.

Signed-off-by: Morten Hustveit <morten.hustveit@gmail.com>
Added ca_type_to_string()

This function converts a type enum to a C string.  It will be used to display
table declarations to useres.

Signed-off-by: Morten Hustveit <morten.hustveit@gmail.com>
type.c: Converted type names to upper-case

This is to look more like SQL.

Signed-off-by: Morten Hustveit <morten.hustveit@gmail.com>
data.c: Removed dead code

This code was disabled by "#if 0" and its functionality was replaced during the
move to the pluggable table backend architecture.

Signed-off-by: Morten Hustveit <morten.hustveit@gmail.com>
Added ca_data_parse_table_declaration()

This can be used to parse encoded table declarations into the
ca_table_declaration struct.

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

This will typically be used to create inverted file indexes.  The ordering of
integers is exploited for compression, and can be further exploited to
accelerate integer set union, intersect and difference operations.

Signed-off-by: Morten Hustveit <morten.hustveit@gmail.com>
select.c: Add some initial support for printing various data types

Previously, only CA_TIME_SERIES (aka. TIME_FLOAT4) could be printed.  This has
now been extended to include table declarations.

Signed-off-by: Morten Hustveit <morten.hustveit@gmail.com>
ts-merge: Added missing "else" to stat error test

Previously, the program would abort if the target file already existed.

Signed-off-by: Morten Hustveit <morten.hustveit@gmail.com>
ts-merge: Add support for merging sorted integer arrays

This will be used to build efficient inverted indexes from unorganized tables.

Signed-off-by: Morten Hustveit <morten.hustveit@gmail.com>
schema.c: Add the schema table itself to any newly created schema table

This is required by Codd's rule 4, and effectively allows inspecting the schema
from ca-shell.  An absolute path is required for schema creation, to increase
the probability of successful later access to the schema.

The continued use of a special TABLE_DECLARATION type is unfortunate, and
should be fixed when the data manipulation API becomes stronger.

Signed-off-by: Morten Hustveit <morten.hustveit@gmail.com>
query-lexer: Allow '.' in identifiers

For now, this is mostly useful for accessing the "ca_catalog.ca_tables" table.

Signed-off-by: Morten Hustveit <morten.hustveit@gmail.com>
Started on the ca_schema_query() function and related shell syntax

This will be a highly specialized function for performing set algebraic queries
on inverted file indexes, and returning file summaries.

The query syntax is for now:

  QUERY [query string] WITH (INDEX = [index table], SUMMARY = [summary table]);

The index table is required to be a TEXT -> SORTED_UINT mapping.  The integers
will be treated as offsets in the summary table.

The summary table is required to contain TEXT values in its second column.
Recall that the first columns is always the primary key with the current
architecture.

Signed-off-by: Morten Hustveit <morten.hustveit@gmail.com>
query-parser.y: Require all queries to be ; terminated

The old grammar was quite broken when it came to this, requiring it for SELECT
queries, but keeping it optional for everything else.

Signed-off-by: Morten Hustveit <morten.hustveit@gmail.com>
query-parser.y: Move to a more PostgreSQL-like syntax for CREATE TABLE

Use "WITH (PATH = 'path')" instead of "PATH 'path'" for designating the storage
path of a table.

Signed-off-by: Morten Hustveit <morten.hustveit@gmail.com>
query-parser: Mark PRIMARY KEY as NOT NULL, and record the type of columns

Previously, the type was discarded and ended up being stored as TEXT.

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