681 Commits

Author SHA1 Message Date
Rob Kiefer
3e194cd48f Update prerequisites in README 2017-12-09 21:13:44 -05:00
Rob Kiefer
a0f62c5156 Improve bootstrap script's robustness
Users can now either force the removal of an existing BUILD_DIR
by passing BUILD_FORCE_REMOVE to ./bootstrap, or they will be
prompted to remove the dir if it already exists. Additionally, the
bootstrap script will now exit if there is an error in mkdir or
cmake.
2017-12-09 13:00:01 -05:00
Rob Kiefer
00a096f2f6 Modify tests to make more platform agnostic
When testing on Windows these tests were returning differences
because of floating point (sql_query_results_*) differences and
because the cost was trivially higher (insert_single). Here we
remove the costs since it was not relevant to the regressions we
want to detect. Further we truncate the floating point averages
to 8 decimal places; enough to see significant differences.
2017-12-09 12:54:01 -05:00
Erik Nordström
0e76b5fa05 Do not add tablespaces to hypertable objects
A hypertable's tablespaces are now always retrieved from
the tablespace metadata table instead of being cached
with the hypertable. This avoids having to do cache invalidation
when updating the tablespace table.
2017-12-09 18:27:50 +01:00
Erik Nordström
176b75e43d Add command to show tablespaces attached to a hypertable
Users can now call `show_tablespaces()` to list the tablespaces
attached to a particular hypertable.
2017-12-09 18:27:50 +01:00
Erik Nordström
6e92383592 Add function to detach tablespaces from hypertables
Tablespaces can now be detached from hypertables using
`tablespace_detach()`. This function can either detach
a tablespace from all tables or only a specific table.

Having the ability to detach tablespace allows more
advanced storage management, for instance, one can detach
tablespaces that are running low on diskspace while attaching
new ones to replace the old ones.
2017-12-09 18:27:50 +01:00
Erik Nordström
e593876cb0 Refactor tablespace handling
Attaching tablespaces to hypertables is now handled
in native code, with improved permissions checking and
caching of tablespaces in the Hypertable data object.
2017-12-09 18:27:50 +01:00
Erik Nordström
c4a46ac8a1 Add hypertable cache lookup on ID/pkey
Hypertables can now be looked up through the cache on
ID/pkey in addition to OID.
2017-12-09 18:27:50 +01:00
Matvey Arye
f38a578578 Fix handling of long constraint names 2017-12-09 12:05:34 -05:00
Kevin Bowling
20c9b28fa7 Unconditionally add pg_config --includedir to src build 2017-12-09 11:08:54 -05:00
Matvey Arye
12dff61c20 Fixes insert for 32bit architecture
Fixes problem with insert on 32bit architecture. Fixes #336.
2017-12-07 16:39:15 -05:00
Rob Kiefer
e44e47ed88 Update add_dimension to take INTERVAL times
The user should be able to add time dimensions using INTERVAL when
the column type is TIMESTAMP/TIMESTAMPTZ/DATE, so this change adds
that support.

Additionally it adds some additional tests and checks for
add_dimension, e.g., a nice error when the table is not a
hypertable.
2017-12-07 12:09:35 -05:00
Rob Kiefer
0763e62f8f Update set_chunk_time_interval to take INTERVAL times
For convenience, the user should be able to specify the new
chunk time intervals using INTERVAL datatype if the hypertable is
using a TIMESTAMP/TIMESTAMPTZ/DATE datatype for its time column.
2017-12-07 12:09:35 -05:00
Rob Kiefer
87c4b4f7f0 Fix test generator to work for PG 10.1
Previously the test generator would create `parallel` tests with a
suffix consisting of the PG major and minor version numbers. This
is unnecessary for PostgreSQL 10 currently since we don't expect
major breakages between minor versions. So now instead the file
is suffixed with just the major version when it is PG10.
2017-12-07 12:09:35 -05:00
Michael J. Freedman
51854ac5c9 Fix error message to reflect that drop_chunks can take a DATE interval 2017-12-05 11:26:01 -05:00
Rob Kiefer
30d1483adb Prepare the repo for next development cycle 2017-11-30 11:33:43 -05:00
Rob Kiefer
00c979112d Release 0.7.1 (on master) 2017-11-30 11:33:43 -05:00
Matvey Arye
72b612cb7a Fix migration script 2017-11-30 11:33:43 -05:00
Matvey Arye
2c2aba8fad Fix installchecklocal
Remove user from regression tests so that the local test will work.
The tests itself will still be run with the appropriate user because
of the logic in runner.sh.
2017-11-27 16:28:51 -05:00
Matvey Arye
8b772be994 Change time handling in drop_chunks for TIMESTAMP times
This PR fixes the handling of drop_chunks when the hypertable's
time field is a TIMESTAMP or DATE field. Previously, such
hypertables needed drop_chunks to be given a timestamptz in UTC.
Now, drop_chunks can take a DATE or TIMESTAMP. Also, the INTERVAL
version of drop_chunks correctly handles these cases.

