| 1 |
/* Copyright (c) 2014, 2026, 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 |
#include "load_data_events.h" |
| 25 |
#include "event_reader_macros.h" |
| 26 |
|
| 27 |
namespace binary_log { |
| 28 |
/** |
| 29 |
The constructor is called by MySQL slave, while applying the events. |
| 30 |
*/ |
| 31 |
Execute_load_query_event::Execute_load_query_event( |
| 32 |
uint32_t file_id_arg, uint32_t fn_pos_start_arg, uint32_t fn_pos_end_arg, |
| 33 |
enum_load_dup_handling dup_arg) |
| 34 |
: Query_event(EXECUTE_LOAD_QUERY_EVENT), |
| 35 |
file_id(file_id_arg), |
| 36 |
fn_pos_start(fn_pos_start_arg), |
| 37 |
fn_pos_end(fn_pos_end_arg), |
| 38 |
dup_handling(dup_arg) {} |
| 39 |
|
| 40 |
/** |
| 41 |
The constructor used in order to decode EXECUTE_LOAD_QUERY_EVENT from a |
| 42 |
packet. It is used on the MySQL server acting as a slave. |
| 43 |
*/ |
| 44 |
Execute_load_query_event::Execute_load_query_event( |
| 45 |
const char *buf, const Format_description_event *fde) |
| 46 |
: Query_event(buf, fde, EXECUTE_LOAD_QUERY_EVENT), |
| 47 |
file_id(0), |
| 48 |
fn_pos_start(0), |
| 49 |
fn_pos_end(0) { |
| 50 |
uint8_t dup_temp; |
| 51 |
BAPI_ENTER( |
| 52 |
"Execute_load_query_event::Execute_load_query_event(const char*, const " |
| 53 |
"Format_description_event*)"); |
| 54 |
READER_TRY_INITIALIZATION; |
| 55 |
|
| 56 |
READER_TRY_CALL(go_to, fde->common_header_len); |
| 57 |
READER_TRY_CALL(forward, ELQ_FILE_ID_OFFSET); |
| 58 |
READER_TRY_SET(file_id, read<int32_t>); |
| 59 |
READER_TRY_SET(fn_pos_start, read<uint32_t>); |
| 60 |
READER_TRY_SET(fn_pos_end, read<uint32_t>); |
| 61 |
READER_TRY_SET(dup_temp, read<uint8_t>); |
| 62 |
dup_handling = (enum_load_dup_handling)(dup_temp); |
| 63 |
|
| 64 |
/* Sanity check */ |
| 65 |
if (fn_pos_start > q_len || fn_pos_end > q_len || |
| 66 |
dup_handling > LOAD_DUP_REPLACE) |
| 67 |
READER_THROW("Invalid Execute_load_query_event."); |
| 68 |
|
| 69 |
READER_CATCH_ERROR; |
| 70 |
BAPI_VOID_RETURN; |
| 71 |
} |
| 72 |
|
| 73 |
Delete_file_event::Delete_file_event(const char *buf, |
| 74 |
const Format_description_event *fde) |
| 75 |
: Binary_log_event(&buf, fde), file_id(0) { |
| 76 |
BAPI_ENTER( |
| 77 |
"Delete_file_event::Delete_file_event(const char*, const " |
| 78 |
"Format_description_event*)"); |
| 79 |
READER_TRY_INITIALIZATION; |
| 80 |
|
| 81 |
READER_ASSERT_POSITION(fde->common_header_len); |
| 82 |
READER_TRY_SET(file_id, read<uint32_t>); |
| 83 |
if (file_id == 0) READER_THROW("Invalid file_id"); |
| 84 |
|
| 85 |
READER_CATCH_ERROR; |
| 86 |
BAPI_VOID_RETURN; |
| 87 |
} |
| 88 |
|
| 89 |
Append_block_event::Append_block_event(const char *buf, |
| 90 |
const Format_description_event *fde) |
| 91 |
: Binary_log_event(&buf, fde), block(nullptr) { |
| 92 |
BAPI_ENTER( |
| 93 |
"Append_block_event::Append_block_event(const char*, const " |
| 94 |
"Format_description_event*)"); |
| 95 |
READER_TRY_INITIALIZATION; |
| 96 |
READER_ASSERT_POSITION(fde->common_header_len); |
| 97 |
|
| 98 |
READER_TRY_SET(file_id, read<uint32_t>); |
| 99 |
block_len = READER_CALL(available_to_read); |
| 100 |
block = const_cast<unsigned char *>( |
| 101 |
reinterpret_cast<const unsigned char *>(READER_CALL(ptr, block_len))); |
| 102 |
|
| 103 |
READER_CATCH_ERROR; |
| 104 |
BAPI_VOID_RETURN; |
| 105 |
} |
| 106 |
|
| 107 |
Begin_load_query_event::Begin_load_query_event( |
| 108 |
const char *buf, const Format_description_event *fde) |
| 109 |
: Append_block_event(buf, fde) { |
| 110 |
BAPI_ENTER( |
| 111 |
"Begin_load_query_event::Begin_load_query_event(const char*, const " |
| 112 |
"Format_description_event*)"); |
| 113 |
BAPI_VOID_RETURN; |
| 114 |
} |
| 115 |
} // end namespace binary_log |