2796 Commits

Author SHA1 Message Date
Markos Fountoulakis
a5caa5562f Fix memory overflow
Fix heap buffer overflow when renaming compressed hypertable columns.
2021-06-23 13:51:49 +03:00
Markos Fountoulakis
c82b5c3262 Fix Regression Linux i386 workflow
Change the postgresql ftp URL from snapshot/ to source/. This way we
do not need to react to every new commit upstream, but only whenever
the postgresql minor version changes.

Co-authored-by: Mats Kindahl <mats.kindahl@gmail.com>
2021-06-23 13:30:41 +03:00
Aleksander Alekseev
9eec2a544c Refactor initialize_func_info().
Replace unnecessary chain of ts_extension_schema_oid() ->
ts_extension_schema_name() -> get_namespace_oid() calls with
a single OID lookup.
2021-06-22 12:34:58 +03:00
Markos Fountoulakis
59d868bdf1 Run sanitizer tests on PG12
Change sanitizer test to run on PG12 and make it use the same
infrastructure as the other linux regression tests.

Co-authored-by: Sven Klemm <sven@timescale.com>
2021-06-22 11:42:48 +03:00
Sven Klemm
374decb5ac Don't skip default path when looking for prove 2021-06-22 09:47:21 +02:00
Aleksander Alekseev
33dfdcf5ea Introduce experimental time_bucket_ng() function
This patch adds time_bucket_ng() function to the experimental
schema. The "ng" part stands for "next generation". Unlike
current time_bucket() implementation the _ng version will support
months, years and timezones.

Current implementation doesn't claim to be complete. For instance,
it doesn't support timezones yet. The reasons to commit it in it's
current state are 1) to shorten the feedback loop 2) to start
experimenting with monthly buckets are soon as possible,
3) to reduce the unnecessary work of rebasing and resolving
conflicts 4) to make the work easier to the reviewers
2021-06-21 12:00:18 +03:00
Nikhil
8aaef4ae14 Fix update tests to handle sequences
The post-update script was handling preserving initprivs for newly
added catalog tables and views. However, newly added catalog sequences
need separate handling otherwise update tests start failing. We also
now grant privileges for all future sequences in the update tests.

In passing, default the PG_VERSION in the update tests to 12 since we
don't work with PG11 anymore.
2021-06-21 13:22:08 +05:30
Sven Klemm
d800e2f46f Add missing ORDER BY clause to dist_hypertable test 2021-06-21 08:49:49 +02:00
Mats Kindahl
71e8f13871 Add workflow and CMake support for formatting
Add a workflow to check that CMake files are correctly formatted as
well as a custom target to format CMake files in the repository. This
commit also runs the formatting on all CMake files in the repository.
2021-06-17 22:52:29 +02:00
Sven Klemm
cf5626bf0c Combine dist_hypertable_pg12 test with dist_hypertable
Combine dist_hypertable_pg12 test since all the tests in that file
can run on all supported PG versions now.
We also rename the views test to information_views to make it clearer
what the test is about and rename the join test to pg_join since
this is the postgres join test ported to hypertables.
2021-06-17 15:16:03 +02:00
Sven Klemm
e0e2e4308b Combine rowsecurity-12 and rowsecurity-13
With the removal of PG11 support we can use the same template for
the rowsecurity test. We still need to keep the output version
specific since the plan output differs between PG12 and PG13.
2021-06-17 15:16:03 +02:00
Sven Klemm
1b08f11297 Filter out chunk and hypertable ids from test output
Currently any tests in regresscheck-shared can only include
EXPLAIN output if they only access the precreated hypertables
as hypertables and chunks created in the test itself will
have ids depending on execution order of the shared tests.
This patch filters out those ids so shared tests can include
EXPLAIN output for local hypertables.
2021-06-17 14:03:28 +02:00
Erik Nordström
38e6c0aee5 Improve trigger handling on distributed hypertables
Triggers on distributed hypertables can now be renamed due to having
the rename statement forwarded to data nodes. This also applies to
other objects on such tables, like constraints and indexes, since they
share the same DDL "rename" machinery. Tests are added for these
cases.

For convenience, trigger functions on distributed hypertables will now
also be created automatically on the data nodes. In other words, it is
no longer necessary to pre-create the trigger function on all data
nodes.

