1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-01 06:46:55 +03:00

Add a limit (as runtime value) for long in queries

This commit is contained in:
mariadb-AndreyPiskunov
2023-07-21 22:14:50 +03:00
parent 6ff121a91c
commit 05547f2342
8 changed files with 132 additions and 60 deletions

View File

@ -9,7 +9,9 @@
*/
#include "rewrites.h"
#include <cstdint>
#include <typeinfo>
#include "constantfilter.h"
#include "objectreader.h"
#include "installdir.h"
#include "parsetree.h"
@ -482,4 +484,19 @@ bool NodeSemanticComparator::operator()(execplan::ParseTree* left, execplan::Par
return left->data()->data() < right->data()->data();
}
bool checkFiltersLimit(execplan::ParseTree* tree, uint64_t limit)
{
uint64_t maxLimit = 0;
auto walker = [](const execplan::ParseTree* node, void* maxLimit){
auto maybe_cf = dynamic_cast<ConstantFilter*>(node->data());
if (maybe_cf != nullptr && (maybe_cf->op()->op() == OpType::OP_OR || maybe_cf->op()->op() == OpType::OP_IN))
{
*((uint64_t*)maxLimit) = std::max(maybe_cf->filterList().size(), *((uint64_t*)maxLimit));
}
};
tree->walk(walker, &maxLimit);
return maxLimit <= limit;
}
} // namespace execplan