timescaledb/sql/updates/latest-dev.sql
Konstantina Skovola dc145b7485 Add parameter check_config to alter_job
Previously users had no way to update the check function
registered with add_job. This commit adds a parameter check_config
to alter_job to allow updating the check function field.

Also, previously the signature expected from a check was of
the form (job_id, config) and there was no validation
that the check function given had the correct signature.
This commit removes the job_id as it is not required and
also checks that the check function has the correct signature
when it is registered with add_job, preventing an error being
thrown at job runtime.
2022-08-25 10:38:03 +03:00

73 lines
2.6 KiB
SQL

DROP FUNCTION IF EXISTS @extschema@.add_retention_policy(REGCLASS, "any", BOOL);
DROP FUNCTION IF EXISTS @extschema@.add_compression_policy(REGCLASS, "any", BOOL);
DROP FUNCTION IF EXISTS @extschema@.detach_data_node;
CREATE TABLE _timescaledb_catalog.dimension_partition (
dimension_id integer NOT NULL REFERENCES _timescaledb_catalog.dimension (id) ON DELETE CASCADE,
range_start bigint NOT NULL,
data_nodes name[] NULL,
UNIQUE (dimension_id, range_start)
);
SELECT pg_catalog.pg_extension_config_dump('_timescaledb_catalog.dimension_partition', '');
GRANT SELECT ON _timescaledb_catalog.dimension_partition TO PUBLIC;
DROP FUNCTION IF EXISTS @extschema@.remove_continuous_aggregate_policy(REGCLASS, BOOL);
-- add a new column to chunk catalog table
ALTER TABLE _timescaledb_catalog.chunk ADD COLUMN osm_chunk boolean ;
UPDATE _timescaledb_catalog.chunk SET osm_chunk = FALSE;
ALTER TABLE _timescaledb_catalog.chunk
ALTER COLUMN osm_chunk SET NOT NULL;
ALTER TABLE _timescaledb_catalog.chunk
ALTER COLUMN osm_chunk SET DEFAULT FALSE;
CREATE INDEX chunk_osm_chunk_idx ON _timescaledb_catalog.chunk (osm_chunk, hypertable_id);
DROP FUNCTION IF EXISTS @extschema@.add_job(REGPROC, INTERVAL, JSONB, TIMESTAMPTZ, BOOL);
DROP FUNCTION IF EXISTS @extschema@.alter_job(INTEGER, INTERVAL, INTERVAL, INTEGER, INTERVAL, BOOL, JSONB, TIMESTAMPTZ, BOOL);
-- add fields for check function
ALTER TABLE _timescaledb_config.bgw_job
ADD COLUMN check_schema NAME,
ADD COLUMN check_name NAME;
-- no need to touch the telemetry jobs since they do not have a check
-- function.
-- add check function to reorder jobs
UPDATE
_timescaledb_config.bgw_job job
SET
check_schema = '_timescaledb_internal',
check_name = 'policy_reorder_check'
WHERE proc_schema = '_timescaledb_internal'
AND proc_name = 'policy_reorder';
-- add check function to compression jobs
UPDATE
_timescaledb_config.bgw_job job
SET
check_schema = '_timescaledb_internal',
check_name = 'policy_compression_check'
WHERE proc_schema = '_timescaledb_internal'
AND proc_name = 'policy_compression';
-- add check function to retention jobs
UPDATE
_timescaledb_config.bgw_job job
SET
check_schema = '_timescaledb_internal',
check_name = 'policy_retention_check'
WHERE proc_schema = '_timescaledb_internal'
AND proc_name = 'policy_retention';
-- add check function to continuous aggregate refresh jobs
UPDATE
_timescaledb_config.bgw_job job
SET
check_schema = '_timescaledb_internal',
check_name = 'policy_refresh_continuous_aggregate_check'
WHERE proc_schema = '_timescaledb_internal'
AND proc_name = 'policy_refresh_continuous_aggregate';
DROP VIEW IF EXISTS timescaledb_information.jobs;