This change also fixes an issue with statement-level triggers, which
weren't properly propagated to data nodes during `CREATE TRIGGER`.

Fixes #3238
2021-06-16 14:12:04 +02:00
Sven Klemm
c4c0c3de4f Harden pg_init_privs query
Since we are only interested in entries with classoid pg_class
our queries should reflect that. Without these restrictions
objects that have entries for multiple classoids can cause the
extension update to fail.
2021-06-16 10:15:53 +02:00
Aleksander Alekseev
3f9adffaf0 Don't access bucket_width directly
Refactoring. Since bucket_width will not be fixed in the future this
patch introduces two new procedures:

- ts_continuous_agg_bucket_width(), for determining the exact width
  of given bucket;
- ts_continuous_agg_max_bucket_width(), for estimating the maximum
  bucket width for given continuous aggregate;

This will allow determining the bucket width on the fly, which is
not possible when ContinuousAgg* -> data.bucket_width is accessed
directly. All accesses to data.bucket_width were changed accordingly.
2021-06-16 10:45:47 +03:00
Sven Klemm
b0cd6495b3 Fix flaky pg_dump test
Call pg_terminate_backend on all active sessions on the database to
be used as template database to prevent on error on CREATE DATABASE.
2021-06-15 21:49:50 +02:00
Markos Fountoulakis
6e7679e222 Fix failed update with parallel workers
When executing "ALTER EXTENSION timescaledb UPDATE TO ..." it will fail
if parallel workers spawn for the update itself. Disable parallel
execution during the update.
2021-06-15 17:50:22 +03:00
Sven Klemm
6d6172b027 Fix pg_init_privs objsubid handling
pg_init_privs can have multiple entries per relation if the relation
has per column privileges. An objsubid different from 0 means that
the entry is for a column privilege. Since we do not currently
restore column privileges we have to ignore those rows otherwise
the update script will fail when tables with column privileges are
present.
2021-06-15 10:15:51 +02:00
Aleksander Alekseev
4dc4e09dc2 Remove two_buckets_to_str() procedure
The two_buckets_to_str() procedure relies on fixed bucket_width
which is not going to be fixed in the future. Since the procedure
is used only to generate a hint that accompanies an error message,
the simplest solution is to remove this procedure. We can improve
error messages later if that would be necessary.
2021-06-15 05:30:22 +03:00
Erik Nordström
98110af75b Constify parameters and return values of core APIs
Harden core APIs by adding the `const` qualifier to pointer parameters
and return values passed by reference. Adding `const` to APIs has
several benefits and potentially reduces bugs.

* Allows core APIs to be called using `const` objects.
* Callers know that objects passed by reference are not modified as a
  side-effect of a function call.
* Returning `const` pointers enforces "read-only" usage of pointers to
  internal objects, forcing users to copy objects when mutating them
  or using explicit APIs for mutations.
* Allows compiler to apply optimizations and helps static analysis.

Note that these changes are so far only applied to core API
functions. Further work can be done to improve other parts of the
code.
2021-06-14 22:09:10 +02:00
Sven Klemm
f1ae6468d8 Make aggregate in caggs fully qualified
When querying continuous aggregate views with a search_path not
including public the query will fail cause the function reference
in the finalize call is not fully qualified.

This can surface when querying caggs through postgres_fdw which
resets search_path to contain only pg_catalog.

Fixes #1919
Fixes #3326
2021-06-14 18:21:27 +02:00
Markos Fountoulakis
ed63a2adf4 Fix compile error
Error: 'nest_level' may be used uninitialized in this function.
2021-06-11 14:42:02 +03:00
Sven Klemm
e5837a55e6 Fix pull_varnos miscomputation of relids set
Upstream fixed a bug with miscomputation of relids for
PlaceHolderVar. Those fixes changed the signature of pull_varnos,
make_simple_restrictinfo and make_restrictinfo.
The fixes got backported to the PG12 and PG13 branch but to not
break compatibility with extensions the old functions were left in.
This patch makes our code use the new functions when compiling
against a postgres version that has them.

