MySQL 8.4.2
Source Code Documentation
sql_xa_recover.h
Go to the documentation of this file.
1/* Copyright (c) 2022, 2024, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef XA_SQL_CMD_XA_RECOVER
25#define XA_SQL_CMD_XA_RECOVER
26
27#include "sql/sql_cmd.h" // Sql_cmd
28#include "sql/xa.h" // xid_t
29
30/**
31 @class Sql_cmd_xa_recover
32
33 This class represents the `XA RECOVER` SQL statement which returns to a
34 client a list of XID's prepared to a XA commit/rollback.
35
36 @see Sql_cmd
37*/
39 public:
40 /**
41 Class constructor.
42
43 @param print_xid_as_hex Whether or not to print the XID as hexadecimal.
44 */
45 explicit Sql_cmd_xa_recover(bool print_xid_as_hex);
46 virtual ~Sql_cmd_xa_recover() override = default;
47
48 /**
49 Retrieves the SQL command code for this class, `SQLCOM_XA_RECOVER`.
50
51 @see Sql_cmd::sql_command_code
52
53 @return The SQL command code for this class, `SQLCOM_XA_RECOVER`.
54 */
55 enum_sql_command sql_command_code() const override;
56 /**
57 Executes the SQL command.
58
59 @see Sql_cmd::execute
60
61 @param thd The `THD` session object within which the command is being
62 executed.
63
64 @return false if the execution is successful, true otherwise.
65 */
66 bool execute(THD *thd) override;
67
68 private:
69 /** Whether or not the XID should be printed in hexadecimal form. */
71
72 /**
73 Return the list of XID's to a client, the same way SHOW commands do.
74
75 @param thd The `THD` session object within which the command is being
76 executed.
77
78 @retval false Success
79 @retval true Failure
80
81 @note
82 I didn't find in XA specs that an RM cannot return the same XID twice,
83 so trans_xa_recover does not filter XID's to ensure uniqueness.
84 It can be easily fixed later, if necessary.
85 */
86 bool trans_xa_recover(THD *thd);
87 /**
88 Check if the current user has a privilege to perform XA RECOVER.
89
90 @param thd The `THD` session object within which the command is being
91 executed.
92
93 @retval false A user has a privilege to perform XA RECOVER
94 @retval true A user doesn't have a privilege to perform XA RECOVER
95 */
96 bool check_xa_recover_privilege(THD *thd) const;
97};
98
99#endif // XA_SQL_CMD_XA_RECOVER
This class represents the XA RECOVER SQL statement which returns to a client a list of XID's prepared...
Definition: sql_xa_recover.h:38
bool m_print_xid_as_hex
Whether or not the XID should be printed in hexadecimal form.
Definition: sql_xa_recover.h:70
enum_sql_command sql_command_code() const override
Retrieves the SQL command code for this class, SQLCOM_XA_RECOVER.
Definition: sql_xa_recover.cc:36
bool check_xa_recover_privilege(THD *thd) const
Check if the current user has a privilege to perform XA RECOVER.
Definition: sql_xa_recover.cc:83
bool trans_xa_recover(THD *thd)
Return the list of XID's to a client, the same way SHOW commands do.
Definition: sql_xa_recover.cc:48
virtual ~Sql_cmd_xa_recover() override=default
Sql_cmd_xa_recover(bool print_xid_as_hex)
Class constructor.
Definition: sql_xa_recover.cc:33
bool execute(THD *thd) override
Executes the SQL command.
Definition: sql_xa_recover.cc:40
Representation of an SQL command.
Definition: sql_cmd.h:83
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
enum_sql_command
Definition: my_sqlcommand.h:46
Representation of an SQL command.