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.
This commit is contained in:
David Kohn 2019-01-25 12:13:48 -05:00 committed by davidkohn88
parent fa61613440
commit 73d3a14665
11 changed files with 44 additions and 44 deletions

View File

@ -21,24 +21,24 @@ INSERT INTO _timescaledb_config.bgw_job (id, application_name, job_type, schedul
(1, 'Telemetry Reporter', 'telemetry_and_version_check_if_enabled', INTERVAL '24h', INTERVAL '100s', -1, INTERVAL '1h')
ON CONFLICT (id) DO NOTHING;
CREATE OR REPLACE FUNCTION add_drop_chunks_policy(main_table REGCLASS, older_than INTERVAL, cascade BOOL = FALSE, if_not_exists BOOL = false) RETURNS INTEGER
CREATE OR REPLACE FUNCTION add_drop_chunks_policy(hypertable REGCLASS, older_than INTERVAL, cascade BOOL = FALSE, if_not_exists BOOL = false) RETURNS INTEGER
AS '@MODULE_PATHNAME@', 'ts_add_drop_chunks_policy'
LANGUAGE C VOLATILE STRICT;
CREATE OR REPLACE FUNCTION add_reorder_policy(main_table REGCLASS, index_name NAME, if_not_exists BOOL = false) RETURNS INTEGER
CREATE OR REPLACE FUNCTION add_reorder_policy(hypertable REGCLASS, index_name NAME, if_not_exists BOOL = false) RETURNS INTEGER
AS '@MODULE_PATHNAME@', 'ts_add_reorder_policy'
LANGUAGE C VOLATILE STRICT;
CREATE OR REPLACE FUNCTION remove_drop_chunks_policy(main_table REGCLASS, if_exists BOOL = false) RETURNS VOID
CREATE OR REPLACE FUNCTION remove_drop_chunks_policy(hypertable REGCLASS, if_exists BOOL = false) RETURNS VOID
AS '@MODULE_PATHNAME@', 'ts_remove_drop_chunks_policy'
LANGUAGE C VOLATILE STRICT;
CREATE OR REPLACE FUNCTION remove_reorder_policy(main_table REGCLASS, if_exists BOOL = false) RETURNS VOID
CREATE OR REPLACE FUNCTION remove_reorder_policy(hypertable REGCLASS, if_exists BOOL = false) RETURNS VOID
AS '@MODULE_PATHNAME@', 'ts_remove_reorder_policy'
LANGUAGE C VOLATILE STRICT;
-- Returns the updated job schedule values
CREATE OR REPLACE FUNCTION alter_policy_schedule(
CREATE OR REPLACE FUNCTION alter_job_schedule(
job_id INTEGER,
schedule_interval INTERVAL = NULL,
max_runtime INTERVAL = NULL,
@ -46,5 +46,5 @@ CREATE OR REPLACE FUNCTION alter_policy_schedule(
retry_period INTERVAL = NULL,
if_exists BOOL = FALSE)
RETURNS TABLE (job_id INTEGER, schedule_interval INTERVAL, max_runtime INTERVAL, max_retries INTEGER, retry_period INTERVAL)
AS '@MODULE_PATHNAME@', 'ts_alter_policy_schedule'
AS '@MODULE_PATHNAME@', 'ts_alter_job_schedule'
LANGUAGE C VOLATILE;

View File

@ -17,7 +17,7 @@ TS_FUNCTION_INFO_V1(ts_add_drop_chunks_policy);
TS_FUNCTION_INFO_V1(ts_add_reorder_policy);
TS_FUNCTION_INFO_V1(ts_remove_drop_chunks_policy);
TS_FUNCTION_INFO_V1(ts_remove_reorder_policy);
TS_FUNCTION_INFO_V1(ts_alter_policy_schedule);
TS_FUNCTION_INFO_V1(ts_alter_job_schedule);
TS_FUNCTION_INFO_V1(ts_reorder_chunk);
Datum
@ -45,9 +45,9 @@ ts_remove_reorder_policy(PG_FUNCTION_ARGS)
}
Datum
ts_alter_policy_schedule(PG_FUNCTION_ARGS)
ts_alter_job_schedule(PG_FUNCTION_ARGS)
{
PG_RETURN_DATUM(ts_cm_functions->alter_policy_schedule(fcinfo));
PG_RETURN_DATUM(ts_cm_functions->alter_job_schedule(fcinfo));
}
Datum
@ -169,7 +169,7 @@ TSDLLEXPORT CrossModuleFunctions ts_cm_functions_default = {
.gapfill_date_time_bucket = error_no_default_fn_pg_community,
.gapfill_timestamp_time_bucket = error_no_default_fn_pg_community,
.gapfill_timestamptz_time_bucket = error_no_default_fn_pg_community,
.alter_policy_schedule = error_no_default_fn_pg_enterprise,
.alter_job_schedule = error_no_default_fn_pg_enterprise,
.reorder_chunk = error_no_default_fn_pg_community,
};

View File

@ -49,7 +49,7 @@ typedef struct CrossModuleFunctions
PGFunction gapfill_date_time_bucket;
PGFunction gapfill_timestamp_time_bucket;
PGFunction gapfill_timestamptz_time_bucket;
PGFunction alter_policy_schedule;
PGFunction alter_job_schedule;
PGFunction reorder_chunk;
} CrossModuleFunctions;

View File

@ -17,7 +17,7 @@ ORDER BY proname;
add_dimension
add_drop_chunks_policy
add_reorder_policy
alter_policy_schedule
alter_job_schedule
attach_tablespace
chunk_relation_size
chunk_relation_size_pretty

View File

@ -174,7 +174,7 @@ tsl_bgw_policy_job_execute(BgwJob *job)
}
Datum
bgw_policy_alter_policy_schedule(PG_FUNCTION_ARGS)
bgw_policy_alter_job_schedule(PG_FUNCTION_ARGS)
{
BgwJob *job;
TupleDesc tupdesc;

View File

@ -21,6 +21,6 @@ extern bool execute_reorder_policy(BgwJob *job, reorder_func reorder, bool fast_
extern bool execute_drop_chunks_policy(int32 job_id);
extern bool tsl_bgw_policy_job_execute(BgwJob *job);
extern Datum bgw_policy_alter_policy_schedule(PG_FUNCTION_ARGS);
extern Datum bgw_policy_alter_job_schedule(PG_FUNCTION_ARGS);
#endif /* TIMESCALEDB_TSL_BGW_POLICY_JOB_H */

View File

@ -62,7 +62,7 @@ CrossModuleFunctions tsl_cm_functions = {
.gapfill_date_time_bucket = ts_date_bucket,
.gapfill_timestamp_time_bucket = ts_timestamp_bucket,
.gapfill_timestamptz_time_bucket = ts_timestamptz_bucket,
.alter_policy_schedule = bgw_policy_alter_policy_schedule,
.alter_job_schedule = bgw_policy_alter_job_schedule,
.reorder_chunk = tsl_reorder_chunk,
};

View File

@ -387,8 +387,8 @@ SELECT COUNT(*) FROM _timescaledb_catalog.chunk as c, _timescaledb_catalog.hyper
SELECT add_drop_chunks_policy('test_drop_chunks_table', INTERVAL '4 months') as drop_chunks_job_id \gset
WARNING: Timescale License expired
SELECT alter_policy_schedule(:drop_chunks_job_id, schedule_interval => INTERVAL '1 second');
alter_policy_schedule
SELECT alter_job_schedule(:drop_chunks_job_id, schedule_interval => INTERVAL '1 second');
alter_job_schedule
---------------------------------------------
(1001,"@ 1 sec","@ 5 mins",-1,"@ 12 hours")
(1 row)

View File

@ -668,70 +668,70 @@ select add_reorder_policy('test_table', 'test_table_time_idx') as job_id \gset
(1 row)
-- No change
select * from alter_policy_schedule(:job_id);
select * from alter_job_schedule(:job_id);
job_id | schedule_interval | max_runtime | max_retries | retry_period
--------+-------------------+-------------+-------------+--------------
1013 | @ 84 hours | @ 0 | -1 | @ 1 day
(1 row)
-- Changes expected
select * from alter_policy_schedule(:job_id, INTERVAL '3 years', INTERVAL '5 min', 5, INTERVAL '123 sec');
select * from alter_job_schedule(:job_id, INTERVAL '3 years', INTERVAL '5 min', 5, INTERVAL '123 sec');
job_id | schedule_interval | max_runtime | max_retries | retry_period
--------+-------------------+-------------+-------------+-----------------
1013 | @ 3 years | @ 5 mins | 5 | @ 2 mins 3 secs
(1 row)
select * from alter_policy_schedule(:job_id, INTERVAL '123 years');
select * from alter_job_schedule(:job_id, INTERVAL '123 years');
job_id | schedule_interval | max_runtime | max_retries | retry_period
--------+-------------------+-------------+-------------+-----------------
1013 | @ 123 years | @ 5 mins | 5 | @ 2 mins 3 secs
(1 row)
select * from alter_policy_schedule(:job_id, retry_period => INTERVAL '33 hours');
select * from alter_job_schedule(:job_id, retry_period => INTERVAL '33 hours');
job_id | schedule_interval | max_runtime | max_retries | retry_period
--------+-------------------+-------------+-------------+--------------
1013 | @ 123 years | @ 5 mins | 5 | @ 33 hours
(1 row)
select * from alter_policy_schedule(:job_id, max_runtime => INTERVAL '456 sec');
select * from alter_job_schedule(:job_id, max_runtime => INTERVAL '456 sec');
job_id | schedule_interval | max_runtime | max_retries | retry_period
--------+-------------------+------------------+-------------+--------------
1013 | @ 123 years | @ 7 mins 36 secs | 5 | @ 33 hours
(1 row)
select * from alter_policy_schedule(:job_id, max_retries => 0);
select * from alter_job_schedule(:job_id, max_retries => 0);
job_id | schedule_interval | max_runtime | max_retries | retry_period
--------+-------------------+------------------+-------------+--------------
1013 | @ 123 years | @ 7 mins 36 secs | 0 | @ 33 hours
(1 row)
select * from alter_policy_schedule(:job_id, max_retries => -1);
select * from alter_job_schedule(:job_id, max_retries => -1);
job_id | schedule_interval | max_runtime | max_retries | retry_period
--------+-------------------+------------------+-------------+--------------
1013 | @ 123 years | @ 7 mins 36 secs | -1 | @ 33 hours
(1 row)
select * from alter_policy_schedule(:job_id, max_retries => 20);
select * from alter_job_schedule(:job_id, max_retries => 20);
job_id | schedule_interval | max_runtime | max_retries | retry_period
--------+-------------------+------------------+-------------+--------------
1013 | @ 123 years | @ 7 mins 36 secs | 20 | @ 33 hours
(1 row)
-- No change
select * from alter_policy_schedule(:job_id, max_runtime => NULL);
select * from alter_job_schedule(:job_id, max_runtime => NULL);
job_id | schedule_interval | max_runtime | max_retries | retry_period
--------+-------------------+------------------+-------------+--------------
1013 | @ 123 years | @ 7 mins 36 secs | 20 | @ 33 hours
(1 row)
select * from alter_policy_schedule(:job_id, max_retries => NULL);
select * from alter_job_schedule(:job_id, max_retries => NULL);
job_id | schedule_interval | max_runtime | max_retries | retry_period
--------+-------------------+------------------+-------------+--------------
1013 | @ 123 years | @ 7 mins 36 secs | 20 | @ 33 hours
(1 row)
-- Check if_exists boolean works correctly
select * from alter_policy_schedule(1234, if_exists => TRUE);
select * from alter_job_schedule(1234, if_exists => TRUE);
NOTICE: cannot alter policy schedule, policy #1234 not found, skipping
job_id | schedule_interval | max_runtime | max_retries | retry_period
--------+-------------------+-------------+-------------+--------------
@ -739,7 +739,7 @@ NOTICE: cannot alter policy schedule, policy #1234 not found, skipping
(1 row)
\set ON_ERROR_STOP 0
select * from alter_policy_schedule(1234);
select * from alter_job_schedule(1234);
ERROR: cannot alter policy schedule, policy #1234 not found
\set ON_ERROR_STOP 1
select remove_reorder_policy('test_table');
@ -760,6 +760,6 @@ select remove_reorder_policy('test_table');
ERROR: cannot execute an enterprise function with an invalid enterprise license
select remove_drop_chunks_policy('test_table');
ERROR: cannot execute an enterprise function with an invalid enterprise license
select alter_policy_schedule(12345);
select alter_job_schedule(12345);
ERROR: cannot execute an enterprise function with an invalid enterprise license
\set ON_ERROR_STOP 1

View File

@ -210,7 +210,7 @@ SELECT COUNT(*) FROM _timescaledb_catalog.chunk as c, _timescaledb_catalog.hyper
SELECT add_drop_chunks_policy('test_drop_chunks_table', INTERVAL '4 months') as drop_chunks_job_id \gset
SELECT alter_policy_schedule(:drop_chunks_job_id, schedule_interval => INTERVAL '1 second');
SELECT alter_job_schedule(:drop_chunks_job_id, schedule_interval => INTERVAL '1 second');
select * from _timescaledb_config.bgw_policy_drop_chunks where job_id=:drop_chunks_job_id;

View File

@ -257,25 +257,25 @@ select * from _timescaledb_config.bgw_job where job_type in ('drop_chunks', 'reo
select add_reorder_policy('test_table', 'test_table_time_idx') as job_id \gset
select * from _timescaledb_config.bgw_job where id=:job_id;
-- No change
select * from alter_policy_schedule(:job_id);
select * from alter_job_schedule(:job_id);
-- Changes expected
select * from alter_policy_schedule(:job_id, INTERVAL '3 years', INTERVAL '5 min', 5, INTERVAL '123 sec');
select * from alter_policy_schedule(:job_id, INTERVAL '123 years');
select * from alter_policy_schedule(:job_id, retry_period => INTERVAL '33 hours');
select * from alter_policy_schedule(:job_id, max_runtime => INTERVAL '456 sec');
select * from alter_policy_schedule(:job_id, max_retries => 0);
select * from alter_policy_schedule(:job_id, max_retries => -1);
select * from alter_policy_schedule(:job_id, max_retries => 20);
select * from alter_job_schedule(:job_id, INTERVAL '3 years', INTERVAL '5 min', 5, INTERVAL '123 sec');
select * from alter_job_schedule(:job_id, INTERVAL '123 years');
select * from alter_job_schedule(:job_id, retry_period => INTERVAL '33 hours');
select * from alter_job_schedule(:job_id, max_runtime => INTERVAL '456 sec');
select * from alter_job_schedule(:job_id, max_retries => 0);
select * from alter_job_schedule(:job_id, max_retries => -1);
select * from alter_job_schedule(:job_id, max_retries => 20);
-- No change
select * from alter_policy_schedule(:job_id, max_runtime => NULL);
select * from alter_policy_schedule(:job_id, max_retries => NULL);
select * from alter_job_schedule(:job_id, max_runtime => NULL);
select * from alter_job_schedule(:job_id, max_retries => NULL);
-- Check if_exists boolean works correctly
select * from alter_policy_schedule(1234, if_exists => TRUE);
select * from alter_job_schedule(1234, if_exists => TRUE);
\set ON_ERROR_STOP 0
select * from alter_policy_schedule(1234);
select * from alter_job_schedule(1234);
\set ON_ERROR_STOP 1
select remove_reorder_policy('test_table');
@ -289,5 +289,5 @@ select add_reorder_policy('test_table', 'test_table_time_idx');
select add_drop_chunks_policy('test_table', INTERVAL '4 months', true);
select remove_reorder_policy('test_table');
select remove_drop_chunks_policy('test_table');
select alter_policy_schedule(12345);
select alter_job_schedule(12345);
\set ON_ERROR_STOP 1