|
|
|
@ -44,7 +44,7 @@ impl<'a> SessionTx<'a> {
|
|
|
|
|
pub(crate) fn execute_relation<'s, S: Storage<'s>>(
|
|
|
|
|
&mut self,
|
|
|
|
|
db: &Db<S>,
|
|
|
|
|
res_iter: impl Iterator<Item = Tuple>,
|
|
|
|
|
res_iter: impl Iterator<Item=Tuple>,
|
|
|
|
|
op: RelationOp,
|
|
|
|
|
meta: &InputRelationHandle,
|
|
|
|
|
headers: &[Symbol],
|
|
|
|
@ -178,7 +178,7 @@ impl<'a> SessionTx<'a> {
|
|
|
|
|
key_bindings,
|
|
|
|
|
*span,
|
|
|
|
|
)?,
|
|
|
|
|
RelationOp::Create | RelationOp::Replace | RelationOp::Put => self.put_into_relation(
|
|
|
|
|
RelationOp::Create | RelationOp::Replace | RelationOp::Put | RelationOp::Insert => self.put_into_relation(
|
|
|
|
|
db,
|
|
|
|
|
res_iter,
|
|
|
|
|
headers,
|
|
|
|
@ -191,6 +191,7 @@ impl<'a> SessionTx<'a> {
|
|
|
|
|
metadata,
|
|
|
|
|
key_bindings,
|
|
|
|
|
dep_bindings,
|
|
|
|
|
op == RelationOp::Insert,
|
|
|
|
|
*span,
|
|
|
|
|
)?,
|
|
|
|
|
};
|
|
|
|
@ -201,7 +202,7 @@ impl<'a> SessionTx<'a> {
|
|
|
|
|
fn put_into_relation<'s, S: Storage<'s>>(
|
|
|
|
|
&mut self,
|
|
|
|
|
db: &Db<S>,
|
|
|
|
|
res_iter: impl Iterator<Item = Tuple>,
|
|
|
|
|
res_iter: impl Iterator<Item=Tuple>,
|
|
|
|
|
headers: &[Symbol],
|
|
|
|
|
cur_vld: ValidityTs,
|
|
|
|
|
callback_targets: &BTreeSet<SmartString<LazyCompact>>,
|
|
|
|
@ -212,6 +213,7 @@ impl<'a> SessionTx<'a> {
|
|
|
|
|
metadata: &StoredRelationMetadata,
|
|
|
|
|
key_bindings: &[Symbol],
|
|
|
|
|
dep_bindings: &[Symbol],
|
|
|
|
|
is_insert: bool,
|
|
|
|
|
span: SourceSpan,
|
|
|
|
|
) -> Result<()> {
|
|
|
|
|
let is_callback_target = callback_targets.contains(&relation_store.name);
|
|
|
|
@ -268,6 +270,16 @@ impl<'a> SessionTx<'a> {
|
|
|
|
|
.map(|ex| ex.extract_data(&tuple, cur_vld))
|
|
|
|
|
.try_collect()?;
|
|
|
|
|
|
|
|
|
|
if is_insert {
|
|
|
|
|
if relation_store.exists(self, &extracted[..relation_store.metadata.keys.len()])? {
|
|
|
|
|
bail!(TransactAssertionFailure {
|
|
|
|
|
relation: relation_store.name.to_string(),
|
|
|
|
|
key: extracted,
|
|
|
|
|
notice: "key exists in database".to_string()
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let key = relation_store.encode_key_for_store(&extracted, span)?;
|
|
|
|
|
let val = relation_store.encode_val_for_store(&extracted, span)?;
|
|
|
|
|
|
|
|
|
@ -496,7 +508,7 @@ impl<'a> SessionTx<'a> {
|
|
|
|
|
fn update_in_relation<'s, S: Storage<'s>>(
|
|
|
|
|
&mut self,
|
|
|
|
|
db: &Db<S>,
|
|
|
|
|
res_iter: impl Iterator<Item = Tuple>,
|
|
|
|
|
res_iter: impl Iterator<Item=Tuple>,
|
|
|
|
|
headers: &[Symbol],
|
|
|
|
|
cur_vld: ValidityTs,
|
|
|
|
|
callback_targets: &BTreeSet<SmartString<LazyCompact>>,
|
|
|
|
@ -770,7 +782,7 @@ impl<'a> SessionTx<'a> {
|
|
|
|
|
|
|
|
|
|
fn ensure_not_in_relation(
|
|
|
|
|
&mut self,
|
|
|
|
|
res_iter: impl Iterator<Item = Tuple>,
|
|
|
|
|
res_iter: impl Iterator<Item=Tuple>,
|
|
|
|
|
headers: &[Symbol],
|
|
|
|
|
cur_vld: ValidityTs,
|
|
|
|
|
relation_store: &mut RelationHandle,
|
|
|
|
@ -817,7 +829,7 @@ impl<'a> SessionTx<'a> {
|
|
|
|
|
|
|
|
|
|
fn ensure_in_relation(
|
|
|
|
|
&mut self,
|
|
|
|
|
res_iter: impl Iterator<Item = Tuple>,
|
|
|
|
|
res_iter: impl Iterator<Item=Tuple>,
|
|
|
|
|
headers: &[Symbol],
|
|
|
|
|
cur_vld: ValidityTs,
|
|
|
|
|
relation_store: &mut RelationHandle,
|
|
|
|
@ -887,7 +899,7 @@ impl<'a> SessionTx<'a> {
|
|
|
|
|
fn remove_from_relation<'s, S: Storage<'s>>(
|
|
|
|
|
&mut self,
|
|
|
|
|
db: &Db<S>,
|
|
|
|
|
res_iter: impl Iterator<Item = Tuple>,
|
|
|
|
|
res_iter: impl Iterator<Item=Tuple>,
|
|
|
|
|
headers: &[Symbol],
|
|
|
|
|
cur_vld: ValidityTs,
|
|
|
|
|
callback_targets: &BTreeSet<SmartString<LazyCompact>>,
|
|
|
|
|