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