diff --git a/lib/features/mysql/mysql_sql_workspace.dart b/lib/features/mysql/mysql_sql_workspace.dart index 4ca7f8f2..c8d13e9d 100644 --- a/lib/features/mysql/mysql_sql_workspace.dart +++ b/lib/features/mysql/mysql_sql_workspace.dart @@ -107,8 +107,11 @@ class MysqlSqlExecutionDelegate extends BaseSqlExecutionDelegate { }, ); final colList = rs.cols.toList(); - final outRows = [ - for (final row in taken.items) + final pool = StringInternPool(); + final outRows = >[]; + for (var r = 0; r < taken.items.length; r++) { + final row = taken.items[r]; + outRows.add( List.generate( row.numOfColumns, (i) { @@ -116,10 +119,16 @@ class MysqlSqlExecutionDelegate extends BaseSqlExecutionDelegate { return mysqlResultCellToDisplayString( row.colAt(i), column: col, + pool: pool, ); }, ), - ]; + ); + if (kResultStringConvertYieldEvery > 0 && + (r + 1) % kResultStringConvertYieldEvery == 0) { + await Future.delayed(Duration.zero); + } + } final truncated = taken.truncated || (effectiveSql != sql && outRows.length >= cap); final n = outRows.length; diff --git a/test/core/database/mysql_grid_types_test.dart b/test/core/database/mysql_grid_types_test.dart index 6f21c737..c3911da8 100644 --- a/test/core/database/mysql_grid_types_test.dart +++ b/test/core/database/mysql_grid_types_test.dart @@ -5,6 +5,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:mysql_client/mysql_client.dart'; import 'package:mysql_client/mysql_protocol.dart'; import 'package:querya_desktop/core/database/mysql_result_cells.dart'; +import 'package:querya_desktop/core/database/result_row_string_convert.dart'; import 'package:querya_desktop/core/database/table_mutation_engine.dart'; void main() { @@ -134,5 +135,16 @@ void main() { expect(mysqlResultCellToDisplayString('1', column: col), 'true'); expect(mysqlResultCellToDisplayString('0', column: col), 'false'); }); + + test('deduplicates identical strings via StringInternPool', () { + final pool = StringInternPool(); + final str1 = String.fromCharCodes('intern_test'.codeUnits); + final str2 = String.fromCharCodes('intern_test'.codeUnits); + expect(identical(str1, str2), isFalse); + + final res1 = mysqlResultCellToDisplayString(str1, pool: pool); + final res2 = mysqlResultCellToDisplayString(str2, pool: pool); + expect(identical(res1, res2), isTrue); + }); }); }