MySQL 9.3.0
Source Code Documentation
query_rest_table_updater.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, 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_QUERY_REST_TABLE_UPDATER_H_
27#define ROUTER_SRC_MYSQL_REST_SERVICE_SRC_MRS_DATABASE_QUERY_REST_TABLE_UPDATER_H_
28
29#ifdef RAPIDJSON_NO_SIZETYPEDEFINE
30#include "my_rapidjson_size_t.h"
31#endif
32
33#include <rapidjson/document.h>
34#include <list>
35#include <map>
36#include <memory>
37#include <string>
38#include <utility>
39#include <vector>
49
50namespace mrs {
51namespace database {
52namespace dv {
53
54class JsonMappingUpdater : public Query {
55 public:
57
58 explicit JsonMappingUpdater(
59 std::shared_ptr<Object> view,
61
62 void check(const rapidjson::Document &doc, bool for_update = false) const;
63
65 const rapidjson::Document &doc);
66
68 const PrimaryKeyColumnValues &pk_values,
69 const rapidjson::Document &doc,
70 bool upsert = false);
71
72 uint64_t delete_(MySQLSession *session,
73 const PrimaryKeyColumnValues &pk_values);
74
75 uint64_t delete_(MySQLSession *session, const FilterObjectGenerator &filter);
76
79 }
80
81 size_t affected() const { return m_affected; }
82
83 class Operation;
84
85 private:
86 std::shared_ptr<Object> view_;
88 size_t m_affected = 0;
89
90 private:
91 std::string select_one(MySQLSession *session,
92 const PrimaryKeyColumnValues &pk_values,
93 bool &is_owned, RowLockType lock_rows) const;
94
95 void check_etag(const std::string &original_doc,
96 const rapidjson::Document &new_doc) const;
97};
98
99} // namespace dv
100} // namespace database
101} // namespace mrs
102
103#endif // ROUTER_SRC_MYSQL_REST_SERVICE_SRC_MRS_DATABASE_QUERY_REST_TABLE_UPDATER_H_
Definition: filter_object_generator.h:44
Definition: object_row_ownership.h:45
Definition: query.h:37
Definition: query_rest_table_updater.h:54
const ObjectRowOwnership & row_ownership_info() const
Definition: query_rest_table_updater.h:77
uint64_t delete_(MySQLSession *session, const PrimaryKeyColumnValues &pk_values)
Definition: query_rest_table_updater.cc:237
size_t affected() const
Definition: query_rest_table_updater.h:81
ObjectRowOwnership m_row_ownership_info
Definition: query_rest_table_updater.h:87
size_t m_affected
Definition: query_rest_table_updater.h:88
PrimaryKeyColumnValues insert(MySQLSession *session, const rapidjson::Document &doc)
Definition: query_rest_table_updater.cc:150
JsonMappingUpdater(std::shared_ptr< Object > view, const ObjectRowOwnership &row_ownership_info={})
Definition: query_rest_table_updater.cc:79
std::shared_ptr< Object > view_
Definition: query_rest_table_updater.h:83
std::string select_one(MySQLSession *session, const PrimaryKeyColumnValues &pk_values, bool &is_owned, RowLockType lock_rows) const
Definition: query_rest_table_updater.cc:315
void check_etag(const std::string &original_doc, const rapidjson::Document &new_doc) const
Definition: query_rest_table_updater.cc:295
PrimaryKeyColumnValues update(MySQLSession *session, const PrimaryKeyColumnValues &pk_values, const rapidjson::Document &doc, bool upsert=false)
Definition: query_rest_table_updater.cc:169
entry::Object Object
Definition: query_rest_table_updater.h:56
void check(const rapidjson::Document &doc, bool for_update=false) const
Definition: query_rest_table_updater.cc:286
Definition: mysql_session.h:157
Define rapidjson::SizeType to be std::uint64_t.
constexpr value_type for_update
Definition: classic_protocol_constants.h:214
MysqlCacheManager::Object Object
Definition: mysql_cache_manager.cc:101
RowLockType
Definition: select.h:47
std::map< std::string, mysqlrouter::sqlstring > PrimaryKeyColumnValues
Definition: select.h:43
Definition: authorize_manager.h:48
Definition: set_operation.h:33