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();
|
||||
|
||||
if (toUpdate.isNone()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// fetch old revision
|
||||
OperationResult opRes = _trx->update(_collection->name, toUpdate, options);
|
||||
if (!isMultiple) {
|
||||
|
@ -649,6 +653,16 @@ AqlItemBlock* UpdateBlock::work(std::vector<AqlItemBlock*>& blocks) {
|
|||
UpsertBlock::UpsertBlock(ExecutionEngine* engine, UpsertNode const* 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
|
||||
AqlItemBlock* UpsertBlock::work(std::vector<AqlItemBlock*>& 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);
|
||||
VPackSlice toInsert = insertDoc.slice();
|
||||
if (toInsert.isObject()) {
|
||||
insertBuilder.add(toInsert);
|
||||
insRows.emplace_back(dstRow);
|
||||
if (_isDBServer && isShardKeyError(toInsert)) {
|
||||
errorCode = TRI_ERROR_CLUSTER_MUST_NOT_SPECIFY_KEY;
|
||||
} else {
|
||||
insertBuilder.add(toInsert);
|
||||
insRows.emplace_back(dstRow);
|
||||
}
|
||||
} else {
|
||||
errorCode = TRI_ERROR_ARANGO_DOCUMENT_TYPE_INVALID;
|
||||
}
|
||||
|
@ -983,6 +1001,10 @@ AqlItemBlock* ReplaceBlock::work(std::vector<AqlItemBlock*>& blocks) {
|
|||
}
|
||||
|
||||
VPackSlice toUpdate = object.slice();
|
||||
|
||||
if (toUpdate.isNone()) {
|
||||
continue;
|
||||
}
|
||||
// fetch old revision
|
||||
OperationResult opRes = _trx->replace(_collection->name, toUpdate, options);
|
||||
if (!isMultiple) {
|
||||
|
|
|
@ -126,6 +126,9 @@ class UpsertBlock : public ModificationBlock {
|
|||
protected:
|
||||
/// @brief the actual work horse for updating data
|
||||
AqlItemBlock* work(std::vector<AqlItemBlock*>&) override final;
|
||||
|
||||
private:
|
||||
bool isShardKeyError(arangodb::velocypack::Slice const) const;
|
||||
};
|
||||
|
||||
} // namespace arangodb::aql
|
||||
|
|
Loading…
Reference in New Issue