MySQL 9.0.0
Source Code Documentation
sql_xa_commit.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_COMMIT
25#define XA_SQL_CMD_XA_COMMIT
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_commit
33
34 This class represents the `XA COMMIT ...` SQL statement which commits and
35 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 committed
45 @param xa_option Additional options for the `XA COMMIT` command
46 */
47 Sql_cmd_xa_commit(xid_t *xid_arg, enum xa_option_words xa_option);
48 virtual ~Sql_cmd_xa_commit() override = default;
49
50 /**
51 Retrieves the SQL command code for this class, `SQLCOM_XA_COMMIT`.
52
53 @see Sql_cmd::sql_command_code
54
55 @return The SQL command code for this class, `SQLCOM_XA_COMMIT`.
56 */
57 enum_sql_command sql_command_code() const override;
58 /**
59 Executes the SQL command.
60
61 @see Sql_cmd::execute
62
63 @param thd The `THD` session object within which the command is being
64 executed.
65
66 @return false if the execution is successful, true otherwise.
67 */
68 bool execute(THD *thd) override;
69 /**
70 Retrieves this `XA COMMIT` extra options.
71
72 @return The `XA COMMIT` extra options.
73 */
74 enum xa_option_words get_xa_opt() const;
75
76 private:
77 /** Options associated with the underlying `XA COMMIT` */
79
80 /**
81 Commit and terminate a XA transaction.
82
83 @param thd The `THD` session object within which the command is being
84 executed.
85
86 @retval false Success
87 @retval true Failure
88 */
89 bool trans_xa_commit(THD *thd);
90 /**
91 Handle the statement XA COMMIT for the case when xid corresponds to an
92 XA transaction that is attached to the thread's THD object, that is a
93 transaction that is part of the current thread's session context.
94
95 @param thd The `THD` session object within which the command is being
96 executed.
97
98 @return operation result
99 @retval false Success
100 @retval true Failure
101 */
102 bool process_attached_xa_commit(THD *thd) const;
103 /**
104 Handle the statement XA COMMIT for the case when xid corresponds to an
105 XA transaction that is detached from the thread's THD, that is a
106 transaction that isn't part of the current's thread session
107 context. When xa_detach_on_prepare is ON (default), this applies to all
108 prepared XA transactions. That is, an XA transaction pepared earlier on
109 this connection or on amy another connection, either still active or
110 already disposed of.
111
112 @param thd The `THD` session object within which the command is being
113 executed.
114
115 @return operation result
116 @retval false Success
117 @retval true Failure
118 */
120};
121
122#endif // XA_SQL_CMD_XA_COMMIT
This class represents the XA COMMIT ... SQL statement which commits and terminates an XA transaction ...
Definition: sql_xa_commit.h:39
bool process_attached_xa_commit(THD *thd) const
Handle the statement XA COMMIT for the case when xid corresponds to an XA transaction that is attache...
Definition: sql_xa_commit.cc:95
bool trans_xa_commit(THD *thd)
Commit and terminate a XA transaction.
Definition: sql_xa_commit.cc:80
Sql_cmd_xa_commit(xid_t *xid_arg, enum xa_option_words xa_option)
Class constructor.
Definition: sql_xa_commit.cc:54
virtual ~Sql_cmd_xa_commit() override=default
enum_sql_command sql_command_code() const override
Retrieves the SQL command code for this class, SQLCOM_XA_COMMIT.
Definition: sql_xa_commit.cc:58
enum xa_option_words get_xa_opt() const
Retrieves this XA COMMIT extra options.
Definition: sql_xa_commit.cc:62
enum xa_option_words m_xa_opt
Options associated with the underlying XA COMMIT
Definition: sql_xa_commit.h:78
bool execute(THD *thd) override
Executes the SQL command.
Definition: sql_xa_commit.cc:64
bool process_detached_xa_commit(THD *thd)
Handle the statement XA COMMIT for the case when xid corresponds to an XA transaction that is detache...
Definition: sql_xa_commit.cc:227
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:36
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
xa_option_words
Definition: xa.h:53