MySQL 8.4.0
Source Code Documentation
transaction_prepared_message.h
Go to the documentation of this file.
1/* Copyright (c) 2018, 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 TRANSACTION_PREPARED_MESSAGE_INCLUDED
25#define TRANSACTION_PREPARED_MESSAGE_INCLUDED
26
28#include <vector>
29
30#include "my_inttypes.h"
32
33/*
34 @class Transaction_prepared_message
35 */
37 public:
39 // This type should not be used anywhere.
41
42 // Length of the payload item: 8 bytes
44
45 // Length of the payload item: 16 bytes.
46 // Optional item.
48
49 // Length of the payload item: 8 bytes
51
52 // Length of the payload item: 1-32
53 // Optional item.
55
56 // No valid type codes can appear after this one.
57 PIT_MAX = 5
58 };
59
60 /**
61 Message constructor
62
63 @param[in] tsid the prepared transaction tsid
64 @param[in] is_tsid_specified information on whether tsid is specified
65 @param[in] gno the prepared transaction gno
66 */
68 bool is_tsid_specified, rpl_gno gno);
69
70 /**
71 Message decode constructor
72
73 @param[in] buf message buffer
74 @param[in] len message buffer length
75 */
76 Transaction_prepared_message(const unsigned char *buf, size_t len);
78
80
81 /**
82 Return the time at which the message contained in the buffer was sent.
83 @see Metrics_handler::get_current_time()
84
85 @param[in] buffer the buffer to decode from.
86 @param[in] length the buffer length
87
88 @return the time on which the message was sent.
89 */
90 static uint64_t get_sent_timestamp(const unsigned char *buffer,
91 size_t length);
92
93 /// @brief returns information on whether TSID is specified for this trx
94 /// @return information on whether TSID is specified for this trx
95 bool is_tsid_specified() const { return m_tsid_specified; }
96
97 /// @brief TSID accessor
98 /// @return Const reference to transaction TSID
99 const gr::Gtid_tsid &get_tsid();
100
102
103 /// @brief Checks whether message encoding/decoding succeeded
104 /// @return Message validity
105 bool is_valid() const;
106
107 /// @brief Gets information about decoding/encoding error
108 /// @return Const reference to decoding/encoding error information
109 const Error_ptr &get_error() const;
110
111 protected:
112 /*
113 Implementation of the template methods
114 */
115 void encode_payload(std::vector<unsigned char> *buffer) const override;
116 void decode_payload(const unsigned char *buffer,
117 const unsigned char *end) override;
118
119 private:
123 /// Holds information about error that might occur during encoding/decoding
125};
126
127#endif /* TRANSACTION_PREPARED_MESSAGE_INCLUDED */
This is the base GCS plugin message.
Definition: gcs_plugin_messages.h:64
Definition: transaction_prepared_message.h:36
Error_ptr m_error
Holds information about error that might occur during encoding/decoding.
Definition: transaction_prepared_message.h:124
void encode_payload(std::vector< unsigned char > *buffer) const override
Encodes the contents of this instance payload into the buffer.
Definition: transaction_prepared_message.cc:45
~Transaction_prepared_message() override
void decode_payload(const unsigned char *buffer, const unsigned char *end) override
Decodes the contents of the buffer and sets the payload field values according to the values decoded.
Definition: transaction_prepared_message.cc:76
const gr::Gtid_tsid & get_tsid()
TSID accessor.
Definition: transaction_prepared_message.cc:123
enum_payload_item_type
Definition: transaction_prepared_message.h:38
@ PIT_MAX
Definition: transaction_prepared_message.h:57
@ PIT_UNKNOWN
Definition: transaction_prepared_message.h:40
@ PIT_SENT_TIMESTAMP
Definition: transaction_prepared_message.h:50
@ PIT_TRANSACTION_PREPARED_TAG
Definition: transaction_prepared_message.h:54
@ PIT_TRANSACTION_PREPARED_GNO
Definition: transaction_prepared_message.h:43
@ PIT_TRANSACTION_PREPARED_SID
Definition: transaction_prepared_message.h:47
mysql::utils::Error_ptr Error_ptr
Definition: transaction_prepared_message.h:101
const Error_ptr & get_error() const
Gets information about decoding/encoding error.
Definition: transaction_prepared_message.cc:142
rpl_gno get_gno()
Definition: transaction_prepared_message.cc:125
rpl_gno m_gno
Definition: transaction_prepared_message.h:121
bool is_tsid_specified() const
returns information on whether TSID is specified for this trx
Definition: transaction_prepared_message.h:95
bool is_valid() const
Checks whether message encoding/decoding succeeded.
Definition: transaction_prepared_message.cc:134
gr::Gtid_tsid m_tsid
Definition: transaction_prepared_message.h:122
bool m_tsid_specified
Definition: transaction_prepared_message.h:120
static uint64_t get_sent_timestamp(const unsigned char *buffer, size_t length)
Return the time at which the message contained in the buffer was sent.
Definition: transaction_prepared_message.cc:127
Transaction_prepared_message(const gr::Gtid_tsid &tsid, bool is_tsid_specified, rpl_gno gno)
Message constructor.
Definition: transaction_prepared_message.cc:28
Represents Transaction Source Identifier which is composed of source UUID and transaction tag.
Definition: tsid.h:47
Some integer typedefs for easier portability.
Definition: buf0block_hint.cc:30
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
std::unique_ptr< mysql::utils::Error > Error_ptr
Definition: error.h:41
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:418
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:192
mysql::gtid::gno_t rpl_gno
GNO, the second (numeric) component of a GTID, is an alias of mysql::gtid::gno_t.
Definition: rpl_gtid.h:112