303 Commits

Author SHA1 Message Date
Sven Klemm
f89fd07c5b Remove year from SQL file license text
This changes the license text for SQL files to be identical
with the license text for C files.
2019-01-13 23:30:22 +01:00
Joshua Lockerman
65894f08cf Add view displaying info about the current license
Currently the view displays the current edition, expiry date, and
whether the license is expired. We're not displaying the license key
itself in the view as it can get rather long, and get be read via SHOW.
We also do not display the license's ID since that is for internal use.
2019-01-10 17:29:59 -05:00
Joshua Lockerman
47b5b7d553 Log which chunks are dropped by background workers
We don't want to do this silently, so that users are
able to debug where their chunks went.
2019-01-10 13:53:38 -05:00
Joshua Lockerman
27cd0fa27d Fix speeling 2019-01-09 17:16:17 -05:00
Joshua Lockerman
fafc98d343 Fix warnings for TSL licenses
So as to reduce the amount of logspam users receive, restrict printing license info
to the following:

  1. On CREATE EXTENSION
       a. in the notice, print the license expiration time, if any
       b. if the license is expired additionally print that
       c. else if the license will expire within a week print an addional warning
  2. On the first usage of a TSL function, print if the license is expired or will
     be expired within a week
2019-01-08 19:35:50 -05:00
Joshua Lockerman
28265dcc1f Use a fixed file for the latest dev version
When developing a feature across releases, timescaledb updates can get
stuck in the wrong update script, breaking the update process. To avoid
this, we introduce a new file "latest-dev.sql" in which all new updates
should go. During a release, this file gets renamed to
"<previous version>--<current version>.sql" ensuring that all new
updates are released and all updates in other branches will
automatically get redirected to the next update script.
2019-01-07 14:03:05 -05:00
Joshua Lockerman
2a284fc84e Move 1.2.0 updates to the correct file 2019-01-02 15:43:48 -05:00
Sven Klemm
6125111dfa Mark gapfill functions parallel safe
Gapfill functions need to be marked parallel safe to not prevent
parallelism. The gapfill node itself is still parallel restricted
but child nodes can be parallel
2019-01-02 15:43:48 -05:00
Joshua Lockerman
4e1e15f079 Add reorder command
New cluster-like command which writes to a new index than swaps,
much like is done for the data table, and only acquires
exclusive locks for said swap. This trades off disk usage for
lower contention: we hold locks for a much lower period of time,
allowing reads to work concurrently, but we have both the old
and new versions of the table existing at once, approximately
doubling storage usage while reorder is running.

Currently only works on chunks.
2019-01-02 15:43:48 -05:00
Amy Tai
9ad73249e1 Move enterprise updates to newest update file 2019-01-02 15:43:48 -05:00
Amy Tai
ef43e52107 Add alter_policy_schedule API function 2019-01-02 15:43:48 -05:00
Sven Klemm
5ba740ed98 Add gapfill query support
This patch adds first level support for gap fill queries, including
support for LOCF (last observation carried forward) and interpolation, without
requiring to join against `generate_series`. This makes it easier to join
timeseries with different or irregular sampling intervals.
2019-01-02 15:43:48 -05:00
Amy Tai
be7c74cdf3 Add logic for automatic DB maintenance functions
This commit adds logic for manipulating internal metadata tables used for enabling users to schedule automatic drop_chunks and recluster policies. This commit includes:

- SQL for creating policy tables and chunk stats table
- Catalog code and C code for accessing these three tables programatically
- Implement and expose new user API functions:  add_*_policy and remove_*_policy
- Stub scheduler logic for running the policies
2019-01-02 15:43:48 -05:00
Joshua Lockerman
4ff6ac7b91 Initial Timescale-Licensed-Module and License-Key Implementation
This commit adds support for dynamically loaded submodules to timescaledb
as well an initial license-key implementation in the tsl subdirectory.
Dynamically loaded modules allow our users to determine which licenses they
wish to use for their version of timescaledb; if they wish to only use
Apache-Licensed code, they do not load the Timescale-Licensed submodule. Calls
from the Apache-Licensed code into the Timescale-Licensed submodule are
handled via dynamicaly-set function pointers; see tsl/src/Readme.module.md for
more details.