https://github.com/postgres/postgres/commit/1cce024fd2
https://github.com/postgres/postgres/commit/73fc2e5bab
2021-06-11 12:56:04 +02:00
gayyappan
318d2fd808 Remove paths that reference parent relids for compressed chunks
We explicilty filter paths for compressed chunks that
have spurious join clauses between the compressed chunk and
the original chunk or hypertable. However there are other
cases where a chunk could be a child rel
(i.e. RELOPT_OTHER_MEMBER_REL) such as when the chunk is
referenced as part of a UNION ALL query. We remove all
paths that have spurious join clauses between the compressed
chunk and any implied parent for the chunk.

Fixes #2917
2021-06-10 15:27:03 -04:00
Aleksander Alekseev
ac031c8aed Remove unused code
While looking for code that relies on fixed bucket_width I discovered
several files that don't seem to be used anymore. This patch removes
these files. Even if there is a value in them we can't rely on fixed
bucket_width in the future anyway.
2021-06-10 18:31:43 +03:00
Markos Fountoulakis
bb43f9c421 Fix memory overflow
Fix heap buffer overflow in remote connection cache.
2021-06-10 15:08:08 +03:00
Aleksander Alekseev
3763b20ff4 Look for PostgresNode.pm in the right path
$(pg_config --libdir)/pgxs/src/test/perl is the right path for
PostgresNode.pm on Linux. On MaxOS and PG 13.x another path seems
to be used: $(pg_config --libdir)/postgresql/pgxs/src/test/perl
2021-06-09 19:16:05 +03:00
Aleksander Alekseev
4ad2440dad Remove unused bucket_width argument
continuous_agg_update_materialization() doesn't use this argument and
we can't rely on a fixed bucket_width in the future anyway.
2021-06-09 18:36:53 +03:00
Nikhil
093d021228 Make provecheck run specific tap tests
Introduce a shell wrapper around perl prove utility to control running
of TAP tests. The following control variable is supported:

PROVE_TESTS: only run TAP tests from this list

e.g make provecheck PROVE_TESTS="t/foo.pl t/bar.pl"

Note that you can also use regular expressions to run multiple taps
tests matching the pattern:

e.g make provecheck PROVE_TESTS="t/*chunk*"

If the existing "TESTS=" option is used along with PROVE_TESTS then
the subset represented by PROVE_TESTS will also get run. Otherwise tap
tests will be skipped if "TESTS=" is specified.

e.g make installcheck TESTS=dist_hyper* PROVE_TESTS="t/001_*"
2021-06-09 19:30:10 +05:30
Erik Nordström
264b77eb20 Move internal API functions to experimental schema
Move the "block new chunks" functions and the chunk-based continuous
aggregate refresh function to the new experimental schema.
2021-06-09 14:47:16 +02:00
Matvey Arye
b72dab16c0 Add some more randomness to chunk assignment
Previously the assignment of data nodes to chunks had a bit
of a thundering-herd problem for multiple hypertables
without space partions: the data node assigned for the
first chunk was always the same across hypertables.
We fix this by adding the hypertable_id to the
index into the datanode array. This de-synchronizes
across hypertables but maintains consistency for any
given hypertable.

We could make this consistent for space partitioned tables
as well but avoid doing so now to prevent partitions
jumping nodes due to this change.

This also effects tablespace selection in the same way.
2021-06-08 14:04:23 +02:00
Erik Nordström
a1cf610d3c Run ABI tests with TAP support
Install the Perl prerequisites when building the image for ABI tests,
including the `prove` binary.

