mirror of https://github.com/citusdata/citus.git
Address reviews
parent
f25c434147
commit
d83f94ce8e
|
@ -16,4 +16,4 @@ ALTER TABLE pg_catalog.pg_dist_placement ADD CONSTRAINT placement_shardid_groupi
|
|||
#include "udfs/citus_internal_update_placement_metadata/10.2-1.sql";
|
||||
#include "udfs/citus_internal_delete_shard_metadata/10.2-1.sql";
|
||||
#include "udfs/citus_internal_update_relation_colocation/10.2-1.sql";
|
||||
#include "udfs/expire_old_time_partitions/10.2-1.sql";
|
||||
#include "udfs/drop_old_time_partitions/10.2-1.sql";
|
||||
|
|
|
@ -17,7 +17,7 @@ DROP FUNCTION pg_catalog.citus_internal_add_placement_metadata(bigint, integer,
|
|||
DROP FUNCTION pg_catalog.citus_internal_update_placement_metadata(bigint, integer, integer);
|
||||
DROP FUNCTION pg_catalog.citus_internal_delete_shard_metadata(bigint);
|
||||
DROP FUNCTION pg_catalog.citus_internal_update_relation_colocation(oid, integer);
|
||||
DROP PROCEDURE pg_catalog.expire_old_time_partitions(regclass, timestamptz);
|
||||
DROP PROCEDURE pg_catalog.drop_old_time_partitions(regclass, timestamptz);
|
||||
|
||||
REVOKE ALL ON FUNCTION pg_catalog.worker_record_sequence_dependency(regclass,regclass,name) FROM PUBLIC;
|
||||
ALTER TABLE pg_catalog.pg_dist_placement DROP CONSTRAINT placement_shardid_groupid_unique_index;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
-- Heavily inspired by the procedure alter_old_partitions_set_access_method
|
||||
CREATE OR REPLACE PROCEDURE pg_catalog.expire_old_time_partitions(
|
||||
CREATE OR REPLACE PROCEDURE pg_catalog.drop_old_time_partitions(
|
||||
parent_table_name regclass,
|
||||
older_than timestamptz)
|
||||
LANGUAGE plpgsql
|
||||
|
@ -28,12 +28,12 @@ BEGIN
|
|||
ORDER BY to_value::timestamptz
|
||||
LOOP
|
||||
RAISE NOTICE 'dropping % with start time % and end time %', r.partition, r.from_value, r.to_value;
|
||||
EXECUTE format('DROP TABLE %I', r.partition);
|
||||
EXECUTE format('DROP TABLE %s', r.partition);
|
||||
COMMIT;
|
||||
END LOOP;
|
||||
END;
|
||||
$$;
|
||||
COMMENT ON PROCEDURE pg_catalog.expire_old_time_partitions(
|
||||
COMMENT ON PROCEDURE pg_catalog.drop_old_time_partitions(
|
||||
parent_table_name regclass,
|
||||
older_than timestamptz)
|
||||
IS 'drop old partitions of a time-partitioned table';
|
|
@ -1,5 +1,5 @@
|
|||
-- Heavily inspired by the procedure alter_old_partitions_set_access_method
|
||||
CREATE OR REPLACE PROCEDURE pg_catalog.expire_old_time_partitions(
|
||||
CREATE OR REPLACE PROCEDURE pg_catalog.drop_old_time_partitions(
|
||||
parent_table_name regclass,
|
||||
older_than timestamptz)
|
||||
LANGUAGE plpgsql
|
||||
|
@ -28,12 +28,12 @@ BEGIN
|
|||
ORDER BY to_value::timestamptz
|
||||
LOOP
|
||||
RAISE NOTICE 'dropping % with start time % and end time %', r.partition, r.from_value, r.to_value;
|
||||
EXECUTE format('DROP TABLE %I', r.partition);
|
||||
EXECUTE format('DROP TABLE %s', r.partition);
|
||||
COMMIT;
|
||||
END LOOP;
|
||||
END;
|
||||
$$;
|
||||
COMMENT ON PROCEDURE pg_catalog.expire_old_time_partitions(
|
||||
COMMENT ON PROCEDURE pg_catalog.drop_old_time_partitions(
|
||||
parent_table_name regclass,
|
||||
older_than timestamptz)
|
||||
IS 'drop old partitions of a time-partitioned table';
|
|
@ -804,7 +804,7 @@ SELECT * FROM multi_extension.print_extension_changes();
|
|||
| function citus_internal_delete_shard_metadata(bigint) void
|
||||
| function citus_internal_update_placement_metadata(bigint,integer,integer) void
|
||||
| function citus_internal_update_relation_colocation(oid,integer) void
|
||||
| function expire_old_time_partitions(regclass,timestamp with time zone)
|
||||
| function drop_old_time_partitions(regclass,timestamp with time zone)
|
||||
| function stop_metadata_sync_to_node(text,integer,boolean) void
|
||||
(11 rows)
|
||||
|
||||
|
|
|
@ -2210,7 +2210,7 @@ SELECT worker_partitioned_relation_total_size(oid) FROM pg_class WHERE relname L
|
|||
|
||||
\c - - - :master_port
|
||||
DROP TABLE "events.Energy Added";
|
||||
-- test expire_old_time_partitions
|
||||
-- test drop_old_time_partitions
|
||||
-- test with date partitioned table
|
||||
CREATE TABLE date_partitioned_table_to_exp (event_date date, event int) partition by range (event_date);
|
||||
SELECT create_distributed_table('date_partitioned_table_to_exp', 'event');
|
||||
|
@ -2227,7 +2227,7 @@ INSERT INTO date_partitioned_table_to_exp VALUES ('2015-01-01', 2);
|
|||
INSERT INTO date_partitioned_table_to_exp VALUES ('2025-01-01', 3);
|
||||
\set VERBOSITY terse
|
||||
-- expire no partitions
|
||||
CALL expire_old_time_partitions('date_partitioned_table_to_exp', '1999-01-01');
|
||||
CALL drop_old_time_partitions('date_partitioned_table_to_exp', '1999-01-01');
|
||||
SELECT partition FROM time_partitions WHERE parent_table = 'date_partitioned_table_to_exp'::regclass ORDER BY partition::text;
|
||||
partition
|
||||
---------------------------------------------------------------------
|
||||
|
@ -2237,7 +2237,7 @@ SELECT partition FROM time_partitions WHERE parent_table = 'date_partitioned_tab
|
|||
(3 rows)
|
||||
|
||||
-- expire 2 old partitions
|
||||
CALL expire_old_time_partitions('date_partitioned_table_to_exp', '2021-01-01');
|
||||
CALL drop_old_time_partitions('date_partitioned_table_to_exp', '2021-01-01');
|
||||
NOTICE: dropping date_partitioned_table_to_exp_d00 with start time 01-01-2000 and end time 12-31-2009
|
||||
NOTICE: dropping date_partitioned_table_to_exp_d10 with start time 01-01-2010 and end time 12-31-2019
|
||||
SELECT partition FROM time_partitions WHERE parent_table = 'date_partitioned_table_to_exp'::regclass ORDER BY partition::text;
|
||||
|
@ -2264,7 +2264,7 @@ INSERT INTO tstz_partitioned_table_to_exp VALUES ('2021-01-01 09:00:00+00', 2);
|
|||
INSERT INTO tstz_partitioned_table_to_exp VALUES ('2021-01-01 13:00:00+00', 3);
|
||||
\set VERBOSITY terse
|
||||
-- expire no partitions
|
||||
CALL expire_old_time_partitions('tstz_partitioned_table_to_exp', '2021-01-01 01:00:00+00');
|
||||
CALL drop_old_time_partitions('tstz_partitioned_table_to_exp', '2021-01-01 01:00:00+00');
|
||||
SELECT partition FROM time_partitions WHERE parent_table = 'tstz_partitioned_table_to_exp'::regclass ORDER BY partition::text;
|
||||
partition
|
||||
---------------------------------------------------------------------
|
||||
|
@ -2274,7 +2274,7 @@ SELECT partition FROM time_partitions WHERE parent_table = 'tstz_partitioned_tab
|
|||
(3 rows)
|
||||
|
||||
-- expire 2 old partitions
|
||||
CALL expire_old_time_partitions('tstz_partitioned_table_to_exp', '2021-01-01 12:00:00+00');
|
||||
CALL drop_old_time_partitions('tstz_partitioned_table_to_exp', '2021-01-01 12:00:00+00');
|
||||
NOTICE: dropping tstz_partitioned_table_to_exp_d0 with start time Thu Dec 31 18:00:00 2020 PST and end time Thu Dec 31 22:00:00 2020 PST
|
||||
NOTICE: dropping tstz_partitioned_table_to_exp_d1 with start time Thu Dec 31 22:00:00 2020 PST and end time Fri Jan 01 02:00:00 2021 PST
|
||||
SELECT partition FROM time_partitions WHERE parent_table = 'tstz_partitioned_table_to_exp'::regclass ORDER BY partition::text;
|
||||
|
|
|
@ -118,9 +118,9 @@ ORDER BY 1;
|
|||
function create_intermediate_result(text,text)
|
||||
function create_reference_table(regclass)
|
||||
function distributed_tables_colocated(regclass,regclass)
|
||||
function drop_old_time_partitions(regclass, timestamp with time zone)
|
||||
function dump_global_wait_edges()
|
||||
function dump_local_wait_edges()
|
||||
function expire_old_time_partitions(regclass, timestamp with time zone)
|
||||
function fetch_intermediate_results(text[],text,integer)
|
||||
function fix_pre_citus10_partitioned_table_constraint_names()
|
||||
function fix_pre_citus10_partitioned_table_constraint_names(regclass)
|
||||
|
|
|
@ -107,9 +107,9 @@ ORDER BY 1;
|
|||
function create_intermediate_result(text,text)
|
||||
function create_reference_table(regclass)
|
||||
function distributed_tables_colocated(regclass,regclass)
|
||||
function drop_old_time_partitions(regclass, timestamp with time zone)
|
||||
function dump_global_wait_edges()
|
||||
function dump_local_wait_edges()
|
||||
function expire_old_time_partitions(regclass, timestamp with time zone)
|
||||
function fetch_intermediate_results(text[],text,integer)
|
||||
function fix_pre_citus10_partitioned_table_constraint_names()
|
||||
function fix_pre_citus10_partitioned_table_constraint_names(regclass)
|
||||
|
|
|
@ -1303,7 +1303,7 @@ SELECT worker_partitioned_relation_total_size(oid) FROM pg_class WHERE relname L
|
|||
\c - - - :master_port
|
||||
DROP TABLE "events.Energy Added";
|
||||
|
||||
-- test expire_old_time_partitions
|
||||
-- test drop_old_time_partitions
|
||||
-- test with date partitioned table
|
||||
CREATE TABLE date_partitioned_table_to_exp (event_date date, event int) partition by range (event_date);
|
||||
SELECT create_distributed_table('date_partitioned_table_to_exp', 'event');
|
||||
|
@ -1318,11 +1318,11 @@ INSERT INTO date_partitioned_table_to_exp VALUES ('2025-01-01', 3);
|
|||
\set VERBOSITY terse
|
||||
|
||||
-- expire no partitions
|
||||
CALL expire_old_time_partitions('date_partitioned_table_to_exp', '1999-01-01');
|
||||
CALL drop_old_time_partitions('date_partitioned_table_to_exp', '1999-01-01');
|
||||
SELECT partition FROM time_partitions WHERE parent_table = 'date_partitioned_table_to_exp'::regclass ORDER BY partition::text;
|
||||
|
||||
-- expire 2 old partitions
|
||||
CALL expire_old_time_partitions('date_partitioned_table_to_exp', '2021-01-01');
|
||||
CALL drop_old_time_partitions('date_partitioned_table_to_exp', '2021-01-01');
|
||||
SELECT partition FROM time_partitions WHERE parent_table = 'date_partitioned_table_to_exp'::regclass ORDER BY partition::text;
|
||||
|
||||
\set VERBOSITY default
|
||||
|
@ -1342,11 +1342,11 @@ INSERT INTO tstz_partitioned_table_to_exp VALUES ('2021-01-01 13:00:00+00', 3);
|
|||
\set VERBOSITY terse
|
||||
|
||||
-- expire no partitions
|
||||
CALL expire_old_time_partitions('tstz_partitioned_table_to_exp', '2021-01-01 01:00:00+00');
|
||||
CALL drop_old_time_partitions('tstz_partitioned_table_to_exp', '2021-01-01 01:00:00+00');
|
||||
SELECT partition FROM time_partitions WHERE parent_table = 'tstz_partitioned_table_to_exp'::regclass ORDER BY partition::text;
|
||||
|
||||
-- expire 2 old partitions
|
||||
CALL expire_old_time_partitions('tstz_partitioned_table_to_exp', '2021-01-01 12:00:00+00');
|
||||
CALL drop_old_time_partitions('tstz_partitioned_table_to_exp', '2021-01-01 12:00:00+00');
|
||||
SELECT partition FROM time_partitions WHERE parent_table = 'tstz_partitioned_table_to_exp'::regclass ORDER BY partition::text;
|
||||
|
||||
\set VERBOSITY default
|
||||
|
|
Loading…
Reference in New Issue