12 Commits

Author SHA1 Message Date
Stephen Polcyn
1dc1850793 Drop_chunks returns list of dropped chunks
Previously, drop_chunks returned an empty table, giving the user
no indication of what (if anything) had happened.
Now, drop_chunks returns a list of the chunks identifiers in the
same style as show_chunks, with the chunk's schema and table name.

Notably, when show_chunks is called directly before drop_chunks, the
output should be the same.
2019-07-19 12:13:24 -04:00
Matvey Arye
e834c2aba8 Better permission checks in API calls
This commit fixes and tests permissions in the following
API calls:
- reorder_chunk (test only)
- alter_job_schedule
- add_drop_chunks_policy
- remove_drop_chunks_policy
- add_reorder_policy
- remove_reorder_policy
- drop_chunks
2019-06-24 10:57:38 -04:00
Joshua Lockerman
2801c6a5f5 Fix handling of types with custom partitioning
In various places, most notably drop_chunks and show_chunks, we
dispatch based on the type of the "time" column of the hypertable, for
things such as determining which interval type to use. With a custom
partition function, this logic is incorrect, as we should instead be
determining this based on the return type of the partitioning function.

This commit changes all relevant access of dimension.column_type to a
new function, ts_dimension_get_partition_type, which has the correct
behavior: it returns the partitioning function's return type, if one
exists, and only otherwise uses the column type. After this commit, all
references to column_type directly should have a comment explaining why
this is appropriate.

fixes Gihub issue #1250
2019-06-21 13:08:51 -04:00
Matvey Arye
74f8d204a5 Optimize getting the chunk_id in continuous aggs
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.
2019-04-29 15:45:23 -04:00
Erik Nordström
d825661b6e Fix invalid client_min_messages level in chunk_utils test
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.
2019-03-15 14:41:05 +01:00
Joshua Lockerman
905cd4becc Add function to determine the chunk for a given row 2019-03-11 16:29:50 -04:00
Sven Klemm
037fbf634d Add missing ORDER BY to chunk_utils tests 2019-02-22 12:33:23 -05:00
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
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
Sven Klemm
ed5067c356 Fix interval_from_now_to_internal timestamptz handling
fix interval_from_now_to_internal to handle timezone properly
for timestamptz and simplify code
2018-12-10 23:24:12 +01: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
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