2016-02-22 05:21:15 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "database/db.hpp"
|
2016-07-18 01:32:35 +08:00
|
|
|
#include "query_engine/util.hpp"
|
2016-06-06 17:29:52 +08:00
|
|
|
#include "query_program.hpp"
|
|
|
|
#include "utils/log/logger.hpp"
|
2016-07-24 10:47:48 +08:00
|
|
|
#include "query_engine/exceptions/exceptions.hpp"
|
2016-02-22 05:21:15 +08:00
|
|
|
|
|
|
|
// preparations before execution
|
|
|
|
// execution
|
|
|
|
// postprocess the results
|
|
|
|
|
|
|
|
class ProgramExecutor
|
|
|
|
{
|
|
|
|
public:
|
2016-08-10 16:39:02 +08:00
|
|
|
auto execute(QueryProgram &program, Db& db)
|
2016-02-22 05:21:15 +08:00
|
|
|
{
|
2016-07-18 01:32:35 +08:00
|
|
|
try {
|
|
|
|
// TODO: return result of query/code exection
|
|
|
|
return program.code->run(db, program.stripped.arguments);
|
|
|
|
} catch (...) {
|
|
|
|
// TODO: return more information about the error
|
|
|
|
throw QueryEngineException("code execution error");
|
|
|
|
}
|
2016-02-22 05:21:15 +08:00
|
|
|
}
|
|
|
|
};
|