MySQL  8.0.27
Source Code Documentation
rpl_utility.h
Go to the documentation of this file.
1 /* Copyright (c) 2006, 2021, 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 
41 struct 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_LIST
49 
50 class Log_event;
51 class Relay_log_info;
52 class 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 
59 struct HASH_ROW_POS {
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  */
65  const uchar *bi_start;
66  const uchar *bi_ends;
67 };
68 
69 struct 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  Wether 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  */
141  bool put(TABLE *table, MY_BITMAP *cols, HASH_ROW_ENTRY *entry);
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  */
156  HASH_ROW_ENTRY *get(TABLE *table, MY_BITMAP *cols);
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 memeory
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 */
247 class table_def {
248  public:
249  /**
250  No-op constructor. Instances of RPL_TABLE_LIST are created by first
251  allocating memory, then placement-new-ing an RPL_TABLE_LIST 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  Returns internal binlog type code for one field,
281  without translation to real types.
282  */
283  enum_field_types binlog_type(ulong index) const {
284  return static_cast<enum_field_types>(m_type[index]);
285  }
286 
287  /// Return the number of JSON columns in this table.
288  int json_column_count() const {
289  // Cache in member field to make successive calls faster.
290  if (m_json_column_count == -1) {
291  int c = 0;
292  for (uint i = 0; i < size(); i++)
293  if (type(i) == MYSQL_TYPE_JSON) c++;
295  }
296  return m_json_column_count;
297  }
298 
299  /*
300  Return a representation of the type data for one field.
301 
302  @param index Field index to return data for
303 
304  @return Will return a representation of the type data for field
305  <code>index</code>. Currently, only the type identifier is
306  returned.
307  */
308  enum_field_types type(ulong index) const {
309  assert(index < m_size);
310  /*
311  If the source type is MYSQL_TYPE_STRING, it can in reality be
312  either MYSQL_TYPE_STRING, MYSQL_TYPE_ENUM, or MYSQL_TYPE_SET, so
313  we might need to modify the type to get the real type.
314  */
315  enum_field_types source_type = binlog_type(index);
316  uint source_metadata = m_field_metadata[index];
317  switch (source_type) {
318  case MYSQL_TYPE_STRING: {
319  int real_type = source_metadata >> 8;
320  if (real_type == MYSQL_TYPE_ENUM || real_type == MYSQL_TYPE_SET)
321  source_type = static_cast<enum_field_types>(real_type);
322  break;
323  }
324 
325  /*
326  This type has not been used since before row-based replication,
327  so we can safely assume that it really is MYSQL_TYPE_NEWDATE.
328  */
329  case MYSQL_TYPE_DATE:
330  source_type = MYSQL_TYPE_NEWDATE;
331  break;
332 
333  default:
334  /* Do nothing */
335  break;
336  }
337 
338  return source_type;
339  }
340 
341  /*
342  This function allows callers to get the extra field data from the
343  table map for a given field. If there is no metadata for that field
344  or there is no extra metadata at all, the function returns 0.
345 
346  The function returns the value for the field metadata for column at
347  position indicated by index. As mentioned, if the field was a type
348  that stores field metadata, that value is returned else zero (0) is
349  returned. This method is used in the unpack() methods of the
350  corresponding fields to properly extract the data from the binary log
351  in the event that the master's field is smaller than the slave.
352  */
353  uint field_metadata(uint index) const {
354  assert(index < m_size);
356  return m_field_metadata[index];
357  else
358  return 0;
359  }
360 
361  /**
362  Returns whether or not the field at `index` is a typed array.
363  */
364  bool is_array(uint index) const {
365  assert(index < m_size);
367  return m_is_array[index];
368  else
369  return false;
370  }
371 
372  /*
373  This function returns whether the field on the master can be null.
374  This value is derived from field->maybe_null().
375  */
376  bool maybe_null(uint index) const {
377  assert(index < m_size);
378  return ((m_null_bits[(index / 8)] & (1 << (index % 8))) ==
379  (1 << (index % 8)));
380  }
381 
382  /*
383  This function returns the field size in raw bytes based on the type
384  and the encoded field data from the master's raw data. This method can
385  be used for situations where the slave needs to skip a column (e.g.,
386  WL#3915) or needs to advance the pointer for the fields in the raw
387  data from the master to a specific column.
388  */
389  uint32 calc_field_size(uint col, const uchar *master_data) const;
390 
391 #ifdef MYSQL_SERVER
392  /**
393  Decide if the table definition is compatible with a table.
394 
395  Compare the definition with a table to see if it is compatible
396  with it.
397 
398  A table definition is compatible with a table if:
399  - The columns types of the table definition is a (not
400  necessarily proper) prefix of the column type of the table.
401 
402  - The other way around.
403 
404  - Each column on the master that also exists on the slave can be
405  converted according to the current settings of @c
406  REPLICA_TYPE_CONVERSIONS.
407 
408  @param thd Current thread
409  @param rli Pointer to relay log info
410  @param table Pointer to table to compare with.
411 
412  @param[out] conv_table_var Pointer to temporary table for holding
413  conversion table.
414 
415  @retval 1 if the table definition is not compatible with @c table
416  @retval 0 if the table definition is compatible with @c table
417  */
418  bool compatible_with(THD *thd, Relay_log_info *rli, TABLE *table,
419  TABLE **conv_table_var) const;
420 
421  /**
422  Create a virtual in-memory temporary table structure.
423 
424  The table structure has records and field array so that a row can
425  be unpacked into the record for further processing.
426 
427  In the virtual table, each field that requires conversion will
428  have a non-NULL value, while fields that do not require
429  conversion will have a NULL value.
430 
431  Some information that is missing in the events, such as the
432  character set for string types, are taken from the table that the
433  field is going to be pushed into, so the target table that the data
434  eventually need to be pushed into need to be supplied.
435 
436  @param thd Thread to allocate memory from.
437  @param rli Relay log info structure, for error reporting.
438  @param target_table Target table for fields.
439 
440  @return A pointer to a temporary table with memory allocated in the
441  thread's memroot, NULL if the table could not be created
442  */
444  TABLE *target_table) const;
445 #endif
446 
447  private:
448  ulong m_size; // Number of elements in the types array
449  unsigned char *m_type; // Array of type descriptors
453  uint16 m_flags; // Table flags
455  mutable int m_json_column_count; // Number of JSON columns
456  bool *m_is_array;
457 };
458 
459 #ifdef MYSQL_SERVER
460 /**
461  Extend the normal table list with a few new fields needed by the
462  slave thread, but nowhere else.
463  */
464 struct RPL_TABLE_LIST : public TABLE_LIST {
465  RPL_TABLE_LIST(const char *db_name_arg, size_t db_length_arg,
466  const char *table_name_arg, size_t table_name_length_arg,
467  const char *alias_arg, enum thr_lock_type lock_type_arg)
468  : TABLE_LIST(db_name_arg, db_length_arg, table_name_arg,
469  table_name_length_arg, alias_arg, lock_type_arg) {}
470 
474 };
475 
477  private:
479 
480  public:
483  /* queue for exection at Query-log-event time prior the Query */
484  int add(Log_event *ev);
485  bool is_empty();
486  bool execute(Relay_log_info *rli);
487  void rewind();
488 };
489 
490 #endif
491 
492 /**
493  Decode field metadata from a char buffer (serialized form) into an int
494  (packed form).
495 
496  @note On little-endian platforms (e.g Intel) this function effectively
497  inverts order of bytes compared to what Field::save_field_metadata()
498  writes. E.g for MYSQL_TYPE_NEWDECIMAL save_field_metadata writes precision
499  into the first byte and decimals into the second, this function puts
500  precision into the second byte and decimals into the first. This layout
501  is expected by replication code that reads metadata in the uint form.
502  Due to this design feature show_sql_type() can't correctly print
503  immediate output of save_field_metadata(), this function have to be used
504  as translator.
505 
506  @param buffer Field metadata, in the character stream form produced by
507  save_field_metadata.
508  @param binlog_type The type of the field, in the form returned by
509  Field::binlog_type and stored in Table_map_log_event.
510  @retval pair where:
511  - the first component is the length of the metadata within 'buffer',
512  i.e., how much the buffer pointer should move forward in order to skip it.
513  - the second component is pair containing:
514  - the metadata, encoded as an 'uint', in the form required by e.g.
515  show_sql_type.
516  - bool indicating whether the field is array (true) or a scalar (false)
517 */
518 
519 std::pair<my_off_t, std::pair<uint, bool>> read_field_metadata(
520  const uchar *buffer, enum_field_types binlog_type);
521 
522 // NB. number of printed bit values is limited to sizeof(buf) - 1
523 #define DBUG_PRINT_BITSET(N, FRM, BS) \
524  do { \
525  char buf[256]; \
526  uint i; \
527  for (i = 0; i < std::min(uint{sizeof(buf) - 1}, (BS)->n_bits); i++) \
528  buf[i] = bitmap_is_set((BS), i) ? '1' : '0'; \
529  buf[i] = '\0'; \
530  DBUG_PRINT((N), ((FRM), buf)); \
531  } while (0)
532 
533 #ifdef MYSQL_SERVER
534 /**
535  Sentry class for managing the need to create and dispose of a local `THD`
536  instance.
537 
538  If the given `THD` object pointer passed on the constructor is `nullptr`, a
539  new instance will be initialized within the constructor and disposed of in the
540  destructor.
541 
542  If the given `THD` object poitner passed on the constructor is not `nullptr`,
543  the reference is kept and nothing is disposed on the destructor.
544 
545  Casting operator to `THD*` is also provided, to easy code replacemente.
546 
547  Usage example:
548 
549  THD_instance_guard thd{current_thd != nullptr ? current_thd :
550  this->info_thd};
551  Acl_cache_lock_guard guard{thd, Acl_cache_lock_mode::READ_MODE};
552  if (guard.lock())
553  ...
554 
555  */
557  public:
558  /**
559  If the given `THD` object pointer is `nullptr`, a new instance will be
560  initialized within the constructor and disposed of in the destructor.
561 
562  If the given `THD` object poitner is not `nullptr`, the reference is kept
563  and nothing is disposed on the destructor.
564 
565  @param thd `THD` object reference that determines if an existence instance
566  is used or a new instance of `THD` must be created.
567  */
568  THD_instance_guard(THD *thd);
569  /**
570  If a new instance of `THD` was created in the constructor, it will be
571  disposed here.
572  */
573  virtual ~THD_instance_guard();
574 
575  /**
576  Returns the active `THD` object pointer.
577 
578  @return a not-nullptr `THD` object pointer.
579  */
580  operator THD *();
581 
582  private:
583  /** The active `THD` object pointer. */
584  THD *m_target{nullptr};
585  /**
586  Tells whether or not the active `THD` object was created in this object
587  constructor.
588  */
590 };
591 #endif // MYSQL_SERVER
592 
593 /**
594  Replaces every occurrence of the string `find` by the string `replace`, within
595  the string `from` and return the resulting string.
596 
597  The original string `from` remains untouched.
598 
599  @param from the string to search within.
600  @param find the string to search for.
601  @param replace the string to replace every occurrence of `from`
602 
603  @return a new string, holding the result of the search and replace operation.
604  */
605 std::string replace_all_in_str(std::string from, std::string find,
606  std::string replace);
607 
608 #ifdef MYSQL_SERVER
609 
610 /**
611  This method shall evaluate if a command being executed goes against any of
612  the restrictions of server variable session.require_row_format.
613 
614  @param thd The thread associated to the command
615  @return true if it violates any restrictions
616  false otherwise
617  */
619 
620 /**
621  This function shall blindly replace some deprecated terms used in the
622  field names with more recent ones. This function must be removed
623  once the related syntax (SHOW SLAVE STATUS and friends) is removed.
624 
625  @param thd the thread context.
626  @param field_list the list of fields that will have their name checked
627  and altered if needed.
628  */
630  THD *thd, mem_root_deque<Item *> &field_list);
631 
632 #endif // MYSQL_SERVER
633 
634 #endif /* RPL_UTILITY_H */
Definition: rpl_utility.h:476
bool is_empty()
Definition: rpl_utility.cc:1168
int add(Log_event *ev)
Definition: rpl_utility.cc:1162
~Deferred_log_events()
Definition: rpl_utility.cc:1160
bool execute(Relay_log_info *rli)
Definition: rpl_utility.cc:1170
void rewind()
Definition: rpl_utility.cc:1184
Prealloced_array< Log_event *, 32 > m_array
Definition: rpl_utility.h:478
Deferred_log_events()
Definition: rpl_utility.cc:1157
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:1045
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:979
HASH_ROW_ENTRY * make_entry()
Allocates an empty entry to be added to the hash table.
Definition: rpl_utility.cc:908
bool next(HASH_ROW_ENTRY **entry)
Gets the entry that stands next to the one pointed to by entry.
Definition: rpl_utility.cc:1004
bool deinit(void)
De-initializes the hash table.
Definition: rpl_utility.cc:900
int size()
Returns the number of entries in the hash table.
Definition: rpl_utility.cc:906
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:1053
bool init(void)
Initializes the hash table.
Definition: rpl_utility.cc:898
bool put(TABLE *table, MY_BITMAP *cols, HASH_ROW_ENTRY *entry)
Puts data into the hash table.
Definition: rpl_utility.cc:958
bool is_empty(void)
Checks if the hash table is empty or not.
Definition: rpl_utility.cc:892
This is the abstract base class for binary log events.
Definition: log_event.h:659
Definition: rpl_rli.h:200
Sentry class for managing the need to create and dispose of a local THD instance.
Definition: rpl_utility.h:556
bool m_is_locally_initialized
Tells whether or not the active THD object was created in this object constructor.
Definition: rpl_utility.h:589
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:1212
THD * m_target
The active THD object pointer.
Definition: rpl_utility.h:584
virtual ~THD_instance_guard()
If a new instance of THD was created in the constructor, it will be disposed here.
Definition: rpl_utility.cc:1224
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:821
std::unordered_multimap, but with my_malloc, so that you can track the memory used using PSI memory k...
Definition: map_helpers.h:188
A table definition from the master.
Definition: rpl_utility.h:247
TABLE * create_conversion_table(THD *thd, Relay_log_info *rli, TABLE *target_table) const
Create a virtual in-memory temporary table structure.
Definition: rpl_utility.cc:604
int m_json_column_count
Definition: rpl_utility.h:455
ulong m_size
Definition: rpl_utility.h:448
uint32 calc_field_size(uint col, const uchar *master_data) const
Definition: rpl_utility.cc:93
enum_field_types type(ulong index) const
Definition: rpl_utility.h:308
table_def()=default
No-op constructor.
bool * m_is_array
Definition: rpl_utility.h:456
uchar * m_memory
Definition: rpl_utility.h:454
int json_column_count() const
Return the number of JSON columns in this table.
Definition: rpl_utility.h:288
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:449
uint m_field_metadata_size
Definition: rpl_utility.h:450
uint * m_field_metadata
Definition: rpl_utility.h:451
enum_field_types binlog_type(ulong index) const
Definition: rpl_utility.h:283
uint16 m_flags
Definition: rpl_utility.h:453
bool is_array(uint index) const
Returns whether or not the field at index is a typed array.
Definition: rpl_utility.h:364
~table_def()
Definition: rpl_utility.cc:864
bool maybe_null(uint index) const
Definition: rpl_utility.h:376
bool compatible_with(THD *thd, Relay_log_info *rli, TABLE *table, TABLE **conv_table_var) const
Decide if the table definition is compatible with a table.
Definition: rpl_utility.cc:464
uchar * m_null_bits
Definition: rpl_utility.h:452
uint field_metadata(uint index) const
Definition: rpl_utility.h:353
This file contains the field type.
enum_field_types
Column types for MySQL.
Definition: field_types.h:57
@ MYSQL_TYPE_SET
Definition: field_types.h:83
@ MYSQL_TYPE_NEWDATE
Internal to MySQL.
Definition: field_types.h:71
@ 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:67
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:65
const byte * find(const Pages *pages, const page_id_t &page_id) noexcept
Find a doublewrite copy of a page.
Definition: buf0dblwr.cc:2519
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:391
PSI_memory_key key_memory_HASH_ROW_ENTRY
Definition: psi_memory_key.cc:50
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:750
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:1260
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:1193
bool evaluate_command_row_only_restrictions(THD *thd)
This method shall evaluate if a command being executed goes against any of the restrictions of server...
Definition: rpl_utility.cc:1232
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
bool is_search_state_inited
Wether this search_state is usable or not.
Definition: rpl_utility.h:100
uint hash_value
Definition: rpl_utility.h:87
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
HASH_ROW_PREAMBLE()=default
Definition: my_bitmap.h:41
Extend the normal table list with a few new fields needed by the slave thread, but nowhere else.
Definition: rpl_utility.h:464
table_def m_tabledef
Definition: rpl_utility.h:472
bool m_tabledef_valid
Definition: rpl_utility.h:471
TABLE * m_conv_table
Definition: rpl_utility.h:473
RPL_TABLE_LIST(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:465
Definition: table.h:2694
Definition: table.h:1394
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:880
thr_lock_type
Definition: thr_lock.h:50
unsigned int uint
Definition: uca-dump.cc:29