This commit also adds code for license keys for the ApacheOnly, Community, and
Enterprise editions. The license key determines which features are enabled,
and controls loading the submodule: when a license key that requires the
sub-module is installed, the module is automatically loaded.
Currently the ApacheOnly and Community license-keys are hardcoded to be
"ApacheOnly" and "Community" respectively. The first version of the enterprise
license-key is described in tsl/src/Readme.module.md
2019-01-02 15:43:48 -05:00
Sven Klemm
31e9c5b5cc Fix time column handling in get_create_command
Fixes get_create_command to produce a valid create_hypertable
call when the column name is a keyword
Add test.execute_sql helper function to test support functions
2018-12-28 18:15:57 +01:00
Joshua Lockerman
a4e79d43c6 Release 1.1.1 on master, prepare for 1.2.0-dev 2018-12-20 19:23:54 -05:00
Joshua Lockerman
d4f0cbd0d3 Prepare the repo for the 1.2.0 development cycle 2018-12-14 10:01:03 -05:00
Joshua Lockerman
1295ac3200 Release 1.1.0
PG11!
Otherwise, mainly performance improvements and bugfixes.
2018-12-13 15:37:56 -05:00
Sven Klemm
c59a30feed Remove unused functions from utils.c
Remove the following unused functions:
_timescaledb_internal.to_microseconds(TIMESTAMPTZ)
_timescaledb_internal.to_timestamp_pg(BIGINT)
_timescaledb_internal.time_to_internal(anyelement)
2018-12-12 20:54:20 +01:00
Erik Nordström
e4a4f8e2f8 Add support for functions on open (time) dimensions
TimescaleDB has always supported functions on closed (space)
dimension, i.e., for hash partitioning. However, functions have not
been supported on open (time) dimensions, instead requiring columns to
have a supported time type (e.g, integer or timestamp). This restricts
the tables that can be time partitioned. Tables with custom "time"
types, which can be transformed by a function expression into a
supported time type, are not supported.

This change generalizes partitioning so that both open and closed
dimensions can have an associated partitioning function that
calculates a dimensional value. Fortunately, since we already support
functions on closed dimensions, the changes necessary to support this
on any dimension are minimal. Thus, open dimensions now support an
(optional) partitioning function that transforms the input type to a
supported time type (e.g., integer or timestamp type). Any indexes on
such dimensional columns become expression indexes.

Tests have been added for chunk expansion and the hashagg and sort
transform optimizations on tables that are using a time partitioning
function.

Currently, not all of these optimizations are well supported, but this
could potentially be fixed in the future.
2018-12-12 10:14:31 +01:00
Joshua Lockerman
8da8ac3d43 Release 1.0.1 on master, prepare for 1.1.0-dev 2018-12-10 13:42:37 -05:00
Amy Tai
83014ee2b0 Implement drop_chunks in C
Remove the existing PLPGSQL function that implements drop_chunks, replacing it with a direct call to the C function, which also implements the old PLPGSQL checks in C. Refactor out much of the code shared between the C implementations of show_chunks and drop_chunks.
2018-12-06 13:27:12 -05:00
Amy Tai
bf15cfec24 Move BGW job tester functions to test module
Previously, delete/insert_job were exposed, even though they were only used for testing. Moved both the C implementations and the SQL functions to the test module.
2018-12-01 11:23:15 -05:00
Narek Galstyan
9a3402809f Implement show_chunks in C and have drop_chunks use it
Timescale provides an efficient and easy to use api to drop individual
chunks from timescale database through drop_chunks. This PR builds on
that functionality and through a new show_chunks function gives the
opportunity to see the chunks that would be dropped if drop_chunks was run.
Additionally, it adds a newer_than option to drop_chunks (also supported
by show_chunks) that allows to see/drop chunks in an interval or newer
than a point in time.

