MySQL 9.3.0
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
query_rest_function.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2023, 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,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License 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
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 */
25
26#ifndef ROUTER_SRC_REST_MRS_SRC_MRS_DATABASE_QUERY_REST_FUNCTION_H_
27#define ROUTER_SRC_REST_MRS_SRC_MRS_DATABASE_QUERY_REST_FUNCTION_H_
28
29#include <memory>
30#include <string>
31#include <vector>
32
34#include "helper/mysql_column.h"
38
39namespace mrs {
40namespace database {
41
42class QueryRestFunction : private Query {
43 using Row = Query::Row;
45 using ParametersValues = std::vector<mysqlrouter::sqlstring>;
46
47 public:
48 using CustomMetadata = std::map<std::string, std::string>;
49 QueryRestFunction(bool encode_bigints_as_strings = false)
50 : encode_bigints_as_strings_{encode_bigints_as_strings} {}
51
52 virtual void query_raw(MySQLSession *session,
53 std::shared_ptr<entry::Object> object,
54 const ParametersValues &values = {});
55 virtual void query_entries(MySQLSession *session,
56 std::shared_ptr<entry::Object> object,
57 const ParametersValues &values = {});
58 virtual void serialize_response(const CustomMetadata &custom_metadata = {});
59
60 const char *get_sql_state();
61 std::string response;
62 uint64_t items{0};
63 bool store_raw_{false};
64
65 protected:
67 JsonType json_type_{JsonType::kNull};
71
72 void query_entries_impl(MySQLSession *session,
73 std::shared_ptr<entry::Object> object,
74 const ParametersValues &values = {});
75 void on_row(const ResultRow &r) override;
76 void on_metadata(unsigned int number, MYSQL_FIELD *fields) override;
77};
78
79} // namespace database
80} // namespace mrs
81
82#endif // ROUTER_SRC_REST_MRS_SRC_MRS_DATABASE_QUERY_REST_FUNCTION_H_
Definition: serializer_to_text.h:47
Definition: serializer_to_text.h:45
Definition: query.h:37
MySQLSession::ResultRow ResultRow
Definition: query.h:41
MySQLSession::Row Row
Definition: query.h:40
Definition: query_rest_function.h:42
std::string response
Definition: query_rest_function.h:61
const char * get_sql_state()
Definition: query_rest_function.cc:98
bool store_raw_
Definition: query_rest_function.h:63
JsonType json_type_
Definition: query_rest_function.h:67
std::map< std::string, std::string > CustomMetadata
Definition: query_rest_function.h:48
void query_entries_impl(MySQLSession *session, std::shared_ptr< entry::Object > object, const ParametersValues &values={})
Definition: query_rest_function.cc:117
void on_metadata(unsigned int number, MYSQL_FIELD *fields) override
Definition: query_rest_function.cc:164
enum_field_types mysql_type_
Definition: query_rest_function.h:66
uint64_t items
Definition: query_rest_function.h:62
bool encode_bigints_as_strings_
Definition: query_rest_function.h:68
helper::json::SerializerToText serializer_
Definition: query_rest_function.h:69
helper::json::SerializerToText::Object json_root_
Definition: query_rest_function.h:70
virtual void query_raw(MySQLSession *session, std::shared_ptr< entry::Object > object, const ParametersValues &values={})
Definition: query_rest_function.cc:103
std::vector< mysqlrouter::sqlstring > ParametersValues
Definition: query_rest_function.h:45
virtual void query_entries(MySQLSession *session, std::shared_ptr< entry::Object > object, const ParametersValues &values={})
Definition: query_rest_function.cc:110
void on_row(const ResultRow &r) override
Definition: query_rest_function.cc:129
virtual void serialize_response(const CustomMetadata &custom_metadata={})
Definition: query_rest_function.cc:171
QueryRestFunction(bool encode_bigints_as_strings=false)
Definition: query_rest_function.h:49
Definition: mysql_session.h:157
enum_field_types
Column types for MySQL Note: Keep include/mysql/components/services/bits/stored_program_bits....
Definition: field_types.h:55
@ MYSQL_TYPE_NULL
Definition: field_types.h:62
JsonType
Definition: mysql_column_types.h:35
Definition: authorize_manager.h:48
const mysql_service_registry_t * r
Definition: pfs_example_plugin_employee.cc:86
Definition: mysql.h:121