diff options
| author | martinko | 2013-02-19 19:55:23 +0000 |
|---|---|---|
| committer | martinko | 2013-02-19 19:55:23 +0000 |
| commit | 6dc6a308b5c73548f8cce88d38ee80aaa44d8807 (patch) | |
| tree | 30ffcc9ffa044c2db11b0525dc79b7eca22462c4 /sql | |
| parent | adac9e08f99c72d05529c74a7d6203471132b958 (diff) | |
londiste.drop_obsolete_partitions: changed to raise notice instead of returning rows; defaults to public schema.
Diffstat (limited to 'sql')
| -rw-r--r-- | sql/londiste/functions/londiste.drop_obsolete_partitions.sql | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/sql/londiste/functions/londiste.drop_obsolete_partitions.sql b/sql/londiste/functions/londiste.drop_obsolete_partitions.sql index ff7e0ce8..732d270e 100644 --- a/sql/londiste/functions/londiste.drop_obsolete_partitions.sql +++ b/sql/londiste/functions/londiste.drop_obsolete_partitions.sql @@ -5,10 +5,10 @@ create or replace function londiste.drop_obsolete_partitions in i_retention_period interval, in i_partition_period text ) - returns setof text + returns void as $$ ------------------------------------------------------------------------------- --- Function: londiste.drop_obsolete_partitions(2) +-- Function: londiste.drop_obsolete_partitions(3) -- -- Drop obsolete partitions of partition-by-date parent table. -- @@ -16,9 +16,6 @@ as $$ -- i_parent_table Master table from which partitions are inherited -- i_retention_period How long to keep partitions around -- i_partition_period One of: year, month, day, hour --- --- Returns: --- Names of partitions dropped ------------------------------------------------------------------------------- declare _schema text not null := lower (split_part (i_parent_table, '.', 1)); @@ -43,6 +40,11 @@ begin raise exception 'not supported i_partition_period: %', i_partition_period; end if; + if length (_table) = 0 then + _table := _schema; + _schema := 'public'; + end if; + for _part in select quote_ident (t.schemaname) ||'.'|| quote_ident (t.tablename) from pg_catalog.pg_tables t @@ -50,8 +52,8 @@ begin and t.tablename ~ ('^'|| _table || _expr ||'$') and t.tablename < _table || to_char (now() - i_retention_period, _dfmt) loop + raise notice 'DROP TABLE %', _part; execute 'drop table '|| _part; - return next _part; end loop; end; $$ language plpgsql; |
