MySQL 8.4.11
Source Code Documentation
rpl_utility.h
Go to the documentation of this file.
1/* Copyright (c) 2006, 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#ifndef RPL_UTILITY_H
25#define RPL_UTILITY_H
26
27#ifndef __cplusplus
28#error "Don't include this C++ header file from a non-C++ file!"
29#endif
30
31#include <sys/types.h>
32#include <algorithm>
33#include <string>
34#include <tuple>
35#include <unordered_map>
36
37#include "field_types.h" // enum_field_types
38#include "my_dbug.h"
39#include "my_inttypes.h"
40#include "my_macros.h"
41#include "sql/psi_memory_key.h"
42
43struct MY_BITMAP;
44
45#ifdef MYSQL_SERVER
46#include <memory>
47
48#include "map_helpers.h"
49#include "prealloced_array.h" // Prealloced_array
50#include "sql/table.h" // Table_ref
51
52class Log_event;
53class Relay_log_info;
54class THD;
55
56/**
57 Hash table used when applying row events on the slave and there is
58 no index on the slave's table.
59 */
60
62 /**
63 Points at the position where the row starts in the
64 event buffer (ie, area in memory before unpacking takes
65 place).
66 */
68 const uchar *bi_ends;
69};
70
71struct HASH_ROW_ENTRY;
72
74 void operator()(HASH_ROW_ENTRY *entry) const;
75};
76
77/**
78 Internal structure that acts as a preamble for HASH_ROW_POS
79 in memory structure.
80
81 Allocation is done in Hash_slave_rows::make_entry as part of
82 the entry allocation.
83 */
85 HASH_ROW_PREAMBLE() = default;
86 /*
87 The actual key.
88 */
90
91 /**
92 The search state used to iterate over multiple entries for a
93 given key.
94 */
96 uint, std::unique_ptr<HASH_ROW_ENTRY, hash_slave_rows_free_entry>>::
97 const_iterator search_state;
98
99 /**
100 whether this search_state is usable or not.
101 */
103};
104
108};
109
111 public:
112 /**
113 Allocates an empty entry to be added to the hash table.
114 It should be called before calling member function @c put.
115
116 @returns NULL if a problem occurred, a valid pointer otherwise.
117 */
119
120 /**
121 Allocates an entry to be added to the hash table. It should be
122 called before calling member function @c put.
123
124 @param bi_start the position to where in the rows buffer the
125 before image begins.
126 @param bi_ends the position to where in the rows buffer the
127 before image ends.
128 @returns NULL if a problem occurred, a valid pointer otherwise.
129 */
130 HASH_ROW_ENTRY *make_entry(const uchar *bi_start, const uchar *bi_ends);
131
132 /**
133 Puts data into the hash table. It calculates the key taking
134 the data on @c TABLE::record as the input for hash computation.
135
136 @param table The table holding the buffer used to calculate the
137 key, ie, table->record[0].
138 @param cols The read_set bitmap signaling which columns are used.
139 @param entry The entry with the values to store.
140
141 @returns true if something went wrong, false otherwise.
142 */
144
145 /**
146 Gets the entry, from the hash table, that matches the data in
147 table->record[0] and signaled using cols.
148
149 @param table The table holding the buffer containing data used to
150 make the entry lookup.
151 @param cols Bitmap signaling which columns, from
152 table->record[0], should be used.
153
154 @returns a pointer that will hold a reference to the entry
155 found. If the entry is not found then NULL shall be
156 returned.
157 */
159
160 /**
161 Gets the entry that stands next to the one pointed to by
162 *entry. Before calling this member function, the entry that one
163 uses as parameter must have: 1. been obtained through get() or
164 next() invocations; and 2. must have not been used before in a
165 next() operation.
166
167 @param[in,out] entry contains a pointer to an entry that we can
168 use to search for another adjacent entry
169 (ie, that shares the same key).
170
171 @returns true if something went wrong, false otherwise. In the
172 case that this entry was already used in a next()
173 operation this member function returns true and does not
174 update the pointer.
175 */
176 bool next(HASH_ROW_ENTRY **entry);
177
178 /**
179 Deletes the entry pointed by entry. It also frees memory used
180 holding entry contents. This is the way to release memory
181 used for entry, freeing it explicitly with my_free will cause
182 undefined behavior.
183
184 @param entry Pointer to the entry to be deleted.
185 @returns true if something went wrong, false otherwise.
186 */
187 bool del(HASH_ROW_ENTRY *entry);
188
189 /**
190 Initializes the hash table.
191
192 @returns true if something went wrong, false otherwise.
193 */
194 bool init(void);
195
196 /**
197 De-initializes the hash table.
198
199 @returns true if something went wrong, false otherwise.
200 */
201 bool deinit(void);
202
203 /**
204 Checks if the hash table is empty or not.
205
206 @returns true if the hash table has zero entries, false otherwise.
207 */
208 bool is_empty(void);
209
210 /**
211 Returns the number of entries in the hash table.
212
213 @returns the number of entries in the hash table.
214 */
215 int size();
216
217 private:
218 /**
219 The hashtable itself.
220 */
222 uint, std::unique_ptr<HASH_ROW_ENTRY, hash_slave_rows_free_entry>>
224
225 /**
226 Auxiliary and internal method used to create an hash key, based on
227 the data in table->record[0] buffer and signaled as used in cols.
228
229 @param table The table that is being scanned
230 @param cols The read_set bitmap signaling which columns are used.
231
232 @returns the hash key created.
233 */
234 uint make_hash_key(TABLE *table, MY_BITMAP *cols);
235};
236
237#endif
238
239/**
240 A table definition from the master.
241
242 The responsibilities of this class is:
243 - Extract and decode table definition data from the table map event
244 - Check if table definition in table map is compatible with table
245 definition on slave
246 - expose the type information so that it can be used when encoding
247 or decoding row event data.
248*/
250 public:
251 /**
252 No-op constructor. Instances of RPL_Table_ref are created by first
253 allocating memory, then placement-new-ing an RPL_Table_ref object
254 containing an uninitialized table_def object which is only conditionally
255 initialized. See Table_map_log_event::do_apply_event().
256 */
257 table_def() = default;
258
259 /**
260 Constructor.
261
262 @param types Array of types, each stored as a byte
263 @param size Number of elements in array 'types'
264 @param field_metadata Array of extra information about fields
265 @param metadata_size Size of the field_metadata array
266 @param null_bitmap The bitmap of fields that can be null
267 @param flags Table flags
268 */
269 table_def(unsigned char *types, ulong size, uchar *field_metadata,
270 int metadata_size, uchar *null_bitmap, uint16 flags);
271
272 ~table_def();
273
274 /**
275 Return whether the table definition metadata was decoded successfully.
276
277 @retval true if the field metadata stream is well-formed and fully consumed
278 @retval false if metadata decoding did not match the encoded metadata bounds
279 */
280 bool is_valid() const { return m_is_valid; }
281
282 /**
283 Return the number of fields there is type data for.
284
285 @return The number of fields that there is type data for.
286 */
287 ulong size() const { return m_size; }
288
289 /**
290 Return the number of fields there is type data for minus
291 the GIPK field if this field does not exist in the replica.
292
293 @return The number of fields there is a type minus the GIPK
294 */
295 ulong filtered_size(bool replica_has_gipk) const {
296 if (m_is_gipk_on_table && !replica_has_gipk) return m_size - 1;
297 return m_size;
298 }
299
300 /*
301 Returns internal binlog type code for one field,
302 without translation to real types.
303 */
304 enum_field_types binlog_type(ulong index) const {
305 return static_cast<enum_field_types>(m_type[index]);
306 }
307
308 /// Return the number of JSON columns in this table.
309 int json_column_count() const {
310 // Cache in member field to make successive calls faster.
311 if (m_json_column_count == -1) {
312 int c = 0;
313 for (uint i = 0; i < size(); i++)
314 if (type(i) == MYSQL_TYPE_JSON) c++;
316 }
317 return m_json_column_count;
318 }
319
320 /*
321 Return a representation of the type data for one field.
322
323 @param index Field index to return data for
324
325 @return Will return a representation of the type data for field
326 <code>index</code>. Currently, only the type identifier is
327 returned.
328 */
329 enum_field_types type(ulong index) const {
330 assert(index < m_size);
331 /*
332 If the source type is MYSQL_TYPE_STRING, it can in reality be
333 either MYSQL_TYPE_STRING, MYSQL_TYPE_ENUM, or MYSQL_TYPE_SET, so
334 we might need to modify the type to get the real type.
335 */
336 enum_field_types source_type = binlog_type(index);
337 uint source_metadata = m_field_metadata[index];
338 switch (source_type) {
339 case MYSQL_TYPE_STRING: {
340 int real_type = source_metadata >> 8;
341 if (real_type == MYSQL_TYPE_ENUM || real_type == MYSQL_TYPE_SET)
342 source_type = static_cast<enum_field_types>(real_type);
343 break;
344 }
345
346 /*
347 This type has not been used since before row-based replication,
348 so we can safely assume that it really is MYSQL_TYPE_NEWDATE.
349 */
350 case MYSQL_TYPE_DATE:
351 source_type = MYSQL_TYPE_NEWDATE;
352 break;
353
354 default:
355 /* Do nothing */
356 break;
357 }
358
359 return source_type;
360 }
361
362 /*
363 This function allows callers to get the extra field data from the
364 table map for a given field. If there is no metadata for that field
365 or there is no extra metadata at all, the function returns 0.
366
367 The function returns the value for the field metadata for column at
368 position indicated by index. As mentioned, if the field was a type
369 that stores field metadata, that value is returned else zero (0) is
370 returned. This method is used in the unpack() methods of the
371 corresponding fields to properly extract the data from the binary log
372 in the event that the master's field is smaller than the slave.
373 */
374 uint field_metadata(uint index) const {
375 assert(index < m_size);
377 return m_field_metadata[index];
378 else
379 return 0;
380 }
381
382 /**
383 Returns whether or not the field at `index` is a typed array.
384 */
385 bool is_array(uint index) const {
386 assert(index < m_size);
388 return m_is_array[index];
389 else
390 return false;
391 }
392
393 /*
394 This function returns whether the field on the master can be null.
395 This value is derived from field->maybe_null().
396 */
397 bool maybe_null(uint index) const {
398 assert(index < m_size);
399 return ((m_null_bits[(index / 8)] & (1 << (index % 8))) ==
400 (1 << (index % 8)));
401 }
402
403 /*
404 This function returns the field size in raw bytes based on the type
405 and the encoded field data from the master's raw data. This method can
406 be used for situations where the slave needs to skip a column (e.g.,
407 WL#3915) or needs to advance the pointer for the fields in the raw
408 data from the master to a specific column.
409 */
410 uint32 calc_field_size(uint col, const uchar *master_data) const;
411
412#ifdef MYSQL_SERVER
413 /**
414 Decide if the table definition is compatible with a table.
415
416 Compare the definition with a table to see if it is compatible
417 with it.
418
419 A table definition is compatible with a table if:
420 - The columns types of the table definition is a (not
421 necessarily proper) prefix of the column type of the table.
422
423 - The other way around.
424
425 - Each column on the master that also exists on the slave can be
426 converted according to the current settings of @c
427 REPLICA_TYPE_CONVERSIONS.
428
429 @param thd Current thread
430 @param rli Pointer to relay log info
431 @param table Pointer to table to compare with.
432
433 @param[out] conv_table_var Pointer to temporary table for holding
434 conversion table.
435
436 @retval 1 if the table definition is not compatible with @c table
437 @retval 0 if the table definition is compatible with @c table
438 */
439 bool compatible_with(THD *thd, Relay_log_info *rli, TABLE *table,
440 TABLE **conv_table_var);
441
442 /**
443 Create a virtual in-memory temporary table structure.
444
445 The table structure has records and field array so that a row can
446 be unpacked into the record for further processing.
447
448 In the virtual table, each field that requires conversion will
449 have a non-NULL value, while fields that do not require
450 conversion will have a NULL value.
451
452 Some information that is missing in the events, such as the
453 character set for string types, are taken from the table that the
454 field is going to be pushed into, so the target table that the data
455 eventually need to be pushed into need to be supplied.
456
457 @param thd Thread to allocate memory from.
458 @param rli Relay log info structure, for error reporting.
459 @param target_table Target table for fields.
460 @param replica_has_gipk Does the replica table contain a GIPK
461
462 @return A pointer to a temporary table with memory allocated in the
463 thread's memroot, NULL if the table could not be created
464 */
466 TABLE *target_table,
467 bool replica_has_gipk) const;
468
469 /**
470 Evaluates if the source table might contain a GIPK
471
472 @note for servers of older versions that do not fully support GIPK, this
473 sets the info that is a guess based on available information replication
474 has.
475
476 In the case when the replica has a GIPK, the source is from an old
477 version that does not indicate if it has a GIPK or not, and the source
478 either has extra columns, or the replica has two more more extra columns
479 true is returned.
480 This function does not report an error.
481
482 @param thd The thread object associated to the application
483 @param table The table in the replica.
484
485 @return true if this table definition is found to be incompatible with the
486 table, false otherwise.
487 */
489
490 /**
491 Checks if the table contains a GIPK
492
493 @note for servers of older versions that do not fully support GIPK, this
494 method returns a guess based on available information replication has.
495
496 @return true if we believe the table to contain a GIPK, false otherwise
497 */
499
500#endif
501
502 private:
503 ulong m_size; // Number of elements in the types array
504 unsigned char *m_type; // Array of type descriptors
508 uint16 m_flags; // Table flags
510 mutable int m_json_column_count; // Number of JSON columns
513 /// Whether the serialized field metadata stream decoded within bounds.
514 bool m_is_valid{true};
516};
517
518#ifdef MYSQL_SERVER
519/**
520 Extend the normal Table_ref with a few new fields needed by the
521 slave thread, but nowhere else.
522 */
523struct RPL_Table_ref : public Table_ref {
524 RPL_Table_ref(const char *db_name_arg, size_t db_length_arg,
525 const char *table_name_arg, size_t table_name_length_arg,
526 const char *alias_arg, enum thr_lock_type lock_type_arg)
527 : Table_ref(db_name_arg, db_length_arg, table_name_arg,
528 table_name_length_arg, alias_arg, lock_type_arg) {}
529
533};
534
536 private:
538
539 public:
542 /* queue for execution at Query-log-event time prior to the Query */
543 int add(Log_event *ev);
544 bool is_empty();
545 bool execute(Relay_log_info *rli);
546 void rewind();
547};
548
549#endif
550
551/**
552 Decode field metadata from a char buffer (serialized form) into an int
553 (packed form).
554
555 @note On little-endian platforms (e.g Intel) this function effectively
556 inverts order of bytes compared to what Field::save_field_metadata()
557 writes. E.g for MYSQL_TYPE_NEWDECIMAL save_field_metadata writes precision
558 into the first byte and decimals into the second, this function puts
559 precision into the second byte and decimals into the first. This layout
560 is expected by replication code that reads metadata in the uint form.
561 Due to this design feature show_sql_type() can't correctly print
562 immediate output of save_field_metadata(), this function have to be used
563 as translator.
564
565 @param buffer Field metadata, in the character stream form produced by
566 save_field_metadata.
567 @param metadata_size Number of bytes available in @c buffer.
568 @param binlog_type The type of the field, in the form returned by
569 Field::binlog_type and stored in Table_map_log_event.
570 @retval tuple where:
571 - the first component is true if decoding would read beyond
572 @c metadata_size, false otherwise.
573 - the second component is the length of the metadata within 'buffer',
574 i.e., how much the buffer pointer should move forward in order to skip it.
575 - the third component is pair containing:
576 - the metadata, encoded as an 'uint', in the form required by e.g.
577 show_sql_type.
578 - bool indicating whether the field is array (true) or a scalar (false)
579*/
580
581std::tuple<bool, my_off_t, std::pair<uint, bool>> read_field_metadata(
582 const uchar *buffer, uint metadata_size, enum_field_types binlog_type);
583
584// NB. number of printed bit values is limited to sizeof(buf) - 1
585#define DBUG_PRINT_BITSET(N, FRM, BS) \
586 do { \
587 char buf[256]; \
588 uint i; \
589 for (i = 0; i < std::min(uint{sizeof(buf) - 1}, (BS)->n_bits); i++) \
590 buf[i] = bitmap_is_set((BS), i) ? '1' : '0'; \
591 buf[i] = '\0'; \
592 DBUG_PRINT((N), ((FRM), buf)); \
593 } while (0)
594
595#ifdef MYSQL_SERVER
596/**
597 Sentry class for managing the need to create and dispose of a local `THD`
598 instance.
599
600 If the given `THD` object pointer passed on the constructor is `nullptr`, a
601 new instance will be initialized within the constructor and disposed of in the
602 destructor.
603
604 If the given `THD` object pointer passed on the constructor is not `nullptr`,
605 the reference is kept and nothing is disposed on the destructor.
606
607 Casting operator to `THD*` is also provided, to easy code replacemente.
608
609 Usage example:
610
611 THD_instance_guard thd{current_thd != nullptr ? current_thd :
612 this->info_thd};
613 Acl_cache_lock_guard guard{thd, Acl_cache_lock_mode::READ_MODE};
614 if (guard.lock())
615 ...
616
617 */
619 public:
620 /**
621 If the given `THD` object pointer is `nullptr`, a new instance will be
622 initialized within the constructor and disposed of in the destructor.
623
624 If the given `THD` object pointer is not `nullptr`, the reference is kept
625 and nothing is disposed on the destructor.
626
627 @param thd `THD` object reference that determines if an existence instance
628 is used or a new instance of `THD` must be created.
629 */
631 /**
632 If a new instance of `THD` was created in the constructor, it will be
633 disposed here.
634 */
635 virtual ~THD_instance_guard();
636
637 /**
638 Returns the active `THD` object pointer.
639
640 @return a not-nullptr `THD` object pointer.
641 */
642 operator THD *();
643
644 private:
645 /** The active `THD` object pointer. */
646 THD *m_target{nullptr};
647 /**
648 Tells whether or not the active `THD` object was created in this object
649 constructor.
650 */
652};
653#endif // MYSQL_SERVER
654
655/**
656 Replaces every occurrence of the string `find` by the string `replace`, within
657 the string `from` and return the resulting string.
658
659 The original string `from` remains untouched.
660
661 @param from the string to search within.
662 @param find the string to search for.
663 @param replace the string to replace every occurrence of `from`
664
665 @return a new string, holding the result of the search and replace operation.
666 */
667std::string replace_all_in_str(std::string from, std::string find,
668 std::string replace);
669
670#ifdef MYSQL_SERVER
671
672/**
673 This method shall evaluate if a command being executed goes against any of
674 the restrictions of server variable session.require_row_format.
675
676 @param thd The thread associated to the command
677 @return true if it violates any restrictions
678 false otherwise
679 */
680bool is_require_row_format_violation(const THD *thd);
681
682/**
683 Checks if the immediate_server_version supports GIPKs or not
684
685 @param thd The THD context to check the version
686
687 @return true if the source server supports GIPK, false otherwise
688 */
690
691/**
692 Returns if the replicated table contains a GIPK or not
693
694 @note for servers of older versions that do not fully support GIPK, this
695 method returns a guess based on available information replication has.
696
697 @param rli The relay log object associated to the channel
698 @param table The table to check for the GIPK
699
700 @return true if we believe the table has a GIPK, false otherwise.
701 */
703
704/**
705 @brief Returns a string representation for a given version
706
707 @param version a version represented using a integer
708
709 @return a string for the given version or "unknown"
710 if version is undefined or unknown.
711*/
713
714#endif // MYSQL_SERVER
715
716#endif /* RPL_UTILITY_H */
Definition: rpl_utility.h:535
bool is_empty()
Definition: rpl_utility.cc:1284
int add(Log_event *ev)
Definition: rpl_utility.cc:1278
~Deferred_log_events()
Definition: rpl_utility.cc:1276
bool execute(Relay_log_info *rli)
Definition: rpl_utility.cc:1286
void rewind()
Definition: rpl_utility.cc:1300
Prealloced_array< Log_event *, 32 > m_array
Definition: rpl_utility.h:537
Deferred_log_events()
Definition: rpl_utility.cc:1273
Definition: rpl_utility.h:110
malloc_unordered_multimap< uint, std::unique_ptr< HASH_ROW_ENTRY, hash_slave_rows_free_entry > > m_hash
The hashtable itself.
Definition: rpl_utility.h:223
bool del(HASH_ROW_ENTRY *entry)
Deletes the entry pointed by entry.
Definition: rpl_utility.cc:1161
HASH_ROW_ENTRY * get(TABLE *table, MY_BITMAP *cols)
Gets the entry, from the hash table, that matches the data in table->record[0] and signaled using col...
Definition: rpl_utility.cc:1095
HASH_ROW_ENTRY * make_entry()
Allocates an empty entry to be added to the hash table.
Definition: rpl_utility.cc:1024
bool next(HASH_ROW_ENTRY **entry)
Gets the entry that stands next to the one pointed to by entry.
Definition: rpl_utility.cc:1120
bool deinit(void)
De-initializes the hash table.
Definition: rpl_utility.cc:1016
int size()
Returns the number of entries in the hash table.
Definition: rpl_utility.cc:1022
uint make_hash_key(TABLE *table, MY_BITMAP *cols)
Auxiliary and internal method used to create an hash key, based on the data in table->record[0] buffe...
Definition: rpl_utility.cc:1169
bool init(void)
Initializes the hash table.
Definition: rpl_utility.cc:1014
bool put(TABLE *table, MY_BITMAP *cols, HASH_ROW_ENTRY *entry)
Puts data into the hash table.
Definition: rpl_utility.cc:1074
bool is_empty(void)
Checks if the hash table is empty or not.
Definition: rpl_utility.cc:1008
This is the abstract base class for binary log events.
Definition: log_event.h:538
A typesafe replacement for DYNAMIC_ARRAY.
Definition: prealloced_array.h:71
Definition: rpl_rli.h:203
Sentry class for managing the need to create and dispose of a local THD instance.
Definition: rpl_utility.h:618
bool m_is_locally_initialized
Tells whether or not the active THD object was created in this object constructor.
Definition: rpl_utility.h:651
THD_instance_guard(THD *thd)
If the given THD object pointer is nullptr, a new instance will be initialized within the constructor...
Definition: rpl_utility.cc:1328
THD * m_target
The active THD object pointer.
Definition: rpl_utility.h:646
virtual ~THD_instance_guard()
If a new instance of THD was created in the constructor, it will be disposed here.
Definition: rpl_utility.cc:1340
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Definition: table.h:2865
std::unordered_multimap, but with my_malloc, so that you can track the memory used using PSI memory k...
Definition: map_helpers.h:198
A table definition from the master.
Definition: rpl_utility.h:249
int m_json_column_count
Definition: rpl_utility.h:510
ulong filtered_size(bool replica_has_gipk) const
Return the number of fields there is type data for minus the GIPK field if this field does not exist ...
Definition: rpl_utility.h:295
ulong m_size
Definition: rpl_utility.h:503
bool compatible_with(THD *thd, Relay_log_info *rli, TABLE *table, TABLE **conv_table_var)
Decide if the table definition is compatible with a table.
Definition: rpl_utility.cc:467
uint32 calc_field_size(uint col, const uchar *master_data) const
Definition: rpl_utility.cc:96
bool compute_source_table_gipk_info(THD &thd, TABLE *table)
Evaluates if the source table might contain a GIPK.
Definition: rpl_utility.cc:793
enum_field_types type(ulong index) const
Definition: rpl_utility.h:329
table_def()=default
No-op constructor.
bool * m_is_array
Definition: rpl_utility.h:511
uchar * m_memory
Definition: rpl_utility.h:509
int json_column_count() const
Return the number of JSON columns in this table.
Definition: rpl_utility.h:309
ulong size() const
Return the number of fields there is type data for.
Definition: rpl_utility.h:287
unsigned char * m_type
Definition: rpl_utility.h:504
uint m_field_metadata_size
Definition: rpl_utility.h:505
TABLE * create_conversion_table(THD *thd, Relay_log_info *rli, TABLE *target_table, bool replica_has_gipk) const
Create a virtual in-memory temporary table structure.
Definition: rpl_utility.cc:647
uint * m_field_metadata
Definition: rpl_utility.h:506
enum_field_types binlog_type(ulong index) const
Definition: rpl_utility.h:304
bool m_is_gipk_on_table
Definition: rpl_utility.h:515
bool m_is_gipk_set
Definition: rpl_utility.h:512
uint16 m_flags
Definition: rpl_utility.h:508
bool is_array(uint index) const
Returns whether or not the field at index is a typed array.
Definition: rpl_utility.h:385
bool is_gipk_present_on_source_table() const
Checks if the table contains a GIPK.
Definition: rpl_utility.cc:788
bool m_is_valid
Whether the serialized field metadata stream decoded within bounds.
Definition: rpl_utility.h:514
~table_def()
Definition: rpl_utility.cc:980
bool maybe_null(uint index) const
Definition: rpl_utility.h:397
bool is_valid() const
Return whether the table definition metadata was decoded successfully.
Definition: rpl_utility.h:280
uchar * m_null_bits
Definition: rpl_utility.h:507
uint field_metadata(uint index) const
Definition: rpl_utility.h:374
This file contains the field type.
enum_field_types
Column types for MySQL Note: Keep include/mysql/components/services/bits/stored_program_bits....
Definition: field_types.h:55
@ MYSQL_TYPE_SET
Definition: field_types.h:82
@ MYSQL_TYPE_NEWDATE
Internal to MySQL.
Definition: field_types.h:70
@ MYSQL_TYPE_JSON
Definition: field_types.h:79
@ MYSQL_TYPE_STRING
Definition: field_types.h:88
@ MYSQL_TYPE_ENUM
Definition: field_types.h:81
@ MYSQL_TYPE_DATE
Definition: field_types.h:66
static int flags[50]
Definition: hp_test1.cc:40
Some integer typedefs for easier portability.
unsigned char uchar
Definition: my_inttypes.h:52
uint16_t uint16
Definition: my_inttypes.h:65
uint32_t uint32
Definition: my_inttypes.h:67
Some common macros.
static bool replace
Definition: mysqlimport.cc:70
static PFS_engine_table_share_proxy table
Definition: pfs.cc:61
Container::const_iterator find(const Container &c, Value &&value)
Definition: generic.h:39
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:418
PSI_memory_key key_memory_HASH_ROW_ENTRY
Definition: psi_memory_key.cc:51
required uint64 version
Definition: replication_group_member_actions.proto:41
bool is_immediate_server_gipk_ready(THD &thd)
Checks if the immediate_server_version supports GIPKs or not.
Definition: rpl_utility.cc:1385
bool is_require_row_format_violation(const THD *thd)
This method shall evaluate if a command being executed goes against any of the restrictions of server...
Definition: rpl_utility.cc:1356
std::string replace_all_in_str(std::string from, std::string find, std::string replace)
Replaces every occurrence of the string find by the string replace, within the string from and return...
Definition: rpl_utility.cc:1309
std::tuple< bool, my_off_t, std::pair< uint, bool > > read_field_metadata(const uchar *buffer, uint metadata_size, enum_field_types binlog_type)
Decode field metadata from a char buffer (serialized form) into an int (packed form).
Definition: rpl_utility.cc:838
bool does_source_table_contain_gipk(Relay_log_info const *rli, TABLE *table)
Returns if the replicated table contains a GIPK or not.
Definition: rpl_utility.cc:1390
std::string decimal_numeric_version_to_string(uint32 version)
Returns a string representation for a given version.
Definition: rpl_utility.cc:1398
Definition: rpl_utility.h:105
HASH_ROW_POS * positions
Definition: rpl_utility.h:107
HASH_ROW_PREAMBLE * preamble
Definition: rpl_utility.h:106
Hash table used when applying row events on the slave and there is no index on the slave's table.
Definition: rpl_utility.h:61
const uchar * bi_start
Points at the position where the row starts in the event buffer (ie, area in memory before unpacking ...
Definition: rpl_utility.h:67
const uchar * bi_ends
Definition: rpl_utility.h:68
Internal structure that acts as a preamble for HASH_ROW_POS in memory structure.
Definition: rpl_utility.h:84
malloc_unordered_multimap< uint, std::unique_ptr< HASH_ROW_ENTRY, hash_slave_rows_free_entry > >::const_iterator search_state
The search state used to iterate over multiple entries for a given key.
Definition: rpl_utility.h:97
bool is_search_state_inited
whether this search_state is usable or not.
Definition: rpl_utility.h:102
uint hash_value
Definition: rpl_utility.h:89
HASH_ROW_PREAMBLE()=default
Definition: my_bitmap.h:43
Extend the normal Table_ref with a few new fields needed by the slave thread, but nowhere else.
Definition: rpl_utility.h:523
RPL_Table_ref(const char *db_name_arg, size_t db_length_arg, const char *table_name_arg, size_t table_name_length_arg, const char *alias_arg, enum thr_lock_type lock_type_arg)
Definition: rpl_utility.h:524
table_def m_tabledef
Definition: rpl_utility.h:531
bool m_tabledef_valid
Definition: rpl_utility.h:530
TABLE * m_conv_table
Definition: rpl_utility.h:532
Definition: table.h:1407
Definition: completion_hash.h:35
Definition: rpl_utility.h:73
void operator()(HASH_ROW_ENTRY *entry) const
Utility methods for handling row based operations.
Definition: rpl_utility.cc:996
thr_lock_type
Definition: thr_lock.h:51