MySQL 9.3.0
Source Code Documentation
delete.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024, 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_INCLUDE_MRS_DATABASE_JSON_MAPPER_VIEW_DELETE_H_
27#define ROUTER_SRC_MYSQL_REST_SERVICE_INCLUDE_MRS_DATABASE_JSON_MAPPER_VIEW_DELETE_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
55 protected:
56 RowDeleteBase(std::shared_ptr<Operation> parent, std::shared_ptr<Table> table,
57 const ObjectRowOwnership &row_ownership);
58
59 RowDeleteBase(std::shared_ptr<Operation> parent, std::shared_ptr<Table> table,
60 const PrimaryKeyColumnValues &pk_values,
61 const ObjectRowOwnership &row_ownership);
62
63 public:
64 void run(MySQLSession *session) override;
65
67 JSONInputArray input) override;
68
70
71 protected:
72 virtual void do_delete(MySQLSession *session);
74
76};
77
78class RowDelete : public RowDeleteBase {
79 public:
80 RowDelete(std::shared_ptr<Table> table,
81 const PrimaryKeyColumnValues &pk_values,
82 const ObjectRowOwnership &row_ownership)
83 : RowDeleteBase({}, table, pk_values, row_ownership) {}
84
85 void process(JSONInputObject input) override;
86
87 private:
88 mysqlrouter::sqlstring delete_sql() const override;
89};
90
92 public:
93 RowDeleteMany(std::shared_ptr<Table> table, mysqlrouter::sqlstring filter,
94 const ObjectRowOwnership &row_ownership)
95 : RowDeleteBase({}, table, row_ownership), filter_(std::move(filter)) {}
96
97 void process(JSONInputObject input) override;
98
99 void append_match_condition(mysqlrouter::sqlstring &sql) const override;
100
101 private:
102 mysqlrouter::sqlstring delete_sql() const override;
103
105};
106
108 public:
109 RowDeleteReferencing(std::shared_ptr<Operation> parent,
110 std::shared_ptr<Table> owning_table,
111 const ObjectRowOwnership &row_ownership)
112 : RowDeleteBase(parent, owning_table, row_ownership) {}
113
114 RowDeleteReferencing(std::shared_ptr<Operation> parent,
115 std::shared_ptr<Table> owning_table,
116 const PrimaryKeyColumnValues &pk_values,
117 const ObjectRowOwnership &row_ownership)
118 : RowDeleteBase(parent, owning_table, pk_values, row_ownership) {}
119
120 void delete_rows(std::vector<PrimaryKeyColumnValues> rows);
121
122 protected:
123 mysqlrouter::sqlstring delete_sql() const override;
124
125 private:
126 std::vector<PrimaryKeyColumnValues> rows_to_delete_;
127};
128
129} // namespace dv
130} // namespace database
131} // namespace mrs
132#endif // ROUTER_SRC_MYSQL_REST_SERVICE_INCLUDE_MRS_DATABASE_JSON_MAPPER_VIEW_DELETE_H_
Definition: object_row_ownership.h:45
Definition: json_input.h:157
Definition: json_input.h:61
std::shared_ptr< Operation > parent() const
Definition: change.h:82
const std::shared_ptr< Table > & table() const
Definition: change.h:80
Definition: delete.h:54
void run(MySQLSession *session) override
Definition: delete.cc:93
RowDeleteBase(std::shared_ptr< Operation > parent, std::shared_ptr< Table > table, const ObjectRowOwnership &row_ownership)
Definition: delete.cc:55
void process_to_one(const ForeignKeyReference &, JSONInputObject) override
Definition: delete.cc:88
virtual void do_delete(MySQLSession *session)
Definition: delete.cc:105
virtual mysqlrouter::sqlstring delete_sql() const =0
bool has_undeletable_fks_
Definition: delete.h:75
void process_to_many(const ForeignKeyReference &ref, JSONInputArray input) override
Definition: delete.cc:66
Definition: delete.h:91
void append_match_condition(mysqlrouter::sqlstring &sql) const override
Definition: delete.cc:152
mysqlrouter::sqlstring delete_sql() const override
Definition: delete.cc:143
RowDeleteMany(std::shared_ptr< Table > table, mysqlrouter::sqlstring filter, const ObjectRowOwnership &row_ownership)
Definition: delete.h:93
mysqlrouter::sqlstring filter_
Definition: delete.h:104
void process(JSONInputObject input) override
Definition: delete.cc:137
void delete_rows(std::vector< PrimaryKeyColumnValues > rows)
Definition: delete.cc:159
mysqlrouter::sqlstring delete_sql() const override
Definition: delete.cc:164
std::vector< PrimaryKeyColumnValues > rows_to_delete_
Definition: delete.h:126
RowDeleteReferencing(std::shared_ptr< Operation > parent, std::shared_ptr< Table > owning_table, const PrimaryKeyColumnValues &pk_values, const ObjectRowOwnership &row_ownership)
Definition: delete.h:114
RowDeleteReferencing(std::shared_ptr< Operation > parent, std::shared_ptr< Table > owning_table, const ObjectRowOwnership &row_ownership)
Definition: delete.h:109
Definition: delete.h:78
RowDelete(std::shared_ptr< Table > table, const PrimaryKeyColumnValues &pk_values, const ObjectRowOwnership &row_ownership)
Definition: delete.h:80
void process(JSONInputObject input) override
Definition: delete.cc:122
mysqlrouter::sqlstring delete_sql() const override
Definition: delete.cc:128
Definition: mysql_session.h:157
Definition: utils_sqlstring.h:67
Define rapidjson::SizeType to be std::uint64_t.
PT & ref(PT *tp)
Definition: tablespace_impl.cc:359
entry::ForeignKeyReference ForeignKeyReference
Definition: select.h:54
std::map< std::string, mysqlrouter::sqlstring > PrimaryKeyColumnValues
Definition: select.h:43
Definition: authorize_manager.h:48