{"record":{"id":"f2421b72678e5009","repo":"tursodatabase/turso","slug":"1-f2421b","errorCode":"1","errorMessage":"SQLite Error 1: 'Managed batch returned more than {state.Statements.Count} results.'.","messagePattern":"SQLite Error 1: 'Managed batch returned more than (.+?) results\\.'\\.","errorType":"error_code","errorClass":"SqliteException","httpStatus":null,"severity":"error","filePath":"bindings/dotnet/src/Turso.Data.Sqlite/SqliteBatch.cs","lineNumber":230,"sourceCode":"                closeCallback);\n        }\n\n        await using (state.Batch)\n        {\n            await WaitForOpenReaderAsync(state.Statements, cancellationToken).ConfigureAwait(false);\n            _activeBatch = state.Batch;\n            try\n            {\n                await using var reader = await state.Batch\n                    .ExecuteReaderAsync(behavior & ~CommandBehavior.CloseConnection, cancellationToken)\n                    .ConfigureAwait(false);\n                var results = new List<ManagedSqliteResult>(state.Statements.Count);\n                var statementIndex = 0;\n                do\n                {\n                    if (statementIndex >= state.Statements.Count)\n                    {\n                        throw new SqliteException(\n                            Properties.Resources.SqliteNativeError(\n                                1,\n                                $\"Managed batch returned more than {state.Statements.Count} results.\"),\n                            1);\n                    }\n\n                    var statement = state.Statements[statementIndex];\n                    var result = await SqliteCommand\n                        .BufferManagedResultAsync(reader, statement.Sql, cancellationToken)\n                        .ConfigureAwait(false);\n                    results.Add(result with\n                    {\n                        RecordsAffected = state.ManagedCommands[statementIndex].RecordsAffected,\n                    });\n                    statementIndex++;\n                }\n                while (await reader.NextResultAsync(cancellationToken).ConfigureAwait(false));\n","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/tursodatabase/turso/blob/6c7252267988c76e632af00a671e4b9788dfae13/bindings/dotnet/src/Turso.Data.Sqlite/SqliteBatch.cs#L212-L248","documentation":"The managed batch executor drives the reader with NextResultAsync once per parsed statement. This invariant error fires when the underlying connection produced more result sets than statements that were parsed from the batch CommandText, indicating the engine returned extra results for the submitted script.","triggerScenarios":"Calling ExecuteReader/ExecuteDbDataReaderAsync on a SqliteBatch whose managed connection emits more result streams than the statements in state.Statements.Count — an engine/driver protocol mismatch, e.g. a statement the parser split differently than the server executed, or a driver bug.","commonSituations":"Rare internal-inconsistency case; typically hit after a driver version upgrade, when the managed statement parser and the remote/embedded replica connection disagree on statement count, or with unusual SQL (triggers, RETURNING, multi-result pragmas).","solutions":["Update the Turso.Data.Sqlite package and server/driver to matching versions","Reduce the batch to individual SqliteCommand executions to isolate which statement produces the extra result","Reproduce and report with the exact CommandText; likely a parser/engine mismatch bug"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await batch.ExecuteReaderAsync(); }\ncatch (SqliteException ex) when (ex.SqliteErrorCode == 1 && ex.Message.Contains(\"more than\")) {\n    // engine/parser statement-count mismatch: log CommandText, retry per-statement\n}","preventionTips":["Keep driver and server versions aligned","Avoid exotic multi-result SQL in batches; run such statements individually","Report reproducible CommandText to the maintainers"],"tags":["dotnet","batch","protocol","invariant"],"backgroundTag":"internal-invariant-violation","analyzedSha":"6c7252267988c76e632af00a671e4b9788dfae13","analyzedAt":"2026-09-06T07:15:26.990Z","contentChangedAt":"2026-09-06T07:15:26.990Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}