32 Commits

Author SHA1 Message Date
Olof Rensfelt
13d3acbcfa Fix bug with alter table add/drop column if exists
Previously, an ALTER TABLE ADD COLUMN IF NOT EXISTS on a hypertable
caused an error if the column already did exist. The reversed problem
with DROP COLUMN is also fixed. Resolves issue #42.
2017-05-15 21:21:33 +02:00
Robin Thomas
72f754a576 use PostgreSQL's own hash_any function as default partfunc;
remove all murmur3-related source code. Alter regression tests
to reflect new hash values for inputs, and a slightly different
set of input data to ensure that sufficient chunks and partitions
are tested. Some changes to .sh scripts in sql/setup that seem
to be used only to power the "unit tests", which I cannot
yet run successfully.
2017-04-29 18:31:44 -04:00
Olof Rensfelt
d070514f2a Fixed time chunk ranges.
To allow better caching and reduce the need for locking, chunks now
have fixed start and stop times set when the chunk is created.
2017-04-23 19:45:46 -04:00
Matvey Arye
a78f1570ba Remove dblink dependency.
The dblink extension is blacklisted by some cloud-hosting providers and
is an unnecessary dependency for single-node operation. Since we don't plan
to use dblink to implement clustering this PR removes the dependency.
2017-04-12 11:14:54 -04:00
Matvey Arye
f908671e04 Fix bug with simultaneous chunk creation.
Previously chunks could be simultaneously created for the same
partition_id and a start_time and end_time of both NULL. This
prevents such bugs bug adding additional unique constraints and
locking the partition for chunk creation (as originally intended).
2017-03-24 12:12:07 -04:00
Erik Nordström
c60b08e83a Fix DROP EXTENSION
DROP EXTENSION didn't properly reset caches and other saved state
causing various errors related to bad state when the extension was
dropped and/or recreated later.

This patch adds functionality to track the state of the extension and
also signals DROP EXTENSION to other backends that might be running,
allowing them to reset their internal extension state.
2017-03-22 19:43:40 +01:00
Matvey Arye
1f13354bf9 Make the planner use metadata cache
Previously, the planner used a direct query via the SPI interface to
retrieve metadata info needed for query planner functions like query
rewriting. This commit updates the planner to use our caching system.
This is a performance improvement for pretty much all operations,
both data modifications and queries.

For hypertables, this added a cache keyed by the main table OID and
added negative entries (because the planner often needs to know if a
table is /not/ a hypertable).
2017-03-13 14:18:33 -04:00
Matvey Arye
fbdcab186f Allow non-superusers to work with the db (but also mess up the catalog)
Previous to this commit non-superusers could not do anything inside
a database with the timescale extension loaded. Now, non-superuser
can create their own hypertables and work inside the db. There are
two big caveats:
      1) All users have read/write permissions to the timescaledb
      catalog.
      2) Permission changes applied to the main tables are not
      propagated to the associated tables.
2017-03-13 10:11:37 -04:00
Matvey Arye
00b69ac010 Change close-chunk logic to use a c-based fastpath
This change is a performance improvement. Previously each insert called
a plpgsql function to check if there is a need to close the chunk. This
patch implements a c-only fastpath for the case when the table size is
less than the configured chunk size.
2017-03-07 12:05:53 -05:00
Erik Nordström
11938ebb08 Default to asking for number of partitions when partitioning column set.
Since create_hypertable() allows you to optionally specify a
partitioning column, it makes sense to default to one partition when
no column is specified and asking for the number of partitions when a
column is specified and the number of partitions is not (instead of
defaulting to one).

This patch also changes the order and type of partitioning-related
input arguments to create_hypertable() so that the number of
partitions can easily be specified alongside the partitioning column
and without type casting.
2017-03-06 20:26:02 +01:00
Rob Kiefer
ee3ad4678d Rename iobeamdb to TimescaleDB 2017-03-06 11:06:49 -05:00
Matvey Arye
2404940315 getting rid of move_plan in cache. creating the plan caused a lock to be taken on the chunk table -- a lock which lead to a deadlock 2017-03-03 10:10:14 -05:00
Erik Nordström
eebd9bbbc1 Use native scan for chunks.
The chunk catalog table is now scanned with a native
scan rather than SPI call.

