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