55 Commits

Author SHA1 Message Date
Amy Tai
472bf6a298 Add runtime error for pgindent if objdump is not installed 2018-07-11 12:17:46 -04:00
Matvey Arye
38f8e0c9d0 Add ABI compatibility tests
Test the ABI compatibility of postgres across minor version updates
wrt timescale. Namely, compile the extension on an early minor version
of postgres and test it on the latest snapshot of the major branch.
2018-03-21 10:02:08 -04:00
Erik Nordström
ddd61bc86d Fix update to 0.9.0
This fixes a bug in the upgrade script to 0.9.0 that was caused by a
bad query to delete orphaned dimension slices.
2018-02-28 10:55:43 -05:00
Rob Kiefer
905e1c58e2 Update test suite to check upgradability for all versions
Previously we just checked that we could upgrade from 0.1.0 until
latest but this missed some issues upgrading from intermediate
versions to latest. Now we check that all released versions can
successfully update.
2018-02-26 11:02:56 -05:00
Matvey Arye
a9e18ae4f8 fix docker-run-tests 2018-01-05 12:15:54 -05:00
Matvey Arye
9c7191e898 Change TIMESTAMP partitioning to be completely tz-independent
Previously, for timezones w/o tz. The range_end and range_start were
defined as UTC, but the constraints on the table were written as as
the local time at the time of chunk creation. This does not work well
if timezones change over the life of the hypertable.

This change removes the dependency on local time for all timestamp
partitioning. Namely, the range_start and range_end remain as UTC
but the constraints are now always written in UTC too. Since old
constraints correctly describe the data currently in the chunks, the
update script to handle this change changes range_start and range_end
instead of the constraints.

Fixes #300.
2017-11-20 09:27:30 -05:00
Erik Nordström
69d7d5800c Add pgindent target to format C source
The C source files can now be formatted with pgindent using
a new CMake build target.

The location of pgindent and dependencies are auto-discovered
by CMake or can be overridden on the command line.
2017-11-17 09:43:04 +01:00
Erik Nordström
500563ffe5 Add support for PostgreSQL 10
The extension now works with PostgreSQL 10, while
retaining compatibility with version 9.6.

PostgreSQL 10 has numerous internal changes to functions and
APIs, which necessitates various glue code and compatibility
wrappers to seamlessly retain backwards compatiblity with older
versions.

Test output might also differ between versions. In particular,
the psql client generates version-specific output with `\d` and
EXPLAINs might differ due to new query optimizations. The test
suite has been modified as follows to handle these issues. First,
tests now use version-independent functions to query system
catalogs instead of using `\d`. Second, changes have been made to
the test suite to be able to verify some test outputs against
version-dependent reference files.
2017-11-10 09:44:20 +01:00
Matvey Arye
81510987d0 Improve update testing by adding a rerun test
The rerun test recreates the hypertable in the newest version
of the extension. This allows us to test correctness of the data
in the catalog.
2017-10-24 11:26:04 -04:00
Erik Nordström
b1ec4fa179 Refactor build system to use CMake
Moving the build system to CMake allows easy cross-platform
compiles, dependency checks, and more. In particular, CMake
allows us to easily build on Windows, and Visual Studio now
has native CMake support.
2017-10-16 20:50:16 +02:00
Rob Kiefer
aceb2e9835 Prepare the repo for next development cycle 2017-10-13 11:49:42 -04:00
Olof Rensfelt
f39d42b182 Add pg version to dump_meta_data script. 2017-10-12 17:16:57 +02:00
Matvey Arye
c3ebc676e3 Fix permission problems with dropping hypertables and chunks
This change fixes permissions with dropping hypertables and chunks.
Fixes #226.
2017-10-05 12:06:09 -04:00
Erik Nordström
040e815dba Remove truncate and hypertable metadata triggers
This is part of the ongoing effort to simplify the metadata tables and
removing any triggers on them that cause side effects.

This change includes the following:

- Remove the on_change_hypertable() trigger on the hypertable catalog
  table.
- Remove the TRUNCATE blocking triggers on all metadata tables. If
  we think such blocking is important, we should do this in an
  event trigger or the processUtility hook.
- Put all SQL files in a single load_order.txt instead of splitting
  across three distinct files. Now all SQL files are included in
  update scripts as well for simplicity and consistency.
- As a result of removing triggers and related functions, the
  setup_main() and restore_timescaledb() functions are no longer
  needed. This also further simplifies the database restore process
  as calling restore_timescaledb() is no longer needed (or possible).
- Refactor create_hypertable_row() to do more validation before
  allocating a new hypertable ID. This avoids incrementing the serial
  ID unnecessarily in case some validations fail.
