mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of github.com:arangodb/arangodb into devel
This commit is contained in:
commit
0ac6b58a61
|
@ -588,6 +588,10 @@ AqlItemBlock* UpdateBlock::work(std::vector<AqlItemBlock*>& blocks) {
|
||||||
|
|
||||||
VPackSlice toUpdate = object.slice();
|
VPackSlice toUpdate = object.slice();
|
||||||
|
|
||||||
|
if (toUpdate.isNone()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// fetch old revision
|
// fetch old revision
|
||||||
OperationResult opRes = _trx->update(_collection->name, toUpdate, options);
|
OperationResult opRes = _trx->update(_collection->name, toUpdate, options);
|
||||||
if (!isMultiple) {
|
if (!isMultiple) {
|
||||||
|
@ -649,6 +653,16 @@ AqlItemBlock* UpdateBlock::work(std::vector<AqlItemBlock*>& blocks) {
|
||||||
UpsertBlock::UpsertBlock(ExecutionEngine* engine, UpsertNode const* ep)
|
UpsertBlock::UpsertBlock(ExecutionEngine* engine, UpsertNode const* ep)
|
||||||
: ModificationBlock(engine, ep) {}
|
: ModificationBlock(engine, ep) {}
|
||||||
|
|
||||||
|
bool UpsertBlock::isShardKeyError(VPackSlice const slice) const {
|
||||||
|
TRI_ASSERT(_isDBServer);
|
||||||
|
|
||||||
|
if (_usesDefaultSharding) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return slice.hasKey(StaticStrings::KeyString);
|
||||||
|
}
|
||||||
|
|
||||||
/// @brief the actual work horse for inserting data
|
/// @brief the actual work horse for inserting data
|
||||||
AqlItemBlock* UpsertBlock::work(std::vector<AqlItemBlock*>& blocks) {
|
AqlItemBlock* UpsertBlock::work(std::vector<AqlItemBlock*>& blocks) {
|
||||||
size_t const count = countBlocksRows(blocks);
|
size_t const count = countBlocksRows(blocks);
|
||||||
|
@ -758,8 +772,12 @@ AqlItemBlock* UpsertBlock::work(std::vector<AqlItemBlock*>& blocks) {
|
||||||
AqlValue const& insertDoc = res->getValueReference(i, insertRegisterId);
|
AqlValue const& insertDoc = res->getValueReference(i, insertRegisterId);
|
||||||
VPackSlice toInsert = insertDoc.slice();
|
VPackSlice toInsert = insertDoc.slice();
|
||||||
if (toInsert.isObject()) {
|
if (toInsert.isObject()) {
|
||||||
insertBuilder.add(toInsert);
|
if (_isDBServer && isShardKeyError(toInsert)) {
|
||||||
insRows.emplace_back(dstRow);
|
errorCode = TRI_ERROR_CLUSTER_MUST_NOT_SPECIFY_KEY;
|
||||||
|
} else {
|
||||||
|
insertBuilder.add(toInsert);
|
||||||
|
insRows.emplace_back(dstRow);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
errorCode = TRI_ERROR_ARANGO_DOCUMENT_TYPE_INVALID;
|
errorCode = TRI_ERROR_ARANGO_DOCUMENT_TYPE_INVALID;
|
||||||
}
|
}
|
||||||
|
@ -983,6 +1001,10 @@ AqlItemBlock* ReplaceBlock::work(std::vector<AqlItemBlock*>& blocks) {
|
||||||
}
|
}
|
||||||
|
|
||||||
VPackSlice toUpdate = object.slice();
|
VPackSlice toUpdate = object.slice();
|
||||||
|
|
||||||
|
if (toUpdate.isNone()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// fetch old revision
|
// fetch old revision
|
||||||
OperationResult opRes = _trx->replace(_collection->name, toUpdate, options);
|
OperationResult opRes = _trx->replace(_collection->name, toUpdate, options);
|
||||||
if (!isMultiple) {
|
if (!isMultiple) {
|
||||||
|
|
|
@ -126,6 +126,9 @@ class UpsertBlock : public ModificationBlock {
|
||||||
protected:
|
protected:
|
||||||
/// @brief the actual work horse for updating data
|
/// @brief the actual work horse for updating data
|
||||||
AqlItemBlock* work(std::vector<AqlItemBlock*>&) override final;
|
AqlItemBlock* work(std::vector<AqlItemBlock*>&) override final;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool isShardKeyError(arangodb::velocypack::Slice const) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace arangodb::aql
|
} // namespace arangodb::aql
|
||||||
|
|
Loading…
Reference in New Issue