MySQL 8.0.40
Source Code Documentation
sql_xa_rollback.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_ROLLBACK
25#define XA_SQL_CMD_XA_ROLLBACK
26
27#include "sql/sql_cmd.h" // Sql_cmd
28#include "sql/xa.h" // xid_t
29#include "sql/xa/sql_xa_second_phase.h" // Sql_cmd_xa_second_phase
30
31/**
32 @class Sql_cmd_xa_rollback
33
34 This class represents the `XA ROLLBACK ...` SQL statement which rollbacks
35 and terminates an XA transaction with the given xid value.
36
37 @see Sql_cmd
38*/
40 public:
41 /**
42 Class constructor.
43
44 @param xid_arg XID of the XA transacation about to be rolled back.
45 */
46 explicit Sql_cmd_xa_rollback(xid_t *xid_arg);
47 virtual ~Sql_cmd_xa_rollback() override = default;
48
49 /**
50 Retrieves the SQL command code for this class, `SQLCOM_XA_ROLLBACK`.
51
52 @see Sql_cmd::sql_command_code
53
54 @return The SQL command code for this class, `SQLCOM_XA_ROLLBACK`.
55 */
56 enum_sql_command sql_command_code() const override;
57 /**
58 Executes the SQL command.
59
60 @see Sql_cmd::execute
61
62 @param thd The `THD` session object within which the command is being
63 executed.
64
65 @return false if the execution is successful, true otherwise.
66 */
67 bool execute(THD *thd) override;
68
69 private:
70 /**
71 Roll back and terminate a XA transaction.
72
73 @param thd The `THD` session object within which the command is being
74 executed.
75
76 @retval false Success
77 @retval true Failure
78 */
79 bool trans_xa_rollback(THD *thd);
80 /**
81 Handle the statement XA ROLLBACK for the case when xid corresponds to an
82 XA transaction that is attached to the thread's THD object, that is a
83 transaction that is part of the current thread's session context.
84
85 @param thd The `THD` session object within which the command is being
86 executed.
87
88 @return operation result
89 @retval false Success
90 @retval true Failure
91 */
92 bool process_attached_xa_rollback(THD *thd) const;
93 /**
94 Handle the statement XA ROLLBACK for the case when xid corresponds to an
95 XA transaction that is detached from the thread's THD, that it a
96 transaction that isn't part of the current's thread session context.
97
98 @param thd The `THD` session object within which the command is being
99 executed.
100
101 @return operation result
102 @retval false Success
103 @retval true Failure
104 */
106};
107
108#endif // XA_SQL_CMD_XA_ROLLBACK
This class represents the XA ROLLBACK ... SQL statement which rollbacks and terminates an XA transact...
Definition: sql_xa_rollback.h:39
virtual ~Sql_cmd_xa_rollback() override=default
Sql_cmd_xa_rollback(xid_t *xid_arg)
Class constructor.
Definition: sql_xa_rollback.cc:36
bool process_attached_xa_rollback(THD *thd) const
Handle the statement XA ROLLBACK for the case when xid corresponds to an XA transaction that is attac...
Definition: sql_xa_rollback.cc:72
enum_sql_command sql_command_code() const override
Retrieves the SQL command code for this class, SQLCOM_XA_ROLLBACK.
Definition: sql_xa_rollback.cc:39
bool trans_xa_rollback(THD *thd)
Roll back and terminate a XA transaction.
Definition: sql_xa_rollback.cc:61
bool execute(THD *thd) override
Executes the SQL command.
Definition: sql_xa_rollback.cc:43
bool process_detached_xa_rollback(THD *thd)
Handle the statement XA ROLLBACK for the case when xid corresponds to an XA transaction that is detac...
Definition: sql_xa_rollback.cc:125
This class abstracts some functionality used by XA statements involved in the second phase of the the...
Definition: sql_xa_second_phase.h:64
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:34
enum_sql_command
Definition: my_sqlcommand.h:46
Representation of an SQL command.
struct xid_t is binary compatible with the XID structure as in the X/Open CAE Specification,...
Definition: xa.h:83