Skip to content

Commit 440809b

Browse files
committed
Merge master into net10.
Conflicts: tests/IntegrationTests/IntegrationTests.csproj
2 parents c9084c7 + 8497ffc commit 440809b

File tree

7 files changed

+92
-12
lines changed

7 files changed

+92
-12
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
uses: actions/checkout@v5
1717

1818
- name: Set up .NET
19-
uses: actions/setup-dotnet@v4
19+
uses: actions/setup-dotnet@v5
2020

2121
- name: Restore
2222
run: dotnet restore
@@ -48,7 +48,7 @@ jobs:
4848
uses: actions/checkout@v5
4949

5050
- name: Set up .NET
51-
uses: actions/setup-dotnet@v4
51+
uses: actions/setup-dotnet@v5
5252

5353
- name: Publish
5454
run: dotnet publish -c Release -r linux-x64 -f ${{ matrix.tfm }} tests/MySqlConnector.NativeAot.Tests/MySqlConnector.NativeAot.Tests.csproj

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
uses: actions/checkout@v5
2828

2929
- name: Set up .NET
30-
uses: actions/setup-dotnet@v4
30+
uses: actions/setup-dotnet@v5
3131

3232
- name: Initialize CodeQL
3333
uses: github/codeql-action/init@v3

src/MySqlConnector/Core/XaEnlistedTransaction.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,25 @@ protected override void OnCommit(Enlistment enlistment)
3030

3131
protected override void OnRollback(Enlistment enlistment)
3232
{
33-
try
33+
if (!IsPrepared)
3434
{
3535
try
3636
{
37-
if (!IsPrepared)
38-
ExecuteXaCommand("END");
37+
ExecuteXaCommand("END");
3938
}
40-
catch (MySqlException ex) when (ex.ErrorCode is MySqlErrorCode.XAERRemoveFail && ex.Message.Contains("ROLLBACK ONLY"))
39+
catch (MySqlException ex) when (ex.ErrorCode is MySqlErrorCode.XARBDeadlock || (ex.ErrorCode is MySqlErrorCode.XAERRemoveFail && ex.Message.Contains("ROLLBACK ONLY")))
4140
{
42-
// ignore unprepared end failure when XAERRemoveFail is returned telling us the XA state is ROLLBACK ONLY.
41+
// ignore deadlock notification AND any unprepared end failure when XAERRemoveFail is returned telling us the XA state is ROLLBACK ONLY.
4342
}
43+
}
4444

45+
try
46+
{
4547
ExecuteXaCommand("ROLLBACK");
4648
}
4749
catch (MySqlException ex) when (ex.ErrorCode is MySqlErrorCode.XARBDeadlock)
4850
{
49-
// ignore deadlock when rolling back
51+
// ignore deadlock notification when rolling back.
5052
}
5153
}
5254

