From ef7f58b368380cbbf3bb5daa1b06f3830249ecaf Mon Sep 17 00:00:00 2001 From: Ziyang Hu Date: Fri, 23 Dec 2022 21:23:19 +0800 Subject: [PATCH] rm does not need all keys --- cozo-core/src/runtime/db.rs | 2 +- cozo-core/src/runtime/relation.rs | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cozo-core/src/runtime/db.rs b/cozo-core/src/runtime/db.rs index a4529a08..cd04632b 100644 --- a/cozo-core/src/runtime/db.rs +++ b/cozo-core/src/runtime/db.rs @@ -867,7 +867,7 @@ impl<'s, S: Storage<'s>> Db { StoreRelationNotFoundError(meta.name.to_string()) ); - existing.ensure_compatible(meta)?; + existing.ensure_compatible(meta, *op == RelationOp::Rm)?; } }; diff --git a/cozo-core/src/runtime/relation.rs b/cozo-core/src/runtime/relation.rs index e85063cd..feb6a79e 100644 --- a/cozo-core/src/runtime/relation.rs +++ b/cozo-core/src/runtime/relation.rs @@ -163,7 +163,7 @@ impl RelationHandle { tuple.serialize(&mut Serializer::new(&mut ret)).unwrap(); Ok(ret) } - pub(crate) fn ensure_compatible(&self, inp: &InputRelationHandle) -> Result<()> { + pub(crate) fn ensure_compatible(&self, inp: &InputRelationHandle, is_remove: bool) -> Result<()> { let InputRelationHandle { metadata, .. } = inp; // check that every given key is found and compatible for col in &metadata.keys { @@ -176,8 +176,10 @@ impl RelationHandle { for col in &self.metadata.keys { metadata.satisfied_by_required_col(col, true)?; } - for col in &self.metadata.non_keys { - metadata.satisfied_by_required_col(col, false)?; + if !is_remove { + for col in &self.metadata.non_keys { + metadata.satisfied_by_required_col(col, false)?; + } } Ok(()) }