MySQL 9.4.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;
55 using PoolManagerRef = std::shared_ptr<PoolManager>;
56
57 public:
59
62 const mysqlrouter::sqlstring &user_id, const std::string &user_name,
63 std::optional<std::string> user_ownership_column,
64 const std::string &schema, const std::string &object,
65 const std::string &url, const MysqlTaskOptions &task_options,
66 const rapidjson::Document &doc, const ResultSets &rs);
67
69 CachedSession session, PoolManagerRef pool_ref,
70 const mysqlrouter::sqlstring &user_id,
71 std::optional<std::string> user_ownership_column,
72 const std::string &schema, const std::string &object,
73 const std::string &url, const MysqlTaskOptions &task_options,
74 const rapidjson::Document &doc, const ResultSets &rs);
75
78 const mysqlrouter::sqlstring &user_id, const std::string &user_name,
79 std::optional<std::string> user_ownership_column,
80 const std::string &schema, const std::string &object,
81 const std::string &url, const MysqlTaskOptions &task_options,
82 const rapidjson::Document &doc, const ResultSets &rs);
83
85 CachedSession session, PoolManagerRef pool_ref,
86 const mysqlrouter::sqlstring &user_id,
87 std::optional<std::string> user_ownership_column,
88 const std::string &schema, const std::string &object,
89 const std::string &url, const MysqlTaskOptions &task_options,
90 const rapidjson::Document &doc, const ResultSets &rs);
91
92 static void kill_task(collector::CountedMySQLSession *session,
93 const mysqlrouter::sqlstring &user_id,
94 const std::string &task_id);
95
96 const char *get_sql_state();
97 uint64_t items;
98 // To be fed to HTTP Result
99 std::string response;
100
101 protected:
102 std::string url_;
104
105 void execute_at_router(CachedSession session, PoolManagerRef pool_ref,
106 const mysqlrouter::sqlstring &user_id,
107 std::optional<std::string> user_ownership_column,
108 bool is_procedure, const std::string &schema,
109 const std::string &object,
110 const MysqlTaskOptions &task_options,
111 const rapidjson::Document &doc, const ResultSets &rs);
112
114 const mysqlrouter::sqlstring &user_id,
115 const std::string &user_name,
116 std::optional<std::string> user_ownership_column,
117 bool is_procedure, const std::string &schema,
118 const std::string &object, const std::string &url,
119 const MysqlTaskOptions &task_options,
120 const rapidjson::Document &doc, const ResultSets &rs);
121
123 const std::string &schema, const std::string &object,
124 const mysqlrouter::sqlstring &user_id,
125 std::optional<std::string> user_ownership_column, const ResultSets &rs,
126 const rapidjson::Document &doc, std::list<std::string> *out_preamble,
127 std::list<std::string> *out_postamble);
128
130 const std::string &schema, const std::string &object,
131 const mysqlrouter::sqlstring &user_id,
132 std::optional<std::string> user_ownership_column, const ResultSets &rs,
133 const rapidjson::Document &doc, std::list<std::string> *out_preamble,
134 std::list<std::string> *out_postamble);
135
137 const std::string &schema, const mysqlrouter::sqlstring &user_id,
138 const std::string &user_name, const MysqlTaskOptions &task_options,
139 mysqlrouter::sqlstring query, std::list<std::string> preamble,
140 std::list<std::string> postamble);
141
142 static std::list<std::string> on_task_error(
143 const std::exception &e, const std::string &task_id,
144 const std::string &progress_event_name);
145};
146
147} // namespace database
148} // namespace mrs
149
150#endif // ROUTER_SRC_MYSQL_REST_SERVICE_SRC_MRS_DATABASE_MYSQL_TASK_H_
Definition: cache_manager.h:41
Definition: counted_mysql_session.h:38
Definition: mysql_fixed_pool_manager.h:40
MySqlFixedCacheManagerImpl::CachedObject CachedObject
Definition: mysql_fixed_pool_manager.h:45
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
void execute_function_at_router(CachedSession session, PoolManagerRef pool_ref, 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:340
QueryRestMysqlTask(mrs::database::MysqlTaskMonitor *task_monitor)
Definition: query_rest_task.cc:101
void execute_at_server(collector::CountedMySQLSession *session, const mysqlrouter::sqlstring &user_id, const std::string &user_name, 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:353
uint64_t items
Definition: query_rest_task.h:97
entry::ResultSets ResultSets
Definition: query_rest_task.h:51
std::shared_ptr< PoolManager > PoolManagerRef
Definition: query_rest_task.h:55
void execute_procedure_at_router(CachedSession session, PoolManagerRef pool_ref, 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:314
const char * get_sql_state()
Definition: query_rest_task.cc:105
mysqlrouter::sqlstring wrap_async_server_call(const std::string &schema, const mysqlrouter::sqlstring &user_id, const std::string &user_name, const MysqlTaskOptions &task_options, mysqlrouter::sqlstring query, std::list< std::string > preamble, std::list< std::string > postamble)
Definition: query_rest_task.cc:261
std::string response
Definition: query_rest_task.h:99
std::string url_
Definition: query_rest_task.h:102
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_preamble, std::list< std::string > *out_postamble)
Definition: query_rest_task.cc:187
void execute_function_at_server(collector::CountedMySQLSession *session, const mysqlrouter::sqlstring &user_id, const std::string &user_name, 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:327
static void kill_task(collector::CountedMySQLSession *session, const mysqlrouter::sqlstring &user_id, const std::string &task_id)
Definition: query_rest_task.cc:537
mrs::database::MysqlTaskMonitor * task_monitor_
Definition: query_rest_task.h:103
void execute_at_router(CachedSession session, PoolManagerRef pool_ref, 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:395
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:520
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:110
void execute_procedure_at_server(collector::CountedMySQLSession *session, const mysqlrouter::sqlstring &user_id, const std::string &user_name, 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:302
Definition: rest_handler.h:121
Definition: utils_sqlstring.h:67
mrs::database::entry::ResultSets ResultSets
Definition: handler_db_object_script.cc:83
Definition: authorize_manager.h:48