MySQL 9.3.0
Source Code Documentation
query_rest_task.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2025, Oracle and/or its affiliates.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, version 2.0,
6 * as published by the Free Software Foundation.
7 *
8 * This program is designed to work with certain software (including
9 * but not limited to OpenSSL) that is licensed under separate terms,
10 * as designated in a particular file or component or in included license
11 * documentation. The authors of MySQL hereby grant you an additional
12 * permission to link the program and your derivative works with the
13 * separately licensed software that they have either included with
14 * the program or referenced in the documentation.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
19 * the GNU General Public License, version 2.0, for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 */
25
26#ifndef ROUTER_SRC_MYSQL_REST_SERVICE_SRC_MRS_DATABASE_MYSQL_TASK_H_
27#define ROUTER_SRC_MYSQL_REST_SERVICE_SRC_MRS_DATABASE_MYSQL_TASK_H_
28
29#include <list>
30#include <memory>
31#include <optional>
32#include <string>
33#include <utility>
34
36#include "helper/mysql_column.h"
42#include "mrs/gtid_manager.h"
45
46namespace mrs {
47namespace database {
48
49class QueryRestMysqlTask : private Query {
50 using Row = Query::Row;
54
55 public:
57
60 const mysqlrouter::sqlstring &user_id,
61 std::optional<std::string> user_ownership_column,
62 const std::string &schema, const std::string &object,
63 const std::string &url, const MysqlTaskOptions &task_options,
64 const rapidjson::Document &doc, const ResultSets &rs);
65
67 CachedSession session, const mysqlrouter::sqlstring &user_id,
68 std::optional<std::string> user_ownership_column,
69 const std::string &schema, const std::string &object,
70 const std::string &url, const MysqlTaskOptions &task_options,
71 const rapidjson::Document &doc, const ResultSets &rs);
72
75 const mysqlrouter::sqlstring &user_id,
76 std::optional<std::string> user_ownership_column,
77 const std::string &schema, const std::string &object,
78 const std::string &url, const MysqlTaskOptions &task_options,
79 const rapidjson::Document &doc, const ResultSets &rs);
80
82 CachedSession session, const mysqlrouter::sqlstring &user_id,
83 std::optional<std::string> user_ownership_column,
84 const std::string &schema, const std::string &object,
85 const std::string &url, const MysqlTaskOptions &task_options,
86 const rapidjson::Document &doc, const ResultSets &rs);
87
88 static void kill_task(collector::CountedMySQLSession *session,
89 const mysqlrouter::sqlstring &user_id,
90 const std::string &task_id);
91
92 const char *get_sql_state();
93 uint64_t items;
94 // To be fed to HTTP Result
95 std::string response;
96
97 protected:
98 std::string url_;
100
101 void execute_at_router(CachedSession session,
102 const mysqlrouter::sqlstring &user_id,
103 std::optional<std::string> user_ownership_column,
104 bool is_procedure, const std::string &schema,
105 const std::string &object,
106 const MysqlTaskOptions &task_options,
107 const rapidjson::Document &doc, const ResultSets &rs);
108
110 const mysqlrouter::sqlstring &user_id,
111 std::optional<std::string> user_ownership_column,
112 bool is_procedure, const std::string &schema,
113 const std::string &object, const std::string &url,
114 const MysqlTaskOptions &task_options,
115 const rapidjson::Document &doc, const ResultSets &rs);
116
118 const std::string &schema, const std::string &object,
119 const mysqlrouter::sqlstring &user_id,
120 std::optional<std::string> user_ownership_column, const ResultSets &rs,
121 const rapidjson::Document &doc, std::list<std::string> *out_preamble,
122 std::list<std::string> *out_postamble);
123
125 const std::string &schema, const std::string &object,
126 const mysqlrouter::sqlstring &user_id,
127 std::optional<std::string> user_ownership_column, const ResultSets &rs,
128 const rapidjson::Document &doc, std::list<std::string> *out_postamble);
129
131 const std::string &schema, const mysqlrouter::sqlstring &user_id,
132 const MysqlTaskOptions &task_options, mysqlrouter::sqlstring query,
133 std::list<std::string> preamble, std::list<std::string> postamble);
134
135 static std::list<std::string> on_task_error(
136 const std::exception &e, const std::string &task_id,
137 const std::string &progress_event_name);
138};
139
140} // namespace database
141} // namespace mrs
142
143#endif // ROUTER_SRC_MYSQL_REST_SERVICE_SRC_MRS_DATABASE_MYSQL_TASK_H_
Definition: cache_manager.h:41
Definition: counted_mysql_session.h:38
MySqlCacheManager::CachedObject CachedObject
Definition: mysql_cache_manager.h:92
Definition: mysql_task_monitor.h:41
Definition: query.h:37
MySQLSession::Row Row
Definition: query.h:40
virtual void query(MySQLSession *session, const std::string &q)
Definition: query.cc:49
Definition: query_rest_task.h:49
QueryRestMysqlTask(mrs::database::MysqlTaskMonitor *task_monitor)
Definition: query_rest_task.cc:54
uint64_t items
Definition: query_rest_task.h:93
entry::ResultSets ResultSets
Definition: query_rest_task.h:51
mysqlrouter::sqlstring build_function_call(const std::string &schema, const std::string &object, const mysqlrouter::sqlstring &user_id, std::optional< std::string > user_ownership_column, const ResultSets &rs, const rapidjson::Document &doc, std::list< std::string > *out_postamble)
Definition: query_rest_task.cc:126
void execute_at_server(collector::CountedMySQLSession *session, const mysqlrouter::sqlstring &user_id, std::optional< std::string > user_ownership_column, bool is_procedure, const std::string &schema, const std::string &object, const std::string &url, const MysqlTaskOptions &task_options, const rapidjson::Document &doc, const ResultSets &rs)
Definition: query_rest_task.cc:254
const char * get_sql_state()
Definition: query_rest_task.cc:58
std::string response
Definition: query_rest_task.h:95
void execute_procedure_at_server(collector::CountedMySQLSession *session, const mysqlrouter::sqlstring &user_id, std::optional< std::string > user_ownership_column, const std::string &schema, const std::string &object, const std::string &url, const MysqlTaskOptions &task_options, const rapidjson::Document &doc, const ResultSets &rs)
Definition: query_rest_task.cc:207
std::string url_
Definition: query_rest_task.h:98
mysqlrouter::sqlstring wrap_async_server_call(const std::string &schema, const mysqlrouter::sqlstring &user_id, const MysqlTaskOptions &task_options, mysqlrouter::sqlstring query, std::list< std::string > preamble, std::list< std::string > postamble)
Definition: query_rest_task.cc:169
void execute_at_router(CachedSession session, const mysqlrouter::sqlstring &user_id, std::optional< std::string > user_ownership_column, bool is_procedure, const std::string &schema, const std::string &object, const MysqlTaskOptions &task_options, const rapidjson::Document &doc, const ResultSets &rs)
Definition: query_rest_task.cc:295
static void kill_task(collector::CountedMySQLSession *session, const mysqlrouter::sqlstring &user_id, const std::string &task_id)
Definition: query_rest_task.cc:414
void execute_function_at_server(collector::CountedMySQLSession *session, const mysqlrouter::sqlstring &user_id, std::optional< std::string > user_ownership_column, const std::string &schema, const std::string &object, const std::string &url, const MysqlTaskOptions &task_options, const rapidjson::Document &doc, const ResultSets &rs)
Definition: query_rest_task.cc:230
mrs::database::MysqlTaskMonitor * task_monitor_
Definition: query_rest_task.h:99
static std::list< std::string > on_task_error(const std::exception &e, const std::string &task_id, const std::string &progress_event_name)
Definition: query_rest_task.cc:397
void execute_function_at_router(CachedSession session, const mysqlrouter::sqlstring &user_id, std::optional< std::string > user_ownership_column, const std::string &schema, const std::string &object, const std::string &url, const MysqlTaskOptions &task_options, const rapidjson::Document &doc, const ResultSets &rs)
Definition: query_rest_task.cc:243
mysqlrouter::sqlstring build_procedure_call(const std::string &schema, const std::string &object, const mysqlrouter::sqlstring &user_id, std::optional< std::string > user_ownership_column, const ResultSets &rs, const rapidjson::Document &doc, std::list< std::string > *out_preamble, std::list< std::string > *out_postamble)
Definition: query_rest_task.cc:63
void execute_procedure_at_router(CachedSession session, const mysqlrouter::sqlstring &user_id, std::optional< std::string > user_ownership_column, const std::string &schema, const std::string &object, const std::string &url, const MysqlTaskOptions &task_options, const rapidjson::Document &doc, const ResultSets &rs)
Definition: query_rest_task.cc:219
Definition: rest_handler.h:117
Definition: utils_sqlstring.h:67
mrs::database::entry::ResultSets ResultSets
Definition: handler_db_object_script.cc:83
Definition: authorize_manager.h:48