A consequence of this change is that drop_chunks cannot be called
on multiple tables (with table_name = NULL or schema_name = NULL)
if the tables have different time column types.
2017-11-27 16:17:42 -05:00
Rob Kiefer
66396fb81e Add build support for Windows
Windows 64-bit binaries should now be buildable using the cmake
build system either from the command line or from Visual Studio.

Previous issues regarding unresolved symbols have been resolved
with compatibility header files to properly export symbols or
getting GUCs via normal APIs.
2017-11-27 12:04:44 -05:00
Erik Nordström
c7cc9114b4 Do not append-optimize plans with result relations (DELETE/UPDATE)
Plans that have a result relation set (DELETE or UPDATE) should
not optimize subplans that contain append nodes. This is because
the PostgreSQL must turn such plans on an inheritance table into
a set of similar plans on each subtable (i.e., it needs to apply
UPDATE and DELETE to each subtable and not just the parent).

Optimizing such plans with, e.g., ConstraintAwareAppend makes
the planner believe it only needs to do the DELETE or UPDATE
on the root table, which means rows in subtables won't be affected.
2017-11-27 17:40:08 +01:00
Erik Nordström
e1a0e819cf Refactor and fix cache invalidation
TimescaleDB cache invalidation happens as a side effect of doing a
full SQL statement (INSERT/UPDATE/DELETE) on a catalog table (via
table triggers). However, triggers aren't invoked when using
PostgreSQL's internal catalog API for updates, since PostgreSQL's
catalog tables don't have triggers that require full statement
parsing, planning, and execution.

Since we are now using the regular PostgreSQL catalog update API for
some TimescaleDB catalog operations, we need to do cache invalidation
also on such operations.

This change adds cache invalidation when updating catalogs using the
internal (C) API and also makes the cache invalidation more fine
grained. For instance, caches are no longer invalidated on some
INSERTS that do not affect the validity of objects already in the
cache, such as adding a new chunk.
2017-11-27 17:33:10 +01:00
Erik Nordström
7b299fa05f Handle empty append plans in ConstraintAwareAppend
Append plans that are empty (no children) are replaced at planning-
time with a Result plan node that returns nothing. Such Result nodes
occur typically when querying outside the time range covered by chunks.
However, the ConstraintAwareAppend plan node did not handle the
case of a Result child node, instead expecting either an Append or
MergeAppend node. This is now fixed so that encountering a Result node
means doing nothing.
2017-11-27 17:24:15 +01:00
Erik Nordström
1e947da456 Permission fixes and allow SET ROLE
This change reduces the usage of SECURITY DEFINER on SQL
functions and fixes related permissions issues. It also
properly checks hypertable permissions relative the current_user
instead of the session_user, which otherwise breaks SET ROLE,
among other things.
2017-11-27 15:55:26 +01:00
Erik Nordström
a2b78aea1b Fix reindex test
The reindex test outputs the OID of a cloned index. This OID might
change with the state of the database, added tests, etc., causing
frequent test failures. The test is now updated to output the name of
the index instead of the OID.
2017-11-22 16:14:10 +01:00
Erik Nordström
33b260225e Fix pgindent on first CMake run
This changes the order in which subdirectories are processed in the
top-level CMakeLists.txt file, so that dependencies from the scripts/
dir are set when processing the src/ dir. Otherwise, the `pgindent`
target won't be enabled on the first CMake run.
2017-11-22 15:57:23 +01:00
Rob Kiefer
32b90e5e03 Prepare the repo for next development cycle 2017-11-21 23:52:59 -05:00
Rob Kiefer
f0d69f6084 Release 0.7.0 0.7.0 2017-11-21 14:37:57 -05:00
Matvey Arye
13e1cb5343 Add reindex function
reindex allows you to reindex the indexes of only certain chunks,
filtering by time. This is a common use case because a user may
want to reindex chunks after they are no longer getting new data once.

