10000 prevent stealing of values from Aql const registers (#14798) · arangodb/arangodb@1898ac4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1898ac4

Browse files
authored
prevent stealing of values from Aql const registers (#14798)
1 parent 4bd72d9 commit 1898ac4

File tree

3 files changed

+53
-2
lines changed

3 files changed

+53
-2
lines changed

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
devel
22
-----
33

4+
* Prevent stealing of values from AQL const value registers. This fixes an
5+
issue for queries that produce constant results (known at query compile time)
6+
when the queries are executed directly on a DB server in a cluster (which is
7+
not supported, but may happen for troubleshooting).
8+
49
* Fixed BTS-562: reduce-extraction-to-projection optimization returns null for
510
one attribute if nested attributes are named the same.
611

arangod/Aql/InputAqlItemRow.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ AqlValue InputAqlItemRow::stealValue(RegisterId registerId) {
157157
TRI_ASSERT(registerId.isConstRegister() || registerId < getNumRegisters());
158158
AqlValue const& a = block().getValueReference(_baseIndex, registerId);
159159
if (!a.isEmpty() && a.requiresDestruction()) {
160+
if (registerId.isConstRegister()) {
161+
// we cannot steal the value of a const register!
162+
return a.clone();
163+
}
164+
160165
// Now no one is responsible for AqlValue a
161166
block().steal(a);
162167
}

tests/js/client/shell/shell-query-dbserver-cluster.js

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function queriesTestSuite () {
4444
'use strict';
4545

4646
return {
47-
setUp: function() {
47+
setUpAll: function() {
4848
arango.reconnect(originalEndpoint, "_system", arango.connectedUser(), "");
4949
db._drop(cn);
5050

@@ -56,10 +56,18 @@ function queriesTestSuite () {
5656
c.insert(docs);
5757
},
5858

59-
tearDown: function() {
59+
tearDownAll: function() {
6060
arango.reconnect(originalEndpoint, "_system", arango.connectedUser(), "");
6161
db._drop(cn);
6262
},
63+
64+
setUp: function() {
65+
arango.reconnect(originalEndpoint, "_system", arango.connectedUser(), "");
66+
},
67+
68+
tearDown: function() {
69+
arango.reconnect(originalEndpoint, "_system", arango.connectedUser(), "");
70+
},
6371

6472
// test executing operations on the coordinator
6573
testCoordinator: function() {
@@ -97,6 +105,39 @@ function queriesTestSuite () {
97105
assertEqual(100, totalToArray);
98106
assertEqual(100, totalQuery);
99107
},
108+
109+
// test executing operations on the coordinator, without collection
110+
testCoordinatorNoCollection: function() {
111+
let result = db._query("RETURN [DECODE_REV('_dpq8a-----'), DECODE_REV('_bpq8a-----')]").toArray();
112+
113+
assertEqual([
114+
[
115+
{ "date" : "2022-02-02T16:22:18.368Z", "count" : 0 },
116+
{ "date" : "2021-01-01T00:00:00.000Z", "count" : 0 }
117+
]
118+
], result);
119+
},
120+
121+
// test executing operations on the DB-Server, without collection
122+
testDBServerNoCollection: function() {
123+
const dbservers = getServers("dbserver");
124+
assertTrue(dbservers.length > 0, "no dbservers found");
125+
126+
dbservers.forEach(function(dbserver, i) {
127+
let id = dbserver.id;
128+
require("console").warn("connecting to dbserver", dbserver.endpoint, id);
129+
arango.reconnect(dbserver.endpoint, "_system", arango.connectedUser(), "");
130+
131+
let result = db._query("RETURN [DECODE_REV('_dpq8a-----'), DECODE_REV('_bpq8a-----')]").toArray();
132+
133+
assertEqual([
134+
[
135+
{ "date" : "2022-02-02T16:22:18.368Z", "count" : 0 },
136+
{ "date" : "2021-01-01T00:00:00.000Z", "count" : 0 }
137+
]
138+
], result);
139+
});
140+
},
100141

101142
};
102143
}

0 commit comments

Comments
 (0)
0