MySQL 26.7.0
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#include <vector>
37
38#include "field_types.h" // enum_field_types
39#include "my_dbug.h"
40#include "my_inttypes.h"
41#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 @param vector_dimensionality Vector dimensionality array
270 */
271 table_def(unsigned char *types, ulong size, uchar *field_metadata,
272 int metadata_size, uchar *null_bitmap, uint16 flags,
273 const std::vector<unsigned int> &vector_dimensionality);
274
275 ~table_def();
276
277 /**
278 Return whether the table definition metadata was decoded successfully.
279
280 @retval true if the field metadata stream is well-formed and fully consumed
281 @retval false if metadata decoding did not match the encoded metadata bounds
282 */
283 bool is_valid() const { return m_is_valid; }
284
285 /**
286 Return the number of fields there is type data for.
287
288 @return The number of fields that there is type data for.
289 */
290 ulong size() const { return m_size; }
291
292 /**
293 Return the number of fields there is type data for minus
294 the GIPK field if this field does not exist in the replica.
295
296 @return The number of fields there is a type minus the GIPK
297 */
298 ulong filtered_size(bool replica_has_gipk) const {
299 if (m_is_gipk_on_table && !replica_has_gipk) return m_size - 1;
300 return m_size;
301 }
302
303 /*
304 Returns internal binlog type code for one field,
305 without translation to real types.
306 */
308 return static_cast<enum_field_types>(m_type[index]);
309 }
310
311 /// Return the number of JSON columns in this table.
312 int json_column_count() const {
313 // Cache in member field to make successive calls faster.
314 if (m_json_column_count == -1) {
315 int c = 0;
316 for (uint i = 0; i < size(); i++)
317 if (type(i) == MYSQL_TYPE_JSON) c++;
319 }
320 return m_json_column_count;
321 }
322
323 /// Return the number of VECTOR columns
324 static uint vector_column_count(const unsigned char *types, ulong size) {
325 uint count = 0;
326 for (ulong i = 0; i < size; i++) {
327 if (static_cast<enum_field_types>(types[i]) == MYSQL_TYPE_VECTOR) {
328 count++;
329 }
330 }
331 return count;
332 }
333
334 /*
335 Return a representation of the type data for one field.
336
337 @param index Field index to return data for
338
339 @return Will return a representation of the type data for field
340 <code>index</code>. Currently, only the type identifier is
341 returned.
342 */
344 assert(index < m_size);
345 /*
346 If the source type is MYSQL_TYPE_STRING, it can in reality be
347 either MYSQL_TYPE_STRING, MYSQL_TYPE_ENUM, or MYSQL_TYPE_SET, so
348 we might need to modify the type to get the real type.
349 */
350 enum_field_types source_type = binlog_type(index);
351 uint source_metadata = m_field_metadata[index];
352 switch (source_type) {
353 case MYSQL_TYPE_STRING: {
354 int real_type = source_metadata >> 8;
355 if (real_type == MYSQL_TYPE_ENUM || real_type == MYSQL_TYPE_SET)
356 source_type = static_cast<enum_field_types>(real_type);
357 break;
358 }
359
360 /*
361 This type has not been used since before row-based replication,
362 so we can safely assume that it really is MYSQL_TYPE_NEWDATE.
363 */
364 case MYSQL_TYPE_DATE:
365 source_type = MYSQL_TYPE_NEWDATE;
366 break;
367
368 default:
369 /* Do nothing */
370 break;
371 }
372
373 return source_type;
374 }
375
376 /*
377 This function allows callers to get the extra field data from the
378 table map for a given field. If there is no metadata for that field
379 or there is no extra metadata at all, the function returns 0.
380
381 The function returns the value for the field metadata for column at
382 position indicated by index. As mentioned, if the field was a type
383 that stores field metadata, that value is returned else zero (0) is
384 returned. This method is used in the unpack() methods of the
385 corresponding fields to properly extract the data from the binary log
386 in the event that the master's field is smaller than the slave.
387 */
388 uint field_metadata(uint index) const {
389 assert(index < m_size);
391 return m_field_metadata[index];
392 else
393 return 0;
394 }
395
396 /**
397 Returns whether or not the field at `index` is a typed array.
398 */
399 bool is_array(uint index) const {
400 assert(index < m_size);
402 return m_is_array[index];
403 else
404 return false;
405 }
406
407 /*
408 This function returns whether the field on the master can be null.
409 This value is derived from field->maybe_null().
410 */
411 bool maybe_null(uint index) const {
412 assert(index < m_size);
413 return ((m_null_bits[(index / 8)] & (1 << (index % 8))) ==
414 (1 << (index % 8)));
415 }
416
417 /*
418 This function returns the field size in raw bytes based on the type
419 and the encoded field data from the master's raw data. This method can
420 be used for situations where the slave needs to skip a column (e.g.,
421 WL#3915) or needs to advance the pointer for the fields in the raw
422 data from the master to a specific column.
423 */
424 uint32 calc_field_size(uint col, const uchar *master_data) const;
425
426 std::vector<unsigned int>::const_iterator get_vector_dimensionality_begin()
427 const {
428 return m_vector_dimensionality.begin();
429 }
430
431 std::vector<unsigned int>::const_iterator get_vector_dimensionality_end()
432 const {
433 return m_vector_dimensionality.end();
434 }
435
436#ifdef MYSQL_SERVER
437 /**
438 Decide if the table definition is compatible with a table.
439
440 Compare the definition with a table to see if it is compatible
441 with it.
442
443 A table definition is compatible with a table if:
444 - The columns types of the table definition is a (not
445 necessarily proper) prefix of the column type of the table.
446
447 - The other way around.
448
449 - Each column on the master that also exists on the slave can be
450 converted according to the current settings of @c
451 REPLICA_TYPE_CONVERSIONS.
452
453 @param thd Current thread
454 @param rli Pointer to relay log info
455 @param table Pointer to table to compare with.
456
457 @param[out] conv_table_var Pointer to temporary table for holding
458 conversion table.
459
460 @retval 1 if the table definition is not compatible with @c table
461 @retval 0 if the table definition is compatible with @c table
462 */
463 bool compatible_with(THD *thd, Relay_log_info *rli, TABLE *table,
464 TABLE **conv_table_var);
465
466 /**
467 Create a virtual in-memory temporary table structure.
468
469 The table structure has records and field array so that a row can
470 be unpacked into the record for further processing.
471
472 In the virtual table, each field that requires conversion will
473 have a non-NULL value, while fields that do not require
474 conversion will have a NULL value.
475
476 Some information that is missing in the events, such as the
477 character set for string types, are taken from the table that the
478 field is going to be pushed into, so the target table that the data
479 eventually need to be pushed into need to be supplied.
480
481 @param thd Thread to allocate memory from.
482 @param rli Relay log info structure, for error reporting.
483 @param target_table Target table for fields.
484 @param replica_has_gipk Does the replica table contain a GIPK
485
486 @return A pointer to a temporary table with memory allocated in the
487 thread's memroot, NULL if the table could not be created
488 */
490 TABLE *target_table,
491 bool replica_has_gipk) const;
492
493 /**
494 Evaluates if the source table might contain a GIPK
495
496 @note for servers of older versions that do not fully support GIPK, this
497 sets the info that is a guess based on available information replication
498 has.
499
500 In the case when the replica has a GIPK, the source is from an old
501 version that does not indicate if it has a GIPK or not, and the source
502 either has extra columns, or the replica has two more more extra columns
503 true is returned.
504 This function does not report an error.
505
506 @param thd The thread object associated to the application
507 @param table The table in the replica.
508
509 @return true if this table definition is found to be incompatible with the
510 table, false otherwise.
511 */
513
514 /**
515 Checks if the table contains a GIPK
516
517 @note for servers of older versions that do not fully support GIPK, this
518 method returns a guess based on available information replication has.
519
520 @return true if we believe the table to contain a GIPK, false otherwise
521 */
523
524#endif
525
526 private:
527 ulong m_size; // Number of elements in the types array
528 unsigned char *m_type; // Array of type descriptors
532 uint16 m_flags; // Table flags
534 mutable int m_json_column_count; // Number of JSON columns
538 /// Whether the serialized field metadata stream decoded within bounds.
539 bool m_is_valid{true};
540 std::vector<unsigned int> m_vector_dimensionality;
541};
542
543#ifdef MYSQL_SERVER
544/**
545 Extend the normal Table_ref with a few new fields needed by the
546 slave thread, but nowhere else.
547 */
548struct RPL_Table_ref : public Table_ref {
549 RPL_Table_ref(const char *db_name_arg, size_t db_length_arg,
550 const char *table_name_arg, size_t table_name_length_arg,
551 const char *alias_arg, enum thr_lock_type lock_type_arg)
552 : Table_ref(db_name_arg, db_length_arg, table_name_arg,
553 table_name_length_arg, alias_arg, lock_type_arg) {}
554
558};
559
561 private:
563
564 public:
567 /* queue for execution at Query-log-event time prior to the Query */
568 int add(Log_event *ev);
569 bool is_empty();
570 bool execute(Relay_log_info *rli);
571 void rewind();
572};
573
574#endif
575
576/**
577 Decode field metadata from a char buffer (serialized form) into an int
578 (packed form).
579
580 @note On little-endian platforms (e.g Intel) this function effectively
581 inverts order of bytes compared to what Field::save_field_metadata()
582 writes. E.g for MYSQL_TYPE_NEWDECIMAL save_field_metadata writes precision
583 into the first byte and decimals into the second, this function puts
584 precision into the second byte and decimals into the first. This layout
585 is expected by replication code that reads metadata in the uint form.
586 Due to this design feature show_sql_type() can't correctly print
587 immediate output of save_field_metadata(), this function have to be used
588 as translator.
589
590 @param buffer Field metadata, in the character stream form produced by
591 save_field_metadata.
592 @param metadata_size Number of bytes available in @c buffer.
593 @param binlog_type The type of the field, in the form returned by
594 Field::binlog_type and stored in Table_map_log_event.
595 @retval tuple where:
596 - the first component is true if decoding would read beyond
597 @c metadata_size, false otherwise.
598 - the second component is the length of the metadata within 'buffer',
599 i.e., how much the buffer pointer should move forward in order to skip it.
600 - the third component is pair containing:
601 - the metadata, encoded as an 'uint', in the form required by e.g.
602 show_sql_type.
603 - bool indicating whether the field is array (true) or a scalar (false)
604*/
605
606std::tuple<bool, my_off_t, std::pair<uint, bool>> read_field_metadata(
607 const uchar *buffer, uint metadata_size, enum_field_types binlog_type);
608
609// NB. number of printed bit values is limited to sizeof(buf) - 1
610#define DBUG_PRINT_BITSET(N, FRM, BS) \
611 do { \
612 char buf[256]; \
613 uint i; \
614 for (i = 0; i < std::min(uint{sizeof(buf) - 1}, (BS)->n_bits); i++) \
615 buf[i] = bitmap_is_set((BS), i) ? '1' : '0'; \
616 buf[i] = '\0'; \
617 DBUG_PRINT((N), ((FRM), buf)); \
618 } while (0)
619
620#ifdef MYSQL_SERVER
621/**
622 Sentry class for managing the need to create and dispose of a local `THD`
623 instance.
624
625 If the given `THD` object pointer passed on the constructor is `nullptr`, a
626 new instance will be initialized within the constructor and disposed of in the
627 destructor.
628
629 If the given `THD` object pointer passed on the constructor is not `nullptr`,
630 the reference is kept and nothing is disposed on the destructor.
631
632 Casting operator to `THD*` is also provided, to easy code replacemente.
633
634 Usage example:
635
636 THD_instance_guard thd{current_thd != nullptr ? current_thd :
637 this->info_thd};
638 Acl_cache_lock_guard guard{thd, Acl_cache_lock_mode::READ_MODE};
639 if (guard.lock())
640 ...
641
642 */
644 public:
645 /**
646 If the given `THD` object pointer is `nullptr`, a new instance will be
647 initialized within the constructor and disposed of in the destructor.
648
649 If the given `THD` object pointer is not `nullptr`, the reference is kept
650 and nothing is disposed on the destructor.
651
652 @param thd `THD` object reference that determines if an existence instance
653 is used or a new instance of `THD` must be created.
654 */
656 /**
657 If a new instance of `THD` was created in the constructor, it will be
658 disposed here.
659 */
660 virtual ~THD_instance_guard();
661
662 /**
663 Returns the active `THD` object pointer.
664
665 @return a not-nullptr `THD` object pointer.
666 */
667 operator THD *();
668
669 private:
670 /** The active `THD` object pointer. */
671 THD *m_target{nullptr};
672 /**
673 Tells whether or not the active `THD` object was created in this object
674 constructor.
675 */
677};
678#endif // MYSQL_SERVER
679
680/**
681 Replaces every occurrence of the string `find` by the string `replace`, within
682 the string `from` and return the resulting string.
683
684 The original string `from` remains untouched.
685
686 @param from the string to search within.
687 @param find the string to search for.
688 @param replace the string to replace every occurrence of `from`
689
690 @return a new string, holding the result of the search and replace operation.
691 */
692std::string replace_all_in_str(std::string from, std::string find,
693 std::string replace);
694
695#ifdef MYSQL_SERVER
696
697/**
698 This method shall evaluate if a command being executed goes against any of
699 the restrictions of server variable session.require_row_format.
700
701 @param thd The thread associated to the command
702 @return true if it violates any restrictions
703 false otherwise
704 */
705bool is_require_row_format_violation(const THD *thd);
706
707/**
708 Checks if the immediate_server_version supports GIPKs or not
709
710 @param thd The THD context to check the version
711
712 @return true if the source server supports GIPK, false otherwise
713 */
715
716/**
717 Returns if the replicated table contains a GIPK or not
718
719 @note for servers of older versions that do not fully support GIPK, this
720 method returns a guess based on available information replication has.
721
722 @param rli The relay log object associated to the channel
723 @param table The table to check for the GIPK
724
725 @return true if we believe the table has a GIPK, false otherwise.
726 */
728
729/**
730 @brief Returns a string representation for a given version
731
732 @param version a version represented using a integer
733
734 @return a string for the given version or "unknown"
735 if version is undefined or unknown.
736*/
738
739#endif // MYSQL_SERVER
740
741#endif /* RPL_UTILITY_H */
Definition: rpl_utility.h:560
bool is_empty()
Definition: rpl_utility.cc:1306
int add(Log_event *ev)
Definition: rpl_utility.cc:1300
~Deferred_log_events()
Definition: rpl_utility.cc:1298
bool execute(Relay_log_info *rli)
Definition: rpl_utility.cc:1308
void rewind()
Definition: rpl_utility.cc:1322
Prealloced_array< Log_event *, 32 > m_array
Definition: rpl_utility.h:562
Deferred_log_events()
Definition: rpl_utility.cc:1295
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:1182
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:1116
HASH_ROW_ENTRY * make_entry()
Allocates an empty entry to be added to the hash table.
Definition: rpl_utility.cc:1045
bool next(HASH_ROW_ENTRY **entry)
Gets the entry that stands next to the one pointed to by entry.
Definition: rpl_utility.cc:1141
bool deinit(void)
De-initializes the hash table.
Definition: rpl_utility.cc:1037
int size()
Returns the number of entries in the hash table.
Definition: rpl_utility.cc:1043
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:1190
bool init(void)
Initializes the hash table.
Definition: rpl_utility.cc:1035
bool put(TABLE *table, MY_BITMAP *cols, HASH_ROW_ENTRY *entry)
Puts data into the hash table.
Definition: rpl_utility.cc:1095
bool is_empty(void)
Checks if the hash table is empty or not.
Definition: rpl_utility.cc:1029
This is the abstract base class for binary log events.
Definition: log_event.h:539
A typesafe replacement for DYNAMIC_ARRAY.
Definition: prealloced_array.h:71
Definition: rpl_rli.h:208
Sentry class for managing the need to create and dispose of a local THD instance.
Definition: rpl_utility.h:643
bool m_is_locally_initialized
Tells whether or not the active THD object was created in this object constructor.
Definition: rpl_utility.h:676
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:1350
THD * m_target
The active THD object pointer.
Definition: rpl_utility.h:671
virtual ~THD_instance_guard()
If a new instance of THD was created in the constructor, it will be disposed here.
Definition: rpl_utility.cc:1362
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:2958
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:534
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:298
ulong m_size
Definition: rpl_utility.h:527
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:475
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:811
enum_field_types type(ulong index) const
Definition: rpl_utility.h:343
std::vector< unsignedint >::const_iterator get_vector_dimensionality_begin() const
Definition: rpl_utility.h:426
table_def()=default
No-op constructor.
bool * m_is_array
Definition: rpl_utility.h:535
uchar * m_memory
Definition: rpl_utility.h:533
int json_column_count() const
Return the number of JSON columns in this table.
Definition: rpl_utility.h:312
ulong size() const
Return the number of fields there is type data for.
Definition: rpl_utility.h:290
unsigned char * m_type
Definition: rpl_utility.h:528
uint m_field_metadata_size
Definition: rpl_utility.h:529
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:665
std::vector< unsignedint >::const_iterator get_vector_dimensionality_end() const
Definition: rpl_utility.h:431
uint * m_field_metadata
Definition: rpl_utility.h:530
enum_field_types binlog_type(ulong index) const
Definition: rpl_utility.h:307
bool m_is_gipk_on_table
Definition: rpl_utility.h:537
bool m_is_gipk_set
Definition: rpl_utility.h:536
uint16 m_flags
Definition: rpl_utility.h:532
bool is_array(uint index) const
Returns whether or not the field at index is a typed array.
Definition: rpl_utility.h:399
static uint vector_column_count(const unsigned char *types, ulong size)
Return the number of VECTOR columns.
Definition: rpl_utility.h:324
bool is_gipk_present_on_source_table() const
Checks if the table contains a GIPK.
Definition: rpl_utility.cc:806
bool m_is_valid
Whether the serialized field metadata stream decoded within bounds.
Definition: rpl_utility.h:539
~table_def()
Definition: rpl_utility.cc:1001
bool maybe_null(uint index) const
Definition: rpl_utility.h:411
bool is_valid() const
Return whether the table definition metadata was decoded successfully.
Definition: rpl_utility.h:283
uchar * m_null_bits
Definition: rpl_utility.h:531
uint field_metadata(uint index) const
Definition: rpl_utility.h:388
std::vector< unsigned int > m_vector_dimensionality
Definition: rpl_utility.h:540
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:56
@ MYSQL_TYPE_SET
Definition: field_types.h:84
@ MYSQL_TYPE_NEWDATE
Internal to MySQL.
Definition: field_types.h:71
@ MYSQL_TYPE_VECTOR
Definition: field_types.h:78
@ MYSQL_TYPE_JSON
Definition: field_types.h:81
@ MYSQL_TYPE_STRING
Definition: field_types.h:90
@ MYSQL_TYPE_ENUM
Definition: field_types.h:83
@ MYSQL_TYPE_DATE
Definition: field_types.h:67
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 int count
Definition: myisam_ftdump.cc:45
static bool replace
Definition: mysqlimport.cc:70
static PFS_engine_table_share_proxy table
Definition: pfs.cc:61
bool index(const std::string &value, const String &search_for, uint32_t *idx)
Definition: contains.h:76
Container::const_iterator find(const Container &c, Value &&value)
Definition: generic.h:40
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:1407
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:1378
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:1331
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:856
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:1412
std::string decimal_numeric_version_to_string(uint32 version)
Returns a string representation for a given version.
Definition: rpl_utility.cc:1420
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:548
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:549
table_def m_tabledef
Definition: rpl_utility.h:556
bool m_tabledef_valid
Definition: rpl_utility.h:555
TABLE * m_conv_table
Definition: rpl_utility.h:557
Definition: table.h:1456
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:1017
thr_lock_type
Definition: thr_lock.h:51