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