Address reviews except partition naming related ones

velioglu/create_timeseries_table
Burak Velioglu 2021-08-27 23:36:45 +03:00
parent 8f179fbb83
commit fa3f661421
No known key found for this signature in database
GPG Key ID: F6827E620F6549C6
7 changed files with 37 additions and 37 deletions

View File

@ -1,7 +1,7 @@
CREATE OR REPLACE FUNCTION pg_catalog.create_missing_partitions( CREATE OR REPLACE FUNCTION pg_catalog.create_missing_partitions(
table_name regclass, table_name regclass,
to_date timestamptz, to_date timestamptz,
start_from timestamptz DEFAULT NULL) start_from timestamptz DEFAULT NULL)
returns boolean returns boolean
LANGUAGE plpgsql LANGUAGE plpgsql
AS $$ AS $$
@ -38,7 +38,7 @@ BEGIN
END; END;
$$; $$;
COMMENT ON FUNCTION pg_catalog.create_missing_partitions( COMMENT ON FUNCTION pg_catalog.create_missing_partitions(
table_name regclass, table_name regclass,
to_date timestamptz, to_date timestamptz,
start_from timestamptz) start_from timestamptz)
IS 'create missing partitions for the given timeseries table and range'; IS 'create missing partitions for the given timeseries table and range';

View File

@ -1,7 +1,7 @@
CREATE OR REPLACE FUNCTION pg_catalog.create_missing_partitions( CREATE OR REPLACE FUNCTION pg_catalog.create_missing_partitions(
table_name regclass, table_name regclass,
to_date timestamptz, to_date timestamptz,
start_from timestamptz DEFAULT NULL) start_from timestamptz DEFAULT NULL)
returns boolean returns boolean
LANGUAGE plpgsql LANGUAGE plpgsql
AS $$ AS $$
@ -38,7 +38,7 @@ BEGIN
END; END;
$$; $$;
COMMENT ON FUNCTION pg_catalog.create_missing_partitions( COMMENT ON FUNCTION pg_catalog.create_missing_partitions(
table_name regclass, table_name regclass,
to_date timestamptz, to_date timestamptz,
start_from timestamptz) start_from timestamptz)
IS 'create missing partitions for the given timeseries table and range'; IS 'create missing partitions for the given timeseries table and range';

View File

@ -5,7 +5,7 @@ CREATE OR REPLACE FUNCTION pg_catalog.create_timeseries_table(
premake_interval_count int DEFAULT NULL, premake_interval_count int DEFAULT NULL,
start_from timestamptz DEFAULT NULL, start_from timestamptz DEFAULT NULL,
compression_threshold INTERVAL DEFAULT NULL, compression_threshold INTERVAL DEFAULT NULL,
retention_threshold INTERVAL DEFAULT NULL) -- can change the order with compression, raise a message about dropping data retention_threshold INTERVAL DEFAULT NULL)
RETURNS void RETURNS void
LANGUAGE C LANGUAGE C
AS 'MODULE_PATHNAME', 'create_timeseries_table'; AS 'MODULE_PATHNAME', 'create_timeseries_table';
@ -20,5 +20,3 @@ COMMENT ON FUNCTION pg_catalog.create_timeseries_table(
compression_threshold INTERVAL, compression_threshold INTERVAL,
retention_threshold INTERVAL) retention_threshold INTERVAL)
IS 'creates a citus timeseries table which will be autopartitioned'; IS 'creates a citus timeseries table which will be autopartitioned';
-- TODO: Add note about alter won't change existing tables

View File

@ -5,7 +5,7 @@ CREATE OR REPLACE FUNCTION pg_catalog.create_timeseries_table(
premake_interval_count int DEFAULT NULL, premake_interval_count int DEFAULT NULL,
start_from timestamptz DEFAULT NULL, start_from timestamptz DEFAULT NULL,
compression_threshold INTERVAL DEFAULT NULL, compression_threshold INTERVAL DEFAULT NULL,
retention_threshold INTERVAL DEFAULT NULL) -- can change the order with compression, raise a message about dropping data retention_threshold INTERVAL DEFAULT NULL)
RETURNS void RETURNS void
LANGUAGE C LANGUAGE C
AS 'MODULE_PATHNAME', 'create_timeseries_table'; AS 'MODULE_PATHNAME', 'create_timeseries_table';

View File

