# HG changeset patch # User Alexandre Fayolle # Date 1314372429 -7200 # Node ID e3da9e7fc5848088be073ce8c5f975d5e31b2759 # Parent df91baa5b837af6857a527ab60b05efa5d12cb28# Parent 681ef2a664ddd5c883507adcd49937d693d339cc merged back oldstable fix to stable diff -r df91baa5b837 -r e3da9e7fc584 server/sources/native.py --- a/server/sources/native.py Fri Aug 19 14:25:06 2011 +0200 +++ b/server/sources/native.py Fri Aug 26 17:27:09 2011 +0200 @@ -1711,21 +1711,24 @@ archive.writestr('sequences/%s' % seq, serialized) def write_table(self, archive, table): + nb_lines_sql = 'SELECT COUNT(*) FROM %s' % table + self.cursor.execute(nb_lines_sql) + rowcount = self.cursor.fetchone()[0] sql = 'SELECT * FROM %s' % table columns, rows_iterator = self._get_cols_and_rows(sql) - self.logger.info('number of rows: %d', self.cursor.rowcount) + self.logger.info('number of rows: %d', rowcount) if table.startswith('cw_'): # entities blocksize = 2000 else: # relations and metadata blocksize = 10000 - if self.cursor.rowcount > 0: - for i, start in enumerate(xrange(0, self.cursor.rowcount, blocksize)): + if rowcount > 0: + for i, start in enumerate(xrange(0, rowcount, blocksize)): rows = list(itertools.islice(rows_iterator, blocksize)) serialized = self._serialize(table, columns, rows) archive.writestr('tables/%s.%04d' % (table, i), serialized) self.logger.debug('wrote rows %d to %d (out of %d) to %s.%04d', start, start+len(rows)-1, - self.cursor.rowcount, + rowcount, table, i) else: rows = []