reindex also has a recreate option which will not use REINDEX
but will rather CREATE INDEX a new index and then
DROP INDEX / RENAME new_index to old_name. This approach has advantages
in terms of blocking reads for a much shorter period of time. However,
it does more work and will use more disk space during the operation.
2017-11-21 14:08:57 -05:00
jwdeitch
6594018e32 Handle when create_hypertable is invoked on partitioned table
- create_hypertable will raise exception on invocation
2017-11-21 12:28:16 -05:00
Matvey Arye
818bdbc31b Add coverity testing 2017-11-20 15:18:56 -05:00
Erik Nordström
5d0cbc12fd Recurse CLUSTER command to chunks
Clustering a table means reordering it according to an index.
This operation requires an exclusive lock and extensive
processing time. On large hypertables with many chunks, CLUSTER
risks blocking a lot of operations by holding locks for a long time.
This is alleviated by processing each chunk in a new transaction,
ensuring locks are only held on one chunk at a time.
2017-11-20 20:15:43 +01: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
741b25662e Mark IMMUTABLE functions as PARALLEL SAFE
Functions marked IMMUTABLE should also be parallel safe, but
aren't by default. This change marks all immutable functions
as parallel safe and removes the IMMUTABLE definitions on
some functions that have been wrongly labeled as IMMUTABLE.

If functions that are IMMUTABLE does not have the PARALLEL SAFE
label, then some standard PostgreSQL regression tests will fail
(this is true for PostgreSQL >= 10).
2017-11-17 20:24:30 +01:00
Erik Nordström
2ffb30d990 Make aggregate serialize and deserialize functions STRICT
Aggregate functions that have serialize and deserialize support
functions (histogram, last, first, etc.) should have these
support functions marked STRICT.

PostgreSQL's regular test suite will fail when the timescaledb
module is loaded without these functions being marked STRICT.
2017-11-17 20:24:30 +01:00
Olof Rensfelt
c552410f69 Add build target to run the standard PostgreSQL regression tests
To verify that PostgreSQL operations on regular tables are unaffected by
the TimescaleDB extension, the regular PostgreSQL regression tests can be
run with the TimescaleDB extension loaded.

To enable the build target (`pginstallcheck`), one needs to set the
CMake `PG_SOURCE_DIR` variable to point to the PostgreSQL source code, which
needs to have at least the regression test suite compiled.

The PostgreSQL tests suite will run on every Travis build.
2017-11-17 20:24:30 +01:00
Matvey Arye
291050b395 Change DATE partitioning to be completely tz-independent
The insert logic in time_value_to_internal was not tz independent,
causing problems with date in some timezones. This is now fixed.

Fixes #306.
2017-11-17 12:08:40 -05:00
Erik Nordström
ca0968aaa0 Make all partitioning functions take anyelement argument
All partitioning functions now has the signature `int func(anyelement)`.
This cleans up some special handling that was necessary to support
the legacy partitioning function that expected text input.
2017-11-17 17:59:16 +01:00
Erik Nordström
0497744803 Fix compilation warning in copy code
This change fixes a compilation warning in the
copy code that was introduced with an earlier
refactoring PR.
2017-11-17 09:49:19 +01:00
Erik Nordström
e6936cbfa5 Make warnings into errors in Travis build
Builds will now fail in Travis if a warning is
raised.
2017-11-17 09:49:19 +01: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
Matvey Arye
a4e1e32d02 Change range_start and range_end semantics
We now use INT64_MAX and INT64_MIN as the max and min values for
dimension_slice ranges. If a dimension_slice has a range_start of
INT64_MIN or the range_end is INT64_MAX, we remove the corresponding
check constraint on the chunk since it signifies that this end of the
range is infinite. Closed ranges now always have INT64_MIN as range_end
of first slice and range_end of INT64_MAX for the last slice.
Also, points corresponding to INT64_MAX are always
put in the same slice as INT64_MAX-1 to avoid problems with the
semantics that coordinate < range_end.
2017-11-14 08:00:10 -08:00
Matvey Arye
2dfbc829b0 Fix off-by-one error on range-end
A hash function can have the value 2147483647, so range_end has to be
2147483648.
2017-11-14 08:00:10 -08:00
Matvey Arye
5be7521a0b Implement changes suggested by coverity analysis 2017-11-13 11:31:16 -05:00
Matvey Arye
959034642e Remove code related to COPY TO statements
Refactor the copy code to get rid of the NOT is_from path. This
removes a lot of confusing dead code.
2017-11-13 11:25:39 -05: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
Erik Nordström
bd36e6d020 Move SQL source file lists to CMakeLists.txt
SQL source files that are joined together were
previously listed in the `load_order.txt` and
`extra_extension_files.txt` files. These SQL file list
were then read by CMake. However, since no dependencies
existed on these list files in Make targets, the project
was not automatically rebuilt if the lists were updated.

This change moves the lists directly to the CMakeLists.txt
file, ensuring that the project is properly rebuilt every
time the lists are updated.
2017-11-10 09:37:45 +01:00
Rob Kiefer
10fa207a12 Prepare the repo for next development cycle 2017-11-07 21:16:58 -05:00
Rob Kiefer
325556e6ac Release 0.6.1 2017-11-07 21:16:58 -05:00