Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit aa6a03c

Browse files
committed
Adds FbTransactionInfo.GetTransactionId().
1 parent ac0fc79 commit aa6a03c

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

‎src/FirebirdSql.Data.FirebirdClient.Tests/FbTransactionTests.cs‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,22 @@ public async Task SnapshotAtNumber()
139139
}
140140
}
141141
}
142+
143+
[Test]
144+
public async Task CanGetTransactionId()
145+
{
146+
if (!EnsureServerVersionAtLeast(new Version(2, 5, 0, 0)))
147+
return;
148+
149+
await using (var transaction1 = await Connection.BeginTransactionAsync())
150+
{
151+
var idFromInfo = await new FbTransactionInfo(transaction1).GetTransactionIdAsync();
152+
Assert.NotZero(idFromInfo);
153+
154+
var command = new FbCommand("SELECT current_transaction FROM rdb$database", Connection, transaction1);
155+
var idFromSql = await command.ExecuteScalarAsync();
156+
157+
Assert.AreEqual(idFromInfo, idFromSql);
158+
}
159+
}
142160
}

‎src/FirebirdSql.Data.FirebirdClient/Common/IscHelper.cs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,10 @@ public static List<object> ParseTransactionInfo(byte[] buffer, Charset charset)
206206
case IscCodes.isc_info_error:
207207
throw FbException.Create("Received error response.");
208208

209+
case IscCodes.isc_info_tra_id:
210+
info.Add(VaxInteger(buffer, pos, length));
211+
break;
212+
209213
case IscCodes.fb_info_tra_snapshot_number:
210214
info.Add(VaxInteger(buffer, pos, length));
211215
break;

‎src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbTransactionInfo.cs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ public sealed class FbTransactionInfo
3333

3434
#region Methods
3535

36+
public long GetTransactionId()
37+
{
38+
return GetValue<long>(IscCodes.isc_info_tra_id);
39+
}
40+
public Task<long> GetTransactionIdAsync(CancellationToken cancellationToken = default)
41+
{
42+
return GetValueAsync<long>(IscCodes.isc_info_tra_id, cancellationToken);
43+
}
44+
3645
public long GetTransactionSnapshotNumber()
3746
{
3847
return GetValue<long>(IscCodes.fb_info_tra_snapshot_number);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /