Skip to content

Commit

Permalink
Remove trailing whitespaces from test code
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziomello committed Nov 18, 2022
1 parent 3588d07 commit 210df95
Show file tree
Hide file tree
Showing 135 changed files with 913 additions and 919 deletions.
2 changes: 1 addition & 1 deletion sql/chunk.sql
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ AS '@MODULE_PATHNAME@', 'ts_chunk_show' LANGUAGE C VOLATILE;
-- table will be renamed and/or moved as necessary.
CREATE OR REPLACE FUNCTION _timescaledb_internal.create_chunk(
hypertable REGCLASS,
slices JSONB,
slices JSONB,
schema_name NAME = NULL,
table_name NAME = NULL,
chunk_table REGCLASS = NULL)
Expand Down
4 changes: 2 additions & 2 deletions sql/job_api.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ CREATE OR REPLACE FUNCTION @extschema@.alter_job(
scheduled BOOL = NULL,
config JSONB = NULL,
next_start TIMESTAMPTZ = NULL,
if_exists BOOL = FALSE,
if_exists BOOL = FALSE,
check_config REGPROC = NULL
)
RETURNS TABLE (job_id INTEGER, schedule_interval INTERVAL, max_runtime INTERVAL, max_retries INTEGER, retry_period INTERVAL, scheduled BOOL, config JSONB,
RETURNS TABLE (job_id INTEGER, schedule_interval INTERVAL, max_runtime INTERVAL, max_retries INTEGER, retry_period INTERVAL, scheduled BOOL, config JSONB,
next_start TIMESTAMPTZ, check_config TEXT)
AS '@MODULE_PATHNAME@', 'ts_job_alter'
LANGUAGE C VOLATILE;
Expand Down
28 changes: 14 additions & 14 deletions sql/job_error_log_retention.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
-- LICENSE-APACHE for a copy of the license.

-- A retention policy is set up for the table _timescaledb_internal.job_errors (Error Log Retention Policy [2])
-- By default, it will run once a month and and drop rows older than a month.
-- By default, it will run once a month and and drop rows older than a month.
CREATE OR REPLACE FUNCTION _timescaledb_internal.policy_job_error_retention(job_id integer, config JSONB) RETURNS integer
LANGUAGE PLPGSQL AS
$BODY$
Expand All @@ -23,28 +23,28 @@ END;
$BODY$ SET search_path TO pg_catalog, pg_temp;

CREATE OR REPLACE FUNCTION _timescaledb_internal.policy_job_error_retention_check(config JSONB) RETURNS VOID
LANGUAGE PLPGSQL AS
LANGUAGE PLPGSQL AS
$BODY$
DECLARE
drop_after interval;
BEGIN
BEGIN
IF config IS NULL THEN
RAISE EXCEPTION 'config cannot be NULL, and must contain drop_after';
END IF;
SELECT config->>'drop_after' INTO STRICT drop_after;
IF drop_after IS NULL THEN
IF drop_after IS NULL THEN
RAISE EXCEPTION 'drop_after interval not provided';
END IF ;
END;
$BODY$ SET search_path TO pg_catalog, pg_temp;

INSERT INTO _timescaledb_config.bgw_job (
id,
id,
application_name,
schedule_interval,
schedule_interval,
max_runtime,
max_retries,
retry_period,
retry_period,
proc_schema,
proc_name,
owner,
Expand All @@ -54,18 +54,18 @@ INSERT INTO _timescaledb_config.bgw_job (
check_name,
fixed_schedule,
initial_start
)
VALUES
)
VALUES
(
2,
'Error Log Retention Policy [2]',
2,
'Error Log Retention Policy [2]',
INTERVAL '1 month',
INTERVAL '1 hour',
INTERVAL '1 hour',
-1,
INTERVAL '1h',
'_timescaledb_internal',
'_timescaledb_internal',
'policy_job_error_retention',
CURRENT_ROLE,
CURRENT_ROLE,
true,
'{"drop_after":"1 month"}',
'_timescaledb_internal',
Expand Down
2 changes: 1 addition & 1 deletion sql/maintenance_utils.sql
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ BEGIN
-- 8: compressed partial

chunk_name := parse_ident(chunk::text);
CASE
CASE
WHEN status = 0 THEN
RAISE EXCEPTION 'call compress_chunk instead of recompress_chunk';
WHEN status = 1 THEN
Expand Down
10 changes: 5 additions & 5 deletions sql/policy_api.sql
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ LANGUAGE C VOLATILE STRICT;

/* compression policy */
CREATE OR REPLACE FUNCTION @extschema@.add_compression_policy(
hypertable REGCLASS, compress_after "any",
hypertable REGCLASS, compress_after "any",
if_not_exists BOOL = false,
schedule_interval INTERVAL = NULL,
schedule_interval INTERVAL = NULL,
initial_start TIMESTAMPTZ = NULL,
timezone TEXT = NULL
)
Expand All @@ -61,9 +61,9 @@ LANGUAGE C VOLATILE STRICT;

/* continuous aggregates policy */
CREATE OR REPLACE FUNCTION @extschema@.add_continuous_aggregate_policy(
continuous_aggregate REGCLASS, start_offset "any",
end_offset "any", schedule_interval INTERVAL,
if_not_exists BOOL = false,
continuous_aggregate REGCLASS, start_offset "any",
end_offset "any", schedule_interval INTERVAL,
if_not_exists BOOL = false,
initial_start TIMESTAMPTZ = NULL,
timezone TEXT = NULL
)
Expand Down
2 changes: 1 addition & 1 deletion sql/schema_info.sql
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ CREATE OR REPLACE FUNCTION _timescaledb_internal.is_main_table(
$BODY$
SELECT EXISTS(
SELECT 1 FROM _timescaledb_catalog.hypertable h
WHERE h.schema_name = is_main_table.schema_name AND
WHERE h.schema_name = is_main_table.schema_name AND
h.table_name = is_main_table.table_name
);
$BODY$ SET search_path TO pg_catalog, pg_temp;
Expand Down
40 changes: 20 additions & 20 deletions sql/updates/1.7.5--2.0.0-rc1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -208,29 +208,29 @@ $BODY$;
CREATE FUNCTION _timescaledb_internal.ts_tmp_get_interval( intval bigint)
RETURNS INTERVAL LANGUAGE SQL AS
$BODY$
SELECT format('%sd %ss', intval/86400000000, (intval%86400000000)/1E6)::interval;
SELECT format('%sd %ss', intval/86400000000, (intval%86400000000)/1E6)::interval;
$BODY$;

UPDATE
_timescaledb_config.bgw_job job
SET
application_name = format('%s [%s]', 'Refresh Continuous Aggregate Policy', id),
proc_schema = '_timescaledb_internal',
proc_name = 'policy_refresh_continuous_aggregate',
job_type = 'custom',
config =
CASE WHEN _timescaledb_internal.ts_tmp_get_time_type( cagg.raw_hypertable_id ) IN ('TIMESTAMP'::regtype, 'DATE'::regtype, 'TIMESTAMPTZ'::regtype)
config =
CASE WHEN _timescaledb_internal.ts_tmp_get_time_type( cagg.raw_hypertable_id ) IN ('TIMESTAMP'::regtype, 'DATE'::regtype, 'TIMESTAMPTZ'::regtype)
THEN
jsonb_build_object('mat_hypertable_id', cagg.mat_hypertable_id, 'start_offset',
CASE WHEN cagg.ignore_invalidation_older_than IS NULL OR cagg.ignore_invalidation_older_than = 9223372036854775807
THEN NULL
ELSE _timescaledb_internal.ts_tmp_get_interval(cagg.ignore_invalidation_older_than)::TEXT
END
jsonb_build_object('mat_hypertable_id', cagg.mat_hypertable_id, 'start_offset',
CASE WHEN cagg.ignore_invalidation_older_than IS NULL OR cagg.ignore_invalidation_older_than = 9223372036854775807
THEN NULL
ELSE _timescaledb_internal.ts_tmp_get_interval(cagg.ignore_invalidation_older_than)::TEXT
END
, 'end_offset', _timescaledb_internal.ts_tmp_get_interval(cagg.refresh_lag)::TEXT)
ELSE
jsonb_build_object('mat_hypertable_id', cagg.mat_hypertable_id, 'start_offset',
CASE WHEN cagg.ignore_invalidation_older_than IS NULL OR cagg.ignore_invalidation_older_than = 9223372036854775807
THEN NULL
jsonb_build_object('mat_hypertable_id', cagg.mat_hypertable_id, 'start_offset',
CASE WHEN cagg.ignore_invalidation_older_than IS NULL OR cagg.ignore_invalidation_older_than = 9223372036854775807
THEN NULL
ELSE cagg.ignore_invalidation_older_than::BIGINT
END
, 'end_offset', cagg.refresh_lag::BIGINT)
Expand Down Expand Up @@ -328,20 +328,20 @@ DECLARE
BEGIN
FOR cagg in SELECT * FROM _timescaledb_catalog.continuous_agg
LOOP
SELECT * INTO dimrow
FROM _timescaledb_catalog.dimension dim
SELECT * INTO dimrow
FROM _timescaledb_catalog.dimension dim
WHERE dim.hypertable_id = cagg.raw_hypertable_id AND dim.num_slices IS NULL AND dim.interval_length IS NOT NULL;

IF dimrow.column_type IN ('TIMESTAMP'::regtype, 'DATE'::regtype, 'TIMESTAMPTZ'::regtype)
THEN
IF cagg.ignore_invalidation_older_than IS NULL OR cagg.ignore_invalidation_older_than = 9223372036854775807
IF cagg.ignore_invalidation_older_than IS NULL OR cagg.ignore_invalidation_older_than = 9223372036854775807
THEN
end_val := -210866803200000001;
ELSE
end_val := (extract(epoch from now()) * 1000000 - cagg.ignore_invalidation_older_than)::int8;
END IF;
ELSE
IF cagg.ignore_invalidation_older_than IS NULL OR cagg.ignore_invalidation_older_than = 9223372036854775807
IF cagg.ignore_invalidation_older_than IS NULL OR cagg.ignore_invalidation_older_than = 9223372036854775807
THEN
end_val := -2147483649;
ELSE
Expand All @@ -350,7 +350,7 @@ BEGIN
END IF;
END IF;

INSERT INTO _timescaledb_catalog.continuous_aggs_materialization_invalidation_log
INSERT INTO _timescaledb_catalog.continuous_aggs_materialization_invalidation_log
VALUES (cagg.mat_hypertable_id, -9223372036854775808, -9223372036854775808, end_val);
END LOOP;
END $$;
Expand Down Expand Up @@ -746,7 +746,7 @@ $BODY$
(ch.total_bytes - COALESCE( ch.index_bytes , 0 ) - COALESCE( ch.toast_bytes, 0 ) + COALESCE( ch.compressed_heap_size , 0 ))::bigint as heap_bytes,
(COALESCE( ch.index_bytes, 0 ) + COALESCE( ch.compressed_index_size , 0) )::bigint as index_bytes,
(COALESCE( ch.toast_bytes, 0 ) + COALESCE( ch.compressed_toast_size, 0 ))::bigint as toast_bytes,
(ch.total_bytes + COALESCE( ch.compressed_total_size, 0 ))::bigint as total_bytes
(ch.total_bytes + COALESCE( ch.compressed_total_size, 0 ))::bigint as total_bytes
FROM
_timescaledb_internal.hypertable_chunk_local_size ch
WHERE
Expand Down Expand Up @@ -851,7 +851,7 @@ CREATE FUNCTION @extschema@.hypertable_compression_stats (hypertable REGCLASS)
node_name name)
LANGUAGE SQL
STABLE STRICT
AS
AS
$BODY$
SELECT
count(*)::bigint AS total_chunks,
Expand Down Expand Up @@ -968,7 +968,7 @@ $BODY$;

CREATE FUNCTION @extschema@.hypertable_size(
hypertable REGCLASS)
RETURNS BIGINT
RETURNS BIGINT
LANGUAGE SQL VOLATILE STRICT AS
$BODY$
-- One row per data node is returned (in case of a distributed
Expand Down
64 changes: 32 additions & 32 deletions sql/updates/2.0.0-rc3--2.0.0-rc4.sql
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ SELECT id, schema_name, table_name, associated_schema_name, associated_table_pre
chunk_target_size,
CASE WHEN compressed is FALSE AND compressed_hypertable_id IS NOT NULL THEN 1
WHEN compressed is TRUE THEN 2
ELSE 0
ELSE 0
END,
compressed_hypertable_id,
replication_factor
FROM _timescaledb_internal.hypertable_tmp;

-- add self referential foreign key
ALTER TABLE _timescaledb_catalog.hypertable ADD CONSTRAINT hypertable_compressed_hypertable_id_fkey FOREIGN KEY ( compressed_hypertable_id )
REFERENCES _timescaledb_catalog.hypertable( id );
Expand All @@ -90,39 +90,39 @@ DROP TABLE _timescaledb_internal.hypertable_tmp;
DROP TABLE _timescaledb_internal.tmp_hypertable_seq_value;

-- add all the other foreign keys
ALTER TABLE _timescaledb_catalog.hypertable_data_node
ALTER TABLE _timescaledb_catalog.hypertable_data_node
ADD CONSTRAINT hypertable_data_node_hypertable_id_fkey
FOREIGN KEY ( hypertable_id ) REFERENCES _timescaledb_catalog.hypertable( id );
ALTER TABLE _timescaledb_catalog.tablespace ADD CONSTRAINT tablespace_hypertable_id_fkey
FOREIGN KEY ( hypertable_id ) REFERENCES _timescaledb_catalog.hypertable( id )
ON DELETE CASCADE;
ALTER TABLE _timescaledb_catalog.dimension ADD CONSTRAINT dimension_hypertable_id_fkey
FOREIGN KEY ( hypertable_id ) REFERENCES _timescaledb_catalog.hypertable( id )
ON DELETE CASCADE;
ALTER TABLE _timescaledb_catalog.chunk ADD CONSTRAINT chunk_hypertable_id_fkey
FOREIGN KEY ( hypertable_id ) REFERENCES _timescaledb_catalog.hypertable( id );
ALTER TABLE _timescaledb_catalog.chunk_index ADD CONSTRAINT chunk_index_hypertable_id_fkey
FOREIGN KEY ( hypertable_id ) REFERENCES _timescaledb_catalog.hypertable( id )
ON DELETE CASCADE;
ALTER TABLE _timescaledb_config.bgw_job ADD CONSTRAINT bgw_job_hypertable_id_fkey
FOREIGN KEY ( hypertable_id ) REFERENCES _timescaledb_catalog.hypertable( id );
ALTER TABLE _timescaledb_catalog.tablespace ADD CONSTRAINT tablespace_hypertable_id_fkey
FOREIGN KEY ( hypertable_id ) REFERENCES _timescaledb_catalog.hypertable( id )
ON DELETE CASCADE;
ALTER TABLE _timescaledb_catalog.dimension ADD CONSTRAINT dimension_hypertable_id_fkey
FOREIGN KEY ( hypertable_id ) REFERENCES _timescaledb_catalog.hypertable( id )
ON DELETE CASCADE;
ALTER TABLE _timescaledb_catalog.chunk ADD CONSTRAINT chunk_hypertable_id_fkey
FOREIGN KEY ( hypertable_id ) REFERENCES _timescaledb_catalog.hypertable( id );
ALTER TABLE _timescaledb_catalog.chunk_index ADD CONSTRAINT chunk_index_hypertable_id_fkey
FOREIGN KEY ( hypertable_id ) REFERENCES _timescaledb_catalog.hypertable( id )
ON DELETE CASCADE;
ALTER TABLE _timescaledb_catalog.continuous_agg ADD CONSTRAINT
continuous_agg_mat_hypertable_id_fkey FOREIGN KEY ( mat_hypertable_id )
REFERENCES _timescaledb_catalog.hypertable( id )
ON DELETE CASCADE;
ALTER TABLE _timescaledb_catalog.continuous_agg ADD CONSTRAINT
continuous_agg_raw_hypertable_id_fkey FOREIGN KEY ( raw_hypertable_id )
REFERENCES _timescaledb_catalog.hypertable( id )
ON DELETE CASCADE;
ALTER TABLE _timescaledb_catalog.continuous_aggs_invalidation_threshold
ADD CONSTRAINT continuous_aggs_invalidation_threshold_hypertable_id_fkey
FOREIGN KEY (hypertable_id) REFERENCES _timescaledb_catalog.hypertable( id )
ON DELETE CASCADE;
ALTER TABLE _timescaledb_catalog.hypertable_compression ADD CONSTRAINT
hypertable_compression_hypertable_id_fkey FOREIGN KEY ( hypertable_id )
ON DELETE CASCADE;
ALTER TABLE _timescaledb_config.bgw_job ADD CONSTRAINT bgw_job_hypertable_id_fkey
FOREIGN KEY ( hypertable_id ) REFERENCES _timescaledb_catalog.hypertable( id )
ON DELETE CASCADE;
ALTER TABLE _timescaledb_catalog.continuous_agg ADD CONSTRAINT
continuous_agg_mat_hypertable_id_fkey FOREIGN KEY ( mat_hypertable_id )
REFERENCES _timescaledb_catalog.hypertable( id )
ON DELETE CASCADE;
ALTER TABLE _timescaledb_catalog.continuous_agg ADD CONSTRAINT
continuous_agg_raw_hypertable_id_fkey FOREIGN KEY ( raw_hypertable_id )
REFERENCES _timescaledb_catalog.hypertable( id )
ON DELETE CASCADE;
ALTER TABLE _timescaledb_catalog.continuous_aggs_invalidation_threshold
ADD CONSTRAINT continuous_aggs_invalidation_threshold_hypertable_id_fkey
FOREIGN KEY (hypertable_id) REFERENCES _timescaledb_catalog.hypertable( id )
ON DELETE CASCADE;
ALTER TABLE _timescaledb_catalog.hypertable_compression ADD CONSTRAINT
hypertable_compression_hypertable_id_fkey FOREIGN KEY ( hypertable_id )
REFERENCES _timescaledb_catalog.hypertable( id )
ON DELETE CASCADE;
ON DELETE CASCADE;

GRANT SELECT ON _timescaledb_catalog.hypertable_id_seq TO PUBLIC;
GRANT SELECT ON _timescaledb_catalog.hypertable TO PUBLIC;
Expand Down
32 changes: 16 additions & 16 deletions sql/updates/2.2.1--2.3.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ CREATE TABLE _timescaledb_internal.tmp_chunk_seq_value AS
SELECT last_value, is_called FROM _timescaledb_catalog.chunk_id_seq;

--drop foreign keys on chunk table
ALTER TABLE _timescaledb_catalog.chunk_constraint DROP CONSTRAINT
ALTER TABLE _timescaledb_catalog.chunk_constraint DROP CONSTRAINT
chunk_constraint_chunk_id_fkey;
ALTER TABLE _timescaledb_catalog.chunk_index DROP CONSTRAINT
ALTER TABLE _timescaledb_catalog.chunk_index DROP CONSTRAINT
chunk_index_chunk_id_fkey;
ALTER TABLE _timescaledb_catalog.chunk_data_node DROP CONSTRAINT
ALTER TABLE _timescaledb_catalog.chunk_data_node DROP CONSTRAINT
chunk_data_node_chunk_id_fkey;
ALTER TABLE _timescaledb_internal.bgw_policy_chunk_stats DROP CONSTRAINT
ALTER TABLE _timescaledb_internal.bgw_policy_chunk_stats DROP CONSTRAINT
bgw_policy_chunk_stats_chunk_id_fkey;
ALTER TABLE _timescaledb_catalog.compression_chunk_size DROP CONSTRAINT
ALTER TABLE _timescaledb_catalog.compression_chunk_size DROP CONSTRAINT
compression_chunk_size_chunk_id_fkey;
ALTER TABLE _timescaledb_catalog.compression_chunk_size DROP CONSTRAINT
ALTER TABLE _timescaledb_catalog.compression_chunk_size DROP CONSTRAINT
compression_chunk_size_compressed_chunk_id_fkey;

--drop dependent views
Expand Down Expand Up @@ -69,22 +69,22 @@ SELECT pg_catalog.pg_extension_config_dump('_timescaledb_catalog.chunk', '');
SELECT pg_catalog.pg_extension_config_dump('_timescaledb_catalog.chunk_id_seq', '');

--add the foreign key constraints
ALTER TABLE _timescaledb_catalog.chunk_constraint ADD CONSTRAINT
chunk_constraint_chunk_id_fkey FOREIGN KEY (chunk_id) REFERENCES _timescaledb_catalog.chunk(id);
ALTER TABLE _timescaledb_catalog.chunk_constraint ADD CONSTRAINT
chunk_constraint_chunk_id_fkey FOREIGN KEY (chunk_id) REFERENCES _timescaledb_catalog.chunk(id);
ALTER TABLE _timescaledb_catalog.chunk_index ADD CONSTRAINT
chunk_index_chunk_id_fkey FOREIGN KEY (chunk_id)
chunk_index_chunk_id_fkey FOREIGN KEY (chunk_id)
REFERENCES _timescaledb_catalog.chunk(id) ON DELETE CASCADE;
ALTER TABLE _timescaledb_catalog.chunk_data_node ADD CONSTRAINT
chunk_data_node_chunk_id_fkey FOREIGN KEY (chunk_id) REFERENCES _timescaledb_catalog.chunk(id);
chunk_data_node_chunk_id_fkey FOREIGN KEY (chunk_id) REFERENCES _timescaledb_catalog.chunk(id);
ALTER TABLE _timescaledb_internal.bgw_policy_chunk_stats ADD CONSTRAINT
bgw_policy_chunk_stats_chunk_id_fkey FOREIGN KEY (chunk_id)
REFERENCES _timescaledb_catalog.chunk(id) ON DELETE CASCADE;
bgw_policy_chunk_stats_chunk_id_fkey FOREIGN KEY (chunk_id)
REFERENCES _timescaledb_catalog.chunk(id) ON DELETE CASCADE;
ALTER TABLE _timescaledb_catalog.compression_chunk_size ADD CONSTRAINT
compression_chunk_size_chunk_id_fkey FOREIGN KEY (chunk_id)
REFERENCES _timescaledb_catalog.chunk(id) ON DELETE CASCADE;
compression_chunk_size_chunk_id_fkey FOREIGN KEY (chunk_id)
REFERENCES _timescaledb_catalog.chunk(id) ON DELETE CASCADE;
ALTER TABLE _timescaledb_catalog.compression_chunk_size ADD CONSTRAINT
compression_chunk_size_compressed_chunk_id_fkey FOREIGN KEY (compressed_chunk_id)
REFERENCES _timescaledb_catalog.chunk(id) ON DELETE CASCADE;
compression_chunk_size_compressed_chunk_id_fkey FOREIGN KEY (compressed_chunk_id)
REFERENCES _timescaledb_catalog.chunk(id) ON DELETE CASCADE;

--cleanup
DROP TABLE _timescaledb_internal.chunk_tmp;
Expand Down
2 changes: 1 addition & 1 deletion sql/updates/2.6.0--2.5.2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ BEGIN
cnt := cnt + 1;
END LOOP;
IF cnt > 0 THEN
RAISE EXCEPTION 'cannot downgrade as compression is enabled for continuous aggregates'
RAISE EXCEPTION 'cannot downgrade as compression is enabled for continuous aggregates'
USING DETAIL = 'Please disable compression on all continuous aggregates before downgrading.',
HINT = 'To disable compression, call decompress_chunk to decompress chunks, then drop any existing compression policy on the continuous aggregate, and finally run ALTER MATERIALIZED VIEW % SET timescaledb.compress = ''false''. ';
END IF;
Expand Down

0 comments on commit 210df95

Please sign in to comment.