Handle case where there is an additional constraint on time.
This makes the pathkeys for the IndexPath incompatible with
upper level ordering. Since we know the appropriate transform
for those pathkeys already, apply it to those paths too.
Common time-series rollups are of the form SELECT date_trunc(const,
time) as t, aggregates... GROUP BY t ORDER BY t DESC LIMIT const2.
Previously, Postgres would not optimize such queries because it
could not match date_trunc(const, time) to any indexes on time, since
it has no way to know that a sort on time is always a valid sort on
date_trunc(const, time).
This commit implements this optimization for date_trunc but it could
apply to a wider range of functions, to be implemented later.
Fix logic for when entire cache is invalidated
Approved-by: ci-vast
Approved-by: RobAtticus NA <rob.kiefer@gmail.com>
Approved-by: Olof Rensfelt <olof@iobeam.com>
Approved-by: Erik Nordström <erik.nordstrom@gmail.com>
Sometimes postgres wants to invalidate the entire cache. In this case it
send a cache invalidation message with relid == InvalidOid. This should
invalidate all the caches. Previously, it did not effect the cache of
the extension state. This fixes that problem and creates one cache reset
code path for both extension dropping and whole-cache reset, cleaning
up some of the logic in the process.
Previously chunks could be simultaneously created for the same
partition_id and a start_time and end_time of both NULL. This
prevents such bugs bug adding additional unique constraints and
locking the partition for chunk creation (as originally intended).
In case new allocations are made during a cache entry update, we
should use the cache's internal memory context to ensure that new data
is allocated and freed in a way consistent with the rest of the cache.
Previously, each test set their own (although mostly the same)
configuration for log output and error verbosity. This is now set
globally in the test runner so that tests only need to set these
configuration parameters if they need to override the defaults. The
log verbosity is also reduced so that errors aren't generated with the
line number of the source file that output the error. Line numbers in
the output can break tests when upgrading to a new PostgreSQL version
that outputs a different line number.
DROP EXTENSION didn't properly reset caches and other saved state
causing various errors related to bad state when the extension was
dropped and/or recreated later.
This patch adds functionality to track the state of the extension and
also signals DROP EXTENSION to other backends that might be running,
allowing them to reset their internal extension state.
If an error is generated in any of the insert triggers, the insert
state kept during a batch insert might be left in an undefined state,
breaking the next insert. This patch makes sure errors are captured in
the insert triggers so that the state can be cleaned up.
Rename setup_db() and fix port for local connections
Approved-by: Matvey Arye <cevian@gmail.com>
Approved-by: Olof Rensfelt <olof@iobeam.com>
Approved-by: ci-vast
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.
Add query tests for ORDER BY time DESC queries LIMIT queries
Approved-by: ci-vast
Approved-by: enordstr NA <erik.nordstrom@gmail.com>
Approved-by: Olof Rensfelt <olof@iobeam.com>
These tests show that non-aggregated queries that have an ORDER BY time
DESC LIMIT x structure perform well. Postgres processes such queries by
using a time DESC index and then performs a MergeAppend. Some further
optimization to avoid touching unnecessary tables due to constraints
can be added but they are not a priority. Much worse is that these
optimizations do not work when grouping by time (either through
integer division or using date_trunc).
In order to use the non-aggregated query optimizations we had
to create an index with time as the leading field and no
WHERE clause on the index.
Generate object dependencies to force 'make' to recompile on changes to headers
Approved-by: Matvey Arye
Approved-by: Olof Rensfelt
Approved-by: ci-vast
Previously, running 'make' did not recompile source files when changes
were made to header files. Now the compiler generates dependency files
that will pick up changes to header files and recompile any source
files that include the updated header.
Also, remove insert.h, which is not needed.