All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog.
cloudsync_network_check_changes()no longer errors withmissing 'url' in check responsewhen the server has not yet prepared any incoming changes for this device. The function now returns the standard "no rows yet" response in that case, so polling loops keep working without spurious errors.
receive.lastFailureJSON field oncloudsync_network_check_changes()andcloudsync_network_sync(), surfacing the most recent server-side failure of the receive pipeline (e.g. the server failed to prepare the next batch of incoming changes for this device). It complements the existingsend.lastFailure(server-side apply failures) andreceive.error(local apply failures on this device), so applications can distinguish "the server has trouble producing my changes" from "I had trouble applying them locally". Each function reports only the failures relevant to its own scope:cloudsync_network_send_changes()reportssend.lastFailure;cloudsync_network_check_changes()reportsreceive.lastFailure;cloudsync_network_sync()reports both.
- Updated the request headers sent to the cloudsync HTTP endpoints (version advertisement, per-endpoint capabilities; legacy
Acceptheader removed).
- Confusing errors when
cloudsync_initwas never called:cloudsync_changes(SQLite),cloudsync_db_version,cloudsync_db_version_next,cloudsync_set_filter,cloudsync_clear_filter, andcloudsync_payload_applynow raise a single actionable message pointing atSELECT cloudsync_init('<table_name>')instead of leaking low-level symptoms (out of memory,not an error, silent-1, multi-line "no such table" dumps). The guard runs only on the error branch, so the sync hot path is unaffected.
- WASM crash in
cloudsync_set_columnon existing rows: Callingcloudsync_set_column(table, col, 'lww', 'block')on a table with pre-existing rows crashed the WASM build with aRuntimeError: function signature mismatchas soon as the block-index migration tried to allocate memory.block_init_allocatorwas castingcloudsync_memory_alloc(auint64_t sizefunction) directly to the fractional-indexing allocator'svoid *(*)(size_t)slot. The cast is a no-op on native platforms wheresize_tis 64-bit, but WASM'scall_indirectenforces strict type checking — the function is registered as(i64) -> i32and called as(i32) -> i32, triggering an immediate runtime error. A thinfi_malloc_wrapper(mirroring the existingfi_calloc_wrapper) now bridges the signatures. Native builds are unaffected.
- Silent receive failures: When
cloudsync_payload_applyfailed during the receive phase (for example with an unknown schema hash, invalid checksum, or decompression error), the error was stored only on the internal cloudsync context and never propagated to the SQL caller. Bothcloudsync_network_check_changes()andcloudsync_network_sync()silently returned no result. Apply errors are now surfaced as areceive.errorfield in the JSON response.
- Error handling contract: endpoint/network errors (server unreachable, auth failure, bad URL) always raise a SQL error. Processing errors (
cloudsync_payload_applyfailures) are returned as structured JSON viareceive.errororsend.lastFailure, so callers can inspect and log them without try/catch logic. cloudsync_network_send_changes()output now includes asend.lastFailureobject whenever the server reports one (raw pass-through of the server'slastFailure—jobId,code,message,retryable,failedAt, …), regardless of whether the computedsend.statusissynced,syncing, orout-of-sync. The field is omitted when the server does not report a failure.cloudsync_network_check_changes()output now includes areceive.errorstring whencloudsync_payload_applyfails, instead of silently returning NULL. Endpoint/network errors still raise a SQL error.cloudsync_network_sync()output now mirrors the samesend.lastFailurefield and, if the receive phase has a processing error (cloudsync_payload_applyfailure), returns structured JSON with areceive.errorstring rather than failing silently. The send result is always preserved so callers can tell that their local changes reached the server even when applying incoming changes failed. Endpoint/network errors during the receive phase still raise a SQL error. The receive retry loop breaks immediately on processing errors (a schema-hash mismatch will not heal across retries).
- Stale
cloudsync_table_settingscrash: Reopening a database that had its base table and<table>_cloudsyncmeta-table dropped without callingcloudsync_cleanupcrashed with a double-free onsqlite3_close. Two bugs were involved: (1)cloudsync_dbversion_rebuildreturnedDBRES_NOMEMwhencloudsync_dbversion_build_queryyielded a NULL SQL string (stale row incloudsync_table_settingsbut no matching*_cloudsynctable insqlite_master), failing extension init; (2) on init failuredbsync_register_functionsmanually freed the context that SQLite already owned via thecloudsync_versiondestructor, causing a double-free when the connection was later closed.cloudsync_dbversion_rebuildnow treats a NULL build query the same ascount == 0(no prepared statement, db_version stays at the minimum and is rebuilt on the nextcloudsync_init), and the manual free in the error path has been removed.
- Unit test
do_test_stale_table_settings_dropped_meta(Stale Table Settings Dropped Meta) covering the drop-base-table + drop-meta-table + reopen scenario.
- Block-level LWW migration: When
cloudsync_set_column(..., 'algo', 'block')is called on a table that already has tracked rows, those rows are now immediately migrated into the blocks table. Previously, pre-existing column values were ignored until the next UPDATE, leaving sync state incomplete. The migration uses a two-phase collect-then-write approach to avoid SQLite cursor invalidation andINSERT OR IGNORE/ON CONFLICT DO NOTHINGsemantics for idempotency.
- Unit test
do_test_block_lww_existing_data(Block LWW Existing Data) verifying block migration onset_column, idempotency of repeatedset_columncalls, and correct materialization after update. - PostgreSQL test
50_block_lww_existing_data.sqlwith equivalent coverage for the PostgreSQL backend.
- Settings loader: Prevent infinite loop in
sqlite3_cloudsync_initwhen reopening a database that has a persisted block-column setting.dbutils_settings_table_load_callbackwas callingcloudsync_setup_block_column, whichREPLACEd the same row intocloudsync_table_settingswhilesqlite3_execwas still iterating it, re-feeding the rewritten row to the cursor. Added apersistflag tocloudsync_setup_block_columnso the loader replays the in-memory setup without writing back. - PostgreSQL tests: Updated 168
cloudsync_initcallsites across 43test/postgresql/*.sqlfiles to pass integer flags (0/1) instead oftrue/false, matching the signature change in 1.0.9. - CI: The
postgres-testjob now fails on SQL errors and[FAIL]markers.psqlis run withON_ERROR_STOP=on,pipefailis enabled around thetee, and the captured log is grepped for[FAIL]/psql ERRORas a final guard.
- Unit test
do_test_block_column_reload(Block Column Reload) that persists a block column with a custom delimiter, closes the database, and reopens it — without the fix this hangs the test process.
- cloudsync_cleanup: Now also drops the
{table}_cloudsync_blockstable when the table has block LWW columns configured viacloudsync_set_column(..., 'algo', 'block').
- Unit test
do_test_block_lww_cleanupverifying that both{table}_cloudsyncand{table}_cloudsync_blocksare removed aftercloudsync_cleanup.
- PostgreSQL: Prevent debug assertion crash on
cloudsync_initerror path (#37). - Row filter:
cloudsync_set_filterandcloudsync_clear_filternow reset the metatable and refill it from scratch, ensuring only rows matching the active filter are tracked for sync (#38).
- Row filter edge-case test coverage: clear/change filter lifecycle, complex expressions (AND, IS NULL), row enter/exit via UPDATE, composite PK with multi-column filters, multi-table roundtrip sync, and pre-existing data prefill tests for both SQLite and PostgreSQL.
- cloudsync_init: Replaced the
forceboolean parameter with aninit_flagsinteger bitmask (CLOUDSYNC_INIT_FLAG), allowing fine-grained control over which schema sanity checks are skipped. Existing callers passing0/falseor1/trueremain compatible. - API: Updated
cloudsync_initSQL signature (PostgreSQL) to acceptintegerinstead ofbooleanfor the third argument, enabling flag combinations via bitwise OR.
CLOUDSYNC_INIT_FLAG_NONE(0),CLOUDSYNC_INIT_FLAG_SKIP_INT_PK_CHECK(1),CLOUDSYNC_INIT_FLAG_SKIP_NOT_NULL_DEFAULT_CHECK(2),CLOUDSYNC_INIT_FLAG_SKIP_NOT_NULL_PRIKEYS_CHECK(4) enum values.- Documentation for
cloudsync_set_filterandcloudsync_clear_filterin API.md.
- CI/CD: Fix flutter package publish workflow not triggering on new releases.
- Harden table initialization against stale config and error cleanup.
- Swift Package: Use binary target and versioned macOS framework for Xcode 26 compatibility.
- Minor bugs in tests, docs, and examples related to the 1.0.0 major release.
- PostgreSQL support: The CloudSync extension can now be built and loaded on PostgreSQL, so both SQLiteCloud and PostgreSQL are supported as the cloud backend database of the sync service. The core CRDT functions are shared by the SQLite and PostgreSQL extensions. Includes support for PostgreSQL-native types (UUID primary keys, composite PKs with mixed types, and automatic type casting).
- Row-Level Security (RLS): Sync payloads are now fully compatible with SQLiteCloud and PostgreSQL Row-Level Security policies. Changes are buffered per primary key and flushed as complete rows, so RLS policies can evaluate all columns at once.
- Block-level LWW for text conflict resolution: Text columns can now be tracked at block level (lines by default) using Last-Writer-Wins. Concurrent edits to different parts of the same text are preserved after sync. New functions:
cloudsync_set_column()to write individual blocks andcloudsync_text_materialize()to reconstruct the full text.
-
BREAKING:
cloudsync_network_initnow accepts amanagedDatabaseIdinstead of a connection string. ThemanagedDatabaseIdis returned by the CloudSync service when a new database is registered for sync. For SQLiteCloud projects, it can be obtained from the project's OffSync page on the dashboard.Before:
SELECT cloudsync_network_init('sqlitecloud://myproject.sqlite.cloud:8860/mydb.sqlite?apikey=KEY');
After:
SELECT cloudsync_network_init('your-managed-database-id');
-
BREAKING: Sync functions now return structured JSON.
cloudsync_network_send_changes,cloudsync_network_check_changes, andcloudsync_network_syncreturn a JSON object instead of a plain integer. This provides richer status information including sync state, version numbers, row counts, and affected table names.Before:
SELECT cloudsync_network_sync(); -- 3 (number of rows received)
After:
SELECT cloudsync_network_sync(); -- '{"send":{"status":"synced","localVersion":5,"serverVersion":5},"receive":{"rows":3,"tables":["tasks"]}}'
-
Batch merge replaces column-by-column processing: During sync, changes to the same row are now applied in a single SQL statement instead of one statement per column. This eliminates the previous behavior where UPDATE triggers fired multiple times per row during synchronization.
-
Network endpoints updated for the CloudSync v2 HTTP service: Internal network layer now targets the new CloudSync service endpoints, including support for multi-organization routing.
-
NULL primary key rejection at runtime: The extension now enforces NULL primary key rejection at runtime, so the explicit
NOT NULLconstraint on primary key columns is no longer a schema requirement.
- Improved error reporting: Sync network functions now surface the actual server error message instead of generic error codes.
- Schema hash verification: Normalized schema comparison now uses only column name (lowercase), type (SQLite affinity), and primary key flag, preventing false mismatches caused by formatting differences.
- SQLite trigger safety: Internal functions used inside triggers are now marked with
SQLITE_INNOCUOUS, fixingunsafe use oferrors when initializing tables that have triggers. - NULL column binding: Column value parameters are now correctly bound even when NULL, preventing sync failures on rows with NULL values.
- Stability and reliability improvements across the SQLite and PostgreSQL codebases, including fixes to memory management, error handling, and CRDT version tracking.