The scanner module is also updated with the option of
of taking locks on found tuples. In the case of chunk
scanning, chunks are typically returned with a share
lock on the tuple.
2017-03-02 12:25:00 +01:00
Erik Nordström
1daec06ce6 Use native scans for partition epochs and partitions.
This patch refactors the code to use native heap/index scans for
finding partition epochs and partitions. It also moves the
partitioning-related code and data structures to partitioning.{c,h}.
2017-03-02 12:25:00 +01:00
Matvey Arye
67ad21ee36 Cache hypertable metadata information for faster inserts.
Add caches for hypertable metadata to make it faster to map
INSERT rows to the chunk they should go into.
2017-03-02 12:24:53 +01:00
Erik Nordström
c09f6013fa Add number of partitions to partition_epoch table.
There are two reasons for adding the partition count to
the partition_epoch table:

* It makes the partition_epoch more self-describing as
  it makes it easy to see how many partitions are
  in the current epoch as well as past ones.
* It simplifies native code that can read the partition
  epoch, allocate memory for the right number of partitions,
  and finally scan the partition table filling in each entry.
2017-02-28 20:07:32 +01:00
Matvey Arye
f12a880d8d prepare hypertable_info plan 2017-02-07 17:09:08 -05:00
Erik Nordström
036c40886c Simplify cluster setup
Setting up single node is now:

```
CREATE EXTENSION IF NOT EXISTS iobeamdb CASCADE;
select setup_single_node();
```

To setup a cluster do (on meta node):
```
CREATE EXTENSION IF NOT EXISTS iobeamdb CASCADE;
select set_meta();
```

on data node:
```
CREATE EXTENSION IF NOT EXISTS iobeamdb CASCADE;
select join_cluster('metadb', 'metahost');
```

This assumes that the commands are issued by the same user on both the
meta node and the data node. Otherwise the data node also has to
specify the user name to use when connecting to the meta node.
2017-02-07 12:22:36 +01:00
Erik Nordström
7b94c573ba Refactor directory structure and tests
- Directory structure now matches common practices
- Regression tests now run with pg_regress via the PGXS infrastructure.
- Unit tests do not integrate well with pg_regress and have to be run
  separately.
- Docker functionality is separate from main Makefile. Run with
  `make -f docker.mk` to build and `make -f docker.mk run` to run
  the database in a container.
2017-01-31 20:14:19 +01:00
Olof Rensfelt
0f3aa8d557 * Add _meta schema to allow all code to be loaded on both meta and nodes.
* Split SQL into functions and setup.
* Remove hash-lib dependency.
* Makes code into Postgresql extension.
2016-12-20 16:10:59 +01:00
Matvey Arye
3c72689664 Finishing refactor TODOs & Formatting. Placement and cross-epoch queries. 2016-11-22 16:49:44 -05:00
Matvey Arye
939a4008ad Cleanup after refactor 2016-11-22 16:42:19 -05:00
Matvey Arye
bfcb25642e added meta table and communication from data nodes to meta 2016-11-22 16:41:27 -05:00
Matvey Arye
42ee7c8586 starting refactor of clustering and naming logic
This fix allows more flexible placement of tables on a node; better
and more flexible logic for remote placement of chunks on nodes.
2016-11-22 16:41:27 -05:00
Matvey Arye
e96509d4c0 fix error codes 2016-11-07 11:25:58 -05:00
Matvey Arye
e6e88ddb99 bug fixes 2016-11-01 22:05:01 -04:00
Matvey Arye
c3d55d339e queries now work with old consumer tests 2016-11-01 14:02:16 -04:00
Rob Kiefer
e3c1dc2ecc Create schema _sysinternal, put underscored funcs in it. 2016-10-28 17:56:46 -04:00
Matvey Arye
a075899beb test and bug fixes; getting rid of jinja2 2016-10-26 17:02:08 -04:00
Matvey Arye
d300471c86 move cluster fdw setup inside core 2016-10-26 14:43:04 -04:00
Matvey Arye
59cc706bda add logic for creating data tables and indexes 2016-10-22 22:04:09 -04:00
Matvey Arye
82a845cf40 checkpoint in redoing cluster managment logic 2016-10-20 14:19:58 -04:00