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