tursodatabase/turso · error · NotSupportedException

Incremental blob I/O is not yet supported by the Turso…

Error message

Incremental blob I/O is not yet supported by the Turso SQLite-compatible provider.

What it means

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.

Solutions

  1. Construct SqliteBlob only via the public constructor (connection, table, column, rowId) so the value is preloaded.
  2. Use the documented whole-value pattern: read via the stream, write back the full byte[] with UPDATE.
  3. Track provider updates for incremental blob support; until then keep blob sizes modest since each access loads the full value.

Example fix

// before
var blob = GetBlobViaInternalsOrReflection(); // no preloaded snapshot -> _stream == null
blob.Read(buf, 0, buf.Length);                // throws: Incremental blob I/O is not yet supported

// after
using var conn = new SqliteConnection(connString);
conn.Open();
using var blob = new SqliteBlob(conn, "files", "data", rowId); // public ctor preloads the value
blob.Read(buf, 0, buf.Length);
Defensive patterns

Strategy: fallback

Validate before calling

static bool IsUsable(SqliteBlob b) {
    try { _ = b.Length; return true; }      // Length goes through GetStream()
    catch (NotSupportedException) { return false; }
}

if (!IsUsable(blob))
    blob = new SqliteBlob(conn, table, column, rowId); // rebuild via the public ctor

Try / catch

try {
    n = blob.Read(buf, 0, buf.Length);
} catch (NotSupportedException) {
    // no incremental backing store: rebuild from SQL and retry
    blob = new SqliteBlob(conn, table, column, rowId);
    n = blob.Read(buf, 0, buf.Length);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of tursodatabase/turso@244cde92a7 (2026-08-20). Data as JSON: /api/errors/1fcef5fe6b1e847c. Report an issue: GitHub.

Appendix: source

Thrown at bindings/dotnet/src/Turso.Data.Sqlite/SqliteBlob.cs:120

            throw new NotSupportedException(Properties.Resources.ResizeNotSupported);

        stream.Write(buffer, offset, count);
        Persist();
    }

    protected override void Dispose(bool disposing)
    {
        if (disposing && !_disposed)
            _stream?.Dispose();

        _disposed = true;
        base.Dispose(disposing);
    }

    private MemoryStream GetStream()
    {
        ObjectDisposedException.ThrowIf(_disposed, this);
        return _stream ?? throw new NotSupportedException("Incremental blob I/O is not yet supported by the Turso SQLite-compatible provider.");
    }

    private void Persist()
    {
        if (_connection is null || _tableName is null || _columnName is null || _readOnly)
            return;

        using var command = _connection.CreateCommand();
        command.CommandText = "UPDATE " + QuoteIdentifier(_tableName) + " SET " + QuoteIdentifier(_columnName) + " = $value WHERE rowid = $rowid;";
        command.Parameters.Add("$value", SqliteType.Blob).Value = GetStream().ToArray();
        command.Parameters.Add("$rowid", SqliteType.Integer).Value = _rowId;
        command.ExecuteNonQuery();
    }

    private static byte[] GetBlobValue(SqliteConnection connection, string tableName, string columnName, long rowId)
    {
        using var command = connection.CreateCommand();
        command.CommandText = "SELECT " + QuoteIdentifier(columnName) + " FROM " + QuoteIdentifier(tableName) + " WHERE rowid = $rowid;";

View on GitHub (pinned to 244cde92a7)