diff --git a/wcs_olap/feeder.py b/wcs_olap/feeder.py index aec0266..2b633c2 100644 --- a/wcs_olap/feeder.py +++ b/wcs_olap/feeder.py @@ -315,11 +315,21 @@ class WcsOlapFeeder(object): def do_schema(self): self.ex('SET search_path = public') self.logger.debug('dropping schema %s', self.schema + '_temp') + self.drop_tables_sequencially() self.ex('DROP SCHEMA IF EXISTS {schema_temp} CASCADE') self.logger.debug('creating schema %s', self.schema) self.ex('CREATE SCHEMA {schema_temp}') self.ex('SET search_path = {schema_temp},public') + def drop_tables_sequencially(self): + """ + Drop tables one by one in order to avoid reaching max_locks_per_transaction + """ + self.ex("SELECT tablename FROM pg_tables WHERE schemaname = '{schema_temp}'") + for table in self.cur.fetchall(): + tablename = '%s%s.%s' % (self.schema, '_temp', table[0]) + self.ex('DROP TABLE IF EXISTS %s CASCADE;' % tablename) + def do_dates_table(self): # test if public.dates exists self.ex("SELECT * FROM information_schema.tables WHERE table_name = 'dates' AND"