This commit includes:
    - Implementation of show_chunks in C
    - Additional helper functions to work with chunks
    - New version of drop_chunks in sql that uses show_chunks. This
      	  also adds a newer_than option to drop_chunks
    - More enhanced tests of drop_chunks and new tests for show_chunks

Among other reasons, show_chunks was implemented in C in order
to be able to have both older_than and newer_than arguments be null. This
was not possible in SQL because the arguments had to have polymorphic types
and whether they are used in function body or not, PL/pgSQL requires these
arguments to typecheck.
2018-11-28 13:46:07 -05:00
Sven Klemm
d4619598a9 Add view to show hypertable information
Add timescaledb_information.hypertable view that lists
hypertables, their owner, number of chunks and storage size
2018-11-28 17:02:56 +01:00
Amy Tai
35dee48e9f Remove version-checking from client-side
Because the server now sends a boolean indicating whether the local version is up-to-date, we simply validate the server's response and remove any version-checking code from the client-side. The client now only checks for well-formed versions before printing, if the local version is not up-to-date.
2018-11-26 13:50:57 -05:00
Sven Klemm
5b6a5f4511 Change size utility and job functions to STRICT
Change hypertable_relation_size, hypertable_relation_size_pretty,
chunk_relation_size, chunk_relation_size_pretty, indexes_relation_size,
indexes_relation_size_pretty, partitioning_column_to_pretty,
insert_job and delete_job to STRICT
2018-11-23 20:54:27 +01:00
Joshua Lockerman
e06733acf0 Fix casing in SQL license header to be consistent with elsewhere 2018-11-15 15:18:58 -05:00
Sven Klemm
f27c0a3f28 Move int time_bucket functions with offset to C 2018-11-12 22:27:02 +01:00
Amy Tai
b77b47ada8 Enable scheduler to update its jobs list
Previously, the scheduler only populated its jobs list once at start time. This commit enables the scheduler to receive notifications for updates (insert, update, delete) to the bgw_job table. Notifications are sent via the cache invalidation framework. Whenever the scheduler receives a notification, it re-reads the bgw_job table. For each job currently in the bgw_job table, it either instantiates new scheduler state for the job or copies over any existing scheduler state, for persisting jobs. For jobs that have disappeared from the bgw_job table, the scheduler deletes any local state it has.

Note that any updates to the bgw_job table must now go through the C, so that the cache invalidation framework in catalog.c can run. In particular, this commit includes a rudimentary API for interacting with the bgw_job table, for testing purposes. This API will be rewritten in the future.
2018-11-07 15:53:04 -05:00
Rob Kiefer
cac0791a5c Prepare the repo for next development cycle 2018-11-01 10:34:08 -04:00
Rob Kiefer
1dc3aa9161 Release 1.0.0 2018-10-30 13:49:38 -04:00
Joshua Lockerman
20ec6914c0 Add license headers to SQL files and test code 2018-10-29 13:28:19 -04:00
Rob Kiefer
2a8cdafb32 Prepare the repo for next development cycle 2018-10-18 18:01:06 -04:00
Rob Kiefer
e9f69edce0 Release 1.0.0-rc3 2018-10-18 15:45:53 -04:00
David Kohn
9ccda0df00 Start stopped workers on restart message
Modify the restart action to start schedulers if they do not exist, this fixes a
potential race condition where a scheduler could be started for a given
database, but before it has shut down (because the extension does not exist) a
create extension command is run, the start action then would not change the
state of the worker but it would be waiting on the wrong vxid, so not see that
the extension exists. This also makes it so the start action can be truly
idempotent and not set the vxid on its startup, thereby respecting any restart
action that has taken place before and better defining how each interacts with
the system.

