diff --git a/src/backend/timeseries/sql/udfs/create_missing_partitions/10.2-1.sql b/src/backend/timeseries/sql/udfs/create_missing_partitions/10.2-1.sql index 89a086a11..ea19a18b9 100644 --- a/src/backend/timeseries/sql/udfs/create_missing_partitions/10.2-1.sql +++ b/src/backend/timeseries/sql/udfs/create_missing_partitions/10.2-1.sql @@ -1,7 +1,7 @@ CREATE OR REPLACE FUNCTION pg_catalog.create_missing_partitions( - table_name regclass, - to_date timestamptz, - start_from timestamptz DEFAULT NULL) + table_name regclass, + to_date timestamptz, + start_from timestamptz DEFAULT NULL) returns boolean LANGUAGE plpgsql AS $$ @@ -38,7 +38,7 @@ BEGIN END; $$; COMMENT ON FUNCTION pg_catalog.create_missing_partitions( - table_name regclass, - to_date timestamptz, - start_from timestamptz) + table_name regclass, + to_date timestamptz, + start_from timestamptz) IS 'create missing partitions for the given timeseries table and range'; diff --git a/src/backend/timeseries/sql/udfs/create_missing_partitions/latest.sql b/src/backend/timeseries/sql/udfs/create_missing_partitions/latest.sql index 89a086a11..ea19a18b9 100644 --- a/src/backend/timeseries/sql/udfs/create_missing_partitions/latest.sql +++ b/src/backend/timeseries/sql/udfs/create_missing_partitions/latest.sql @@ -1,7 +1,7 @@ CREATE OR REPLACE FUNCTION pg_catalog.create_missing_partitions( - table_name regclass, - to_date timestamptz, - start_from timestamptz DEFAULT NULL) + table_name regclass, + to_date timestamptz, + start_from timestamptz DEFAULT NULL) returns boolean LANGUAGE plpgsql AS $$ @@ -38,7 +38,7 @@ BEGIN END; $$; COMMENT ON FUNCTION pg_catalog.create_missing_partitions( - table_name regclass, - to_date timestamptz, - start_from timestamptz) + table_name regclass, + to_date timestamptz, + start_from timestamptz) IS 'create missing partitions for the given timeseries table and range'; diff --git a/src/backend/timeseries/sql/udfs/create_timeseries_table/10.2-1.sql b/src/backend/timeseries/sql/udfs/create_timeseries_table/10.2-1.sql index 67d434333..61704b180 100644 --- a/src/backend/timeseries/sql/udfs/create_timeseries_table/10.2-1.sql +++ b/src/backend/timeseries/sql/udfs/create_timeseries_table/10.2-1.sql @@ -5,7 +5,7 @@ CREATE OR REPLACE FUNCTION pg_catalog.create_timeseries_table( premake_interval_count int DEFAULT NULL, start_from timestamptz 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 LANGUAGE C AS 'MODULE_PATHNAME', 'create_timeseries_table'; @@ -20,5 +20,3 @@ COMMENT ON FUNCTION pg_catalog.create_timeseries_table( compression_threshold INTERVAL, retention_threshold INTERVAL) IS 'creates a citus timeseries table which will be autopartitioned'; - --- TODO: Add note about alter won't change existing tables diff --git a/src/backend/timeseries/sql/udfs/create_timeseries_table/latest.sql b/src/backend/timeseries/sql/udfs/create_timeseries_table/latest.sql index 0799c12c4..61704b180 100644 --- a/src/backend/timeseries/sql/udfs/create_timeseries_table/latest.sql +++ b/src/backend/timeseries/sql/udfs/create_timeseries_table/latest.sql @@ -5,7 +5,7 @@ CREATE OR REPLACE FUNCTION pg_catalog.create_timeseries_table( premake_interval_count int DEFAULT NULL, start_from timestamptz 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 LANGUAGE C AS 'MODULE_PATHNAME', 'create_timeseries_table'; diff --git a/src/backend/timeseries/sql/udfs/drop_timeseries_table_metadata/latest.sql b/src/backend/timeseries/sql/udfs/drop_timeseries_table_metadata/latest.sql index b98e33450..f79fe0d7f 100644 --- a/src/backend/timeseries/sql/udfs/drop_timeseries_table_metadata/latest.sql +++ b/src/backend/timeseries/sql/udfs/drop_timeseries_table_metadata/latest.sql @@ -6,4 +6,4 @@ AS 'MODULE_PATHNAME', 'drop_timeseries_table_metadata'; COMMENT ON FUNCTION pg_catalog.drop_timeseries_table_metadata( logicalrelid regclass) -IS 'drop a citus timeseries table''s metadata'; +IS 'drops citus timeseries table''s metadata'; diff --git a/src/backend/timeseries/sql/udfs/get_missing_partition_ranges/10.2-1.sql b/src/backend/timeseries/sql/udfs/get_missing_partition_ranges/10.2-1.sql index a543967fd..b4505aff7 100644 --- a/src/backend/timeseries/sql/udfs/get_missing_partition_ranges/10.2-1.sql +++ b/src/backend/timeseries/sql/udfs/get_missing_partition_ranges/10.2-1.sql @@ -1,11 +1,10 @@ CREATE OR REPLACE FUNCTION pg_catalog.get_missing_partition_ranges( - table_name regclass, - to_date timestamptz, - start_from timestamptz DEFAULT NULL) + table_name regclass, + to_date timestamptz, + start_from timestamptz DEFAULT NULL) returns table( range_from_value text, - range_to_value text -) + range_to_value text) LANGUAGE plpgsql AS $$ DECLARE @@ -48,7 +47,8 @@ BEGIN INTO current_range_from_value, current_range_to_value FROM pg_catalog.time_partitions 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 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 FROM pg_catalog.time_partitions WHERE parent_table = table_name - ORDER BY from_value::timestamptz; + ORDER BY from_value::timestamptz ASC + LIMIT 1; END IF; /* @@ -148,7 +149,7 @@ BEGIN END; $$; COMMENT ON FUNCTION pg_catalog.create_missing_partitions( - table_name regclass, - to_date timestamptz, - start_from timestamptz) + table_name regclass, + to_date timestamptz, + start_from timestamptz) IS 'create missing partitions for the given timeseries table'; diff --git a/src/backend/timeseries/sql/udfs/get_missing_partition_ranges/latest.sql b/src/backend/timeseries/sql/udfs/get_missing_partition_ranges/latest.sql index a543967fd..b4505aff7 100644 --- a/src/backend/timeseries/sql/udfs/get_missing_partition_ranges/latest.sql +++ b/src/backend/timeseries/sql/udfs/get_missing_partition_ranges/latest.sql @@ -1,11 +1,10 @@ CREATE OR REPLACE FUNCTION pg_catalog.get_missing_partition_ranges( - table_name regclass, - to_date timestamptz, - start_from timestamptz DEFAULT NULL) + table_name regclass, + to_date timestamptz, + start_from timestamptz DEFAULT NULL) returns table( range_from_value text, - range_to_value text -) + range_to_value text) LANGUAGE plpgsql AS $$ DECLARE @@ -48,7 +47,8 @@ BEGIN INTO current_range_from_value, current_range_to_value FROM pg_catalog.time_partitions 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 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 FROM pg_catalog.time_partitions WHERE parent_table = table_name - ORDER BY from_value::timestamptz; + ORDER BY from_value::timestamptz ASC + LIMIT 1; END IF; /* @@ -148,7 +149,7 @@ BEGIN END; $$; COMMENT ON FUNCTION pg_catalog.create_missing_partitions( - table_name regclass, - to_date timestamptz, - start_from timestamptz) + table_name regclass, + to_date timestamptz, + start_from timestamptz) IS 'create missing partitions for the given timeseries table';