8000 Backport to 3.7. (#14781) · open-bigdata/arangodb@9b489d2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9b489d2

Browse files
neunhoefKVS85
andauthored
Backport to 3.7. (arangodb#14781)
Co-authored-by: Vadim <vadim@arangodb.com>
1 parent f735a0c commit 9b489d2

File tree

3 files changed

+82
-3
lines changed

3 files changed

+82
-3
lines changed

CHANGELOG

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
v3.7.15 (XXXX-XX-XX)
22
--------------------
33

4-
* Fix active failover, so that the new host actually has working
5-
foxx services. (BTS-558)
4+
* Fixed a bug for array indexes on update of documents (BTS-548).
5+
6+
* Fix active failover, so that the new host actually has working foxx services
7+
(BTS-558).
68

79
* Updated OpenSSL to 1.1.1l and OpenLDAP to 2.4.59.
810

arangod/RocksDBEngine/RocksDBVPackIndex.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,15 @@ namespace {
921921

922922
if (begin->shouldExpand &&
923923
first.isArray() && second.isArray()) {
924+
if (first.length() != second.length()) {
925+
// Nonequal length, so there is a difference!
926+
// We have to play this carefully here. It is possible that the
927+
// set of values found is the same, but we must err on the side
928+
// of caution in this case and use the slow path. Note in
929+
// particular that the following code returns `true`, if one
930+
// of the arrays is empty, which is not correct!
931+
return false;
932+
}
924933
auto next = begin + 1;
925934
VPackArrayIterator it1(first), it2(second);
926935
while (it1.valid() && it2.valid()) {

tests/js/server/shell/shell-array-index-noncluster.js

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,75 @@ function arraySkiplistIndexSuite () {
275275
catch (err) {
276276
assertEqual(errors.ERROR_ARANGO_UNIQUE_CONSTRAINT_VIOLATED.code, err.errorNum);
277277
}
278-
}
278+
},
279+
280+
////////////////////////////////////////////////////////////////////////////////
281+
/// @brief test: Test update of an array index where entries are removed:
282+
////////////////////////////////////////////////////////////////////////////////
283+
284+
testPersistentArrayIndexUpdates : function () {
285+
collection.ensureIndex({type:"persistent", fields: ["a[*].b"], unique: true});
286+
287+
let meta = collection.insert({a: [{b:"xyz"}]});
288+
289+
try {
290+
collection.insert({a: [{b:"xyz"}]});
291+
fail();
292+
}
293+
catch (err) {
294+
assertEqual(errors.ERROR_ARANGO_UNIQUE_CONSTRAINT_VIOLATED.code, err.errorNum);
295+
}
296+
297+
collection.update(meta._key, {a: []});
298+
299+
let meta2 = collection.insert({a: [{b:"xyz"}]}); // must work again
300+
301+
try {
302+
collection.insert({a: [{b:"xyz"}]});
303+
fail();
304+
}
305+
catch (err) {
306+
assertEqual(errors.ERROR_ARANGO_UNIQUE_CONSTRAINT_VIOLATED.code, err.errorNum);
307+
}
308+
309+
collection.replace(meta2._key, {a: []});
310+
311+
collection.insert({a: [{b:"xyz"}]}); // must work again
312+
},
313+
314+
////////////////////////////////////////////////////////////////////////////////
315+
/// @brief test: Test update of an array index where entries are changed:
316+
////////////////////////////////////////////////////////////////////////////////
317+
318+
testPersistentArrayIndexUpdates2 : function () {
319+
collection.ensureIndex({type:"persistent", fields: ["a[*].b"], unique: true});
320+
321+
let meta = collection.insert({a: [{b:"xyz"}]});
322+
323+
try {
324+
collection.insert({a: [{b:"xyz"}]});
325+
fail();
326+
}
327+
catch (err) {
328+
assertEqual(errors.ERROR_ARANGO_UNIQUE_CONSTRAINT_VIOLATED.code, err.errorNum);
329+
}
330+
331+
collection.update(meta._key, {a: [{b:"123"}]});
332+
333+
let meta2 = collection.insert({a: [{b:"xyz"}]}); // must work again
334+
335+
try {
336+
collection.insert({a: [{b:"xyz"}]});
337+
fail();
338+
}
339+
catch (err) {
340+
assertEqual(errors.ERROR_ARANGO_UNIQUE_CONSTRAINT_VIOLATED.code, err.errorNum);
341+
}
342+
343+
collection.replace(meta2._key, {a: [{b:"456"}]});
344+
345+
collection.insert({a: [{b:"xyz"}]}); // must work again
346+
},
279347

280348
};
281349
}

0 commit comments

Comments
 (0)
0