Additionally, we decided that the previous behavior in which launchers were not
started up on, say, alter extension update actions was not all that desirable as
it worked if the stop action had happened, but the database had not restarted,
if the database restarted, then the stop action would have no effect. We decided
that if we desire the ability to disable schedulers for a particular database,
we will implement it in the future as a standalone feature that takes effect
across server restarts rather than having somewhat ill-defined behavior with an
implicit feature of the stop action.
2018-10-18 11:28:20 -04:00
Sven Klemm
3e3bb0c796 Add bool created to create_hypertable and add_dimension return value
Add bool created to return value of create_hypertable and add_dimension.
When if_not_exists is true and creation is skipped because the object
already exists created will be false, otherwise it will be true. This
modifies the functions to return meta data even when no object was
created.
2018-10-17 17:12:53 +02:00
Sven Klemm
d9b2dfed6b Change return value of add_dimension to TABLE
Change the return value of add_dimension to return a record consisting
of dimension_id, schema_name, table_name, column_name. This improves
user feedback about success of the operation but also gives the function
an API returning useful information for non-human consumption.
2018-10-15 17:53:00 +02:00
Matvey Arye
19299cf349 Make all time_bucket function STRICT
All time bucket function should return NULL on any NULL parameters.
2018-10-15 10:16:10 -04:00
Matvey Arye
297d88551b Add a version of time_bucket that takes an origin
This allows people to explicitly specify the origin point.
2018-10-15 10:16:10 -04:00
Sven Klemm
a83e2838c9 Change return value of create_hypertable to TABLE
Change create_hypertable to return a record consisting of
(hypertable_id, schema_name, table_name). This improves user feedback
about success of the operation but also gives the function an API
returning useful information for non-human consumption.
2018-10-12 17:40:10 +02:00
Sven Klemm
5883d0d833 Check GRANTs in update tests 2018-10-10 20:07:57 +02:00
Sven Klemm
aea7c7edac Add GRANTs to update script for pg_dump to work 2018-10-10 18:23:09 +02:00
Rob Kiefer
bff0d4e405 Prepare the repo for the next development cycle 2018-10-01 10:56:02 -04:00
Rob Kiefer
d19f869016 Release 1.0.0-rc2 2018-09-28 13:26:28 -04:00
Joshua Lockerman
b43574f82e Switch 'IO' error prefix to 'TS'
Our errorcodes have a 'IO' prefix from when we were Iobeam. This commit
switches that prefix to 'TS' for consistency.
2018-09-27 13:06:11 -04:00
Joshua Lockerman
974788516a Prefix public C functions with ts_
We've decided to adopt the ts_ prefix on all exported C functions in
order to avoid having symbol conflicts with future postgres functions.
We've already started using this prefix on new functions and this commit
adds the prefix to to the old functions.
2018-09-27 11:45:04 -04:00
Sven Klemm
248f6621e4 Fix pg_dump for unprivileged users
When timescaledb is installed in template1 and a user with only createdb
privileges creates a database, the user won't be able to dump the
database because of lacking permissions. This patch grants the missing
permissions to PUBLIC for pg_dump to succeed.

We need to grant SELECT to PUBLIC for all tables even those not
marked as being dumped because pg_dump will try to access all
tables initially to detect inheritance chains and then decide
which objects actually need to be dumped.
2018-09-26 18:04:11 +02:00
Sven Klemm
625e3fa129 Fix negative value handling in int time_bucket
The integer variants of time_bucket don't handle negative time values
properly and return the upper boundary of the interval instead of the
lower boundary for negative time values.
2018-09-25 14:10:12 +02:00
Erik Nordström
18b8068ad7 Remove unnecessary index on dimension metadata table
The `dimension` metadata table had both a `(hypertable_id)` and a
`UNIQUE(hypertable_id, column_name)` index. Having only the latter
index should suffice.

This change removes the unnecessary index, which will save some space,
and make the schema more clear.
2018-09-24 13:24:22 +02:00