2022-02-22 20:33:45 +08:00
|
|
|
// Copyright 2022 Memgraph Ltd.
|
2021-10-26 14:53:56 +08:00
|
|
|
//
|
|
|
|
// Use of this software is governed by the Business Source License
|
|
|
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
|
|
|
// License, and you may not use this file except in compliance with the Business Source License.
|
|
|
|
//
|
|
|
|
// As of the Change Date specified in that file, in accordance with
|
|
|
|
// the Business Source License, use of this software will be governed
|
|
|
|
// by the Apache License, Version 2.0, included in the file
|
|
|
|
// licenses/APL.txt.
|
|
|
|
|
2017-11-23 21:26:53 +08:00
|
|
|
#include "communication/result_stream_faker.hpp"
|
2022-11-04 22:23:43 +08:00
|
|
|
#include "license/license.hpp"
|
2021-06-30 17:19:13 +08:00
|
|
|
#include "query/config.hpp"
|
2017-11-23 21:26:53 +08:00
|
|
|
#include "query/interpreter.hpp"
|
2021-06-14 21:47:57 +08:00
|
|
|
#include "storage/v2/isolation_level.hpp"
|
2019-11-22 00:24:01 +08:00
|
|
|
#include "storage/v2/storage.hpp"
|
2021-05-14 21:38:59 +08:00
|
|
|
#include "utils/on_scope_exit.hpp"
|
2017-11-23 21:26:53 +08:00
|
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
|
|
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
|
|
|
|
|
|
|
// parse the first cmd line argument as the query
|
|
|
|
if (argc < 2) {
|
|
|
|
std::cout << "Usage: ./single_query 'RETURN \"query here\"'" << std::endl;
|
|
|
|
exit(1);
|
|
|
|
}
|
2019-10-10 17:23:33 +08:00
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
memgraph::storage::Storage db;
|
2021-05-14 21:38:59 +08:00
|
|
|
auto data_directory = std::filesystem::temp_directory_path() / "single_query_test";
|
2022-02-22 20:33:45 +08:00
|
|
|
memgraph::utils::OnScopeExit([&data_directory] { std::filesystem::remove_all(data_directory); });
|
2021-09-30 01:14:39 +08:00
|
|
|
|
2022-11-04 22:23:43 +08:00
|
|
|
memgraph::license::global_license_checker.EnableTesting();
|
2022-02-22 20:33:45 +08:00
|
|
|
memgraph::query::InterpreterContext interpreter_context{&db, memgraph::query::InterpreterConfig{}, data_directory};
|
|
|
|
memgraph::query::Interpreter interpreter{&interpreter_context};
|
2019-10-10 17:23:33 +08:00
|
|
|
|
2019-11-22 00:24:01 +08:00
|
|
|
ResultStreamFaker stream(&db);
|
2021-07-22 22:22:08 +08:00
|
|
|
auto [header, _, qid] = interpreter.Prepare(argv[1], {}, nullptr);
|
2019-10-10 17:23:33 +08:00
|
|
|
stream.Header(header);
|
|
|
|
auto summary = interpreter.PullAll(&stream);
|
|
|
|
stream.Summary(summary);
|
2018-07-20 18:31:22 +08:00
|
|
|
std::cout << stream;
|
2019-10-10 17:23:33 +08:00
|
|
|
|
2017-11-23 21:26:53 +08:00
|
|
|
return 0;
|
|
|
|
}
|