8000 Bug fix 3.4/disallow subqueries in prune (#10266) · arangodb/arangodb@69747bc · GitHub
[go: up one dir, main page]

Skip to content

Commit 69747bc

Browse files
jsteemannKVS85
authored andcommitted
Bug fix 3.4/disallow subqueries in prune (#10266)
* backport of #10231 * added derived files
1 parent ae508c7 commit 69747bc

File tree

9 files changed

+671
-597
lines changed

9 files changed

+671
-597
lines changed

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
v3.4.9 (XXX-XX-XX)
22
-------------------
33

4+
* Disallow the usage of subqueries inside AQL traversal PRUNE conditions.
5+
Using subqueries inside PRUNE conditions causes undefined behavior,
6+
so such queries will now be aborted early on with a parse error
7+
instead of running into undefined behavior.
8+
49
* Fixed search not working in document view while in code mode.
510

611
* Fixed issue #10090: fix repeatable seek to the same document in

arangod/Aql/Ast.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,23 @@ AstNode* Ast::createNodeReference(Variable const* variable) {
743743
return node;
744744
}
745745

746+
/// @brief create an AST subquery reference node
747+
AstNode* Ast::createNodeSubqueryReference(std::string const& variableName) {
748+
AstNode* node = createNode(NODE_TYPE_REFERENCE);
749+
node->setFlag(AstNodeFlagType::FLAG_SUBQUERY_REFERENCE);
750+
751+
auto variable = _scopes.getVariable(variableName);
752+
753+
if (variable == nullptr) {
754+
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL,
755+
"variable not found in reference AstNode");
756+
}
757+
758+
node->setData(variable);
759+
760+
return node;
761+
}
762+
746763
/// @brief create an AST variable access
747764
AstNode* Ast::createNodeAccess(Variable const* variable,
748765
std::vector<basics::AttributeName> const& field) {

arangod/Aql/Ast.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,9 @@ class Ast {
246246
/// @brief create an AST reference node
247247
AstNode* createNodeReference(Variable const* variable);
248248

249+
/// @brief create an AST subquery reference node
250+
AstNode* createNodeSubqueryReference(std::string const& variableName);
251+
249252
/// @brief create an AST parameter node for a value literal
250253
AstNode* createNodeParameter(char const* name, size_t length);
251254

arangod/Aql/AstNode.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ enum AstNodeFlagType : AstNodeFlagsType {
7171
FLAG_KEEP_VARIABLENAME = 0x0010000, // node is a reference to a variable name, not the variable value (used in KEEP nodes)
7272
FLAG_BIND_PARAMETER = 0x0020000, // node was created from a bind parameter
7373
FLAG_FINALIZED = 0x0040000, // node has been finalized and should not be modified; only set and checked in maintainer mode
74+
FLAG_SUBQUERY_REFERENCE = 0x0080000, // node references a subquery
7475
};
7576

7677
/// @brief enumeration of AST node value types

0 commit comments

Comments
 (0)
0