public async Task ExceptionOnDoubleClose() { using var dbInfo = DisposableFile.GenerateInTemp("db"); await using var duckDBConnection = new DuckDBConnection(dbInfo.ConnectionString); await duckDBConnection.OpenAsync(); await duckDBConnection.CloseAsync(); await duckDBConnection.CloseAsync(); }
public async Task SingleThreadedOpenAndCloseOfSameFile() { using var db1 = DisposableFile.GenerateInTemp("db", 1); var cs = db1.ConnectionString; await using var duckDBConnection = new DuckDBConnection(cs); await duckDBConnection.OpenAsync(); var createTable = "CREATE TABLE INSERTIONS(TASK_ID INTEGER, INSERTION_INDEX INTEGER);"; await duckDBConnection.ExecuteAsync(createTable); await using var dd1 = new DuckDBConnection(cs); await using var dd2 = new DuckDBConnection(cs); const int reps = 10; for (int i = 0; i < reps; i++) { Console.WriteLine(i); await dd1.OpenAsync(); var insertAValue = $"INSERT INTO INSERTIONS VALUES ({1}, {i});"; await dd1.ExecuteAsync(insertAValue); await dd2.OpenAsync(); insertAValue = $"INSERT INTO INSERTIONS VALUES ({2}, {i});"; await dd2.ExecuteAsync(insertAValue); await dd1.CloseAsync(); await dd2.CloseAsync(); } var expectedInsertions = 2 * reps; var insertions = await duckDBConnection.QuerySingleAsync <int>("SELECT COUNT(*) FROM INSERTIONS;"); insertions.Should().Be(expectedInsertions); }