8000 Fixing some remaining issues with non existing collections · arangodb/arangodb@3b3cbb1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3b3cbb1

Browse files
committed
Fixing some remaining issues with non existing collections
1 parent 99067f7 commit 3b3cbb1

File tree

11 files changed

+45
-29
lines changed

11 files changed

+45
-29
lines changed

arangod/MMFiles/MMFilesAqlFunctions.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,15 +212,16 @@ AqlValue MMFilesAqlFunctions::Fulltext(
212212
}
213213
}
214214

215-
// add the collection to the query for proper cache handling
216-
query->collections()->add(cname, AccessMode::Type::READ);
217215
TRI_voc_cid_t cid = trx->resolver()->getCollectionIdLocal(cname);
218-
trx->addCollectionAtRuntime(cid, cname);
219-
LogicalCollection* collection = trx->documentCollection(cid);
220-
if (collection == nullptr) {
221-
THROW_ARANGO_EXCEPTION_FORMAT(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND,
222-
"", cname.c_str());
216+
if (cid == 0) {
217+
THROW_ARANGO_EXCEPTION_FORMAT(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND, "%s",
218+
cname.c_str());
223219
}
220+
// add the collection to the query for proper cache handling
221+
query->collections()->add(cname, AccessMode::Type::READ);
222+
trx->addCollectionAtRuntime(cid, cname, AccessMode::Type::READ);
223+
LogicalCollection const* collection = trx->documentCollection(cid);
224+
TRI_ASSERT(collection != nullptr);
224225

225226
// split requested attribute name on '.' character to create a proper
226227
// vector of AttributeNames

arangod/MMFiles/MMFilesCollection.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1977,7 +1977,7 @@ Result MMFilesCollection::read(transaction::Methods* trx, StringRef const& key,
19771977

19781978
bool MMFilesCollection::readDocument(transaction::Methods* trx,
19791979
LocalDocumentId const& documentId,
1980-
ManagedDocumentResult& result) {
1980+
ManagedDocumentResult& result) const {
19811981
uint8_t const* vpack = lookupDocumentVPack(documentId);
19821982
if (vpack != nullptr) {
19831983
result.setUnmanaged(vpack, documentId);
@@ -1988,7 +1988,7 @@ bool MMFilesCollection::readDocument(transaction::Methods* trx,
19881988

19891989
bool MMFilesCollection::readDocumentWithCallback(transaction::Methods* trx,
19901990
LocalDocumentId const& documentId,
1991-
IndexIterator::DocumentCallback const& cb) {
1991+
IndexIterator::DocumentCallback const& cb) const {
19921992
uint8_t const* vpack = lookupDocumentVPack(documentId);
19931993
if (vpack != nullptr) {
19941994
cb(documentId, VPackSlice(vpack));
@@ -1999,7 +1999,7 @@ bool MMFilesCollection::readDocumentWithCallback(transaction::Methods* trx,
19991999

20002000
size_t MMFilesCollection::readDocumentWithCallback(transaction::Methods* trx,
20012001
std::vector<std::pair<LocalDocumentId, uint8_t const*>>& documentIds,
2002-
IndexIterator::DocumentCallback const& cb) {
2002+
IndexIterator::DocumentCallback const& cb){
20032003
size_t count = 0;
20042004
batchLookupRevisionVPack(documentIds);
20052005
for (auto const& it : documentIds) {

arangod/MMFiles/MMFilesCollection.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,11 +339,11 @@ class MMFilesCollection final : public PhysicalCollection {
339339

340340
bool readDocument(transaction::Methods* trx,
341341
LocalDocumentId const& documentId,
342-
ManagedDocumentResult& result) override;
342+
ManagedDocumentResult& result) const override;
343343

344344
bool readDocumentWithCallback(transaction::Methods* trx,
345345
LocalDocumentId const& documentId,
346-
IndexIterator::DocumentCallback const& cb) override;
346+
IndexIterator::DocumentCallback const& cb) const override;
347347

348348
size_t readDocumentWithCallback(transaction::Methods* trx,
349349
std::vector<std::pair<LocalDocumentId, uint8_t const*>>& documentIds,

arangod/RocksDBEngine/RocksDBAqlFunctions.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ static ExecutionCondition const NotInCoordinator = [] {
5151
AqlValue RocksDBAqlFunctions::Fulltext(
5252
arangodb::aql::Query* query, transaction::Methods* trx,
5353
VPackFunctionParameters const& parameters) {
54+
TRI_ASSERT(!ServerState::instance()->isCoordinator());
5455
ValidateParameters(parameters, "FULLTEXT", 3, 4);
5556

5657
AqlValue collectionValue = ExtractFunctionParameterValue(parameters, 0);
@@ -90,15 +91,16 @@ AqlValue RocksDBAqlFunctions::Fulltext(
9091
}
9192
}
9293

93-
// add the collection to the query for proper cache handling
94-
query->collections()->add(cname, AccessMode::Type::READ);
9594
TRI_voc_cid_t cid = trx->resolver()->getCollectionIdLocal(cname);
96-
trx->addCollectionAtRuntime(cid, cname);
97-
LogicalCollection* collection = trx->documentCollection(cid);
98-
if (collection == nullptr) {
99-
THROW_ARANGO_EXCEPTION_FORMAT(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND, "",
95+
if (cid == 0) {
96+
THROW_ARANGO_EXCEPTION_FORMAT(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND, "%s",
10097
cname.c_str());
10198
}
99+
// add the collection to the query for proper cache handling
100+
query->collections()->add(cname, AccessMode::Type::READ);
101+
trx->addCollectionAtRuntime(cid, cname);
102+
LogicalCollection const* collection = trx->documentCollection(cid);
103+
TRI_ASSERT(collection != nullptr);
102104

103105
// NOTE: The shared_ptr is protected by trx lock.
104106
// It is save to use the raw pointer directly.

arangod/RocksDBEngine/RocksDBCollection.cpp

Lines changed: 2 additions & 2 deletions
Original file line n F438 umberDiff line numberDiff line change
@@ -788,7 +788,7 @@ Result RocksDBCollection::read(transaction::Methods* trx,
788788
// read using a token!
789789
bool RocksDBCollection::readDocument(transaction::Methods* trx,
790790
LocalDocumentId const& documentId,
791-
ManagedDocumentResult& result) {
791+
ManagedDocumentResult& result) const {
792792
if (documentId.isSet()) {
793793
auto res = lookupDocumentVPack(documentId, trx, result, true);
794794
return res.ok();
@@ -799,7 +799,7 @@ bool RocksDBCollection::readDocument(transaction::Methods* trx,
799799
// read using a token!
800800
bool RocksDBCollection::readDocumentWithCallback(
801801
transaction::Methods* trx, LocalDocumentId const& documentId,
802-
IndexIterator::DocumentCallback const& cb) {
802+
IndexIterator::DocumentCallback const& cb) const {
803803
if (documentId.isSet()) {
804804
auto res = lookupDocumentVPack(documentId, trx, cb, true);
805805
return res.ok();

arangod/RocksDBEngine/RocksDBCollection.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,11 @@ class RocksDBCollection final : public PhysicalCollection {
138138

139139
bool readDocument(transaction::Methods* trx,
140140
LocalDocumentId const& token,
141-
ManagedDocumentResult& result) override;
141+
ManagedDocumentResult& result) const override;
142142

143143
bool readDocumentWithCallback(
144144
transaction::Methods* trx, LocalDocumentId const& token,
145-
IndexIterator::DocumentCallback const& cb) override;
145+
IndexIterator::DocumentCallback const& cb) const override;
146146

147147
Result insert(arangodb::transaction::Methods* trx,
148148
arangodb::velocypack::Slice const newSlice,

arangod/StorageEngine/PhysicalCollection.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,11 @@ class PhysicalCollection {
152152

153153
virtual bool readDocument(transaction::Methods* trx,
154154
LocalDocumentId const& token,
155-
ManagedDocumentResult& result) = 0;
155+
ManagedDocumentResult& result) const = 0;
156156

157157
virtual bool readDocumentWithCallback(transaction::Methods* trx,
158158
LocalDocumentId const& token,
159-
IndexIterator::DocumentCallback const& cb) = 0;
159+
IndexIterator::DocumentCallback const& cb) const = 0;
160160

161161
virtual Result insert(arangodb::transaction::Methods* trx,
162162
arangodb::velocypack::Slice const newSlice,

arangod/VocBase/LogicalCollection.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,13 +1255,13 @@ Result LogicalCollection::remove(transaction::Methods* trx,
12551255

12561256
bool LogicalCollection::readDocument(transaction::Methods* trx,
12571257
LocalDocumentId const& token,
1258-
ManagedDocumentResult& result) {
1258+
ManagedDocumentResult& result) const {
12591259
return getPhysical()->readDocument(trx, token, result);
12601260
}
12611261

12621262
bool LogicalCollection::readDocumentWithCallback(transaction::Methods* trx,
12631263
LocalDocumentId const& token,
1264-
IndexIterator::DocumentCallback const& cb) {
1264+
IndexIterator::DocumentCallback const& cb) const {
12651265
return getPhysical()->readDocumentWithCallback(trx, token, cb);
12661266
}
12671267

arangod/VocBase/LogicalCollection.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,11 +325,11 @@ class LogicalCollection {
325325

326326
bool readDocument(transaction::Methods* trx,
327327
LocalDocumentId const& token,
328-
ManagedDocumentResult& result);
328+
ManagedDocumentResult& result) const;
329329

330330
bool readDocumentWithCallback(transaction::Methods* trx,
331331
LocalDocumentId const& token,
332-
IndexIterator::DocumentCallback const& cb);
332+
IndexIterator::DocumentCallback const& cb) const;
333333

334334
/// @brief Persist the connected physical collection.
335335
/// This should be called AFTER the collection is successfully

js/server/tests/aql/aql-optimizer-fulltext.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,19 @@ function optimizerRuleTestSuite() {
165165
let r2 = AQL_EXECUTE(q, {});
166166
assertEqual(r1.json, r, "Invalid fulltext result");
167167
assertEqual(r2.json, r, "Invalid fulltext result");
168-
} // testRuleBasics
168+
}, // testRuleBasics
169+
170+
testInvalidQuery : function () {
171+
let q = "FOR d IN FULLTEXT('" + colName + "', 't1', 'möchten,müller',3) RETURN 1";
172+
let plan = AQL_EXPLAIN(q, {});
173+
hasIndexNode(plan,q);
174+
175+
let r = [ 1, 1 ];
176+
let r1 = AQL_EXECUTE(q, {}, { optimizer: { rules: [ "-all" ] } });
177+
let r2 = AQL_EXECUTE(q, {});
178+
assertEqual(r1.json, r, "Invalid fulltext result");
179+
assertEqual(r2.json, r, "Invalid fulltext result");
180+
}
169181

170182
}; // test dictionary (return)
171183
} // optimizerRuleTestSuite

0 commit comments

Comments
 (0)
0