<commit_before>
CREATE OR REPLACE FUNCTION londiste.drop_obsolete_partitions
(
  IN i_parent_table text,
  IN i_retention_period interval
)
  RETURNS SETOF text
AS $$
-------------------------------------------------------------------------------
--  Function: londiste.drop_obsolete_partitions(2)
--
--    Drop obsolete partitions of partition-by-date parent table.
--
--  Parameters:
--    i_parent_table      Master table from which partitions are inherited
--    i_retention_period  How long to keep partitions around
--
--  Returns:
--    Names of partitions dropped
-------------------------------------------------------------------------------
DECLARE
  _schema text NOT NULL := lower( split_part( i_parent_table, '.', 1));
  _table  text NOT NULL := lower( split_part( i_parent_table, '.', 2));
  _part   text;
BEGIN
  FOR _part IN
    SELECT quote_ident( t.schemaname) ||'.'|| quote_ident( t.tablename)
      FROM pg_catalog.pg_tables t
     WHERE t.schemaname = _schema
       AND t.tablename ~ ('^'|| _table ||'_[0-9]{4}_[0-9]{2}_[0-9]{2}$')
       AND t.tablename < _table || to_char( now() - i_retention_period, '_YYYY_MM_DD')
  LOOP
    EXECUTE 'DROP TABLE '|| _part;
    RETURN NEXT _part;
  END LOOP;
END;
$$ LANGUAGE plpgsql;

-- vim:et:sw=2:ts=2:nowrap:<commit_msg>londiste: reformatted drop_obsolete_partitions() to lower case<commit_after>
create or replace function londiste.drop_obsolete_partitions
(
  in i_parent_table text,
  in i_retention_period interval
)
  returns setof text
as $$
-------------------------------------------------------------------------------
--  Function: londiste.drop_obsolete_partitions(2)
--
--    Drop obsolete partitions of partition-by-date parent table.
--
--  Parameters:
--    i_parent_table      Master table from which partitions are inherited
--    i_retention_period  How long to keep partitions around
--
--  Returns:
--    Names of partitions dropped
-------------------------------------------------------------------------------
declare
  _schema text not null := lower (split_part (i_parent_table, '.', 1));
  _table  text not null := lower (split_part (i_parent_table, '.', 2));
  _part   text;
begin
  for _part in
    select quote_ident (t.schemaname) ||'.'|| quote_ident (t.tablename)
      from pg_catalog.pg_tables t
     where t.schemaname = _schema
       and t.tablename ~ ('^'|| _table ||'_[0-9]{4}_[0-9]{2}_[0-9]{2}$')
       and t.tablename < _table || to_char (now() - i_retention_period, '_YYYY_MM_DD')
  loop
    execute 'drop table '|| _part;
    return next _part;
  end loop;
end;
$$ language plpgsql;

-- vim:et:sw=2:ts=2:nowrap:
{'fraction_non_alphanumeric': 0.22888803974016048, 'fraction_numerical': 0.010699273977837218, 'mean_word_length': 2.1618357487922704, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7389992', 'n_tokens_mistral': 838, 'n_tokens_neox': 817, 'n_words': 214}