We replace chunk_for_tuple with chunk_id_from_relid for getting
chunk id fields when materializing continuous aggs. The old
function required passing in the entire row. This was very slow
because a lot of data was passed around at execution time.
The new function just uses the internal `tableoid` attribute to
convert the table relid to a chunk_id. This is much more efficient.
We also add memoization to the new function because it is most often
called consecutively for the same chunk.
The chunk_utils test sets `client_min_messages` to `FATAL` in order to
mute some error messages, which differ between PostgreSQL versions and
would otherwise cause test failures on some platforms. However,
according to the PostgreSQL documentation going back to at least 9.6,
this is not a valid log level for this configuration
parameter, although it has been allowed for legacy reasons. However,
starting with PostgreSQL 11.2, `FATAL` is silently turned into `ERROR`
and will cause the test to output the error anyway and thus fail.
This change removes the muting altogether, because the error that is
output is actually a TimescaleDB error and not a PostgreSQL error. The
generated error output probably changed at some point and therefore
this muting is no longer necessary.
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.
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.