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