@ -6,4 +6,4 @@ AS 'MODULE_PATHNAME', 'drop_timeseries_table_metadata';
COMMENT ON FUNCTION pg_catalog.drop_timeseries_table_metadata( COMMENT ON FUNCTION pg_catalog.drop_timeseries_table_metadata(
logicalrelid regclass) logicalrelid regclass)
IS 'drop a citus timeseries table''s metadata'; IS 'drops citus timeseries table''s metadata';

View File

@ -1,11 +1,10 @@
CREATE OR REPLACE FUNCTION pg_catalog.get_missing_partition_ranges( CREATE OR REPLACE FUNCTION pg_catalog.get_missing_partition_ranges(
table_name regclass, table_name regclass,
to_date timestamptz, to_date timestamptz,
start_from timestamptz DEFAULT NULL) start_from timestamptz DEFAULT NULL)
returns table( returns table(
range_from_value text, range_from_value text,
range_to_value text range_to_value text)
)
LANGUAGE plpgsql LANGUAGE plpgsql
AS $$ AS $$
DECLARE DECLARE
@ -48,7 +47,8 @@ BEGIN
INTO current_range_from_value, current_range_to_value INTO current_range_from_value, current_range_to_value
FROM pg_catalog.time_partitions FROM pg_catalog.time_partitions
WHERE parent_table = table_name WHERE parent_table = table_name
ORDER BY from_value::timestamptz; ORDER BY from_value::timestamptz ASC
LIMIT 1;
WHILE current_range_from_value > start_from LOOP WHILE current_range_from_value > start_from LOOP
current_range_from_value := current_range_from_value - table_partition_interval; current_range_from_value := current_range_from_value - table_partition_interval;
@ -92,7 +92,8 @@ BEGIN
INTO current_range_from_value, current_range_to_value INTO current_range_from_value, current_range_to_value
FROM pg_catalog.time_partitions FROM pg_catalog.time_partitions
WHERE parent_table = table_name WHERE parent_table = table_name
ORDER BY from_value::timestamptz; ORDER BY from_value::timestamptz ASC
LIMIT 1;
END IF; END IF;
/* /*
@ -148,7 +149,7 @@ BEGIN
END; END;
$$; $$;
COMMENT ON FUNCTION pg_catalog.create_missing_partitions( COMMENT ON FUNCTION pg_catalog.create_missing_partitions(
table_name regclass, table_name regclass,
to_date timestamptz, to_date timestamptz,
start_from timestamptz) start_from timestamptz)
IS 'create missing partitions for the given timeseries table'; IS 'create missing partitions for the given timeseries table';

View File

@ -1,11 +1,10 @@
CREATE OR REPLACE FUNCTION pg_catalog.get_missing_partition_ranges( CREATE OR REPLACE FUNCTION pg_catalog.get_missing_partition_ranges(
table_name regclass, table_name regclass,
to_date timestamptz, to_date timestamptz,
start_from timestamptz DEFAULT NULL) start_from timestamptz DEFAULT NULL)
returns table( returns table(
range_from_value text, range_from_value text,
range_to_value text range_to_value text)
)
LANGUAGE plpgsql LANGUAGE plpgsql
AS $$ AS $$
DECLARE DECLARE
@ -48,7 +47,8 @@ BEGIN
INTO current_range_from_value, current_range_to_value INTO current_range_from_value, current_range_to_value
FROM pg_catalog.time_partitions FROM pg_catalog.time_partitions
WHERE parent_table = table_name WHERE parent_table = table_name
ORDER BY from_value::timestamptz; ORDER BY from_value::timestamptz ASC
LIMIT 1;
WHILE current_range_from_value > start_from LOOP WHILE current_range_from_value > start_from LOOP
current_range_from_value := current_range_from_value - table_partition_interval; current_range_from_value := current_range_from_value - table_partition_interval;
@ -92,7 +92,8 @@ BEGIN
INTO current_range_from_value, current_range_to_value INTO current_range_from_value, current_range_to_value
FROM pg_catalog.time_partitions FROM pg_catalog.time_partitions
WHERE parent_table = table_name WHERE parent_table = table_name
ORDER BY from_value::timestamptz; ORDER BY from_value::timestamptz ASC
LIMIT 1;
END IF; END IF;
/* /*
@ -148,7 +149,7 @@ BEGIN
END; END;
$$; $$;
COMMENT ON FUNCTION pg_catalog.create_missing_partitions( COMMENT ON FUNCTION pg_catalog.create_missing_partitions(
table_name regclass, table_name regclass,
to_date timestamptz, to_date timestamptz,
start_from timestamptz) start_from timestamptz)
IS 'create missing partitions for the given timeseries table'; IS 'create missing partitions for the given timeseries table';