870
870
case replace_expr_kind:
872
872
update_expr_base* e = static_cast<update_expr_base*>(node);
873
expr_kind_t kind = e->get_expr_kind();
874
std::vector<expr*> sources;
875
theSourceFinder->findNodeSources(e->getTargetExpr(), &udfCaller, sources);
876
markSources(sources);
875
// The target node cannot be a shared node because the update would be seen
876
// by multiple trees. For updates that delete nodes (delete and replace), the
877
// whole tree must be standalone because we have to sum up the reference
878
// counts of all the nodes in the delete subtree and that won't work if the
879
// deleted subtree contains shared nodes.
880
if (kind == replace_expr_kind || kind == delete_expr_kind)
882
std::vector<expr*> sources;
883
theSourceFinder->findNodeSources(e->getTargetExpr(), &udfCaller, sources);
884
markSources(sources);
888
markInUnsafeContext(node);
878
891
static_context* sctx = e->get_sctx();
893
// TODO: apply no-copy rule to insert and replace updates
880
894
if (e->getSourceExpr() != NULL &&
881
(e->get_expr_kind() == insert_expr_kind ||
882
(e->get_expr_kind() == replace_expr_kind &&
895
(kind == insert_expr_kind ||
896
(kind == replace_expr_kind &&
883
897
static_cast<replace_expr*>(e)->getType() == store::UpdateConsts::NODE)) &&
884
(sctx->inherit_mode() != StaticContextConsts::no_inherit_ns ||
885
sctx->preserve_mode() != StaticContextConsts::no_preserve_ns))
898
(sctx->inherit_mode() == StaticContextConsts::inherit_ns &&
899
sctx->preserve_mode() == StaticContextConsts::preserve_ns))
887
901
std::vector<expr*> sources;
888
902
theSourceFinder->findNodeSources(e->getSourceExpr(), &udfCaller, sources);