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