From 3e2d0ab1340ba26f7076fac58601e76e23aa829b Mon Sep 17 00:00:00 2001 From: "A.Shakhmatov" Date: Sun, 9 Aug 2026 15:11:28 +0300 Subject: [PATCH] commands: a count reply is an int32 Two of the tests added alongside endSessions read the count reply's `n` as int64. ReleaseFast does not check the union tag, so both passed there and aborted in ReleaseSafe -- which is the whole argument for running the suite in both, and the reason the plan makes ReleaseSafe non-optional. 175/175 in ReleaseFast and ReleaseSafe. --- src/commands.zig | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/commands.zig b/src/commands.zig index 2bdd392..75ee4d5 100644 --- a/src/commands.zig +++ b/src/commands.zig @@ -3157,13 +3157,13 @@ fn run_for_code(ctx: *Context, name: []const u8, value: bson.Value, extra: []con return null; } -fn doc_count(ctx: *Context, coll: []const u8) !i64 { +fn doc_count(ctx: *Context, coll: []const u8) !i32 { var reply = wire.Reply.init(testing.allocator); defer reply.deinit(); var msg = try parse_fake_msg("count", .{ .string = coll }, &.{}); defer msg.deinit(); try dispatch(ctx, &msg, &reply); - return bson.get_pair(reply.pairs.items, "n").?.int64; + return bson.get_pair(reply.pairs.items, "n").?.int32; } test "a well-formed session id changes nothing and is not echoed" { @@ -3191,7 +3191,7 @@ test "a well-formed session id changes nothing and is not echoed" { // mongod answers a well-formed lsid with exactly `{ok: 1}` and no echo, // measured; a driver reads only `$clusterTime` and `operationTime` back. try testing.expect(bson.get_pair(reply.pairs.items, "lsid") == null); - try testing.expectEqual(@as(i64, 1), try doc_count(&ctx, "sess")); + try testing.expectEqual(@as(i32, 1), try doc_count(&ctx, "sess")); } test "a malformed session id is refused without leaking a lock" { @@ -3271,7 +3271,7 @@ test "a transactional write is refused rather than applied" { .{ .key = "startTransaction", .value = .{ .bool = true } }, .{ .key = "autocommit", .value = .{ .bool = false } }, })).?); - try testing.expectEqual(@as(i64, 0), try doc_count(&ctx, "txn")); + try testing.expectEqual(@as(i32, 0), try doc_count(&ctx, "txn")); // The order the checks fire in is mongod's, measured: a missing session id // is reported before the standalone refusal, and a bad type before both. @@ -3289,7 +3289,7 @@ test "a transactional write is refused rather than applied" { .{ .key = "lsid", .value = lsid }, .{ .key = "startTransaction", .value = .{ .bool = true } }, })).?); - try testing.expectEqual(@as(i64, 0), try doc_count(&ctx, "txn")); + try testing.expectEqual(@as(i32, 0), try doc_count(&ctx, "txn")); } test "endSessions judges the array it is handed" {