src/MySqlConnector/MySqlBulkCopy.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ private async ValueTask<MySqlBulkCopyResult> WriteToServerAsync(IOBehavior ioBeh
231231
using (var reader = await cmd.ExecuteReaderAsync(CommandBehavior.SchemaOnly, ioBehavior, cancellationToken).ConfigureAwait(false))
232232
{
233233
var schema = reader.GetColumnSchema();
234-
for (var i = 0; i < Math.Min(m_valuesEnumerator!.FieldCount, schema.Count); i++)
234+
for (var i = 0; i < schema.Count; i++)
235235
{
236236
var destinationColumn = reader.GetName(i);
237237
if (schema[i].DataTypeName == "BIT")
@@ -260,7 +260,7 @@ private async ValueTask<MySqlBulkCopyResult> WriteToServerAsync(IOBehavior ioBeh
260260
}
261261

262262
// set columns and expressions from the column mappings
263-
for (var i = 0; i < m_valuesEnumerator.FieldCount; i++)
263+
for (var i = 0; i < m_valuesEnumerator!.FieldCount; i++)
264264
{
265265
var columnMapping = columnMappings.FirstOrDefault(x => x.SourceOrdinal == i);
266266
if (columnMapping is null)

src/MySqlConnector/MySqlBulkLoader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ internal async ValueTask<int> LoadAsync(IOBehavior ioBehavior, CancellationToken
183183
else
184184
{
185185
if (!Local)
186-
throw new InvalidOperationException("Local must be true to use SourceStream, SourceDataTable, or SourceDataReader.");
186+
throw new InvalidOperationException("Local must be true to use SourceStream.");
187187

188188
FileName = GenerateSourceFileName();
189189
AddSource(FileName, Source!);

tests/IntegrationTests/BulkLoaderAsync.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,45 @@ public async Task BulkCopyNullDataReader()
635635
var bulkCopy = new MySqlBulkCopy(connection);
636636
await Assert.ThrowsAsync<ArgumentNullException>(async () => await bulkCopy.WriteToServerAsync(default(DbDataReader)));
637637
}
638+
639+
[Fact]
640+
public async Task BulkCopyGeometryAsync()
641+
{
642+
var dataTable = new DataTable()
643+
{
644+
Columns =
645+
{
646+
new DataColumn("geo_data", typeof(MySqlGeometry)),
647+
},
648+
Rows =
649+
{
650+
new object[] { MySqlGeometry.FromWkb(0, [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 240, 63, 0, 0, 0, 0, 0, 0, 240, 63]) },
651+
},
652+
};
653+
654+
using var connection = new MySqlConnection(GetLocalConnectionString());
655+
await connection.OpenAsync();
656+
using (var cmd = new MySqlCommand(@"drop table if exists bulk_load_data_table;
657+
create table bulk_load_data_table(id BIGINT UNIQUE NOT NULL AUTO_INCREMENT, geo_data GEOMETRY NOT NULL);", connection))
658+
{
659+
await cmd.ExecuteNonQueryAsync();
660+
}
661+
662+
var bc = new MySqlBulkCopy(connection)
663+
{
664+
DestinationTableName = "bulk_load_data_table",
665+
ColumnMappings =
666+
{
667+
new()
668+
{
669+
SourceOrdinal = 0,
670+
DestinationColumn = "geo_data",
671+
},
672+
},
673+
};
674+
675+
await bc.WriteToServerAsync(dataTable);
676+
}
638677
#endif
639678

640679
private static string GetConnectionString() => BulkLoaderSync.GetConnectionString();

tests/IntegrationTests/BulkLoaderSync.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,45 @@ public void BulkCopyDataTableConflictOption(MySqlBulkLoaderConflictOption confli
12841284
using (var cmd = new MySqlCommand("select b from bulk_load_data_table;", connection))
12851285
Assert.Equal(expected, cmd.ExecuteScalar());
12861286
}
1287+
1288+
[Fact]
1289+
public void BulkCopyGeometry()
1290+
{
1291+
var dataTable = new DataTable()
1292+
{
1293+
Columns =
1294+
{
1295+
new DataColumn("geo_data", typeof(MySqlGeometry)),
1296+
},
1297+
Rows =
1298+
{
1299+
new object[] { MySqlGeometry.FromWkb(0, [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 240, 63, 0, 0, 0, 0, 0, 0, 240, 63]) },
1300+
},
1301+
};
1302+
1303+
using var connection = new MySqlConnection(GetLocalConnectionString());
1304+
connection.Open();
1305+
using (var cmd = new MySqlCommand(@"drop table if exists bulk_load_data_table;
1306+
create table bulk_load_data_table(id BIGINT UNIQUE NOT NULL AUTO_INCREMENT, geo_data GEOMETRY NOT NULL);", connection))
1307+
{
1308+
cmd.ExecuteNonQuery();
1309+
}
1310+
1311+
var bc = new MySqlBulkCopy(connection)
1312+
{
1313+
DestinationTableName = "bulk_load_data_table",
1314+
ColumnMappings =
1315+
{
1316+
new()
1317+
{
1318+
SourceOrdinal = 0,
1319+
DestinationColumn = "geo_data",
1320+
},
1321+
},
1322+
};
1323+
1324+
bc.WriteToServer(dataTable);
1325+
}
12871326
#endif
12881327

12891328
internal static string GetConnectionString() => AppConfig.ConnectionString;

0 commit comments

Comments
 (0)