Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions crates/bench/benches/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ impl Index for IBTree {
Self(<_>::default())
}
fn insert(&mut self, key: K, val: RowPointer) -> Result<(), RowPointer> {
self.0.insert(key, val)
// SAFETY: we never insert `(key, val)` twice in benchmarks.
unsafe { self.0.insert(key, val) }
}
fn seek(&self, key: K) -> impl Iterator<Item = RowPointer> {
self.0.seek_range(&(key..=key))
Expand Down Expand Up @@ -250,7 +251,8 @@ impl Index for IDirectIndex {
Self(<_>::default())
}
fn insert(&mut self, key: K, val: RowPointer) -> Result<(), RowPointer> {
self.0.insert(key, val)
// SAFETY: we never insert `(key, val)` twice in benchmarks.
unsafe { self.0.insert(key, val) }
}
fn seek(&self, key: K) -> impl Iterator<Item = RowPointer> {
self.0.seek_point(&key)
Expand Down
4 changes: 3 additions & 1 deletion crates/datastore/src/locking_tx_datastore/committed_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,9 @@ impl CommittedState {
let is_unique = unique_constraints.contains(&(table_id, columns));

let index = table.new_index(&algo, is_unique)?;
// SAFETY: `index` was derived from `table`.
// SAFETY:
// 1. `index` was derived from `table`.
// 2. `index` was just created, so it is empty.
unsafe { table.insert_index(blob_store, index_id, index) };
index_id_map.insert(index_id, table_id);
}
Expand Down
27 changes: 23 additions & 4 deletions crates/datastore/src/locking_tx_datastore/mut_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1213,8 +1213,12 @@ impl MutTxId {
// due to the existing rows having the same value for some column(s).
let build_from_rows = |index: &mut TableIndex, table: &Table, bs: &dyn BlobStore| -> Result<()> {
let rows = table.scan_rows(bs);
// SAFETY: (1) `tx_index` / `commit_index` was derived from `table` / `commit_table`
// SAFETY:
//
// (1) `tx_index` / `commit_index` was derived from `table` / `commit_table`
// which in turn was derived from `commit_table`.
//
// (2) Both `tx_index` and `commit_index` are empty before this call.
let violation = unsafe { index.build_from_rows(rows) };
violation.map_err(|v| map_violation(v, index, table, bs))
};
Expand Down Expand Up @@ -2705,8 +2709,13 @@ pub(super) fn insert<'a, const GENERATE: bool>(
let ok = |row_ref| Ok((gen_cols, row_ref, insert_flags));

// `CHECK_SAME_ROW = true`, as there might be an identical row already in the tx state.
// SAFETY: `tx_table.is_row_present(row)` holds as we still haven't deleted the row,
// SAFETY:
//
// - `tx_table.is_row_present(row)` holds as we still haven't deleted the row,
// in particular, the `write_gen_val_to_col` call does not remove the row.
//
// - `tx_row_ptr` was freshly made
// so we couldn't have inserted it into any of the indices yet.
let res = unsafe { tx_table.confirm_insertion::<true>(tx_blob_store, tx_row_ptr, blob_bytes) };

match res {
Expand Down Expand Up @@ -2931,9 +2940,14 @@ impl MutTxId {
// but it cannot, as the committed state already has `X` for `C`.
// So we don't need to check the tx state for a duplicate row.
//
// SAFETY: `tx_table.is_row_present(row)` holds as we still haven't deleted the row,
// SAFETY:
//
// - `tx_table.is_row_present(row)` holds as we still haven't deleted the row,
// in particular, the `write_gen_val_to_col` call does not remove the row.
// On error, `tx_row_ptr` has already been removed, so don't do it again.
//
// - `tx_row_ptr` was freshly made
// so we couldn't have inserted it into any of the indices yet.
let (_, tx_row_ptr) =
unsafe { tx_table.confirm_insertion::<false>(tx_blob_store, tx_row_ptr, blob_bytes) }?;

Expand All @@ -2950,9 +2964,14 @@ impl MutTxId {
// This ensures that the old row is removed from the indices
// before attempting to insert the new row into the indices.
//
// SAFETY: `tx_table.is_row_present(tx_row_ptr)` and `tx_table.is_row_present(old_ptr)` both hold
// SAFETY:
//
// - `tx_table.is_row_present(tx_row_ptr)` and `tx_table.is_row_present(old_ptr)` both hold
// as we've deleted neither.
// In particular, the `write_gen_val_to_col` call does not remove the row.
//
// - `tx_row_ptr` was freshly made
// so we couldn't have inserted it into any of the indices yet.
let tx_row_ptr = unsafe { tx_table.confirm_update(tx_blob_store, tx_row_ptr, old_ptr, blob_bytes) }?;

if let Some(old_commit_del_ptr) = old_commit_del_ptr {
Expand Down
2 changes: 1 addition & 1 deletion crates/sats/src/proptest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ fn generate_array_value(ty: AlgebraicType) -> BoxedStrategy<ArrayValue> {
}
}

fn gen_with<T: Clone + Debug, US: Strategy>(
pub fn gen_with<T: Clone + Debug, US: Strategy>(
with: impl Strategy<Value = T>,
then: impl Fn(T) -> US,
) -> impl Strategy<Value = (T, US::Value)> {
Expand Down
4 changes: 3 additions & 1 deletion crates/table/benches/page_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,9 @@ fn make_table_with_index<R: IndexedRow>(unique: bool) -> (Table, IndexId) {
let index_id = IndexId::SENTINEL;
let algo = BTreeAlgorithm { columns: cols }.into();
let idx = tbl.new_index(&algo, unique).unwrap();
// SAFETY: index was derived from the table.
// SAFETY:
// 1. Index was derived from the table.
// 2. Index was empty before this call.
unsafe { tbl.insert_index(&NullBlobStore, index_id, idx) };

(tbl, index_id)
Expand Down
1 change: 1 addition & 0 deletions crates/table/proptest-regressions/table_index/mod.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
# everyone who runs the test benefits from these saved cases.
cc 3276d3db4a1a70d78db9a6a01eaa3bba810a2317e9c67e4d5d8d93cbba472c99 # shrinks to ((ty, cols, pv), is_unique) = ((ProductType {None: Bool}, [ColId(0)], ProductValue { elements: [Bool(false)] }), false)
cc bc80b80ac2390452c0a152d2c6e2abc29ce146642f3cd0fe136ffe6173cf4c8c # shrinks to (ty, cols, pv) = (ProductType {None: I64}, [ColId(0)], ProductValue { elements: [I64(0)] }), kind = Direct
cc b08557e7170d6255f0eb54bf8d213c5f20d33b104bf9dba106c3360a6c4db742 # shrinks to (ty, cols, pvs) = (ProductType {None: Array(ArrayType { elem_ty: Product(ProductType {}) }), None: Product(ProductType {}), None: Product(ProductType {"field_0": I32, "field_1": Product(ProductType {}), "field_2": F32, "field_3": U8, "field_4": Product(ProductType {})}), None: Product(ProductType {"field_0": U128, "field_1": String, "field_2": String, "field_3": Product(ProductType {}), "field_4": Product(ProductType {}), "field_5": U256, "field_6": String, "field_7": Product(ProductType {}), "field_8": Product(ProductType {}), "field_9": Product(ProductType {}), "field_10": Product(ProductType {}), "field_11": Product(ProductType {}), "field_12": Product(ProductType {}), "field_13": String, "field_14": I8}), None: Sum(SumType {"variant_0": Product(ProductType {}), "variant_1": Product(ProductType {}), "variant_2": Product(ProductType {}), "variant_3": String, "variant_4": I256, "variant_5": I16, "variant_6": U32, "variant_7": Product(ProductType {}), "variant_8": String, "variant_9": U128, "variant_10": Product(ProductType {}), "variant_11": String, "variant_12": U8, "variant_13": String, "variant_14": Product(ProductType {})})}, [ColId(0)], {ProductValue { elements: [Array([ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }]), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [I32(-1328563213), Product(ProductValue { elements: [] }), F32(Total(958158200000.0)), U8(203), Product(ProductValue { elements: [] })] }), Product(ProductValue { elements: [U128(Packed(251502612027954903598235106926969200112)), String("açѨ𑾰ಫ𞄅\u{1cf44}"), String("¥ⶥ𓅴/"), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), U256(14146624945421842192487613124473728284456634249970206008103750852206939464228), String("ⷜΌ05<ਛ"), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), String("?<:ꩥ𐌼3¥ᒐ🕴*"), I8(26)] }), Sum(SumValue { tag: 9, value: U128(Packed(125257749904311445818453176702095543350)) })] }, ProductValue { elements: [Array([ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }]), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [I32(-751750749), Product(ProductValue { elements: [] }), F32(Total(3.336987e-35)), U8(42), Product(ProductValue { elements: [] })] }), Product(ProductValue { elements: [U128(Packed(339104954473373805302093813396056989268)), String("D¡fে"), String("t,$᪖~?\\¤<\\8{%:ট𞹉𐨜/|\u{113d2}q"), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), U256(41773988496513295035720168499770300429513056844463058281982480850904823330850), String("Ⱥ\u{d62}\u{a0}u$u/ଳ🯖𞹛סּ𐠼ͼ\u{ccd}/*k&=$(ᆴ%:ꡨ𖭝𞢘d:"), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), String("꯲ஐ𞹇Ⱥﺘ𐄂𐐠ⷃ&ã𞹡4Ⴭ𞟮\u{1bc9d}፱5`$𐵻ῩH"), I8(-70)] }), Sum(SumValue { tag: 1, value: Product(ProductValue { elements: [] }) })] }, ProductValue { elements: [Array([ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }]), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [I32(-1118630758), Product(ProductValue { elements: [] }), F32(Total(-0.0)), U8(239), Product(ProductValue { elements: [] })] }), Product(ProductValue { elements: [U128(Packed(27536991987242777193405425217462174222)), String("𝅀𝔛`>ଅ$?𐖐ᛡࡩ𑛗𐊛𑛃Y$𖫬🕴\u{180b}b$𝋎𖵘𞹛𐂥.'ਬȺ\"$"), String("𑴈சT'V)ø𑌞𝍨%$hÆN🕴\"¥;o!ଂ @{/k`"), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), U256(29647333290262267566949551720292103306397329265983271305104466210817874163429), String("4p¢𪦝R$𞺉Ῠ+𝒞a\\`ᅩ𐞗\u{11368}:𑶧\u{9d7}U{?}w¼\"?𐄚M𝌤"), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), String("ቝဓk𐵁ȺcNໆגּ`"), I8(-48)] }), Sum(SumValue { tag: 2, value: Product(ProductValue { elements: [] }) })] }, ProductValue { elements: [Array([ProductValue { elements: [] }, ProductValue { elements: [] }]), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [I32(698027962), Product(ProductValue { elements: [] }), F32(Total(-39284745000000.0)), U8(112), Product(ProductValue { elements: [] })] }), Product(ProductValue { elements: [U128(Packed(174967764461688626745346351186100520227)), String("\u{1932}'\\*ᝧ¥'\u{1c31}P"), String("%vȺ𖩧Ⱥ𖼁=🕴𐆠:𐮙ȺA0𝼖𐄀M𑶌"), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), U256(37717031760385427292736334126399394818959330048323119881691271279214480342799), String("JﬖF𫦴Ѩ[/🜸𞸻1Yᝧ�9\u{1e029}(𝼪"), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), String("꣕vﶩG\u{cc8}/e=Ѩ2ೝ𐔓𐭟*"), I8(-75)] }), Sum(SumValue { tag: 8, value: String("ⴚq//Gmâଋ$,>=") })] }, ProductValue { elements: [Array([ProductValue { elements: [] }]), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [I32(808239480), Product(ProductValue { elements: [] }), F32(Total(-3.414441e37)), U8(177), Product(ProductValue { elements: [] })] }), Product(ProductValue { elements: [U128(Packed(10204641291867593007668743197885064201)), String("3G𝔩+\"�\"ໆMꬠ𐁑'{{𑱁=H&P𝒻:É�\u{10a05}¥Ⱥ\u{a0}'"), String("?=ì#ተ+𖩗¥ஜ"), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), U256(14046885727081498117947153136180091694669074271105084926963954623447898517582), String("ໃ$🬯pꔣ<:�tȺ𑚯[𐕡\"/�🕴pi-%\u{11d3a}"), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), String("'"), I8(105)] }), Sum(SumValue { tag: 11, value: String("æ\"") })] }, ProductValue { elements: [Array([ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }]), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [I32(-70980545), Product(ProductValue { elements: [] }), F32(Total(1.171588e-29)), U8(223), Product(ProductValue { elements: [] })] }), Product(ProductValue { elements: [U128(Packed(88777670818810963552904284719155639123)), String("𐼑𐶁ῖ🫖t𞺦🟡iꬓ\u{11d90}(<$É\\G?᥀ᅵ¶𓄌9`&னȸ"), String("\"\":*ï"), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), U256(54010679623959203229181053928725898254083356964342913551887149504923935650601), String("𞹗&`B𝍴Sೳ𞠰_F𑂚ꧣ𝒷⭽/\\Ⱥ\\⭷੦&O.𪹟8"), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), String("🫤.`𑴄\u{1d17e}🝥x"), I8(53)] }), Sum(SumValue { tag: 11, value: String("¬Z") })] }, ProductValue { elements: [Array([ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }, ProductValue { elements: [] }]), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [I32(108646348), Product(ProductValue { elements: [] }), F32(Total(7.8576715e33)), U8(222), Product(ProductValue { elements: [] })] }), Product(ProductValue { elements: [U128(Packed(40574578188674017083176300176629015122)), String(".🕴.{`ધ:쁏Ѩඒ𝧅J¥𐍇]'*<𮰼ᾦ\"¥/yT\\𐭹ᥱ{=}"), String("\u{dd6}`H+𛅒Ѩ<ῐr*ࡷ𞓔�`=ಐᳳ??Ѩ𐿢?"), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), U256(60630591893869796294376955453587017416654442715111668314202502849166405246984), String("Y*V\u{11366}\u{8cd}מּ\"`H𝆹𝅥%"), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), String("ⶱÅቔ%�=𑇳Ꮱ"), I8(31)] }), Sum(SumValue { tag: 1, value: Product(ProductValue { elements: [] }) })] }, ProductValue { elements: [Array([ProductValue { elements: [] }, ProductValue { elements: [] }]), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [I32(830118612), Product(ProductValue { elements: [] }), F32(Total(1.101187e-33)), U8(65), Product(ProductValue { elements: [] })] }), Product(ProductValue { elements: [U128(Packed(137337744496642533251742504155558136608)), String("\u{dd3}&`/[`6࠳*xtäנּ.KE"), String("tP�V:`?A/𑃳"), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), U256(80787311696497238070344266539849847782086419751086673488319811239072145291490), String("&�𑶔ਸr𞸧\"\\&%�\u{1182f}𝔄𑊨Gx𱇨J${\"ₙ$🂼*"), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), String("?🕴�'ᏽ\u{89a}*C�¥¥0\u{cd6}𑋰𑎐\\q᧪\u{bcd}ൽ/=🕴"), I8(26)] }), Sum(SumValue { tag: 6, value: U32(2024581402) })] }, ProductValue { elements: [Array([]), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [I32(24951015), Product(ProductValue { elements: [] }), F32(Total(-12695150000000.0)), U8(173), Product(ProductValue { elements: [] })] }), Product(ProductValue { elements: [U128(Packed(258919236975175920825620631536077804022)), String("=<|/\\s'צw{¬'.¥"), String("⫓\\*ஸ\u{ac7}Y: ?t:$2Ѩ5୧%'𐿱ਗ਼𞥟$>"), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), U256(22057633765777686815195263370569165748936401038219764560190933715062466133713), String("i*�ໜ𑿜𒍽X'Èꟙ?$/x/'𑴈ງ{\u{bd7}"), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), Product(ProductValue { elements: [] }), String("G\"\u{11357}XਵὠzѨ@+Þ'V/"), I8(-125)] }), Sum(SumValue { tag: 7, value: Product(ProductValue { elements: [] }) })] }}), kind = BTree, is_unique = false
Loading
Loading