MySQL 8.0.32
Source Code Documentation
sql_xa_prepare.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_PREPARE
24#define XA_SQL_CMD_XA_PREPARE
25
26#include "sql/sql_cmd.h" // Sql_cmd
27#include "sql/xa.h" // xid_t
28
29/**
30 @class Sql_cmd_xa_prepare
31
32 This class represents the `XA PREPARE ...` SQL statement which puts in the
33 PREPARED state an XA transaction with the given xid value.
34
35 @see Sql_cmd
36*/
38 public:
39 /**
40 Class constructor.
41
42 @param xid_arg XID of the XA transacation about to be prepared
43 */
44 explicit Sql_cmd_xa_prepare(xid_t *xid_arg);
45 virtual ~Sql_cmd_xa_prepare() override = default;
46
47 /**
48 Retrieves the SQL command code for this class, `SQLCOM_XA_PREPARE`.
49
50 @see Sql_cmd::sql_command_code
51
52 @return The SQL command code for this class, `SQLCOM_XA_PREPARE`.
53 */
54 enum_sql_command sql_command_code() const override;
55 /**
56 Executes the SQL command.
57
58 @see Sql_cmd::execute
59
60 @param thd The `THD` session object within which the command is being
61 executed.
62
63 @return false if the execution is successful, true otherwise.
64 */
65 bool execute(THD *thd) override;
66
67 private:
68 /** The XID associated with the underlying XA transaction. */
70
71 /**
72 Puts an XA transaction in the PREPARED state.
73
74 @param thd The `THD` session object within which the command is being
75 executed.
76
77 @retval false Success
78 @retval true Failure
79 */
80 bool trans_xa_prepare(THD *thd);
81};
82
83#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:37
bool execute(THD *thd) override
Executes the SQL command.
Definition: sql_xa_prepare.cc:100
Sql_cmd_xa_prepare(xid_t *xid_arg)
Class constructor.
Definition: sql_xa_prepare.cc:94
xid_t * m_xid
The XID associated with the underlying XA transaction.
Definition: sql_xa_prepare.h:69
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:96
bool trans_xa_prepare(THD *thd)
Puts an XA transaction in the PREPARED state.
Definition: sql_xa_prepare.cc:112
Representation of an SQL command.
Definition: sql_cmd.h:64
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