mirror of https://gitee.com/bigwinds/arangodb
fixed memlekas
This commit is contained in:
parent
56b270be18
commit
12c16b0a09
|
@ -1757,11 +1757,11 @@ bool TRI_ContainsImpossibleAql (const TRI_vector_pointer_t* const fieldAccesses)
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief clone a vector of ranges
|
/// @brief clone a vector of accesses
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
TRI_vector_pointer_t* TRI_CloneRangesAql (TRI_aql_context_t* const context,
|
TRI_vector_pointer_t* TRI_CloneAccessesAql (TRI_aql_context_t* const context,
|
||||||
const TRI_vector_pointer_t* const source) {
|
const TRI_vector_pointer_t* const source) {
|
||||||
TRI_vector_pointer_t* result;
|
TRI_vector_pointer_t* result;
|
||||||
|
|
||||||
if (!source) {
|
if (!source) {
|
||||||
|
@ -1987,14 +1987,11 @@ TRI_vector_pointer_t* TRI_AddAccessAql (TRI_aql_context_t* const context,
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// create a new vector
|
// create a new vector
|
||||||
accesses = (TRI_vector_pointer_t*) TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_vector_pointer_t), false);
|
accesses = CreateEmptyVector(context);
|
||||||
if (accesses == NULL) {
|
if (accesses == NULL) {
|
||||||
// OOM
|
// OOM
|
||||||
TRI_SetErrorContextAql(context, TRI_ERROR_OUT_OF_MEMORY, NULL);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_InitVectorPointer(accesses, TRI_UNKNOWN_MEM_ZONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(accesses);
|
assert(accesses);
|
||||||
|
@ -2019,13 +2016,14 @@ TRI_vector_pointer_t* TRI_AddAccessAql (TRI_aql_context_t* const context,
|
||||||
|
|
||||||
// free existing field access
|
// free existing field access
|
||||||
TRI_FreeAccessAql(existing);
|
TRI_FreeAccessAql(existing);
|
||||||
// insert candidate instead
|
|
||||||
copy = TRI_CloneAccessAql(context, candidate);
|
copy = TRI_CloneAccessAql(context, candidate);
|
||||||
if (!copy) {
|
if (!copy) {
|
||||||
// OOM
|
// OOM
|
||||||
TRI_SetErrorContextAql(context, TRI_ERROR_OUT_OF_MEMORY, NULL);
|
TRI_SetErrorContextAql(context, TRI_ERROR_OUT_OF_MEMORY, NULL);
|
||||||
return accesses;
|
return accesses;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// insert copy of candidate instead
|
||||||
accesses->_buffer[i] = (void*) copy;
|
accesses->_buffer[i] = (void*) copy;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2033,7 +2031,7 @@ TRI_vector_pointer_t* TRI_AddAccessAql (TRI_aql_context_t* const context,
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
// not found, now add this candidate
|
// not found, now add this candidate
|
||||||
TRI_PushBackVectorPointer(accesses, candidate);
|
TRI_PushBackVectorPointer(accesses, TRI_CloneAccessAql(context, candidate));
|
||||||
}
|
}
|
||||||
|
|
||||||
return accesses;
|
return accesses;
|
||||||
|
|
|
@ -157,11 +157,11 @@ TRI_aql_field_access_t* TRI_CreateImpossibleAccessAql (TRI_aql_context_t* const)
|
||||||
bool TRI_ContainsImpossibleAql (const TRI_vector_pointer_t* const);
|
bool TRI_ContainsImpossibleAql (const TRI_vector_pointer_t* const);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief clone a vector of ranges
|
/// @brief clone a vector of accesses
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
TRI_vector_pointer_t* TRI_CloneRangesAql (TRI_aql_context_t* const,
|
TRI_vector_pointer_t* TRI_CloneAccessesAql (TRI_aql_context_t* const,
|
||||||
const TRI_vector_pointer_t* const);
|
const TRI_vector_pointer_t* const);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief free access structure with its members and the pointer
|
/// @brief free access structure with its members and the pointer
|
||||||
|
|
|
@ -146,6 +146,7 @@ static void PatchForLoops (TRI_aql_context_t* const context) {
|
||||||
|
|
||||||
// merge the field access found into the already existing field accesses for the node
|
// merge the field access found into the already existing field accesses for the node
|
||||||
PatchForNode(context, scope->_node, fieldAccess);
|
PatchForNode(context, scope->_node, fieldAccess);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_FreeString(TRI_CORE_MEM_ZONE, prefix);
|
TRI_FreeString(TRI_CORE_MEM_ZONE, prefix);
|
||||||
|
@ -164,7 +165,7 @@ static void FreeScope (TRI_aql_optimiser_scope_t* const scope) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scope->_ranges) {
|
if (scope->_ranges) {
|
||||||
TRI_FreeVectorPointer(TRI_UNKNOWN_MEM_ZONE, scope->_ranges);
|
TRI_FreeAccessesAql(scope->_ranges);
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_Free(TRI_UNKNOWN_MEM_ZONE, scope);
|
TRI_Free(TRI_UNKNOWN_MEM_ZONE, scope);
|
||||||
|
@ -216,9 +217,10 @@ static void StartScope (TRI_aql_context_t* const context,
|
||||||
|
|
||||||
if (context->_optimiser._scopes._length > 0) {
|
if (context->_optimiser._scopes._length > 0) {
|
||||||
// copy ranges of parent scope into current one
|
// copy ranges of parent scope into current one
|
||||||
scope->_ranges = TRI_CloneRangesAql(context, CurrentScope(&context->_optimiser._scopes)->_ranges);
|
scope->_ranges = TRI_CloneAccessesAql(context, CurrentScope(&context->_optimiser._scopes)->_ranges);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// finally, add the new scope
|
||||||
TRI_PushBackVectorPointer(&context->_optimiser._scopes, scope);
|
TRI_PushBackVectorPointer(&context->_optimiser._scopes, scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -486,13 +488,18 @@ TRY_LOOP:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!TRI_IsConstantValueNodeAql(expression)) {
|
if (!TRI_IsConstantValueNodeAql(expression)) {
|
||||||
TRI_vector_pointer_t* ranges;
|
TRI_vector_pointer_t* oldRanges;
|
||||||
|
TRI_vector_pointer_t* newRanges;
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
||||||
ranges = TRI_OptimiseRangesAql(context, expression, &changed, scope->_ranges);
|
oldRanges = scope->_ranges;
|
||||||
|
newRanges = TRI_OptimiseRangesAql(context, expression, &changed, oldRanges);
|
||||||
|
|
||||||
if (ranges) {
|
if (newRanges) {
|
||||||
scope->_ranges = ranges;
|
if (oldRanges) {
|
||||||
|
TRI_FreeAccessesAql(oldRanges);
|
||||||
|
}
|
||||||
|
scope->_ranges = newRanges;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
|
|
Loading…
Reference in New Issue