@@ -214,6 +214,54 @@ pub mod raw {
214214 out : * mut u32 ,
215215 ) -> u16 ;
216216
217+ /// Deletes all rows found in the index identified by `index_id`,
218+ /// according to the:
219+ /// - `prefix = prefix_ptr[..prefix_len]`,
220+ /// - `rstart = rstart_ptr[..rstart_len]`,
221+ /// - `rend = rend_ptr[..rend_len]`,
222+ /// in WASM memory.
223+ ///
224+ /// This syscall will delete all the rows found by
225+ /// [`datastore_btree_scan_bsatn`] with the same arguments passed,
226+ /// including `prefix_elems`.
227+ /// See `datastore_btree_scan_bsatn` for details.
228+ ///
229+ /// The number of rows deleted is written to the WASM pointer `out`.
230+ ///
231+ /// # Traps
232+ ///
233+ /// Traps if:
234+ /// - `prefix_elems > 0`
235+ /// and (`prefix_ptr` is NULL or `prefix` is not in bounds of WASM memory).
236+ /// - `rstart` is NULL or `rstart` is not in bounds of WASM memory.
237+ /// - `rend` is NULL or `rend` is not in bounds of WASM memory.
238+ /// - `out` is NULL or `out[..size_of::<u32>()]` is not in bounds of WASM memory.
239+ ///
240+ /// # Errors
241+ ///
242+ /// Returns an error:
243+ ///
244+ /// - `NOT_IN_TRANSACTION`, when called outside of a transaction.
245+ /// - `NO_SUCH_INDEX`, when `index_id` is not a known ID of an index.
246+ /// - `WRONG_INDEX_ALGO` if the index is not a btree index.
247+ /// - `BSATN_DECODE_ERROR`, when `prefix` cannot be decoded to
248+ /// a `prefix_elems` number of `AlgebraicValue`
249+ /// typed at the initial `prefix_elems` `AlgebraicType`s of the index's key type.
250+ /// Or when `rstart` or `rend` cannot be decoded to an `Bound<AlgebraicValue>`
251+ /// where the inner `AlgebraicValue`s are
252+ /// typed at the `prefix_elems + 1` `AlgebraicType` of the index's key type.
253+ pub fn _datastore_delete_by_btree_scan_bsatn (
254+ index_id : IndexId ,
255+ prefix_ptr : * const u8 ,
256+ prefix_len : usize ,
257+ prefix_elems : ColId ,
258+ rstart_ptr : * const u8 , // Bound<AlgebraicValue>
259+ rstart_len : usize ,
260+ rend_ptr : * const u8 , // Bound<AlgebraicValue>
261+ rend_len : usize ,
262+ out : * mut u32 ,
263+ ) -> u16 ;
264+
217265 /// Deletes those rows, in the table identified by `table_id`,
218266 /// that match any row in the byte string `rel = rel_ptr[..rel_len]` in WASM memory.
219267 ///
@@ -898,6 +946,53 @@ pub fn datastore_btree_scan_bsatn(
898946 Ok ( RowIter { raw } )
899947}
900948
949+ /// Deletes all rows found in the index identified by `index_id`,
950+ /// according to the `prefix`, `rstart`, and `rend`.
951+ ///
952+ /// This syscall will delete all the rows found by
953+ /// [`datastore_btree_scan_bsatn`] with the same arguments passed,
954+ /// including `prefix_elems`.
955+ /// See `datastore_btree_scan_bsatn` for details.
956+ ///
957+ /// The number of rows deleted is returned on success.
958+ ///
959+ /// # Errors
960+ ///
961+ /// Returns an error:
962+ ///
963+ /// - `NOT_IN_TRANSACTION`, when called outside of a transaction.
964+ /// - `NO_SUCH_INDEX`, when `index_id` is not a known ID of an index.
965+ /// - `WRONG_INDEX_ALGO` if the index is not a btree index.
966+ /// - `BSATN_DECODE_ERROR`, when `prefix` cannot be decoded to
967+ /// a `prefix_elems` number of `AlgebraicValue`
968+ /// typed at the initial `prefix_elems` `AlgebraicType`s of the index's key type.
969+ /// Or when `rstart` or `rend` cannot be decoded to an `Bound<AlgebraicValue>`
970+ /// where the inner `AlgebraicValue`s are
971+ /// typed at the `prefix_elems + 1` `AlgebraicType` of the index's key type.
972+ pub fn datastore_delete_by_btree_scan_bsatn (
973+ index_id : IndexId ,
974+ prefix : & [ u8 ] ,
975+ prefix_elems : ColId ,
976+ rstart : & [ u8 ] ,
977+ rend : & [ u8 ] ,
978+ ) -> Result < u32 , Errno > {
979+ unsafe {
980+ call ( |out| {
981+ raw:: _datastore_delete_by_btree_scan_bsatn (
982+ index_id,
983+ prefix. as_ptr ( ) ,
984+ prefix. len ( ) ,
985+ prefix_elems,
986+ rstart. as_ptr ( ) ,
987+ rstart. len ( ) ,
988+ rend. as_ptr ( ) ,
989+ rend. len ( ) ,
990+ out,
991+ )
992+ } )
993+ }
994+ }
995+
901996/// Iterate through a table, filtering by an encoded `spacetimedb_lib::filter::Expr`.
902997///
903998/// # Errors
0 commit comments