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