Although the ABI tests currently don't run TAP tests, CMake still
failed the configuration since it expects the prerequisites to be
installed unless it is run with `-DTAP_CHECKS=off`.
2021-06-07 15:20:52 +02:00
Sven Klemm
7e39797d46 Use ExecComputeStoredGeneratedCompat macro
When adding support for PG13 we introduced a macro hide the
function signature differences of ExecComputeStoredGenerated
but the callers of this function never got adjusted to use the
macro.
2021-06-07 11:14:42 +02:00
Erik Nordström
8e1273cd13 Detect TAP test prerequisites with CMake
CMake now detects if the necessary prerequisites for running TAP
tests are installed on the local system. This includes perl
installation and other dependencies, such as the IPC::Run module and
prove binary.
2021-06-05 12:08:21 +02:00
Mats Kindahl
10e339f591 Add experimental schema
This commit adds an experimental schema where experimental features can
be added.
2021-06-04 08:28:27 +02:00
Sven Klemm
5719c50e51 Remove TTSOps pointer macros
Remove TTSOpsVirtualP, TTSOpsHeapTupleP, TTSOpsMinimalTupleP and
TTSOpsBufferHeapTupleP macros since they were only needed on PG11
to allow us to define compatibility macros for TupleTableSlot
operations.
2021-06-03 14:34:31 +02:00
Sven Klemm
3b48d734ce Fix flaky pg_dump test
Stop background workers in test after calling timescaledb_post_restore
since this function restarts background workers.
2021-06-02 19:53:40 +02:00
Sven Klemm
dd3e422964 Remove update files for PG11
Remove update files that were only used for PG11 versions since
those versions do not support postgres past PG11
2021-06-01 20:21:06 +02:00
Sven Klemm
110d77a2fe Combine test files
Merge test files that after the removal of PG11 support need
to be no longer version specific.
2021-06-01 20:21:06 +02:00
Sven Klemm
fb863f12c7 Remove support for PG11
Remove support for compiling against PostgreSQL 11. This patch also
removes PG11 specific compatibility macros.
2021-06-01 20:21:06 +02:00
Sven Klemm
22ceabcb83 Remove PG11 specific test output files 2021-06-01 20:21:06 +02:00
Sven Klemm
e9066d5531 Remove PG11 from CI
Remove all CI runs against postgres 11
2021-06-01 20:21:06 +02:00
Juanito Fatas
9fe90ebcea Fix broken links in TimescaleDB NOTICE
Link to Telemetry page explains more than disable it

Co-authored-by: Mike Freedman <mfreed@cs.princeton.edu>
2021-05-31 06:46:44 +02:00
Erik Nordström
ec06f9a7d0 Add 2.3.0 to update test scripts
The update tests for PG11, PG12, and PG13 are updated to include
release 2.3.0.
2021-05-27 16:41:28 +02:00
Mats Kindahl
e039043b04 Fix issues in update smoke test
Corrected a function name and replaced a variable with the explicit
commands to use.
2021-05-27 14:59:36 +02:00
Erik Nordström
04da7684b8 Use correct heading level in changelog
The 2.3.0 release used the wrong heading level. Fix it for future
releases.
2021-05-27 14:22:16 +02:00
Sven Klemm
c861efa0e2 Remove unused job_type from policies
When refactoring the job code the job_type was removed from our
catalog but a few places got overlooked that still had a variable
holding the job type.
2021-05-26 22:06:50 +02:00
Erik Nordström
77a3d5a033 Release 2.3.0
This release adds major new features since the 2.2.1 release. We deem
it moderate priority for upgrading.

This release adds support for inserting data into compressed chunks
and improves performance when inserting data into distributed
hypertables. Distributed hypertables now also support triggers and
compression policies.

The bug fixes in this release address issues related to the handling
of privileges on compressed hypertables, locking, and triggers with
transition tables.

**Features**
* #3116 Add distributed hypertable compression policies
* #3162 Use COPY when executing distributed INSERTs
* #3199 Add GENERATED column support on distributed hypertables
* #3210 Add trigger support on distributed hypertables
* #3230 Support for inserts into compressed chunks

**Bugfixes**
* #3213 Propagate grants to compressed hypertables
* #3229 Use correct lock mode when updating chunk
* #3243 Fix assertion failure in decompress_chunk_plan_create
* #3250 Fix constraint triggers on hypertables
* #3251 Fix segmentation fault due to incorrect call to chunk_scan_internal
* #3252 Fix blocking triggers with transition tables

**Thanks**
* @yyjdelete for reporting a crash with decompress_chunk and identifying the bug in the code
* @fabriziomello for documenting the prerequisites when compiling against PostgreSQL 13
2021-05-25 15:11:55 +02:00
Sven Klemm
fe872cb684 Add policy_recompression procedure
This patch adds a recompress procedure that may be used as custom
job when compression and recompression should run as separate
background jobs.
2021-05-24 18:03:47 -04:00
gayyappan
426918c59f Fix locking issue when updating chunk status
Two insert transactions could potentially try
to update the chunk status to unordered. This results in
one of the transactions failing with a tuple concurrently
update error.
Before updating status, lock the tuple for update, thus
forcing the other transaction to wait for the tuple lock, then
check status column value and update it if needed.
2021-05-24 18:03:47 -04:00