Skip to content

V2 metadata format. Bump version to 0.18 - #26

Open
gorbak25 wants to merge 66 commits into
mainfrom
gorbak/new-clock-tables
Open

V2 metadata format. Bump version to 0.18#26
gorbak25 wants to merge 66 commits into
mainfrom
gorbak/new-clock-tables

Conversation

@gorbak25

Copy link
Copy Markdown

No description provided.

@gorbak25
gorbak25 force-pushed the gorbak/new-clock-tables branch 8 times, most recently from 2e2097c to f518c86 Compare July 26, 2026 19:13
@gorbak25
gorbak25 force-pushed the gorbak/new-clock-tables branch 11 times, most recently from c0de1b2 to 2e0ab78 Compare August 5, 2026 14:55
- Add V2 schema: v2_pks, v2_clock, v2_tombstones, v2_tombstone_pks, v2_col_map tables
- Add on-demand V1-to-V2 hydration for rows not yet migrated
- Add V2 local write triggers (after_insert, after_delete, after_update)
- Add V2 merge path in changes_vtab_write (v2_merge_insert, v2_packed_merge)
- Add backfill_v2 for migrating existing V1 metadata to V2
- Add alter_v2 for schema migration support
- Add bootstrap_v2 for initial V2 table creation
- Add hash_pk for PK hashing in V2 format
- Add migrate.rs for V1-to-V2 migration orchestration
- Add teardown_v2 for V2 table cleanup
- Update config with metadata-write-version and metadata-use-version settings
- Add unconditional timestamp check in merge_insert
- Refactor v1_to_v2_hydrate_row to deduplicate clock copy logic
- Add v2_tests.rs: dual-write wire convergence, ts error handling, backfill tests
- Add v2_compat_tests.rs: V1/V2 compatibility and wire format sync tests
- Add rowid_check.rs: rowid key handling tests for V2
- Update sync helpers to use transactions with crsql_set_ts
- Update test_db_version.rs with crsql_set_ts after BEGIN blocks
- Add crsql_set_ts calls in C test sync helpers and transaction blocks
- Update ext-data with timestamp field for V2 metadata writes
- Update consts.h with V2 constants
- Wrap syncLeftToRight in BEGIN/COMMIT with crsql_set_ts
@gorbak25
gorbak25 force-pushed the gorbak/new-clock-tables branch 4 times, most recently from 49cafd7 to 3d56b6c Compare August 5, 2026 16:46
c.db_version as db_vrsn,
site_tbl.site_id as site_id,
c.cell_key >> {col_id_bits} as key,
crsql_pack_varint_agg(c.seq ORDER BY cm.col_id) as seq,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to pass down the idx_string so that partial select (seq > :start and seq < :end on seq work?

gorbak25 and others added 13 commits September 1, 2026 20:37
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
Wrap create_v2_tables, create_triggers, and backfill_table_v2 calls
with descriptive error context (table name, key_is_rowid, skip_hash).
If this isn't done, the in-memory schema version is out of data,
and might not compact for the right version when commit_alter is
run after a table update

bug:
- create table (create table t1 (a primary key, b, c)
- select t1 as crr
- insert some values
- update metadata-write-version to 2 so we double write
- do another insert
- run begin-alter -> drop column -> commit map
- v2 tables aren't updated and still contain old columns
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
When crsql_set_ts() is not called for a transaction and default-ts is
set (>0), the default value is used as the transaction timestamp.
Unlike other config settings, default-ts is per-connection only and
not persisted in crsql_master — it resets to 0 on every new connection.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants