Skip to content

Commit dbe13f1

Browse files
Merge pull request #135 from pepelev/environment-info-overflow
ArithmeticOverflow in EnvironmentInfo
2 parents 5037ff1 + 2eb29f2 commit dbe13f1

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

src/LightningDB.Tests/EnvironmentTests.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,14 @@ public void StartingTransactionBeforeEnvironmentOpen()
5151
Assert.Throws<InvalidOperationException>(() => _env.BeginTransaction());
5252
}
5353

54-
[Fact]
55-
public void CanGetEnvironmentInfo()
54+
[Theory]
55+
[InlineData(1024 * 1024 * 200)]
56+
[InlineData(1024 * 1024 * 1024 * 3L)]
57+
public void CanGetEnvironmentInfo(long mapSize)
5658
{
5759
_env = new LightningEnvironment(_path, new EnvironmentConfiguration
5860
{
59-
MapSize = 1024 * 1024 * 200,
61+
MapSize = mapSize,
6062
});
6163
_env.Open();
6264
var info = _env.Info;

src/LightningDB/EnvironmentInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ public class EnvironmentInfo
88
/// <summary>
99
/// ID of the last used page
1010
/// </summary>
11-
public int LastPageNumber { get; set; }
11+
public long LastPageNumber { get; set; }
1212

1313
/// <summary>
1414
/// ID of the last committed transaction
1515
/// </summary>
16-
public int LastTransactionId { get; set; }
16+
public long LastTransactionId { get; set; }
1717

1818
/// <summary>
1919
/// Size of the data memory map
2020
/// </summary>
21-
public int MapSize { get; set; }
21+
public long MapSize { get; set; }
2222
}
2323
}

src/LightningDB/LightningEnvironment.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ public EnvironmentInfo Info
153153
mdb_env_info(Handle(), out var nativeInfo);
154154
return new EnvironmentInfo
155155
{
156-
MapSize = nativeInfo.me_mapsize.ToInt32(),
157-
LastPageNumber = nativeInfo.me_last_pgno.ToInt32(),
158-
LastTransactionId = nativeInfo.me_last_txnid.ToInt32(),
156+
MapSize = nativeInfo.me_mapsize.ToInt64(),
157+
LastPageNumber = nativeInfo.me_last_pgno.ToInt64(),
158+
LastTransactionId = nativeInfo.me_last_txnid.ToInt64(),
159159
};
160160
}
161161
}

0 commit comments

Comments
 (0)