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