Insert a `row` into this table, storing its large var-len members in the `blob_store`. On success, returns the hash, if any, of the newly-inserted row, and a `RowRef` referring to the row.s The hash is only computed if this table has a [`PointerMap`], i.e., does not have any unique indexes. If the table has unique indexes, the returned `Option ` will be `None`. When a row equal to `row`
(
&'a mut self,
pool: &PagePool,
blob_store: &'a mut dyn BlobStore,
row: &ProductValue,
)
| 611 | /// |
| 612 | /// TODO(error-handling): describe errors from `write_row_to_pages` and return meaningful errors. |
| 613 | pub fn insert<'a>( |
| 614 | &'a mut self, |
| 615 | pool: &PagePool, |
| 616 | blob_store: &'a mut dyn BlobStore, |
| 617 | row: &ProductValue, |
| 618 | ) -> Result<(Option<RowHash>, RowRef<'a>), InsertError> { |
| 619 | // Optimistically insert the `row` before checking any constraints |
| 620 | // under the assumption that errors (unique constraint & set semantic violations) are rare. |
| 621 | let (row_ref, blob_bytes) = self.insert_physically_pv(pool, blob_store, row)?; |
| 622 | let row_ptr = row_ref.pointer(); |
| 623 | |
| 624 | // Confirm the insertion, checking any constraints, removing the physical row on error. |
| 625 | // SAFETY: We just inserted `ptr`, so it must be present. |
| 626 | // Re. `CHECK_SAME_ROW = true`, |
| 627 | // where `insert` is called, we are not dealing with transactions, |
| 628 | // and we already know there cannot be a duplicate row error, |
| 629 | // but we check just in case it isn't. |
| 630 | let (hash, row_ptr) = unsafe { self.confirm_insertion::<true>(blob_store, row_ptr, blob_bytes) }?; |
| 631 | // SAFETY: Per post-condition of `confirm_insertion`, `row_ptr` refers to a valid row. |
| 632 | let row_ref = unsafe { self.get_row_ref_unchecked(blob_store, row_ptr) }; |
| 633 | Ok((hash, row_ref)) |
| 634 | } |
| 635 | |
| 636 | /// Physically inserts `row` into the page |
| 637 | /// without inserting it logically into the pointer map. |
nothing calls this directly
no test coverage detected