119 Commits

Author SHA1 Message Date
gayyappan
2dbc28df82 Create base infrastructure for continuous aggs
This PR adds a catalog table for storing metadata about
continuous aggregates. It also adds code for creating the
materialization hypertable and 2 views that are used by the
continuous aggregate system:

1) The user view - This is the actual view queried by the enduser.
   It is a query on top of the materialized hypertable and is
   responsible for finalizing and combining partials in a manner
   that return to the user the data as defined by the original
   user-defined view.
2) The partial view - which queries the raw table and returns
   columns as defined in the materialized table. This will be used
   by the materializer to calculate the data that will be inserted
   into the materialization table. Note the data here is the partial
   state of any aggregates.
2019-04-26 13:08:00 -04:00
gayyappan
b45343b3cc Add ability to work with aggregate partials
The ability to get aggregate partials instead of the final state
is important for both continuous aggregation and clustering.

This commit adds the ability to work with aggregate partials.
Namely a function called _timescaledb_internal.partialize_agg
can now wrap an aggregate and return the partial results as a bytea.

The _timescaledb_internal.finalize_agg aggregate allows you to combine
and finalize partials.

The partialize_agg function works as a marker in the planner to force
the planner to return partial result.

Unfortunately, we could not get the planner to modify the plan directly
to aggregate partials. Instead, the finalize_agg is a real aggregate
that performs aggregation on the partial state. Note that it is not
yet parallel.

Aggregate that use FINALFUNC_EXTRA are currently not supported.

Co-authored-by: gayyappan <gayathri@timescale.com>
Co-authored-by: David Kohn <david@timescale.com>
2019-04-12 12:12:17 -04:00
Dmitry Simonenko
4daeb06eee Track hypertables used during process utility hook execution
This patch does refactoring necessary to support execution of DDL
commands on remote servers.

Basically it extends cross module api with ddl_command_start,
ddl_command_end and sql_drop functions.

Variable hypertables_list added to ProcessUtilityArg. It is used
to keep a list of found hypertables during Utility/DDL statement
parsing. This information and information gathered from other
hook functions will be used to distinct distributed hypertables
and forward DDL commands to any remote servers associated with
them.
2019-03-29 13:04:18 +03:00
Matvey Arye
34edba16a9 Run clang-format on code 2019-02-05 16:55:16 -05:00
David Kohn
73d3a14665 Rename alter_policy_schedule & main_table for better UI
Rename alter_policy_schedule to alter_job_schedule for consistency with the job_id argument passed in.
Also rename main_table to hypertable in all of the policy related functions as they must deal with
hypertables that have already been created.
2019-01-25 13:51:52 -05: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
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
Sven Klemm
81d85ff60d Differentiate between required license in error hints
Show different error hint depending on the license required
to use a feature.
2019-01-07 23:05:38 +01:00
Joshua Lockerman
73ad5b9dde Allow module shutdown to work in ApacheOnly builds
In cases where we're going from ApacheOnly to ApacheOnly
allow a nop shutdown hook. This prevents spurious errors.
2019-01-07 15:06:18 -05:00
Joshua Lockerman
acc41a7712 Update license header
Only have the copyright in the NOTICE. Hopefully
only having to update one place each year will
keep it consistent.
2019-01-03 11:57:51 -05:00
Joshua Lockerman
6811296db7 Clean windows warnings
After this, the only remaining warnings on Windows are from postgres
itself.
2019-01-03 10:50:18 -05:00
Joshua Lockerman
888dea71b5 Stop using the extra field for now and other Windows bugs
Something is causing a heap corruption upon setting the license key to
default when we try to use the guc extra on windows. For now stop using
it and just rerun the validation function, if we get to the assign hook
we must have a valid key, so it will never fail.

Also Fixes error message on windows;
turns out windows does not like to print NULL strings.
Don't do that.

Fixes other minor windows bugs.
2019-01-02 15:43:48 -05:00
Joshua Lockerman
0436d3b4b0 Edit launcher to load TSL strictly after timescale itself
Reloading shared libraries (which is done to start parallel
workers) is done is the order in which load_file completes.
If we try to load the TSL from PG_init, this causes postgres to
attempt to load the TSL before timescale itself, which causes an
error.

Also disables the warning on normal TSL startup.
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
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
568749c5ac Add more license key fields and telemetry
Add more license fields and useful for tracking which kinds of licenses
are in use.
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