MySQL 9.1.0
Source Code Documentation
sql_xa_prepare.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_PREPARE
25#define XA_SQL_CMD_XA_PREPARE
26
27#include "sql/sql_cmd.h" // Sql_cmd
28#include "sql/xa.h" // xid_t
29
30/**
31 @class Sql_cmd_xa_prepare
32
33 This class represents the `XA PREPARE ...` SQL statement which puts in the
34 PREPARED state 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 prepared
44 */
45 explicit Sql_cmd_xa_prepare(xid_t *xid_arg);
46 virtual ~Sql_cmd_xa_prepare() override = default;
47
48 /**
49 Retrieves the SQL command code for this class, `SQLCOM_XA_PREPARE`.
50
51 @see Sql_cmd::sql_command_code
52
53 @return The SQL command code for this class, `SQLCOM_XA_PREPARE`.
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 /** The XID associated with the underlying XA transaction. */
71
72 /**
73 Puts an XA transaction in the PREPARED state.
74
75 @param thd The `THD` session object within which the command is being
76 executed.
77
78 @retval false Success
79 @retval true Failure
80 */
81 bool trans_xa_prepare(THD *thd);
82};
83
84#endif // XA_SQL_CMD_XA_PREPARE
This class represents the XA PREPARE ... SQL statement which puts in the PREPARED state an XA transac...
Definition: sql_xa_prepare.h:38
bool execute(THD *thd) override
Executes the SQL command.
Definition: sql_xa_prepare.cc:101
Sql_cmd_xa_prepare(xid_t *xid_arg)
Class constructor.
Definition: sql_xa_prepare.cc:95
xid_t * m_xid
The XID associated with the underlying XA transaction.
Definition: sql_xa_prepare.h:70
virtual ~Sql_cmd_xa_prepare() override=default
enum_sql_command sql_command_code() const override
Retrieves the SQL command code for this class, SQLCOM_XA_PREPARE.
Definition: sql_xa_prepare.cc:97
bool trans_xa_prepare(THD *thd)
Puts an XA transaction in the PREPARED state.
Definition: sql_xa_prepare.cc:113
Representation of an SQL command.
Definition: sql_cmd.h:83
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