{"record":{"id":"1fcef5fe6b1e847c","repo":"tursodatabase/turso","slug":"incremental-blob-i-o-is-not-yet-supported-by-the-t","errorCode":null,"errorMessage":"Incremental blob I/O is not yet supported by the Turso SQLite-compatible provider.","messagePattern":"Incremental blob I/O is not yet supported by the Turso SQLite-compatible provider\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"bindings/dotnet/src/Turso.Data.Sqlite/SqliteBlob.cs","lineNumber":120,"sourceCode":"            throw new NotSupportedException(Properties.Resources.ResizeNotSupported);\n\n        stream.Write(buffer, offset, count);\n        Persist();\n    }\n\n    protected override void Dispose(bool disposing)\n    {\n        if (disposing && !_disposed)\n            _stream?.Dispose();\n\n        _disposed = true;\n        base.Dispose(disposing);\n    }\n\n    private MemoryStream GetStream()\n    {\n        ObjectDisposedException.ThrowIf(_disposed, this);\n        return _stream ?? throw new NotSupportedException(\"Incremental blob I/O is not yet supported by the Turso SQLite-compatible provider.\");\n    }\n\n    private void Persist()\n    {\n        if (_connection is null || _tableName is null || _columnName is null || _readOnly)\n            return;\n\n        using var command = _connection.CreateCommand();\n        command.CommandText = \"UPDATE \" + QuoteIdentifier(_tableName) + \" SET \" + QuoteIdentifier(_columnName) + \" = $value WHERE rowid = $rowid;\";\n        command.Parameters.Add(\"$value\", SqliteType.Blob).Value = GetStream().ToArray();\n        command.Parameters.Add(\"$rowid\", SqliteType.Integer).Value = _rowId;\n        command.ExecuteNonQuery();\n    }\n\n    private static byte[] GetBlobValue(SqliteConnection connection, string tableName, string columnName, long rowId)\n    {\n        using var command = connection.CreateCommand();\n        command.CommandText = \"SELECT \" + QuoteIdentifier(columnName) + \" FROM \" + QuoteIdentifier(tableName) + \" WHERE rowid = $rowid;\";","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/tursodatabase/turso/blob/244cde92a7df7f9b8b8b7a4075c35a12977e303e/bindings/dotnet/src/Turso.Data.Sqlite/SqliteBlob.cs#L102-L138","documentation":"The provider materializes the whole blob into a MemoryStream at construction; true incremental blob I/O (SQLite's sqlite3_blob_open/read/write against the database file) is not implemented. GetStream() is the guard: an instance with no backing stream (_stream == null) surfaces any Read/Write/Seek/Flush as this NotSupportedException stating incremental blob I/O is not yet supported.","triggerScenarios":"Obtaining a SqliteBlob through a path that does not preload the value (the internal byte[] factory or reflection into internals); calling stream methods on an instance that was never given a live snapshot.","commonSituations":"Consumers constructing SqliteBlob via reflection or internals; code written against Microsoft.Data.Sqlite's SqliteBlob (which does support incremental I/O via sqlite3_blob) ported to this provider; version transitions where an incremental API was partially wired.","solutions":["Construct SqliteBlob only via the public constructor (connection, table, column, rowId) so the value is preloaded.","Use the documented whole-value pattern: read via the stream, write back the full byte[] with UPDATE.","Track provider updates for incremental blob support; until then keep blob sizes modest since each access loads the full value."],"exampleFix":"// before\nvar blob = GetBlobViaInternalsOrReflection(); // no preloaded snapshot -> _stream == null\nblob.Read(buf, 0, buf.Length);                // throws: Incremental blob I/O is not yet supported\n\n// after\nusing var conn = new SqliteConnection(connString);\nconn.Open();\nusing var blob = new SqliteBlob(conn, \"files\", \"data\", rowId); // public ctor preloads the value\nblob.Read(buf, 0, buf.Length);","handlingStrategy":"fallback","validationCode":"static bool IsUsable(SqliteBlob b) {\n    try { _ = b.Length; return true; }      // Length goes through GetStream()\n    catch (NotSupportedException) { return false; }\n}\n\nif (!IsUsable(blob))\n    blob = new SqliteBlob(conn, table, column, rowId); // rebuild via the public ctor","typeGuard":null,"tryCatchPattern":"try {\n    n = blob.Read(buf, 0, buf.Length);\n} catch (NotSupportedException) {\n    // no incremental backing store: rebuild from SQL and retry\n    blob = new SqliteBlob(conn, table, column, rowId);\n    n = blob.Read(buf, 0, buf.Length);\n}","preventionTips":["Never construct SqliteBlob via reflection or internal factories.","Create blobs from the public constructor right before use and dispose promptly.","Keep whole-value read/write helpers so all code uses the one supported path."],"tags":["dotnet","sqlite-blob","not-implemented","incremental-io"],"backgroundTag":"unsupported-feature","analyzedSha":"244cde92a7df7f9b8b8b7a4075c35a12977e303e","analyzedAt":"2026-08-20T07:02:18.389Z","contentChangedAt":"2026-08-20T07:02:18.389Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}