tiny.sql.relationRoot
Defined in version.
Source
Source: lib/sql/src/version.zig:502
zig
pub fn relationRoot(allocator: Allocator, name: []const u8, catalog_schema: catalog_mod.Schema, handle: *const catalog_mod.RelationHandle, stats: ?*const catalog_mod.RelationStats) Error!RelationRoot { const owned_name = try allocator.dupe(u8, name); errdefer allocator.free(owned_name); var table_root = try mapRoot(allocator, &handle.relation.table.rows); errdefer table_root.deinit(); var schema_descriptor = try RelationSchema.init(allocator, handle.definitions, handle.index_definitions); errdefer schema_descriptor.deinit(); const schema_hash = schemaHash(schema_descriptor.columns, schema_descriptor.indexes); const stats_root = relationStatsRoot(stats); const indexes = try allocator.alloc(IndexRoot, handle.specs.len); var index_count: usize = 0; errdefer { for (indexes[0..index_count]) |*index| index.deinit(); allocator.free(indexes); } for (handle.specs, indexes) |spec, *target| { var index_tree = try handle.relation.space.tree(spec.root_page); var map = try mapRoot(allocator, &index_tree); var map_assigned = false; errdefer if (!map_assigned) map.deinit(); const index_stats = findIndexStats(stats, spec.root_page); const index_stats_hash = indexStatsHash(index_stats); target.* = .{ .fields = fieldsHash(spec.fields, spec.columns), .map = map, .stats = index_stats_hash, .hash = indexHash(spec.fields, spec.columns, map.hash, index_stats_hash), }; map_assigned = true; index_count += 1; } var builder = Builder.init("sql.relation"); builder.writeU32(format_version); builder.bytes(name); builder.hash(schema_hash); builder.hash(table_root.hash); builder.hash(stats_root.hash); builder.writeU64(indexes.len); for (indexes) |index| builder.hash(index.hash); return .{ .allocator = allocator, .name = owned_name, .catalog = .{ .format = catalog_schema.format, .version = catalog_schema.version, }, .schema = schema_hash, .schema_descriptor = schema_descriptor, .table = table_root, .indexes = indexes, .stats = stats_root, .hash = builder.finish(), };}Source: lib/sql/src/root.zig:291
zig
pub const relationRoot = version.relationRoot;Complete caller list
17 direct callers.
lib.sql.src.blame.snapshotCommit[function] — private source atlib/sql/src/blame.zig:248in nearest public ownertiny.sql.blametiny.sql.Connection.relationView[method] atlib/sql/src/connection.zig:516lib.sql.src.diff.test_relation_diff_marks_rows_when_schema_roots_differ[function] — test source atlib/sql/src/diff.zig:394in nearest public ownertiny.sql.difflib.sql.src.diff.test_relation_diff_reports_added_removed_and_modified_rows[function] — test source atlib/sql/src/diff.zig:336in nearest public ownertiny.sql.difflib.sql.src.diff.test_relation_diff_skips_equal_table_subtrees[function] — test source atlib/sql/src/diff.zig:444in nearest public ownertiny.sql.difflib.sql.src.history.store.test_history_merkle_relation_roots_preserve_diff_behavior_across_reopen[function] — test source atlib/sql/src/history/store.zig:2127in nearest public ownerlib.sql.src.history.storelib.sql.src.merge.test_database_merge_applies_clean_relation_edits_and_derives_root[function] — test source atlib/sql/src/merge.zig:1060in nearest public ownertiny.sql.mergelib.sql.src.merge.test_database_merge_matches_relation_names_and_preserves_independent_relation_set_changes[function] — test source atlib/sql/src/merge.zig:1249in nearest public ownertiny.sql.mergelib.sql.src.merge.test_database_merge_records_relation_topology_conflicts_under_database_root[function] — test source atlib/sql/src/merge.zig:1386in nearest public ownertiny.sql.mergelib.sql.src.merge.test_database_merge_supersedes_stale_slots_and_persists_complete_conflict_root[function] — test source atlib/sql/src/merge.zig:1151in nearest public ownertiny.sql.mergelib.sql.src.merge.test_relation_merge_coalesces_identical_concurrent_edits[function] — test source atlib/sql/src/merge.zig:998in nearest public ownertiny.sql.mergelib.sql.src.merge.test_relation_merge_records_divergent_same_row_conflicts[function] — test source atlib/sql/src/merge.zig:933in nearest public ownertiny.sql.mergelib.sql.src.merge.test_relation_merge_resolves_nonoverlapping_row_edits[function] — test source atlib/sql/src/merge.zig:856in nearest public ownertiny.sql.mergetiny.sql.version.databaseRoot[function] atlib/sql/src/version.zig:976lib.sql.src.version.test_relation_root_from_materialized_rows_matches_live_logical_maps[function] — test source atlib/sql/src/version.zig:1899in nearest public ownertiny.sql.versionlib.sql.src.version.test_relation_root_hash_is_stable_across_reopen_and_changes_after_row_write[function] — test source atlib/sql/src/version.zig:1968in nearest public ownertiny.sql.versionlib.sql.src.version.test_relation_root_ignores_unrelated_catalog_schema_version_bumps[function] — test source atlib/sql/src/version.zig:1727in nearest public ownertiny.sql.version
Complete call list
15 direct calls.
lib.sql.src.version.Builder.bytes[method] — private source atlib/sql/src/version.zig:1367in nearest public ownertiny.sql.versionlib.sql.src.version.Builder.finish[method] — private source atlib/sql/src/version.zig:1357in nearest public ownertiny.sql.versionlib.sql.src.version.Builder.hash[method] — private source atlib/sql/src/version.zig:1363in nearest public ownertiny.sql.versionlib.sql.src.version.Builder.init[function] — private source atlib/sql/src/version.zig:1351in nearest public ownertiny.sql.versionlib.sql.src.version.Builder.writeU32[method] — private source atlib/sql/src/version.zig:1443in nearest public ownertiny.sql.versionlib.sql.src.version.Builder.writeU64[method] — private source atlib/sql/src/version.zig:1449in nearest public ownertiny.sql.versiontiny.sql.RelationSchema.deinit[method] atlib/sql/src/version.zig:86tiny.sql.RelationSchema.init[function] atlib/sql/src/version.zig:56lib.sql.src.version.fieldsHash[function] — private source atlib/sql/src/version.zig:1216in nearest public ownertiny.sql.versionlib.sql.src.version.findIndexStats[function] — private source atlib/sql/src/version.zig:1246in nearest public ownertiny.sql.versionlib.sql.src.version.indexHash[function] — private source atlib/sql/src/version.zig:1208in nearest public ownertiny.sql.versionlib.sql.src.version.indexStatsHash[function] — private source atlib/sql/src/version.zig:1254in nearest public ownertiny.sql.versiontiny.sql.version.mapRoot[function] atlib/sql/src/version.zig:1069lib.sql.src.version.relationStatsRoot[function] — private source atlib/sql/src/version.zig:1225in nearest public ownertiny.sql.versiontiny.sql.version.schemaHash[function] atlib/sql/src/version.zig:1133
Audit
| Definitions | 1 |
|---|---|
| Public names | 2 |
| Members | 0 |
| Version | 26.7.0 |
| Revision | daab053ee433 |