2017-10-05 09:56:32 +02:00
Erik Nordström
097db3d589 Refactor chunk index handling
This change refactors the chunk index handling to make better use
of standard PostgreSQL catalog information, while removing the
hypertable_index metadata table and associated triggers, including
those on the chunk_index table. The chunk_index table itself is
also simplified.

A benefit of this refactoring is that indexes are no longer
created using string mangling to construct the CREATE INDEX command
for a chunk, based on the string definition of the hypertable
index. Instead, indexes are created in C using proper index-related
internal data structures.

Chunk indexes can now also be renamed and are added in the parent
index tablespace. Changing tablespace on a hypertable index also
recurses to chunks, as expected. Default indexes that are added when
creating a hypertable use the hypertable's tablespace.

Creating Hypertable indexes with the CONCURRENTLY modifier is
currently blocked, due to unclear semantics regarding concurrent
creation over many tables, including how to deal with snapshots.
2017-10-03 10:51:32 +02:00
Erik Nordström
bf6fd3158f Tweak the docker image build script
- Save an intermediate build image to avoid having to download APK
  packages for every build
- Add debug symbols and assertions to extension build
- Install git and gdb by default for easier debugging
2017-10-02 11:01:31 +02:00
Erik Nordström
48fbfaf99a Make update test script restore database instead of reinserting data
The update test script compares a TimescaleDB instance, which is
updated to the latest version from an older version, to a cleanly
installed one at the latest version. It does this by inserting the
same data on both and comparing the data and metadata tables. This
comparison breaks if the new version has changed some behavior (e.g.,
chunk indexes might use a different naming scheme), because the
updated version will retain the metadata related to the old behavior
while the latest version will create metadata according to the new
behavior.

To fix this issue, the update script now performs a database backup on
the old version and restores it on the cleanly installed version of
TimescaleDB. This retains the metadata in accordance with the old
behavior, although the new version will create new metadata according
to the new behavior. This has the further benefit of testing the
restore process during upgrades, which is probably the way people will
move to a new version of TimescaleDB if they do not update the
extension with the data in place.

The capture errors related to broken update scripts, the update test
now includes an integrity test for some metadata tables.
2017-09-22 08:58:02 +02:00
Olof Rensfelt
d53c705796 Add script to dump meta data that can be useful for debugging.
This also adds support for a <exclude_from_test> tag that is used
to allow changing outputs for parts of a test without causing an
error.
2017-09-19 17:29:27 +02:00
Matvey Arye
4dcbe6114d Add support for hypertable constraints
This PR add support for primary-key, foreign-key, unique, and exclusion constraints.
Previously supported are CHECK and NOT NULL constraints. Now, foreign key
constraints where a hypertable references a plain table is support
(while vice versa, with a plain table references a hypertable, is still not).
2017-09-07 11:31:48 -04:00
Rob Kiefer
997556af40 Add backup/restore scripts for single hypertables
Using pg_dump/pg_restore for a database with hypertables will back
up all internal tables too, which is sometimes not desired. These
scripts allow one to backup regular PostgreSQL tables separately
and then pick and choose which hypertables to backup and restore.
This also provides a forward-compatible way of backing up and
restoring hypertables, since data is dumped to CSV and restored
by re-creating and re-inserting the data.
2017-09-06 11:24:45 -04:00
Rob Kiefer
bb8ea37965 Remove out-dated migrate_data.sh script
This script no longer is needed since chunks close appropriately
even when the insert spans multiple chunks.
2017-09-05 13:51:52 -04:00
Erik Nordström
f103fc7de3 Make generate-typedefs.sh work on Linux 2017-08-11 11:37:56 +02:00
Matvey Arye
486da7fd5f Reduce local non-docker dependencies for update tests
Get rid of dependencies on a local psql and stop mounting data volumes.
2017-07-27 12:26:39 -04:00
Olof Rensfelt
6cc5aa19bb Add update scripts from earlier versions to the extension.
To allow upgrading versions older than the most recent one,
update scripts from older versions need to be added to the
extension. This is now done by including all files in the
file extra_extension_files.txt to the extension. Currently
that file needs to be manually updated when a new release
is built.
2017-07-18 10:27:36 +02:00
Matvey Arye
3c1f7522bb Make travis run update tests 2017-07-13 08:33:08 -04:00
Matvey Arye
a0db5004f4 Add update script for PR #121
Also includes some update infrastructure changes. Main difference
is that sql/updates/ scripts are now split into pre- and post- files.
This is needed because table updates need to happen before reloading
functions (some functions checked for accessing right schema at
definition time). Meanwhile trigger updates need to happen after
since triggers must refer to valid functions at definition time.
2017-07-13 08:33:08 -04:00
Olof Rensfelt
4d2a65daa6 Add infrastructure to build update script files.
SQL code is now split into setup, functions, and init files to
allow a subset to be run when the extension is updated. During
build, an update script is now also generated.
2017-07-12 13:00:29 -04:00
Erik Nordström
3192c8a6bf Remove Dockerfile and docker.mk
Release Docker builds are now provided in a separate repository,
https://github.com/timescale/timescaledb-docker.

Tests and development builds for Docker are now provided
by two new scripts in the scripts directory:

- `docker-build.sh` to build a development image from current sources.
- `docker-run-tests.sh` to run tests for current sources through a Docker container.
2017-06-19 22:30:46 +02:00
Matvey Arye
bfe58b61f7 Refactor towards supporting version upgrades
Clean up the table schema to get rid of legacy tables and functionality
that makes it more difficult to provide an upgrade path.

Notable changes:
* Get rid of legacy tables and code
* Simplify directory structure for SQL code
* Simplify table hierarchy: remove root table and make chunk tables
* inherit directly from main table
* Change chunk table suffix from _data to _chunk
* Simplify schema usage: _timescaledb_internal for internal functions.
* _timescaledb_catalog for metadata tables.
* Remove postgres_fdw dependency
* Improve code comments in sql code
2017-06-08 13:55:05 -04:00
Matvey Arye
cedcafc959 Remove setup_timescaledb() and fix pg_dump/pg_restore.
This PR removes the need to run setup_timescaledb. It also fixes
pg_dump and pg_restore. Previously, the database would restore in
a broken state because trigger functions were never attached to
meta tables (since setup_timescaledb() was not run). However, attaching
those triggers at extension creation also causes problems since the data
copy happens after extension creation but we don't want triggers fired
on the data restored (that could cause duplicate rows, for example).

The solution to this chicken-and-egg problem in this PR is to have
a special configuration (GUC) variable `timescaledb.restoring` that,
if 'on', would prevent the extension from attaching triggers at
extension creation. Then, after restoration, you'd call
restore_timescaledb() to attach the triggers and unset the GUC above.
This procedure is documented in the README as part of this PR.
2017-05-22 16:12:21 -04:00
Rob Kiefer
9e3bafc2f4 Add instructions to run Docker image.
This commit adds an example how to run the Docker image so the
data is persisted between restarts based on our docker-run.sh
script. It also fixes a typo in the docker-run.sh script where
the default DATA_DIR was not correctly set.
2017-04-19 21:05:37 -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
Rob Kiefer
cb90eef350 Rename setup_db() and fix port for local connections
If a user attempts to setup a database while not connecting using
the network, port is NULL and thus fails constraint checks. Instead,
we now use the default Postgres port of 5432 when this happens.

Also, setup_db() is renamed to setup_timescaledb() for clarity in
the presence of other extensions.
2017-03-22 09:26:03 -04:00
Erik Nordström
b4c9055184 Move generate_typedef.sh to scripts directory 2017-03-16 10:48:21 +01:00
Rob Kiefer
55736b9262 Add a migrate data script for large datasets
Currently TimescaleDB does not close chunks mid-insert, so large
batches will overfill a chunk. This commit adds a script to
split large CSV files into smaller batches to allow reasonable
closing of chunks.
2017-03-10 11:41:11 -05:00
Rob Kiefer
3760993519 Renames setup_single_node() to setup_db() 2017-03-06 15:36:29 -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
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
Rob Kiefer
a2198b7c72 Initial draft of sample docs. Update README 2017-02-02 12:44:25 -05:00
Rob Kiefer
574d6202cd Add bash script for setting up single-node cluster with user-defined DB name 2017-02-01 16:03:24 -05:00
Matvey Arye
d3a3670aa6 Merged in install-nits (pull request #71)
nit to installation/docker
2017-01-31 22:03:14 +00: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
b919df869f runs test docker om different port 2017-01-31 13:04:27 +01:00
Erik Nordström
8abc301e51 Add support for tablespaces
Identically named tablespaces need to exist on each data node before
a hypertable is created from a table that references a tablespace.
2017-01-31 10:38:01 +01:00
Matvey Arye
97205a7cec Misc usability fixes 2017-01-24 17:26:57 -05:00
Matvey Arye
ce5e1aecd7 Changes to Makefile and associated scripts to make docker commands act as expected + to mount a data volume 2017-01-24 14:59:54 -05:00
Rob Kiefer
29bc320cfb Add Getting Started instructions to README 2017-01-19 14:53:38 -05:00
Matvey Arye
64526426c5 Allow single-node deployments that use one database.
Allowing database deployments that use the same database for both the
meta and node roles simplifies operations when iobeamdb is deployed on
a single-node. It allows the database to operate without any
cross-network communication (either through dblink or postgres_fdw) and
thus offers stronger consistency guarantees.
2017-01-18 19:03:53 -05:00
Rob Kiefer
0ec5095cf5 Cleanup Makefile targets, script names, and README 2017-01-16 10:49:08 -05:00