MySQL  8.0.12
Source Code Documentation
fil0fil.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved.
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24  The lines above are intentionally left blank
25 */
26 
27 /** @file include/fil0fil.h
28  The low-level file system
29 
30  Created 10/25/1995 Heikki Tuuri
31  *******************************************************/
32 
33 #ifndef fil0fil_h
34 #define fil0fil_h
35 
36 #include "univ.i"
37 
38 #include "dict0types.h"
39 #include "fil0types.h"
40 #include "log0recv.h"
41 #include "page0size.h"
42 #ifndef UNIV_HOTBACKUP
43 #include "ibuf0types.h"
44 #endif /* !UNIV_HOTBACKUP */
45 #include "ut0new.h"
46 
47 #include "sql/dd/object_id.h"
48 
49 #include <list>
50 #include <vector>
51 
52 extern const char general_space_name[];
53 extern volatile bool recv_recovery_on;
54 
55 #ifdef UNIV_HOTBACKUP
56 #include <unordered_set>
57 using Dir_set = std::unordered_set<std::string>;
58 extern Dir_set rem_gen_ts_dirs;
59 extern bool replay_in_datadir;
60 #endif /* UNIV_HOTBACKUP */
61 
62 // Forward declaration
63 struct trx_t;
64 class page_id_t;
65 
66 using Filenames = std::vector<std::string, ut_allocator<std::string>>;
67 using Space_ids = std::vector<space_id_t, ut_allocator<space_id_t>>;
68 
69 /** File types */
70 enum fil_type_t : uint8_t {
71  /** temporary tablespace (temporary undo log or tables) */
73  /** a tablespace that is being imported (no logging until finished) */
75  /** persistent tablespace (for system, undo log or tables) */
77  /** redo log covering changes to files of FIL_TYPE_TABLESPACE */
79 };
80 
81 /** Result of comparing a path. */
82 enum class Fil_state {
83  /** The path matches what was found during the scan. */
84  MATCHES,
85 
86  /** No MLOG_FILE_DELETE record and the file could not be found. */
87  MISSING,
88 
89  /** A MLOG_FILE_DELETE was found, file was deleted. */
90  DELETED,
91 
92  /** Space ID matches but the paths don't match. */
93  MOVED,
94 
95  /** Tablespace and/or filename was renamed. The DDL log will handle
96  this case. */
97  RENAMED
98 };
99 
100 /** Check if fil_type is any of FIL_TYPE_TEMPORARY, FIL_TYPE_IMPORT
101 or FIL_TYPE_TABLESPACE.
102 @param[in] type variable of type fil_type_t
103 @return true if any of FIL_TYPE_TEMPORARY, FIL_TYPE_IMPORT
104 or FIL_TYPE_TABLESPACE */
105 inline bool fil_type_is_data(fil_type_t type) {
106  return (type == FIL_TYPE_TEMPORARY || type == FIL_TYPE_IMPORT ||
107  type == FIL_TYPE_TABLESPACE);
108 }
109 
110 struct fil_space_t;
111 
112 /** File node of a tablespace or the log data space */
113 struct fil_node_t {
115 
116  /** tablespace containing this file */
118 
119  /** file name; protected by Fil_shard::m_mutex and log_sys->mutex. */
120  char *name;
121 
122  /** whether this file is open. Note: We set the is_open flag after
123  we increase the write the MLOG_FILE_OPEN record to redo log. Therefore
124  we increment the in_use reference count before setting the OPEN flag. */
125  bool is_open;
126 
127  /** file handle (valid if is_open) */
129 
130  /** event that groups and serializes calls to fsync */
132 
133  /** whether the file actually is a raw device or disk partition */
135 
136  /** size of the file in database pages (0 if not known yet);
137  the possible last incomplete megabyte may be ignored
138  if space->id == 0 */
140 
141  /** initial size of the file in database pages;
142  FIL_IBD_FILE_INITIAL_SIZE by default */
144 
145  /** maximum size of the file in database pages */
147 
148  /** count of pending i/o's; is_open must be true if nonzero */
149  size_t n_pending;
150 
151  /** count of pending flushes; is_open must be true if nonzero */
153 
154  /** e.g., when a file is being extended or just opened. */
155  size_t in_use;
156 
157  /** number of writes to the file since the system was started */
159 
160  /** the modification_counter of the latest flush to disk */
161  int64_t flush_counter;
162 
163  /** link to the fil_system->LRU list (keeping track of open files) */
165 
166  /** whether the file system of this file supports PUNCH HOLE */
168 
169  /** block size to use for punching holes */
170  size_t block_size;
171 
172  /** whether atomic write is enabled for this file */
174 
175  /** FIL_NODE_MAGIC_N */
176  size_t magic_n;
177 };
178 
179 /** Tablespace or log data space */
180 struct fil_space_t {
182  using Files = std::vector<fil_node_t, ut_allocator<fil_node_t>>;
183 
184  /** Tablespace name */
185  char *name;
186 
187  /** Tablespace ID */
189 
190  /** true if we want to rename the .ibd file of tablespace and
191  want to stop temporarily posting of new i/o requests on the file */
192  bool stop_ios;
193 
194  /** We set this true when we start deleting a single-table
195  tablespace. When this is set following new ops are not allowed:
196  * read IO request
197  * ibuf merge
198  * file flush
199  Note that we can still possibly have new write operations because we
200  don't check this flag when doing flush batches. */
202 
203 #ifdef UNIV_DEBUG
204  /** Reference count for operations who want to skip redo log in
205  the file space in order to make fsp_space_modify_check pass. */
207 #endif /* UNIV_DEBUG */
208 
209  /** Purpose */
211 
212  /** Files attached to this tablespace. Note: Only the system tablespace
213  can have multiple files, this is a legacy issue. */
215 
216  /** Tablespace file size in pages; 0 if not known yet */
218 
219  /** FSP_SIZE in the tablespace header; 0 if not known yet */
221 
222  /** Length of the FSP_FREE list */
223  uint32_t free_len;
224 
225  /** Contents of FSP_FREE_LIMIT */
227 
228  /** Tablespace flags; see fsp_flags_is_valid() and
229  page_size_t(ulint) (constructor).
230  This is protected by space->latch and tablespace MDL */
231  uint32_t flags;
232 
233  /** Number of reserved free extents for ongoing operations like
234  B-tree page split */
236 
237  /** This is positive when flushing the tablespace to disk;
238  dropping of the tablespace is forbidden if this is positive */
240 
241  /** This is positive when we have pending operations against this
242  tablespace. The pending operations can be ibuf merges or lock
243  validation code trying to read a block. Dropping of the tablespace
244  is forbidden if this is positive. Protected by Fil_shard::m_mutex. */
245  uint32_t n_pending_ops;
246 
247 #ifndef UNIV_HOTBACKUP
248  /** Latch protecting the file space storage allocation */
250 #endif /* !UNIV_HOTBACKUP */
251 
252  /** List of spaces with at least one unflushed file we have
253  written to */
255 
256  /** true if this space is currently in unflushed_spaces */
258 
259  /** Compression algorithm */
261 
262  /** Encryption algorithm */
264 
265  /** Encrypt key */
266  byte encryption_key[ENCRYPTION_KEY_LEN];
267 
268  /** Encrypt key length*/
270 
271  /** Encrypt initial vector */
272  byte encryption_iv[ENCRYPTION_KEY_LEN];
273 
274  /** Release the reserved free extents.
275  @param[in] n_reserved number of reserved extents */
276  void release_free_extents(ulint n_reserved);
277 
278  /** FIL_SPACE_MAGIC_N */
279  ulint magic_n;
280 
281  /** System tablespace */
283 
284  /** Redo log tablespace */
286 
287 #ifdef UNIV_DEBUG
288  /** Print the extent descriptor pages of this tablespace into
289  the given output stream.
290  @param[in] out the output stream.
291  @return the output stream. */
292  std::ostream &print_xdes_pages(std::ostream &out) const;
293 
294  /** Print the extent descriptor pages of this tablespace into
295  the given file.
296  @param[in] filename the output file name. */
297  void print_xdes_pages(const char *filename) const;
298 #endif /* UNIV_DEBUG */
299 };
300 
301 /** Value of fil_space_t::magic_n */
302 constexpr size_t FIL_SPACE_MAGIC_N = 89472;
303 
304 /** Value of fil_node_t::magic_n */
305 constexpr size_t FIL_NODE_MAGIC_N = 89389;
306 
307 /** Common InnoDB file extentions */
308 enum ib_file_suffix { NO_EXT = 0, IBD = 1, CFG = 2, CFP = 3 };
309 
310 extern const char *dot_ext[];
311 
312 #define DOT_IBD dot_ext[IBD]
313 #define DOT_CFG dot_ext[CFG]
314 #define DOT_CFP dot_ext[CFP]
315 
316 #ifdef _WIN32
317 /* Initialization of m_abs_path() produces warning C4351:
318 "new behavior: elements of array '...' will be default initialized."
319 See https://msdn.microsoft.com/en-us/library/1ywe7hcy.aspx */
320 #pragma warning(disable : 4351)
321 #endif /* _WIN32 */
322 
323 /** Wrapper for a path to a directory that may or may not exist. */
324 class Fil_path {
325  public:
326  /** schema '/' table separator */
327  static constexpr auto DB_SEPARATOR = '/';
328 
329  /** OS specific path separator. */
330  static constexpr auto OS_SEPARATOR = OS_PATH_SEPARATOR;
331 
332  /** Directory separators that are supported. */
333 #if defined(__SUNPRO_CC)
334  static char *SEPARATOR;
335  static char *DOT_SLASH;
336  static char *DOT_DOT_SLASH;
337 #else
338  static constexpr auto SEPARATOR = "\\/";
339 #ifdef _WIN32
340  static constexpr auto DOT_SLASH = ".\\";
341  static constexpr auto DOT_DOT_SLASH = "..\\";
342 #else
343  static constexpr auto DOT_SLASH = "./";
344  static constexpr auto DOT_DOT_SLASH = "../";
345 #endif /* _WIN32 */
346 
347 #endif /* __SUNPRO_CC */
348 
349  /** Default constructor. Defaults to MySQL_datadir_path. */
350  Fil_path();
351 
352  /** Constructor
353  @param[in] path Path, not necessarily NUL terminated
354  It's the callers responsibility to
355  ensure that the path is normalized.
356  @param[in] len Length of path */
357  Fil_path(const char *path, size_t len);
358 
359  /** Constructor
360  @param[in] path pathname (may also include the file basename)
361  It's the callers responsibility to
362  ensure that the path is normalized. */
363  explicit Fil_path(const std::string &path);
364 
365  /** Destructor */
366  ~Fil_path();
367 
368  /** Implicit type conversion
369  @return pointer to m_path.c_str() */
370  operator const char *() const { return (m_path.c_str()); }
371 
372  /** Explicit type conversion
373  @return pointer to m_path.c_str() */
374  const char *operator()() const { return (m_path.c_str()); }
375 
376  /** @return the value of m_path */
377  const std::string &path() const MY_ATTRIBUTE((warn_unused_result)) {
378  return (m_path);
379  }
380 
381  /** @return the length of m_path */
382  size_t len() const MY_ATTRIBUTE((warn_unused_result)) {
383  return (m_path.length());
384  }
385 
386  /** @return the length of m_abs_path */
387  size_t abs_len() const MY_ATTRIBUTE((warn_unused_result)) {
388  return (m_abs_path.length());
389  }
390 
391  /** Determine if this path is equal to the other path.
392  @param[in] lhs Path to compare to
393  @return true if the paths are the same */
394  bool operator==(const Fil_path &lhs) const {
395  return (m_path.compare(lhs.m_path));
396  }
397 
398  /** Check if m_path is the same as path.
399  @param[in] path directory path to compare to
400  @return true if m_path is the same as path */
401  bool is_same_as(const std::string &path) const
402  MY_ATTRIBUTE((warn_unused_result)) {
403  if (m_path.empty() || path.empty()) {
404  return (false);
405  }
406 
407  return (m_abs_path == get_real_path(path));
408  }
409 
410  /** Check if m_path is the parent of name.
411  @param[in] name Path to compare to
412  @return true if m_path is an ancestor of name */
413  bool is_ancestor(const std::string &name) const
414  MY_ATTRIBUTE((warn_unused_result)) {
415  if (m_path.empty() || name.empty()) {
416  return (false);
417  }
418 
419  return (is_ancestor(m_abs_path, name));
420  }
421 
422  /** Check if m_path is the parent of other.m_path.
423  @param[in] other Path to compare to
424  @return true if m_path is an ancestor of name */
425  bool is_ancestor(const Fil_path &other) const
426  MY_ATTRIBUTE((warn_unused_result)) {
427  if (m_path.empty() || other.m_path.empty()) {
428  return (false);
429  }
430 
431  return (is_ancestor(m_abs_path, other.m_abs_path));
432  }
433 
434  /** @return true if m_path exists and is a file. */
435  bool is_file_and_exists() const MY_ATTRIBUTE((warn_unused_result));
436 
437  /** @return true if m_path exists and is a directory. */
438  bool is_directory_and_exists() const MY_ATTRIBUTE((warn_unused_result));
439 
440  /** Return the absolute path */
441  const std::string &abs_path() const MY_ATTRIBUTE((warn_unused_result)) {
442  return (m_abs_path);
443  }
444 
445  /** @return true if the path is an absolute path. */
446  bool is_absolute_path() const MY_ATTRIBUTE((warn_unused_result)) {
447  if (m_path.empty()) {
448  return (false);
449  }
450 
451  return (is_absolute_path(m_path));
452  }
453 
454  /** This validation is only for ':'.
455  @return true if the path is valid. */
456  bool is_valid() const MY_ATTRIBUTE((warn_unused_result));
457 
458  /** Remove quotes e.g., 'a;b' or "a;b" -> a;b.
459  Assumes matching quotes.
460  @return pathspec with the quotes stripped */
461  static std::string parse(const char *pathspec) {
462  std::string path(pathspec);
463 
464  ut_ad(!path.empty());
465 
466  if (path.size() >= 2 && (path.front() == '\'' || path.back() == '"')) {
467  path.erase(0, 1);
468 
469  if (path.back() == '\'' || path.back() == '"') {
470  path.erase(path.size() - 1);
471  }
472  }
473 
474  return (path);
475  }
476 
477  /** Convert the paths into absolute paths and compare them. The
478  paths to compare must be valid paths, otherwise the result is
479  undefined.
480  @param[in] lhs Filename to compare
481  @param[in] rhs Filename to compare
482  @return true if they are the same */
483  static bool equal(const std::string &lhs, const std::string &rhs)
484  MY_ATTRIBUTE((warn_unused_result)) {
485  Fil_path path1(lhs);
486  Fil_path path2(rhs);
487 
488  return (path1.abs_path().compare(path2.abs_path()) == 0);
489  }
490 
491  /** Determine if a path is an absolute path or not.
492  @param[in] path OS directory or file path to evaluate
493  @retval true if an absolute path
494  @retval false if a relative path */
495  static bool is_absolute_path(const std::string &path)
496  MY_ATTRIBUTE((warn_unused_result)) {
497  if (path.empty()) {
498  return (false);
499 
500  } else if (path.at(0) == '\\' || path.at(0) == '/') {
501  /* Any string that starts with an OS_SEPARATOR is
502  an absolute path. This includes any OS and even
503  paths like "\\Host\share" on Windows. */
504 
505  return (true);
506  }
507 #ifdef _WIN32
508  /* Windows may have an absolute path like 'A:\' */
509  if (path.length() >= 3 && isalpha(path.at(0)) && path.at(1) == ':' &&
510  (path.at(2) == '\\' || path.at(2) == '/')) {
511  return (true);
512  }
513 #endif /* _WIN32 */
514 
515  return (false);
516  }
517 
518  /* Check if the path is prefixed with pattern.
519  @return true if prefix matches */
520  static bool has_prefix(const std::string &path, const std::string prefix)
521  MY_ATTRIBUTE((warn_unused_result)) {
522  return (path.size() >= prefix.size() &&
523  std::equal(prefix.begin(), prefix.end(), path.begin()));
524  }
525 
526  /** Normalizes a directory path for the current OS:
527  On Windows, we convert '/' to '\', else we convert '\' to '/'.
528  @param[in,out] path Directory and file path */
529  static void normalize(std::string &path) {
530  for (auto &c : path) {
531  if (c == OS_PATH_SEPARATOR_ALT) {
532  c = OS_SEPARATOR;
533  }
534  }
535  }
536 
537  /** Normalizes a directory path for the current OS:
538  On Windows, we convert '/' to '\', else we convert '\' to '/'.
539  @param[in,out] path A NUL terminated path */
540  static void normalize(char *path) {
541  for (auto ptr = path; *ptr; ++ptr) {
542  if (*ptr == OS_PATH_SEPARATOR_ALT) {
543  *ptr = OS_SEPARATOR;
544  }
545  }
546  }
547 
548  /** @return true if the path exists and is a file . */
549  static os_file_type_t get_file_type(const std::string &path)
550  MY_ATTRIBUTE((warn_unused_result));
551 
552  /** Get the real path for a directory or a file name, useful for
553  comparing symlinked files.
554  @param[in] path Directory or filename
555  @return the absolute path of dir + filename, or "" on error. */
556  static std::string get_real_path(const std::string &path)
557  MY_ATTRIBUTE((warn_unused_result));
558 
559  /** Check if lhs is the ancestor of rhs. If the two paths are the
560  same it will return false.
561  @param[in] lhs Parent path to check
562  @param[in] rhs Descendent path to check
563  @return true if lhs is an ancestor of rhs */
564  static bool is_ancestor(const std::string &lhs, const std::string &rhs)
565  MY_ATTRIBUTE((warn_unused_result)) {
566  if (lhs.empty() || rhs.empty() || rhs.length() <= lhs.length()) {
567  return (false);
568  }
569 
570  return (std::equal(lhs.begin(), lhs.end(), rhs.begin()));
571  }
572 
573  /** Check if the name is an undo tablespace name.
574  @param[in] name Tablespace name
575  @return true if it is an undo tablespace name */
576  static bool is_undo_tablespace_name(const std::string &name)
577  MY_ATTRIBUTE((warn_unused_result));
578 
579  /** Check if the file has the .ibd suffix
580  @param[in] path Filename to check
581  @return true if it has the the ".ibd" suffix. */
582  static bool has_ibd_suffix(const std::string &path) {
583  static const char suffix[] = ".ibd";
584  static constexpr auto len = sizeof(suffix) - 1;
585 
586  return (path.size() >= len &&
587  path.compare(path.size() - len, len, suffix) == 0);
588  }
589 
590  /** Check if a character is a path separator ('\' or '/')
591  @param[in] c Character to check
592  @return true if it is a separator */
593  static bool is_separator(char c) { return (c == '\\' || c == '/'); }
594 
595  /** Allocate and build a file name from a path, a table or
596  tablespace name and a suffix.
597  @param[in] path_in nullptr or the direcory path or
598  the full path and filename
599  @param[in] name_in nullptr if path is full, or
600  Table/Tablespace name
601  @param[in] ext the file extension to use
602  @param[in] trim whether last name on the path should
603  be trimmed
604  @return own: file name; must be freed by ut_free() */
605  static char *make(const std::string &path_in, const std::string &name_in,
606  ib_file_suffix ext, bool trim = false)
607  MY_ATTRIBUTE((warn_unused_result));
608 
609  /** Allocate and build a CFG file name from a path.
610  @param[in] path_in Full path to the filename
611  @return own: file name; must be freed by ut_free() */
612  static char *make_cfg(const std::string &path_in)
613  MY_ATTRIBUTE((warn_unused_result)) {
614  return (make(path_in, "", CFG));
615  }
616 
617  /** Allocate and build a CFP file name from a path.
618  @param[in] path_in Full path to the filename
619  @return own: file name; must be freed by ut_free() */
620  static char *make_cfp(const std::string &path_in)
621  MY_ATTRIBUTE((warn_unused_result)) {
622  return (make(path_in, "", CFP));
623  }
624 
625  /** Allocate and build a file name from a path, a table or
626  tablespace name and a suffix.
627  @param[in] path_in nullptr or the direcory path or
628  the full path and filename
629  @param[in] name_in nullptr if path is full, or
630  Table/Tablespace name
631  @return own: file name; must be freed by ut_free() */
632  static char *make_ibd(const std::string &path_in, const std::string &name_in)
633  MY_ATTRIBUTE((warn_unused_result)) {
634  return (make(path_in, name_in, IBD));
635  }
636 
637  /** Allocate and build a file name from a path, a table or
638  tablespace name and a suffix.
639  @param[in] name_in Table/Tablespace name
640  @return own: file name; must be freed by ut_free() */
641  static char *make_ibd_from_table_name(const std::string &name_in)
642  MY_ATTRIBUTE((warn_unused_result)) {
643  return (make("", name_in, IBD));
644  }
645 
646  /** Create an IBD path name after replacing the basename in an old path
647  with a new basename. The old_path is a full path name including the
648  extension. The tablename is in the normal form "schema/tablename".
649  @param[in] path_in Pathname
650  @param[in] name_in Contains new base name
651  @return new full pathname */
652  static std::string make_new_ibd(const std::string &path_in,
653  const std::string &name_in)
654  MY_ATTRIBUTE((warn_unused_result));
655 
656  /** This function reduces a null-terminated full remote path name
657  into the path that is sent by MySQL for DATA DIRECTORY clause.
658  It replaces the 'databasename/tablename.ibd' found at the end of the
659  path with just 'tablename'.
660 
661  Since the result is always smaller than the path sent in, no new
662  memory is allocated. The caller should allocate memory for the path
663  sent in. This function manipulates that path in place. If the path
664  format is not as expected, set data_dir_path to "" and return.
665 
666  The result is used to inform a SHOW CREATE TABLE command.
667  @param[in,out] data_dir_path Full path/data_dir_path */
668  static void make_data_dir_path(char *data_dir_path);
669 
670  /** @return the null path */
671  static const Fil_path &null() MY_ATTRIBUTE((warn_unused_result)) {
672  return (s_null_path);
673  }
674 
675 #ifndef UNIV_HOTBACKUP
676  /** Check if the filepath provided is in a valid placement.
677  1) File-per-table must be in a dir named for the schema.
678  2) File-per-table must not be in the datadir.
679  3) General tablespace must no be under the datadir.
680  @param[in] space_name tablespace name
681  @param[in] path filepath to validate
682  @retval true if the filepath is a valid datafile location */
683  static bool is_valid_location(const char *space_name,
684  const std::string &path);
685 
686  /** Convert filename to the file system charset format.
687  @param[in,out] name Filename to convert */
688  static void convert_to_filename_charset(std::string &name);
689 #endif /* !UNIV_HOTBACKUP */
690 
691  protected:
692  /** Path to a file or directory. */
693  std::string m_path;
694 
695  /** A full absolute path to the same file. */
696  std::string m_abs_path;
697 
698  /** Empty (null) path. */
700 };
701 
702 /** The MySQL server --datadir value */
704 
705 /** Initial size of a single-table tablespace in pages */
706 constexpr size_t FIL_IBD_FILE_INITIAL_SIZE = 7;
707 
708 /** An empty tablespace (CREATE TABLESPACE) has minimum
709 of 4 pages and an empty CREATE TABLE (file_per_table) has 6 pages.
710 Minimum of these two is 4 */
711 constexpr size_t FIL_IBD_FILE_INITIAL_SIZE_5_7 = 4;
712 
713 /** 'null' (undefined) page offset in the context of file spaces */
714 constexpr page_no_t FIL_NULL = std::numeric_limits<page_no_t>::max();
715 
716 /** Maximum Page Number, one less than FIL_NULL */
717 constexpr page_no_t PAGE_NO_MAX = std::numeric_limits<page_no_t>::max() - 1;
718 
719 /** Unknown space id */
720 constexpr space_id_t SPACE_UNKNOWN = std::numeric_limits<space_id_t>::max();
721 
722 /* Space address data type; this is intended to be used when
723 addresses accurate to a byte are stored in file pages. If the page part
724 of the address is FIL_NULL, the address is considered undefined. */
725 
726 /** 'type' definition in C: an address stored in a file page is a
727 string of bytes */
729 
730 /** File space address */
731 struct fil_addr_t {
732  /* Default constructor */
733  fil_addr_t() : page(FIL_NULL), boffset(0) {}
734 
735  /** Constructor
736  @param[in] p Logical page number
737  @param[in] boff Offset within the page */
738  fil_addr_t(page_no_t p, uint32_t boff) : page(p), boffset(boff) {}
739 
740  /** Compare to instances
741  @param[in] rhs Instance to compare with
742  @return true if the page number and page offset are equal */
743  bool is_equal(const fil_addr_t &rhs) const {
744  return (page == rhs.page && boffset == rhs.boffset);
745  }
746 
747  /** Check if the file address is null.
748  @return true if null */
749  bool is_null() const { return (page == FIL_NULL && boffset == 0); }
750 
751  /** Print a string representation.
752  @param[in,out] out Stream to write to */
753  std::ostream &print(std::ostream &out) const {
754  out << "[fil_addr_t: page=" << page << ", boffset=" << boffset << "]";
755 
756  return (out);
757  }
758 
759  /** Page number within a space */
761 
762  /** Byte offset within the page */
763  uint32_t boffset;
764 };
765 
766 /* For printing fil_addr_t to a stream.
767 @param[in,out] out Stream to write to
768 @param[in] obj fil_addr_t instance to write */
769 inline std::ostream &operator<<(std::ostream &out, const fil_addr_t &obj) {
770  return (obj.print(out));
771 }
772 
773 /** The null file address */
775 
776 using page_type_t = uint16_t;
777 
778 /** File page types (values of FIL_PAGE_TYPE) @{ */
779 /** B-tree node */
780 constexpr page_type_t FIL_PAGE_INDEX = 17855;
781 
782 /** R-tree node */
783 constexpr page_type_t FIL_PAGE_RTREE = 17854;
784 
785 /** Tablespace SDI Index page */
786 constexpr page_type_t FIL_PAGE_SDI = 17853;
787 
788 /** Undo log page */
790 
791 /** Index node */
793 
794 /** Insert buffer free list */
796 
797 /* File page types introduced in MySQL/InnoDB 5.1.7 */
798 /** Freshly allocated page */
800 
801 /** Insert buffer bitmap */
803 
804 /** System page */
806 
807 /** Transaction system data */
809 
810 /** File space header */
812 
813 /** Extent descriptor page */
815 
816 /** Uncompressed BLOB page */
818 
819 /** First compressed BLOB page */
821 
822 /** Subsequent compressed BLOB page */
824 
825 /** In old tablespaces, garbage in FIL_PAGE_TYPE is replaced with
826 this value when flushing pages. */
828 
829 /** Compressed page */
831 
832 /** Encrypted page */
834 
835 /** Compressed and Encrypted page */
837 
838 /** Encrypted R-tree page */
840 
841 /** Uncompressed SDI BLOB page */
843 
844 /** Commpressed SDI BLOB page */
846 
847 /** Available for future use */
849 
850 /** Rollback Segment Array page */
852 
853 /** Index pages of uncompressed LOB */
855 
856 /** Data pages of uncompressed LOB */
858 
859 /** The first page of an uncompressed LOB */
861 
862 /** The first page of a compressed LOB */
864 
865 /** Data pages of compressed LOB */
867 
868 /** Index pages of compressed LOB. This page contains an array of
869 z_index_entry_t objects.*/
871 
872 /** Fragment pages of compressed LOB. */
874 
875 /** Index pages of fragment pages (compressed LOB). */
877 
878 /** Used by i_s.cc to index into the text description. */
880 
881 /** Check whether the page type is index (Btree or Rtree or SDI) type */
882 #define fil_page_type_is_index(page_type) \
883  (page_type == FIL_PAGE_INDEX || page_type == FIL_PAGE_SDI || \
884  page_type == FIL_PAGE_RTREE)
885 
886 /** Check whether the page is index page (either regular Btree index or Rtree
887 index */
888 #define fil_page_index_page_check(page) \
889  fil_page_type_is_index(fil_page_get_type(page))
890 
891 /** The number of fsyncs done to the log */
892 extern ulint fil_n_log_flushes;
893 
894 /** Number of pending redo log flushes */
895 extern ulint fil_n_pending_log_flushes;
896 /** Number of pending tablespace flushes */
898 
899 /** Number of files currently open */
900 extern ulint fil_n_file_opened;
901 
902 /** Look up a tablespace.
903 The caller should hold an InnoDB table lock or a MDL that prevents
904 the tablespace from being dropped during the operation,
905 or the caller should be in single-threaded crash recovery mode
906 (no user connections that could drop tablespaces).
907 If this is not the case, fil_space_acquire() and fil_space_release()
908 should be used instead.
909 @param[in] space_id Tablespace ID
910 @return tablespace, or nullptr if not found */
912  MY_ATTRIBUTE((warn_unused_result));
913 
914 #ifndef UNIV_HOTBACKUP
915 /** Returns the latch of a file space.
916 @param[in] space_id Tablespace ID
917 @return latch protecting storage allocation */
919  MY_ATTRIBUTE((warn_unused_result));
920 
921 #ifdef UNIV_DEBUG
922 /** Gets the type of a file space.
923 @param[in] space_id Tablespace ID
924 @return file type */
926  MY_ATTRIBUTE((warn_unused_result));
927 #endif /* UNIV_DEBUG */
928 
929 /** Note that a tablespace has been imported.
930 It is initially marked as FIL_TYPE_IMPORT so that no logging is
931 done during the import process when the space ID is stamped to each page.
932 Now we change it to FIL_SPACE_TABLESPACE to start redo and undo logging.
933 NOTE: temporary tablespaces are never imported.
934 @param[in] space_id Tablespace ID */
935 void fil_space_set_imported(space_id_t space_id);
936 #endif /* !UNIV_HOTBACKUP */
937 
938 /** Append a file to the chain of files of a space.
939 @param[in] name file name of a file that is not open
940 @param[in] size file size in entire database blocks
941 @param[in,out] space tablespace from fil_space_create()
942 @param[in] is_raw whether this is a raw device or partition
943 @param[in] atomic_write true if atomic write enabled
944 @param[in] max_pages maximum number of pages in file
945 @return pointer to the file name
946 @retval nullptr if error */
947 char *fil_node_create(const char *name, page_no_t size, fil_space_t *space,
948  bool is_raw, bool atomic_write,
949  page_no_t max_pages = PAGE_NO_MAX)
950  MY_ATTRIBUTE((warn_unused_result));
951 
952 /** Create a space memory object and put it to the fil_system hash table.
953 The tablespace name is independent from the tablespace file-name.
954 Error messages are issued to the server log.
955 @param[in] name Tablespace name
956 @param[in] space_id Tablespace ID
957 @param[in] flags tablespace flags
958 @param[in] purpose tablespace purpose
959 @return pointer to created tablespace, to be filled in with fil_node_create()
960 @retval nullptr on failure (such as when the same tablespace exists) */
961 fil_space_t *fil_space_create(const char *name, space_id_t space_id,
962  ulint flags, fil_type_t purpose)
963  MY_ATTRIBUTE((warn_unused_result));
964 
965 /** Assigns a new space id for a new single-table tablespace.
966 This works simply by incrementing the global counter. If 4 billion id's
967 is not enough, we may need to recycle id's.
968 @param[in,out] space_id New space ID
969 @return true if assigned, false if not */
970 bool fil_assign_new_space_id(space_id_t *space_id)
971  MY_ATTRIBUTE((warn_unused_result));
972 
973 /** Returns the path from the first fil_node_t found with this space ID.
974 The caller is responsible for freeing the memory allocated here for the
975 value returned.
976 @param[in] space_id Tablespace ID
977 @return own: A copy of fil_node_t::path, nullptr if space ID is zero
978  or not found. */
979 char *fil_space_get_first_path(space_id_t space_id)
980  MY_ATTRIBUTE((warn_unused_result));
981 
982 /** Returns the size of the space in pages. The tablespace must be cached
983 in the memory cache.
984 @param[in] space_id Tablespace ID
985 @return space size, 0 if space not found */
987  MY_ATTRIBUTE((warn_unused_result));
988 
989 /** Returns the flags of the space. The tablespace must be cached
990 in the memory cache.
991 @param[in] space_id Tablespace ID for which to get the flags
992 @return flags, ULINT_UNDEFINED if space not found */
993 ulint fil_space_get_flags(space_id_t space_id)
994  MY_ATTRIBUTE((warn_unused_result));
995 
996 /** Sets the flags of the tablespace. The tablespace must be locked
997 in MDL_EXCLUSIVE MODE.
998 @param[in] space tablespace in-memory struct
999 @param[in] flags tablespace flags */
1000 void fil_space_set_flags(fil_space_t *space, ulint flags);
1001 
1002 /** Open each file of a tablespace if not already open.
1003 @param[in] space_id Tablespace ID
1004 @retval true if all file nodes were opened
1005 @retval false on failure */
1006 bool fil_space_open(space_id_t space_id) MY_ATTRIBUTE((warn_unused_result));
1007 
1008 /** Close each file of a tablespace if open.
1009 @param[in] space_id Tablespace ID */
1010 void fil_space_close(space_id_t space_id);
1011 
1012 /** Returns the page size of the space and whether it is compressed or not.
1013 The tablespace must be cached in the memory cache.
1014 @param[in] space_id Tablespace ID
1015 @param[out] found true if tablespace was found
1016 @return page size */
1017 const page_size_t fil_space_get_page_size(space_id_t space_id, bool *found)
1018  MY_ATTRIBUTE((warn_unused_result));
1019 
1020 /** Initializes the tablespace memory cache.
1021 @param[in] max_n_open Max number of open files. */
1022 void fil_init(ulint max_n_open);
1023 
1024 /** Initializes the tablespace memory cache. */
1025 void fil_close();
1026 
1027 /** Opens all log files and system tablespace data files.
1028 They stay open until the database server shutdown. This should be called
1029 at a server startup after the space objects for the log and the system
1030 tablespace have been created. The purpose of this operation is to make
1031 sure we never run out of file descriptors if we need to read from the
1032 insert buffer or to write to the log. */
1034 
1035 /** Closes all open files. There must not be any pending i/o's or not flushed
1036 modifications in the files. */
1037 void fil_close_all_files();
1038 
1039 /** Closes the redo log files. There must not be any pending i/o's or not
1040 flushed modifications in the files.
1041 @param[in] free_all Whether to free the instances. */
1042 void fil_close_log_files(bool free_all);
1043 
1044 /** Iterate over the files in all the tablespaces. */
1046  public:
1047  using Function = std::function<dberr_t(fil_node_t *)>;
1048 
1049  /** For each data file, exclude redo log files.
1050  @param[in] include_log include files, if true
1051  @param[in] f Callback */
1052  template <typename F>
1053  static dberr_t for_each_file(bool include_log, F &&f) {
1054  return (iterate(include_log, [=](fil_node_t *file) { return (f(file)); }));
1055  }
1056 
1057  /** Iterate over the spaces and file lists.
1058  @param[in] include_log if true then fetch log files too
1059  @param[in,out] f Callback */
1060  static dberr_t iterate(bool include_log, Function &&f);
1061 };
1062 
1063 /** Sets the max tablespace id counter if the given number is bigger than the
1064 previous value.
1065 @param[in] max_id Maximum known tablespace ID */
1067 
1068 #ifndef UNIV_HOTBACKUP
1069 /** Write the flushed LSN to the page header of the first page in the
1070 system tablespace.
1071 @param[in] lsn Flushed LSN
1072 @return DB_SUCCESS or error number */
1073 dberr_t fil_write_flushed_lsn(lsn_t lsn) MY_ATTRIBUTE((warn_unused_result));
1074 
1075 #else /* !UNIV_HOTBACKUP */
1076 /** Extends all tablespaces to the size stored in the space header. During the
1077 mysqlbackup --apply-log phase we extended the spaces on-demand so that log
1078 records could be applied, but that may have left spaces still too small
1079 compared to the size stored in the space header. */
1080 void meb_extend_tablespaces_to_stored_len();
1081 
1082 /** Process a file name passed as an input
1083 @param[in] name absolute path of tablespace file
1084 @param[in] space_id the tablespace ID */
1085 void meb_fil_name_process(const char *name, space_id_t space_id);
1086 
1087 #endif /* !UNIV_HOTBACKUP */
1088 
1089 /** Acquire a tablespace when it could be dropped concurrently.
1090 Used by background threads that do not necessarily hold proper locks
1091 for concurrency control.
1092 @param[in] space_id Tablespace ID
1093 @return the tablespace, or nullptr if missing or being deleted */
1095  MY_ATTRIBUTE((warn_unused_result));
1096 
1097 /** Acquire a tablespace that may not exist.
1098 Used by background threads that do not necessarily hold proper locks
1099 for concurrency control.
1100 @param[in] space_id Tablespace ID
1101 @return the tablespace, or nullptr if missing or being deleted */
1103  MY_ATTRIBUTE((warn_unused_result));
1104 
1105 /** Release a tablespace acquired with fil_space_acquire().
1106 @param[in,out] space Tablespace to release */
1107 void fil_space_release(fil_space_t *space);
1108 
1109 /** Fetch the file name opened for a space_id during recovery
1110 from the file map.
1111 @param[in] space_id Undo tablespace ID
1112 @return file name that was opened, empty string if space ID not found. */
1113 std::string fil_system_open_fetch(space_id_t space_id)
1114  MY_ATTRIBUTE((warn_unused_result));
1115 
1116 /** Truncate the tablespace to needed size.
1117 @param[in] space_id Id of tablespace to truncate
1118 @param[in] size_in_pages Truncate size.
1119 @return true if truncate was successful. */
1120 bool fil_truncate_tablespace(space_id_t space_id, page_no_t size_in_pages)
1121  MY_ATTRIBUTE((warn_unused_result));
1122 
1123 /** Closes a single-table tablespace. The tablespace must be cached in the
1124 memory cache. Free all pages used by the tablespace.
1125 @param[in,out] trx Transaction covering the close
1126 @param[in] space_id Tablespace ID
1127 @return DB_SUCCESS or error */
1129  MY_ATTRIBUTE((warn_unused_result));
1130 
1131 /** Discards a single-table tablespace. The tablespace must be cached in the
1132 memory cache. Discarding is like deleting a tablespace, but
1133 
1134  1. We do not drop the table from the data dictionary;
1135 
1136  2. We remove all insert buffer entries for the tablespace immediately;
1137  in DROP TABLE they are only removed gradually in the background;
1138 
1139  3. When the user does IMPORT TABLESPACE, the tablespace will have the
1140  same id as it originally had.
1141 
1142  4. Free all the pages in use by the tablespace if rename=true.
1143 @param[in] space_id Tablespace ID
1144 @return DB_SUCCESS or error */
1146  MY_ATTRIBUTE((warn_unused_result));
1147 
1148 /** Test if a tablespace file can be renamed to a new filepath by checking
1149 if that the old filepath exists and the new filepath does not exist.
1150 @param[in] space_id Tablespace ID
1151 @param[in] old_path Old filepath
1152 @param[in] new_path New filepath
1153 @param[in] is_discarded Whether the tablespace is discarded
1154 @return innodb error code */
1155 dberr_t fil_rename_tablespace_check(space_id_t space_id, const char *old_path,
1156  const char *new_path, bool is_discarded)
1157  MY_ATTRIBUTE((warn_unused_result));
1158 
1159 /** Rename a single-table tablespace.
1160 The tablespace must exist in the memory cache.
1161 @param[in] space_id Tablespace ID
1162 @param[in] old_path Old file name
1163 @param[in] new_name New tablespace name in the schema/name format
1164 @param[in] new_path_in New file name, or nullptr if it is located in
1165  The normal data directory
1166 @return true if success */
1167 bool fil_rename_tablespace(space_id_t space_id, const char *old_path,
1168  const char *new_name, const char *new_path_in)
1169  MY_ATTRIBUTE((warn_unused_result));
1170 
1171 /** Create a tablespace file.
1172 @param[in] space_id Tablespace ID
1173 @param[in] name Tablespace name in dbname/tablename format.
1174  For general tablespaces, the 'dbname/' part
1175  may be missing.
1176 @param[in] path Path and filename of the datafile to create.
1177 @param[in] flags Tablespace flags
1178 @param[in] size Initial size of the tablespace file in pages,
1179  must be >= FIL_IBD_FILE_INITIAL_SIZE
1180 @return DB_SUCCESS or error code */
1181 dberr_t fil_ibd_create(space_id_t space_id, const char *name, const char *path,
1182  ulint flags, page_no_t size)
1183  MY_ATTRIBUTE((warn_unused_result));
1184 
1185 /** Deletes an IBD tablespace, either general or single-table.
1186 The tablespace must be cached in the memory cache. This will delete the
1187 datafile, fil_space_t & fil_node_t entries from the file_system_t cache.
1188 @param[in] space_id Tablespace ID
1189 @param[in] buf_remove Specify the action to take on the pages
1190 for this table in the buffer pool.
1191 @return DB_SUCCESS, DB_TABLESPCE_NOT_FOUND or DB_IO_ERROR */
1193  MY_ATTRIBUTE((warn_unused_result));
1194 
1195 /** Open a single-table tablespace and optionally check the space id is
1196 right in it. If not successful, print an error message to the error log. This
1197 function is used to open a tablespace when we start up mysqld, and also in
1198 IMPORT TABLESPACE.
1199 NOTE that we assume this operation is used either at the database startup
1200 or under the protection of the dictionary mutex, so that two users cannot
1201 race here.
1202 
1203 The fil_node_t::handle will not be left open.
1204 
1205 @param[in] validate whether we should validate the tablespace
1206  (read the first page of the file and
1207  check that the space id in it matches id)
1208 @param[in] purpose FIL_TYPE_TABLESPACE or FIL_TYPE_TEMPORARY
1209 @param[in] space_id Tablespace ID
1210 @param[in] flags tablespace flags
1211 @param[in] space_name tablespace name of the datafile
1212  If file-per-table, it is the table name in the
1213  databasename/tablename format
1214 @param[in] table_name table name in case need to build filename
1215 from it
1216 @param[in] path_in expected filepath, usually read from dictionary
1217 @param[in] strict whether to report error when open ibd failed
1218 @param[in] old_space whether it is a 5.7 tablespace opening
1219  by upgrade
1220 @return DB_SUCCESS or error code */
1221 dberr_t fil_ibd_open(bool validate, fil_type_t purpose, space_id_t space_id,
1222  ulint flags, const char *space_name,
1223  const char *table_name, const char *path_in, bool strict,
1224  bool old_space) MY_ATTRIBUTE((warn_unused_result));
1225 
1226 /** Returns true if a matching tablespace exists in the InnoDB tablespace
1227 memory cache.
1228 @param[in] space_id Tablespace ID
1229 @param[in] name Tablespace name used in
1230  fil_space_create().
1231 @param[in] print_err detailed error information to the
1232  error log if a matching tablespace is
1233  not found from memory.
1234 @param[in] adjust_space Whether to adjust spaceid on mismatch
1235 @param[in] heap Heap memory
1236 @param[in] table_id table id
1237 @return true if a matching tablespace exists in the memory cache */
1238 bool fil_space_exists_in_mem(space_id_t space_id, const char *name,
1239  bool print_err, bool adjust_space,
1240  mem_heap_t *heap, table_id_t table_id)
1241  MY_ATTRIBUTE((warn_unused_result));
1242 
1243 /** Extends all tablespaces to the size stored in the space header. During the
1244 mysqlbackup --apply-log phase we extended the spaces on-demand so that log
1245 records could be appllied, but that may have left spaces still too small
1246 compared to the size stored in the space header. */
1248 
1249 /** Try to extend a tablespace if it is smaller than the specified size.
1250 @param[in,out] space Tablespace ID
1251 @param[in] size desired size in pages
1252 @return whether the tablespace is at least as big as requested */
1253 bool fil_space_extend(fil_space_t *space, page_no_t size)
1254  MY_ATTRIBUTE((warn_unused_result));
1255 
1256 /** Tries to reserve free extents in a file space.
1257 @param[in] space_id Tablespace ID
1258 @param[in] n_free_now Number of free extents now
1259 @param[in] n_to_reserve How many one wants to reserve
1260 @return true if succeed */
1261 bool fil_space_reserve_free_extents(space_id_t space_id, ulint n_free_now,
1262  ulint n_to_reserve)
1263  MY_ATTRIBUTE((warn_unused_result));
1264 
1265 /** Releases free extents in a file space.
1266 @param[in] space_id Tablespace ID
1267 @param[in] n_reserved How many were reserved */
1268 void fil_space_release_free_extents(space_id_t space_id, ulint n_reserved);
1269 
1270 /** Gets the number of reserved extents. If the database is silent, this
1271 number should be zero.
1272 @param[in] space_id Tablespace ID
1273 @return the number of reserved extents */
1275  MY_ATTRIBUTE((warn_unused_result));
1276 
1277 /** Read or write redo log data (synchronous buffered IO).
1278 @param[in] type IO context
1279 @param[in] page_id where to read or write
1280 @param[in] page_size page size
1281 @param[in] byte_offset remainder of offset in bytes
1282 @param[in] len this must not cross a file boundary;
1283 @param[in,out] buf buffer where to store read data or from where
1284  to write
1285 @retval DB_SUCCESS if all OK */
1286 dberr_t fil_redo_io(const IORequest &type, const page_id_t &page_id,
1287  const page_size_t &page_size, ulint byte_offset, ulint len,
1288  void *buf) MY_ATTRIBUTE((warn_unused_result));
1289 
1290 /** Read or write data.
1291 @param[in] type IO context
1292 @param[in] sync If true then do synchronous IO
1293 @param[in] page_id page id
1294 @param[in] page_size page size
1295 @param[in] byte_offset remainder of offset in bytes; in aio this
1296  must be divisible by the OS block size
1297 @param[in] len how many bytes to read or write; this must
1298  not cross a file boundary; in aio this must
1299  be a block size multiple
1300 @param[in,out] buf buffer where to store read data or from where
1301  to write; in aio this must be appropriately
1302  aligned
1303 @param[in] message message for aio handler if !sync, else ignored
1304 @return error code
1305 @retval DB_SUCCESS on success
1306 @retval DB_TABLESPACE_DELETED if the tablespace does not exist */
1307 dberr_t fil_io(const IORequest &type, bool sync, const page_id_t &page_id,
1308  const page_size_t &page_size, ulint byte_offset, ulint len,
1309  void *buf, void *message) MY_ATTRIBUTE((warn_unused_result));
1310 
1311 /** Waits for an aio operation to complete. This function is used to write the
1312 handler for completed requests. The aio array of pending requests is divided
1313 into segments (see os0file.cc for more info). The thread specifies which
1314 segment it wants to wait for.
1315 @param[in] segment The number of the segment in the AIO array
1316  to wait for */
1317 void fil_aio_wait(ulint segment);
1318 
1319 /** Flushes to disk possible writes cached by the OS. If the space does
1320 not exist or is being dropped, does not do anything.
1321 @param[in] space_id Tablespace ID (this can be a group of log files
1322  or a tablespace of the database) */
1323 void fil_flush(space_id_t space_id);
1324 
1325 /** Flush to disk the writes in file spaces of the given type
1326 possibly cached by the OS. */
1327 void fil_flush_file_redo();
1328 
1329 /** Flush to disk the writes in file spaces of the given type
1330 possibly cached by the OS.
1331 @param[in] purpose FIL_TYPE_TABLESPACE or FIL_TYPE_LOG, can
1332  be ORred. */
1333 void fil_flush_file_spaces(uint8_t purpose);
1334 
1335 #ifdef UNIV_DEBUG
1336 /** Checks the consistency of the tablespace cache.
1337 @return true if ok */
1338 bool fil_validate();
1339 #endif /* UNIV_DEBUG */
1340 
1341 /** Returns true if file address is undefined.
1342 @param[in] addr File address to check
1343 @return true if undefined */
1344 bool fil_addr_is_null(const fil_addr_t &addr)
1345  MY_ATTRIBUTE((warn_unused_result));
1346 
1347 /** Get the predecessor of a file page.
1348 @param[in] page File page
1349 @return FIL_PAGE_PREV */
1351  MY_ATTRIBUTE((warn_unused_result));
1352 
1353 /** Get the successor of a file page.
1354 @param[in] page File page
1355 @return FIL_PAGE_NEXT */
1356 page_no_t fil_page_get_next(const byte *page)
1357  MY_ATTRIBUTE((warn_unused_result));
1358 
1359 /** Sets the file page type.
1360 @param[in,out] page File page
1361 @param[in] type File page type to set */
1362 void fil_page_set_type(byte *page, ulint type);
1363 
1364 /** Reset the page type.
1365 Data files created before MySQL 5.1 may contain garbage in FIL_PAGE_TYPE.
1366 In MySQL 3.23.53, only undo log pages and index pages were tagged.
1367 Any other pages were written with uninitialized bytes in FIL_PAGE_TYPE.
1368 @param[in] page_id page number
1369 @param[in,out] page page with invalid FIL_PAGE_TYPE
1370 @param[in] type expected page type
1371 @param[in,out] mtr mini-transaction */
1372 void fil_page_reset_type(const page_id_t &page_id, byte *page, ulint type,
1373  mtr_t *mtr);
1374 
1375 /** Get the file page type.
1376 @param[in] page File page
1377 @return page type */
1378 inline page_type_t fil_page_get_type(const byte *page) {
1379  return (static_cast<page_type_t>(mach_read_from_2(page + FIL_PAGE_TYPE)));
1380 }
1381 /** Check (and if needed, reset) the page type.
1382 Data files created before MySQL 5.1 may contain
1383 garbage in the FIL_PAGE_TYPE field.
1384 In MySQL 3.23.53, only undo log pages and index pages were tagged.
1385 Any other pages were written with uninitialized bytes in FIL_PAGE_TYPE.
1386 @param[in] page_id page number
1387 @param[in,out] page page with possibly invalid FIL_PAGE_TYPE
1388 @param[in] type expected page type
1389 @param[in,out] mtr mini-transaction */
1390 inline void fil_page_check_type(const page_id_t &page_id, byte *page,
1391  ulint type, mtr_t *mtr) {
1392  ulint page_type = fil_page_get_type(page);
1393 
1394  if (page_type != type) {
1395  fil_page_reset_type(page_id, page, type, mtr);
1396  }
1397 }
1398 
1399 /** Check (and if needed, reset) the page type.
1400 Data files created before MySQL 5.1 may contain
1401 garbage in the FIL_PAGE_TYPE field.
1402 In MySQL 3.23.53, only undo log pages and index pages were tagged.
1403 Any other pages were written with uninitialized bytes in FIL_PAGE_TYPE.
1404 @param[in,out] block block with possibly invalid FIL_PAGE_TYPE
1405 @param[in] type expected page type
1406 @param[in,out] mtr mini-transaction */
1407 #define fil_block_check_type(block, type, mtr) \
1408  fil_page_check_type(block->page.id, block->frame, type, mtr)
1409 
1410 #ifdef UNIV_DEBUG
1411 /** Increase redo skipped of a tablespace.
1412 @param[in] space_id Tablespace ID */
1414 
1415 /** Decrease redo skipped of a tablespace.
1416 @param[in] space_id Tablespace ID */
1418 
1419 /** Check whether a single-table tablespace is redo skipped.
1420 @param[in] space_id Tablespace ID
1421 @return true if redo skipped */
1423  MY_ATTRIBUTE((warn_unused_result));
1424 #endif /* UNIV_DEBUG */
1425 
1426 /** Delete the tablespace file and any related files like .cfg.
1427 This should not be called for temporary tables.
1428 @param[in] path File path of the tablespace
1429 @return true on success */
1430 bool fil_delete_file(const char *path) MY_ATTRIBUTE((warn_unused_result));
1431 
1432 /** Callback functor. */
1434  /** Default constructor */
1435  PageCallback() : m_page_size(0, 0, false), m_filepath() UNIV_NOTHROW {}
1436 
1437  virtual ~PageCallback() UNIV_NOTHROW {}
1438 
1439  /** Called for page 0 in the tablespace file at the start.
1440  @param file_size size of the file in bytes
1441  @param block contents of the first page in the tablespace file
1442  @retval DB_SUCCESS or error code. */
1443  virtual dberr_t init(os_offset_t file_size, const buf_block_t *block)
1444  MY_ATTRIBUTE((warn_unused_result)) UNIV_NOTHROW = 0;
1445 
1446  /** Called for every page in the tablespace. If the page was not
1447  updated then its state must be set to BUF_PAGE_NOT_USED. For
1448  compressed tables the page descriptor memory will be at offset:
1449  block->frame + UNIV_PAGE_SIZE;
1450  @param offset physical offset within the file
1451  @param block block read from file, note it is not from the buffer pool
1452  @retval DB_SUCCESS or error code. */
1453  virtual dberr_t operator()(os_offset_t offset, buf_block_t *block)
1454  MY_ATTRIBUTE((warn_unused_result)) UNIV_NOTHROW = 0;
1455 
1456  /** Set the name of the physical file and the file handle that is used
1457  to open it for the file that is being iterated over.
1458  @param filename then physical name of the tablespace file.
1459  @param file OS file handle */
1460  void set_file(const char *filename, pfs_os_file_t file) UNIV_NOTHROW {
1461  m_file = file;
1462  m_filepath = filename;
1463  }
1464 
1465  /** @return the space id of the tablespace */
1466  virtual space_id_t get_space_id() const
1467  MY_ATTRIBUTE((warn_unused_result)) UNIV_NOTHROW = 0;
1468 
1469  /**
1470  @retval the space flags of the tablespace being iterated over */
1471  virtual ulint get_space_flags() const
1472  MY_ATTRIBUTE((warn_unused_result)) UNIV_NOTHROW = 0;
1473 
1474  /** Set the tablespace table size.
1475  @param[in] page a page belonging to the tablespace */
1476  void set_page_size(const buf_frame_t *page) UNIV_NOTHROW;
1477 
1478  /** The compressed page size
1479  @return the compressed page size */
1480  const page_size_t &get_page_size() const MY_ATTRIBUTE((warn_unused_result)) {
1481  return (m_page_size);
1482  }
1483 
1484  /** The tablespace page size. */
1486 
1487  /** File handle to the tablespace */
1489 
1490  /** Physical file path. */
1491  const char *m_filepath;
1492 
1493  // Disable copying
1494  PageCallback(PageCallback &&) = delete;
1495  PageCallback(const PageCallback &) = delete;
1496  PageCallback &operator=(const PageCallback &) = delete;
1497 };
1498 
1499 /** Iterate over all the pages in the tablespace.
1500 @param table the table definiton in the server
1501 @param n_io_buffers number of blocks to read and write together
1502 @param callback functor that will do the page updates
1503 @return DB_SUCCESS or error code */
1504 dberr_t fil_tablespace_iterate(dict_table_t *table, ulint n_io_buffers,
1505  PageCallback &callback)
1506  MY_ATTRIBUTE((warn_unused_result));
1507 
1508 /** Looks for a pre-existing fil_space_t with the given tablespace ID
1509 and, if found, returns the name and filepath in newly allocated buffers that
1510 the caller must free.
1511 @param[in] space_id The tablespace ID to search for.
1512 @param[out] name Name of the tablespace found.
1513 @param[out] filepath The filepath of the first datafile for thtablespace found.
1514 @return true if tablespace is found, false if not. */
1515 bool fil_space_read_name_and_filepath(space_id_t space_id, char **name,
1516  char **filepath)
1517  MY_ATTRIBUTE((warn_unused_result));
1518 
1519 /** Convert a file name to a tablespace name.
1520 @param[in] filename directory/databasename/tablename.ibd
1521 @return database/tablename string, to be freed with ut_free() */
1522 char *fil_path_to_space_name(const char *filename)
1523  MY_ATTRIBUTE((warn_unused_result));
1524 
1525 /** Returns the space ID based on the tablespace name.
1526 The tablespace must be found in the tablespace memory cache.
1527 This call is made from external to this module, so the mutex is not owned.
1528 @param[in] name Tablespace name
1529 @return space ID if tablespace found, SPACE_UNKNOWN if space not. */
1530 space_id_t fil_space_get_id_by_name(const char *name)
1531  MY_ATTRIBUTE((warn_unused_result));
1532 
1533 /** Check if swapping two .ibd files can be done without failure
1534 @param[in] old_table old table
1535 @param[in] new_table new table
1536 @param[in] tmp_name temporary table name
1537 @return innodb error code */
1538 dberr_t fil_rename_precheck(const dict_table_t *old_table,
1539  const dict_table_t *new_table, const char *tmp_name)
1540  MY_ATTRIBUTE((warn_unused_result));
1541 
1542 /** Set the compression type for the tablespace of a table
1543 @param[in] table Table that should be compressesed
1544 @param[in] algorithm Text representation of the algorithm
1545 @return DB_SUCCESS or error code */
1546 dberr_t fil_set_compression(dict_table_t *table, const char *algorithm)
1547  MY_ATTRIBUTE((warn_unused_result));
1548 
1549 /** Get the compression type for the tablespace
1550 @param[in] space_id Space ID to check
1551 @return the compression algorithm */
1553  MY_ATTRIBUTE((warn_unused_result));
1554 
1555 /** Set encryption.
1556 @param[in,out] req_type IO request
1557 @param[in] page_id Page address for IO
1558 @param[in,out] space Tablespace instance */
1559 void fil_io_set_encryption(IORequest &req_type, const page_id_t &page_id,
1560  fil_space_t *space);
1561 
1562 /** Set the encryption type for the tablespace
1563 @param[in] space_id Space ID of tablespace for which to set
1564 @param[in] algorithm Encryption algorithm
1565 @param[in] key Encryption key
1566 @param[in] iv Encryption iv
1567 @return DB_SUCCESS or error code */
1569  byte *key, byte *iv)
1570  MY_ATTRIBUTE((warn_unused_result));
1571 
1572 /** @return true if the re-encrypt success */
1573 bool fil_encryption_rotate() MY_ATTRIBUTE((warn_unused_result));
1574 
1575 /** During crash recovery, open a tablespace if it had not been opened
1576 yet, to get valid size and flags.
1577 @param[in,out] space Tablespace instance */
1579  if (space->size == 0) {
1580  /* Initially, size and flags will be set to 0,
1581  until the files are opened for the first time.
1582  fil_space_get_size() will open the file
1583  and adjust the size and flags. */
1584  page_no_t size = fil_space_get_size(space->id);
1585 
1586  ut_a(size == space->size);
1587  }
1588 }
1589 
1590 #if !defined(NO_FALLOCATE) && defined(UNIV_LINUX)
1591 /**
1592 Try and enable FusionIO atomic writes.
1593 @param[in] file OS file handle
1594 @return true if successful */
1595 bool fil_fusionio_enable_atomic_write(pfs_os_file_t file)
1596  MY_ATTRIBUTE((warn_unused_result));
1597 #endif /* !NO_FALLOCATE && UNIV_LINUX */
1598 
1599 /** Note that the file system where the file resides doesn't support PUNCH HOLE
1600 @param[in,out] file File node to set */
1601 void fil_no_punch_hole(fil_node_t *file);
1602 
1603 #ifdef UNIV_ENABLE_UNIT_TEST_MAKE_FILEPATH
1604 void test_make_filepath();
1605 #endif /* UNIV_ENABLE_UNIT_TEST_MAKE_FILEPATH */
1606 
1607 /** @return the system tablespace instance */
1608 #define fil_space_get_sys_space() (fil_space_t::s_sys_space)
1609 
1610 /** Redo a tablespace create
1611 @param[in] ptr redo log record
1612 @param[in] end end of the redo log buffer
1613 @param[in] page_id Tablespace Id and first page in file
1614 @param[in] parsed_bytes Number of bytes parsed so far
1615 @param[in] parse_only Don't apply the log if true
1616 @return pointer to next redo log record
1617 @retval nullptr if this log record was truncated */
1619  const page_id_t &page_id, ulint parsed_bytes,
1620  bool parse_only)
1621  MY_ATTRIBUTE((warn_unused_result));
1622 
1623 /** Redo a tablespace drop
1624 @param[in] ptr redo log record
1625 @param[in] end end of the redo log buffer
1626 @param[in] page_id Tablespace Id and first page in file
1627 @param[in] parsed_bytes Number of bytes parsed so far
1628 @param[in] parse_only Don't apply the log if true
1629 @return pointer to next redo log record
1630 @retval nullptr if this log record was truncated */
1632  const page_id_t &page_id, ulint parsed_bytes,
1633  bool parse_only)
1634  MY_ATTRIBUTE((warn_unused_result));
1635 
1636 /** Redo a tablespace rename
1637 @param[in] ptr redo log record
1638 @param[in] end end of the redo log buffer
1639 @param[in] page_id Tablespace Id and first page in file
1640 @param[in] parsed_bytes Number of bytes parsed so far
1641 @param[in] parse_only Don't apply the log if true
1642 @return pointer to next redo log record
1643 @retval nullptr if this log record was truncated */
1645  const page_id_t &page_id, ulint parsed_bytes,
1646  bool parse_only)
1647  MY_ATTRIBUTE((warn_unused_result));
1648 
1649 /** Parse and process an encryption redo record.
1650 @param[in] ptr redo log record
1651 @param[in] end end of the redo log buffer
1652 @param[in] space_id the tablespace ID
1653 @return log record end, nullptr if not a complete record */
1655  space_id_t space_id)
1656  MY_ATTRIBUTE((warn_unused_result));
1657 
1658 /** Read the tablespace id to path mapping from the file
1659 @param[in] recovery true if called from crash recovery */
1660 void fil_tablespace_open_init_for_recovery(bool recovery);
1661 
1662 /** Lookup the space ID.
1663 @param[in] space_id Tablespace ID to lookup
1664 @return true if space ID is known and open */
1666  MY_ATTRIBUTE((warn_unused_result));
1667 
1668 /** Lookup the tablespace ID and return the path to the file. The filename
1669 is ignored when testing for equality. Only the path up to the file name is
1670 considered for matching: e.g. ./test/a.ibd == ./test/b.ibd.
1671 @param[in] dd_object_id Server DD tablespace ID
1672 @param[in] space_id Tablespace ID to lookup
1673 @param[in] space_name Tablespace name
1674 @param[in] old_path Path in the data dictionary
1675 @param[out] new_path New path if scanned path not equal to path
1676 @return status of the match. */
1678  space_id_t space_id,
1679  const char *space_name,
1680  std::string old_path,
1681  std::string *new_path)
1682  MY_ATTRIBUTE((warn_unused_result));
1683 
1684 /** This function should be called after recovery has completed.
1685 Check for tablespace files for which we did not see any MLOG_FILE_DELETE
1686 or MLOG_FILE_RENAME record. These could not be recovered
1687 @return true if there were some filenames missing for which we had to
1688 ignore redo log records during the apply phase */
1689 bool fil_check_missing_tablespaces() MY_ATTRIBUTE((warn_unused_result));
1690 
1691 /** Discover tablespaces by reading the header from .ibd files.
1692 @param[in] directories Directories to scan
1693 @return DB_SUCCESS if all goes well */
1694 dberr_t fil_scan_for_tablespaces(const std::string &directories);
1695 
1696 /** Open the tabelspace and also get the tablespace filenames, space_id must
1697 already be known.
1698 @param[in] space_id Tablespace ID to lookup
1699 @return true if open was successful */
1701  MY_ATTRIBUTE((warn_unused_result));
1702 
1703 /** Callback to check tablespace size with space header size and extend
1704 Caller must own the Fil_shard mutex that the file belongs to.
1705 @param[in] file file node
1706 @return error code */
1708  MY_ATTRIBUTE((warn_unused_result));
1709 
1710 /** Replay a file rename operation for ddl replay.
1711 @param[in] page_id Space ID and first page number in the file
1712 @param[in] old_name old file name
1713 @param[in] new_name new file name
1714 @return whether the operation was successfully applied
1715 (the name did not exist, or new_name did not exist and
1716 name was successfully renamed to new_name) */
1717 bool fil_op_replay_rename_for_ddl(const page_id_t &page_id,
1718  const char *old_name, const char *new_name);
1719 
1720 /** Free the Tablespace_files instance.
1721 @param[in] read_only_mode true if InnoDB is started in read only mode.
1722 @return DB_SUCCESS if all OK */
1723 dberr_t fil_open_for_business(bool read_only_mode)
1724  MY_ATTRIBUTE((warn_unused_result));
1725 
1726 /** Check if a path is known to InnoDB.
1727 @param[in] path Path to check
1728 @return true if path is known to InnoDB */
1729 bool fil_check_path(const std::string &path) MY_ATTRIBUTE((warn_unused_result));
1730 
1731 /** Get the list of directories that InnoDB will search on startup.
1732 @return the list of directories 'dir1;dir2;....;dirN' */
1733 std::string fil_get_dirs() MY_ATTRIBUTE((warn_unused_result));
1734 
1735 /** Rename a tablespace by its name only
1736 @param[in] old_name old tablespace name
1737 @param[in] new_name new tablespace name
1738 @return DB_SUCCESS on success */
1739 dberr_t fil_rename_tablespace_by_name(const char *old_name,
1740  const char *new_name)
1741  MY_ATTRIBUTE((warn_unused_result));
1742 
1743 /** Free the data structures required for recovery. */
1744 void fil_free_scanned_files();
1745 
1746 /** Update the tablespace name. Incase, the new name
1747 and old name are same, no update done.
1748 @param[in,out] space tablespace object on which name
1749  will be updated
1750 @param[in] name new name for tablespace */
1751 void fil_space_update_name(fil_space_t *space, const char *name);
1752 
1753 #endif /* fil0fil_h */
PageCallback()
Default constructor.
Definition: fil0fil.h:1435
unsigned char byte
Blob class.
Definition: common.h:159
const char * m_filepath
Physical file path.
Definition: fil0fil.h:1491
page_no_t free_limit
Contents of FSP_FREE_LIMIT.
Definition: fil0fil.h:226
constexpr page_type_t FIL_PAGE_TYPE_LAST
Used by i_s.cc to index into the text description.
Definition: fil0fil.h:879
constexpr page_no_t PAGE_NO_MAX
Maximum Page Number, one less than FIL_NULL.
Definition: fil0fil.h:717
page_no_t page
Page number within a space.
Definition: fil0fil.h:760
space_id_t fil_space_get_id_by_name(const char *name)
Returns the space ID based on the tablespace name.
Definition: fil0fil.cc:5687
constexpr page_type_t FIL_PAGE_TYPE_LOB_INDEX
Index pages of uncompressed LOB.
Definition: fil0fil.h:854
void fil_close()
Initializes the tablespace memory cache.
Definition: fil0fil.cc:7709
constexpr size_t FIL_SPACE_MAGIC_N
Value of fil_space_t::magic_n.
Definition: fil0fil.h:302
buf_remove_t
Algorithm to remove the pages for a tablespace from the buffer pool.
Definition: buf0types.h:76
File node of a tablespace or the log data space.
Definition: fil0fil.h:113
constexpr page_type_t FIL_PAGE_TYPE_ZBLOB2
Subsequent compressed BLOB page.
Definition: fil0fil.h:823
bool fil_space_reserve_free_extents(space_id_t space_id, ulint n_free_now, ulint n_to_reserve)
Tries to reserve free extents in a file space.
Definition: fil0fil.cc:6563
std::vector< space_id_t, ut_allocator< space_id_t > > Space_ids
Definition: fil0fil.h:67
rw_lock_t * fil_space_get_latch(space_id_t id)
Returns the latch of a file space.
Definition: fil0fil.cc:1962
space_id_t id
Tablespace ID.
Definition: fil0fil.h:188
dberr_t fil_delete_tablespace(space_id_t space_id, buf_remove_t buf_remove)
Deletes an IBD tablespace, either general or single-table.
Definition: fil0fil.cc:4034
Space ID matches but the paths don&#39;t match.
constexpr page_type_t FIL_PAGE_TYPE_ZLOB_FRAG
Fragment pages of compressed LOB.
Definition: fil0fil.h:873
The path matches what was found during the scan.
uint32 page_no_t
Page number.
Definition: api0api.h:57
The structure used in the spin lock implementation of a read-write lock.
Definition: sync0rw.h:554
uint64_t lsn_t
Type used for all log sequence number storage and arithmetics.
Definition: log0types.h:59
Definition: fil0fil.h:308
constexpr page_type_t FIL_PAGE_SDI_ZBLOB
Commpressed SDI BLOB page.
Definition: fil0fil.h:845
bool fil_space_exists_in_mem(space_id_t space_id, const char *name, bool print_err, bool adjust_space, mem_heap_t *heap, table_id_t table_id)
Returns true if a matching tablespace exists in the InnoDB tablespace memory cache.
Definition: fil0fil.cc:5673
bool is_raw_disk
whether the file actually is a raw device or disk partition
Definition: fil0fil.h:134
size_t len() const
Definition: fil0fil.h:382
static std::string parse(const char *pathspec)
Remove quotes e.g., &#39;a;b&#39; or "a;b" -> a;b.
Definition: fil0fil.h:461
bool is_in_unflushed_spaces
true if this space is currently in unflushed_spaces
Definition: fil0fil.h:257
size_t n_pending_flushes
count of pending flushes; is_open must be true if nonzero
Definition: fil0fil.h:152
const char * operator()() const
Explicit type conversion.
Definition: fil0fil.h:374
static bool has_prefix(const std::string &path, const std::string prefix)
Definition: fil0fil.h:520
dberr_t fil_close_tablespace(trx_t *trx, space_id_t space_id)
Closes a single-table tablespace.
Definition: fil0fil.cc:3743
const string name("\ame\)
constexpr page_type_t FIL_PAGE_IBUF_BITMAP
Insert buffer bitmap.
Definition: fil0fil.h:802
constexpr size_t FIL_IBD_FILE_INITIAL_SIZE
Initial size of a single-table tablespace in pages.
Definition: fil0fil.h:706
const page_size_t fil_space_get_page_size(space_id_t space_id, bool *found)
Returns the page size of the space and whether it is compressed or not.
Definition: fil0fil.cc:3223
bool fil_truncate_tablespace(space_id_t space_id, page_no_t size_in_pages)
Truncate the tablespace to needed size.
Definition: fil0fil.cc:4113
static fil_space_t * s_sys_space
System tablespace.
Definition: fil0fil.h:282
constexpr page_type_t FIL_PAGE_INDEX
File page types (values of FIL_PAGE_TYPE)
Definition: fil0fil.h:780
bool atomic_write
whether atomic write is enabled for this file
Definition: fil0fil.h:173
std::string fil_system_open_fetch(space_id_t space_id)
Fetch the file name opened for a space_id during recovery from the file map.
Definition: fil0fil.cc:3881
constexpr size_t FIL_IBD_FILE_INITIAL_SIZE_5_7
An empty tablespace (CREATE TABLESPACE) has minimum of 4 pages and an empty CREATE TABLE (file_per_ta...
Definition: fil0fil.h:711
void fil_page_reset_type(const page_id_t &page_id, byte *page, ulint type, mtr_t *mtr)
Reset the page type.
Definition: fil0fil.cc:7701
dberr_t fil_set_compression(dict_table_t *table, const char *algorithm)
Set the compression type for the tablespace of a table.
Definition: fil0fil.cc:8198
constexpr page_type_t FIL_PAGE_COMPRESSED
Compressed page.
Definition: fil0fil.h:830
Definition: trx0trx.h:713
ib_file_suffix
Common InnoDB file extentions.
Definition: fil0fil.h:308
static char * make_ibd(const std::string &path_in, const std::string &name_in)
Allocate and build a file name from a path, a table or tablespace name and a suffix.
Definition: fil0fil.h:632
void fil_space_release_free_extents(space_id_t space_id, ulint n_reserved)
Releases free extents in a file space.
Definition: fil0fil.cc:6589
size_t abs_len() const
Definition: fil0fil.h:387
The buffer control block structure.
Definition: buf0buf.h:1301
Page identifier.
Definition: buf0types.h:153
pfs_os_file_t m_file
File handle to the tablespace.
Definition: fil0fil.h:1488
constexpr page_type_t FIL_PAGE_TYPE_ZLOB_DATA
Data pages of compressed LOB.
Definition: fil0fil.h:866
std::string m_path
Path to a file or directory.
Definition: fil0fil.h:693
void fil_aio_wait(ulint segment)
Waits for an aio operation to complete.
Definition: fil0fil.cc:7279
static const Fil_path & null()
Definition: fil0fil.h:671
Fil_state
Result of comparing a path.
Definition: fil0fil.h:82
void fil_io_set_encryption(IORequest &req_type, const page_id_t &page_id, fil_space_t *space)
Set encryption.
Definition: fil0fil.cc:6774
void fil_close_log_files(bool free_all)
Closes the redo log files.
Definition: fil0fil.cc:3406
bool fil_space_extend(fil_space_t *space, page_no_t size)
Try to extend a tablespace if it is smaller than the specified size.
Definition: fil0fil.cc:5999
void fil_flush(space_id_t space_id)
Flushes to disk possible writes cached by the OS.
Definition: fil0fil.cc:7588
void fil_flush_file_spaces(uint8_t purpose)
Flush to disk the writes in file spaces of the given type possibly cached by the OS.
Definition: fil0fil.cc:7657
void fil_tablespace_open_init_for_recovery(bool recovery)
Read the tablespace id to path mapping from the file.
fil_addr_t(page_no_t p, uint32_t boff)
Constructor.
Definition: fil0fil.h:738
const std::string & abs_path() const
Return the absolute path.
Definition: fil0fil.h:441
Recovery.
bool fil_tablespace_open_for_recovery(space_id_t space_id)
Open the tabelspace and also get the tablespace filenames, space_id must already be known...
Definition: fil0fil.cc:8862
Tablespace or log data space.
Definition: fil0fil.h:180
ulint fil_space_get_n_reserved_extents(space_id_t space_id)
Gets the number of reserved extents.
Definition: fil0fil.cc:6608
static const ulint ENCRYPTION_KEY_LEN
Encryption key length.
Definition: os0file.h:217
fil_space_t * space
tablespace containing this file
Definition: fil0fil.h:117
static void normalize(char *path)
Normalizes a directory path for the current OS: On Windows, we convert &#39;/&#39; to &#39;\&#39;, else we convert &#39;\&#39; to &#39;/&#39;.
Definition: fil0fil.h:540
bool fil_validate()
Checks the consistency of the tablespace cache.
Definition: fil0fil.cc:1654
bool fil_type_is_data(fil_type_t type)
Check if fil_type is any of FIL_TYPE_TEMPORARY, FIL_TYPE_IMPORT or FIL_TYPE_TABLESPACE.
Definition: fil0fil.h:105
constexpr page_type_t FIL_PAGE_TYPE_BLOB
Uncompressed BLOB page.
Definition: fil0fil.h:817
constexpr page_type_t FIL_PAGE_TYPE_FSP_HDR
File space header.
Definition: fil0fil.h:811
Data structure for a database table.
Definition: dict0mem.h:1488
Definition: varlen_sort.h:182
constexpr page_type_t FIL_PAGE_TYPE_ZLOB_FIRST
The first page of a compressed LOB.
Definition: fil0fil.h:863
void fil_space_dec_redo_skipped_count(space_id_t space_id)
Decrease redo skipped of a tablespace.
Definition: fil0fil.cc:4138
constexpr page_type_t FIL_PAGE_RTREE
R-tree node.
Definition: fil0fil.h:783
ulint magic_n
FIL_SPACE_MAGIC_N.
Definition: fil0fil.h:279
page_no_t size_in_header
FSP_SIZE in the tablespace header; 0 if not known yet.
Definition: fil0fil.h:220
dberr_t fil_scan_for_tablespaces(const std::string &directories)
Discover tablespaces by reading the header from .ibd files.
Definition: fil0fil.cc:10093
Type
Algorithm types supported.
Definition: file.h:54
static Fil_path s_null_path
Empty (null) path.
Definition: fil0fil.h:699
void fil_space_release(fil_space_t *space)
Release a tablespace acquired with fil_space_acquire().
Definition: fil0fil.cc:3559
bool is_valid(const dd::Spatial_reference_system *srs, const Geometry *g, const char *func_name, bool *is_valid) noexcept
Decides if a geometry is valid.
Definition: is_valid.cc:94
fil_space_t * fil_space_acquire_silent(space_id_t space_id)
Acquire a tablespace that may not exist.
Definition: fil0fil.cc:3553
uint32_t free_len
Length of the FSP_FREE list.
Definition: fil0fil.h:223
fil_addr_t fil_addr_null
The null file address.
Definition: fil0fil.cc:288
bool punch_hole
whether the file system of this file supports PUNCH HOLE
Definition: fil0fil.h:167
byte fil_faddr_t
&#39;type&#39; definition in C: an address stored in a file page is a string of bytes
Definition: fil0fil.h:728
page_no_t fil_page_get_next(const byte *page)
Get the successor of a file page.
Definition: fil0fil.cc:7682
static bool is_absolute_path(const std::string &path)
Determine if a path is an absolute path or not.
Definition: fil0fil.h:495
Definition: fil0fil.h:308
std::function< dberr_t(fil_node_t *)> Function
Definition: fil0fil.h:1047
Compression::Type fil_get_compression(space_id_t space_id)
Get the compression type for the tablespace.
Definition: fil0fil.cc:8262
constexpr page_type_t FIL_PAGE_SDI
Tablespace SDI Index page.
Definition: fil0fil.h:786
static char * make_cfp(const std::string &path_in)
Allocate and build a CFP file name from a path.
Definition: fil0fil.h:620
The info structure stored at the beginning of a heap block.
Definition: mem0mem.h:343
void fil_set_max_space_id_if_bigger(space_id_t max_id)
Sets the max tablespace id counter if the given number is bigger than the previous value...
Definition: fil0fil.cc:3474
std::vector< fil_node_t, ut_allocator< fil_node_t > > Files
Definition: fil0fil.h:182
uint32_t flags
Tablespace flags; see fsp_flags_is_valid() and page_size_t(ulint) (constructor).
Definition: fil0fil.h:231
Definition: fil0fil.h:308
dberr_t fil_open_for_business(bool read_only_mode)
Free the Tablespace_files instance.
Definition: fil0fil.cc:8754
bool fil_assign_new_space_id(space_id_t *space_id)
Assigns a new space id for a new single-table tablespace.
Definition: fil0fil.cc:3036
constexpr page_type_t FIL_PAGE_INODE
Index node.
Definition: fil0fil.h:792
Wrapper for a path to a directory that may or may not exist.
Definition: fil0fil.h:324
void fil_flush_file_redo()
Flush to disk the writes in file spaces of the given type possibly cached by the OS.
Definition: fil0fil.cc:7663
Insert buffer global types.
virtual ~PageCallback() 1
Definition: fil0fil.h:1437
constexpr page_type_t FIL_PAGE_TYPE_XDES
Extent descriptor page.
Definition: fil0fil.h:814
dberr_t fil_rename_tablespace_by_name(const char *old_name, const char *new_name)
Rename a tablespace by its name only.
Definition: fil0fil.cc:4769
List_node unflushed_spaces
List of spaces with at least one unflushed file we have written to.
Definition: fil0fil.h:254
bool fil_op_replay_rename_for_ddl(const page_id_t &page_id, const char *old_name, const char *new_name)
Replay a file rename operation for ddl replay.
Definition: fil0fil.cc:8765
fil_addr_t()
Definition: fil0fil.h:733
void fil_space_update_name(fil_space_t *space, const char *name)
Update the tablespace name.
Definition: fil0fil.cc:10163
constexpr page_type_t FIL_PAGE_COMPRESSED_AND_ENCRYPTED
Compressed and Encrypted page.
Definition: fil0fil.h:836
The IO Context that is passed down to the low level IO code.
Definition: os0file.h:492
dberr_t fil_write_flushed_lsn(lsn_t lsn)
Write the flushed LSN to the page header of the first page in the system tablespace.
Definition: fil0fil.cc:3486
static bool equal(Item *i1, Item *i2, Field *f2)
Definition: sql_select.cc:2969
constexpr page_type_t FIL_PAGE_TYPE_ZLOB_INDEX
Index pages of compressed LOB.
Definition: fil0fil.h:870
int64_t flush_counter
the modification_counter of the latest flush to disk
Definition: fil0fil.h:161
bool fil_check_missing_tablespaces()
This function should be called after recovery has completed.
Definition: fil0fil.cc:9049
os_event_t sync_event
event that groups and serializes calls to fsync
Definition: fil0fil.h:131
uint32_t n_reserved_extents
Number of reserved free extents for ongoing operations like B-tree page split.
Definition: fil0fil.h:235
ulint fil_n_file_opened
Number of files currently open.
Definition: fil0fil.cc:257
static bool is_separator(char c)
Check if a character is a path separator (&#39;\&#39; or &#39;/&#39;)
Definition: fil0fil.h:593
Type
Algorithm types supported.
Definition: os0file.h:268
Definition: fil0fil.h:308
const page_size_t & get_page_size() const
The compressed page size.
Definition: fil0fil.h:1480
ulint fil_space_get_flags(space_id_t space_id)
Returns the flags of the space.
Definition: fil0fil.cc:3156
int page
Definition: ctype-mb.cc:1220
void fil_page_check_type(const page_id_t &page_id, byte *page, ulint type, mtr_t *mtr)
Check (and if needed, reset) the page type.
Definition: fil0fil.h:1390
byte * fil_tablespace_redo_create(byte *ptr, const byte *end, const page_id_t &page_id, ulint parsed_bytes, bool parse_only)
Redo a tablespace create.
Definition: fil0fil.cc:9061
static bool equal(const std::string &lhs, const std::string &rhs)
Convert the paths into absolute paths and compare them.
Definition: fil0fil.h:483
void fil_page_set_type(byte *page, ulint type)
Sets the file page type.
Definition: fil0fil.cc:7689
Data dictionary global types.
page_no_t max_size
maximum size of the file in database pages
Definition: fil0fil.h:146
fil_type_t
File types.
Definition: fil0fil.h:70
char * fil_path_to_space_name(const char *filename)
Convert a file name to a tablespace name.
Definition: fil0fil.cc:5230
byte * fil_tablespace_redo_rename(byte *ptr, const byte *end, const page_id_t &page_id, ulint parsed_bytes, bool parse_only)
Redo a tablespace rename.
Definition: fil0fil.cc:9165
No MLOG_FILE_DELETE record and the file could not be found.
void fil_open_log_and_system_tablespace_files()
Opens all log files and system tablespace data files.
Definition: fil0fil.cc:3303
Tablespace and/or filename was renamed.
bool fil_space_is_redo_skipped(space_id_t space_id)
Check whether a single-table tablespace is redo skipped.
Definition: fil0fil.cc:4156
byte buf_frame_t
A buffer frame.
Definition: buf0types.h:59
page_type_t fil_page_get_type(const byte *page)
Get the file page type.
Definition: fil0fil.h:1378
List_node LRU
link to the fil_system->LRU list (keeping track of open files)
Definition: fil0fil.h:164
bool is_null() const
Check if the file address is null.
Definition: fil0fil.h:749
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:191
bool is_equal(const fil_addr_t &rhs) const
Compare to instances.
Definition: fil0fil.h:743
dberr_t fil_rename_tablespace_check(space_id_t space_id, const char *old_path, const char *new_path, bool is_discarded)
Test if a tablespace file can be renamed to a new filepath by checking if that the old filepath exist...
Definition: fil0fil.cc:4408
bool is_ancestor(const std::string &name) const
Check if m_path is the parent of name.
Definition: fil0fil.h:413
std::string m_abs_path
A full absolute path to the same file.
Definition: fil0fil.h:696
constexpr page_type_t FIL_PAGE_TYPE_LOB_DATA
Data pages of uncompressed LOB.
Definition: fil0fil.h:857
bool fil_encryption_rotate()
Rotate the tablespace keys by new master key.
Definition: fil0fil.cc:8385
constexpr page_type_t FIL_PAGE_TYPE_LOB_FIRST
The first page of an uncompressed LOB.
Definition: fil0fil.h:860
dberr_t
Definition: db0err.h:38
redo log covering changes to files of FIL_TYPE_TABLESPACE
Definition: fil0fil.h:78
bool fil_addr_is_null(const fil_addr_t &addr)
Returns true if file address is undefined.
Definition: fil0fil.cc:7668
bool fil_space_open(space_id_t space_id)
Open each file of a tablespace if not already open.
Definition: fil0fil.cc:3194
static char * path
Definition: mysqldump.cc:142
static fil_space_t * s_redo_space
Redo log tablespace.
Definition: fil0fil.h:285
std::ostream & print(std::ostream &out) const
Print a string representation.
Definition: fil0fil.h:753
void set_file(const char *filename, pfs_os_file_t file) 1
Set the name of the physical file and the file handle that is used to open it for the file that is be...
Definition: fil0fil.h:1460
void fil_init(ulint max_n_open)
Initializes the tablespace memory cache.
Definition: fil0fil.cc:3238
static bool is_ancestor(const std::string &lhs, const std::string &rhs)
Check if lhs is the ancestor of rhs.
Definition: fil0fil.h:564
Instrumented memory allocator.
uint16_t page_type_t
Definition: fil0fil.h:776
Files files
Files attached to this tablespace.
Definition: fil0fil.h:214
unsigned int len
Definition: dbug_analyze.cc:216
uint32_t n_pending_ops
This is positive when we have pending operations against this tablespace.
Definition: fil0fil.h:245
File space address.
Definition: fil0fil.h:731
static mysql_service_status_t init()
Definition: test_udf_registration.cc:150
constexpr page_type_t FIL_PAGE_TYPE_ZBLOB
First compressed BLOB page.
Definition: fil0fil.h:820
ulint encryption_klen
Encrypt key length.
Definition: fil0fil.h:269
os_file_type_t
Definition: os0file.h:801
Compression::Type compression_type
Compression algorithm.
Definition: fil0fil.h:260
#define ut_a(EXPR)
Abort execution if EXPR does not evaluate to nonzero.
Definition: ut0dbg.h:48
static const char * prefix
Definition: log_sink_syseventlog.cc:104
unsigned long long Object_id
Definition: object_id.h:30
std::ostream & operator<<(std::ostream &out, const fil_addr_t &obj)
Definition: fil0fil.h:769
char * fil_node_create(const char *name, page_no_t size, fil_space_t *space, bool is_raw, bool atomic_write, page_no_t max_pages=PAGE_NO_MAX)
Append a file to the chain of files of a space.
Definition: fil0fil.cc:2157
fil_space_t * fil_space_acquire(space_id_t space_id)
Acquire a tablespace when it could be dropped concurrently.
Definition: fil0fil.cc:3544
uint32_t n_pending_flushes
This is positive when flushing the tablespace to disk; dropping of the tablespace is forbidden if thi...
Definition: fil0fil.h:239
ulint fil_n_log_flushes
The number of fsyncs done to the log.
Definition: fil0fil.cc:248
dberr_t fil_io(const IORequest &type, bool sync, const page_id_t &page_id, const page_size_t &page_size, ulint byte_offset, ulint len, void *buf, void *message)
Read or write data.
Definition: fil0fil.cc:7350
Fil_path MySQL_datadir_path
The MySQL server –datadir value.
Definition: fil0fil.cc:239
ib_id_t table_id_t
Table or partition identifier (unique within an InnoDB instance).
Definition: dict0types.h:61
bool stop_ios
true if we want to rename the .ibd file of tablespace and want to stop temporarily posting of new i/o...
Definition: fil0fil.h:192
Encryption::Type encryption_type
Encryption algorithm.
Definition: fil0fil.h:263
constexpr page_type_t FIL_PAGE_IBUF_FREE_LIST
Insert buffer free list.
Definition: fil0fil.h:795
uint32_t boffset
Byte offset within the page.
Definition: fil0fil.h:763
Iterate over the files in all the tablespaces.
Definition: fil0fil.h:1045
char * name
Tablespace name.
Definition: fil0fil.h:185
constexpr page_type_t FIL_PAGE_TYPE_UNUSED
Available for future use.
Definition: fil0fil.h:848
bool is_same_as(const std::string &path) const
Check if m_path is the same as path.
Definition: fil0fil.h:401
bool is_open
whether this file is open.
Definition: fil0fil.h:125
static const char * key
Definition: suite_stubs.c:14
constexpr page_type_t FIL_PAGE_TYPE_RSEG_ARRAY
Rollback Segment Array page.
Definition: fil0fil.h:851
byte * fil_tablespace_redo_delete(byte *ptr, const byte *end, const page_id_t &page_id, ulint parsed_bytes, bool parse_only)
Redo a tablespace drop.
Definition: fil0fil.cc:9288
fil_type_t fil_space_get_type(space_id_t space_id)
Gets the type of a file space.
Definition: fil0fil.cc:1979
bool fil_check_path(const std::string &path)
Check if a path is known to InnoDB.
Definition: fil0fil.cc:10147
volatile bool recv_recovery_on
true when applying redo log records during crash recovery; false otherwise.
Definition: log0recv.cc:97
void fil_free_scanned_files()
Free the data structures required for recovery.
Definition: fil0fil.cc:10156
uint32 space_id_t
Tablespace identifier.
Definition: api0api.h:59
void fil_space_set_flags(fil_space_t *space, ulint flags)
Sets the flags of the tablespace.
Definition: fil0fil.cc:8482
dberr_t fil_ibd_open(bool validate, fil_type_t purpose, space_id_t space_id, ulint flags, const char *space_name, const char *table_name, const char *path_in, bool strict, bool old_space)
Open a single-table tablespace and optionally check the space id is right in it.
Definition: fil0fil.cc:5041
void fil_space_set_imported(space_id_t space_id)
Note that a tablespace has been imported.
Definition: fil0fil.cc:1999
constexpr space_id_t SPACE_UNKNOWN
Unknown space id.
Definition: fil0fil.h:720
constexpr page_type_t FIL_PAGE_TYPE_ALLOCATED
Freshly allocated page.
Definition: fil0fil.h:799
const std::string & path() const
Definition: fil0fil.h:377
ib_uint64_t os_offset_t
File offset in bytes.
Definition: os0file.h:73
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:60
page_no_t size
size of the file in database pages (0 if not known yet); the possible last incomplete megabyte may be...
Definition: fil0fil.h:139
constexpr page_type_t FIL_PAGE_TYPE_ZLOB_FRAG_ENTRY
Index pages of fragment pages (compressed LOB).
Definition: fil0fil.h:876
dberr_t fil_discard_tablespace(space_id_t space_id)
Discards a single-table tablespace.
Definition: fil0fil.cc:4185
persistent tablespace (for system, undo log or tables)
Definition: fil0fil.h:76
fil_type_t purpose
Purpose.
Definition: fil0fil.h:210
size_t block_size
block size to use for punching holes
Definition: fil0fil.h:170
A MLOG_FILE_DELETE was found, file was deleted.
static dberr_t for_each_file(bool include_log, F &&f)
For each data file, exclude redo log files.
Definition: fil0fil.h:1053
Page size descriptor.
Definition: page0size.h:50
ulint fil_n_pending_tablespace_flushes
Number of pending tablespace flushes.
Definition: fil0fil.cc:254
const char * filename
Definition: pfs_example_component_population.cc:64
dberr_t fil_ibd_create(space_id_t space_id, const char *name, const char *path, ulint flags, page_no_t size)
Create a tablespace file.
Definition: fil0fil.cc:4784
constexpr page_type_t FIL_PAGE_TYPE_UNKNOWN
In old tablespaces, garbage in FIL_PAGE_TYPE is replaced with this value when flushing pages...
Definition: fil0fil.h:827
a tablespace that is being imported (no logging until finished)
Definition: fil0fil.h:74
static size_t file_size
Definition: mysql_config_editor.cc:70
UT_LIST_NODE_T(fil_space_t) List_node
Definition: fil0fil.h:181
The low-level file system page header & trailer offsets.
Callback functor.
Definition: fil0fil.h:1433
static char * make_ibd_from_table_name(const std::string &name_in)
Allocate and build a file name from a path, a table or tablespace name and a suffix.
Definition: fil0fil.h:641
page_no_t fil_page_get_prev(const byte *page)
Get the predecessor of a file page.
Definition: fil0fil.cc:7675
std::vector< std::string, ut_allocator< std::string > > Filenames
Definition: fil0fil.h:66
A class describing a page size.
const char * dot_ext[]
Common InnoDB file extentions.
Definition: fil0fil.cc:245
static char * filepath
Definition: myisamlog.cc:91
constexpr size_t FIL_NODE_MAGIC_N
Value of fil_node_t::magic_n.
Definition: fil0fil.h:305
Common file descriptor for file IO instrumentation with PFS on windows and other platforms.
Definition: os0file.h:128
UT_LIST_NODE_T(fil_node_t) List_node
Definition: fil0fil.h:114
constexpr page_type_t FIL_PAGE_UNDO_LOG
Undo log page.
Definition: fil0fil.h:789
static char * trim(char *ptr)
Definition: testapp.c:546
constexpr page_type_t FIL_PAGE_ENCRYPTED
Encrypted page.
Definition: fil0fil.h:833
bool fil_rename_tablespace(space_id_t space_id, const char *old_path, const char *new_name, const char *new_path_in)
Rename a single-table tablespace.
Definition: fil0fil.cc:4689
dberr_t fil_rename_precheck(const dict_table_t *old_table, const dict_table_t *new_table, const char *tmp_name)
Check if swapping two .ibd files can be done without failure.
Definition: fil0fil.cc:8111
InnoDB condition variable.
Definition: os0event.cc:63
temporary tablespace (temporary undo log or tables)
Definition: fil0fil.h:72
void fil_close_all_files()
Closes all open files.
Definition: fil0fil.cc:3351
bool fil_tablespace_lookup_for_recovery(space_id_t space_id)
Lookup the space ID.
Definition: fil0fil.cc:8817
size_t magic_n
FIL_NODE_MAGIC_N.
Definition: fil0fil.h:176
void fil_extend_tablespaces_to_stored_len()
Extends all tablespaces to the size stored in the space header.
page_size_t m_page_size
The tablespace page size.
Definition: fil0fil.h:1485
constexpr page_type_t FIL_PAGE_TYPE_TRX_SYS
Transaction system data.
Definition: fil0fil.h:808
constexpr page_type_t FIL_PAGE_TYPE_SYS
System page.
Definition: fil0fil.h:805
size_t in_use
e.g., when a file is being extended or just opened.
Definition: fil0fil.h:155
bool is_absolute_path() const
Definition: fil0fil.h:446
#define FIL_PAGE_TYPE
file page type: FIL_PAGE_INDEX,..., 2 bytes.
Definition: fil0types.h:75
const char * p
Definition: ctype-mb.cc:1221
dberr_t fil_set_encryption(space_id_t space_id, Encryption::Type algorithm, byte *key, byte *iv)
Set the encryption type for the tablespace.
Definition: fil0fil.cc:8274
constexpr page_no_t FIL_NULL
&#39;null&#39; (undefined) page offset in the context of file spaces
Definition: fil0fil.h:714
page_no_t size
Tablespace file size in pages; 0 if not known yet.
Definition: fil0fil.h:217
constexpr page_type_t FIL_PAGE_SDI_BLOB
Uncompressed SDI BLOB page.
Definition: fil0fil.h:842
static bool has_ibd_suffix(const std::string &path)
Check if the file has the .ibd suffix.
Definition: fil0fil.h:582
static char * make_cfg(const std::string &path_in)
Allocate and build a CFG file name from a path.
Definition: fil0fil.h:612
char * name
file name; protected by Fil_shard::m_mutex and log_sys->mutex.
Definition: fil0fil.h:120
pfs_os_file_t handle
file handle (valid if is_open)
Definition: fil0fil.h:128
bool fil_delete_file(const char *path)
Delete the tablespace file and any related files like .cfg.
Definition: fil0fil.cc:8080
void fil_no_punch_hole(fil_node_t *file)
Note that the file system where the file resides doesn&#39;t support PUNCH HOLE.
Definition: fil0fil.cc:8192
static int flags[50]
Definition: hp_test1.cc:39
std::string fil_get_dirs()
Get the list of directories that InnoDB will search on startup.
Definition: fil0fil.cc:10153
void fil_space_inc_redo_skipped_count(space_id_t space_id)
Increase redo skipped of a tablespace.
Definition: fil0fil.cc:4122
fil_space_t * fil_space_create(const char *name, space_id_t space_id, ulint flags, fil_type_t purpose)
Create a space memory object and put it to the fil_system hash table.
Definition: fil0fil.cc:2935
rw_lock_t latch
Latch protecting the file space storage allocation.
Definition: fil0fil.h:249
page_no_t init_size
initial size of the file in database pages; FIL_IBD_FILE_INITIAL_SIZE by default
Definition: fil0fil.h:143
bool fil_space_read_name_and_filepath(space_id_t space_id, char **name, char **filepath)
Looks for a pre-existing fil_space_t with the given tablespace ID and, if found, returns the name and...
Definition: fil0fil.cc:5200
dberr_t fil_redo_io(const IORequest &type, const page_id_t &page_id, const page_size_t &page_size, ulint byte_offset, ulint len, void *buf)
Read or write redo log data (synchronous buffered IO).
Definition: fil0fil.cc:7257
Mini-transaction handle and buffer.
Definition: mtr0mtr.h:164
page_no_t fil_space_get_size(space_id_t space_id)
Returns the size of the space in pages.
Definition: fil0fil.cc:3138
dberr_t fil_check_extend_space(fil_node_t *file)
Callback to check tablespace size with space header size and extend Caller must own the Fil_shard mut...
Definition: fil0fil.cc:10101
void fil_space_open_if_needed(fil_space_t *space)
During crash recovery, open a tablespace if it had not been opened yet, to get valid size and flags...
Definition: fil0fil.h:1578
ulint fil_n_pending_log_flushes
Number of pending redo log flushes.
Definition: fil0fil.cc:251
char * fil_space_get_first_path(space_id_t space_id)
Returns the path from the first fil_node_t found with this space ID.
Definition: fil0fil.cc:3112
#define UT_LIST_NODE_T(TYPE)
Definition: innodb_utility.h:40
#define false
Definition: config_static.h:43
UNIV_INLINE uint16_t mach_read_from_2(const byte *b)
The following function is used to fetch data from 2 consecutive bytes.
size_t n_pending
count of pending i/o&#39;s; is_open must be true if nonzero
Definition: fil0fil.h:149
static void normalize(std::string &path)
Normalizes a directory path for the current OS: On Windows, we convert &#39;/&#39; to &#39;\&#39;, else we convert &#39;\&#39; to &#39;/&#39;.
Definition: fil0fil.h:529
bool stop_new_ops
We set this true when we start deleting a single-table tablespace.
Definition: fil0fil.h:201
const char general_space_name[]
This tablespace name is used internally during recovery to open a general tablespace before the data ...
Definition: fil0fil.cc:236
byte * fil_tablespace_redo_encryption(byte *ptr, const byte *end, space_id_t space_id)
Parse and process an encryption redo record.
Definition: fil0fil.cc:9378
constexpr page_type_t FIL_PAGE_ENCRYPTED_RTREE
Encrypted R-tree page.
Definition: fil0fil.h:839
dberr_t fil_tablespace_iterate(dict_table_t *table, ulint n_io_buffers, PageCallback &callback)
Iterate over all the pages in the tablespace.
Definition: fil0fil.cc:7909
bool is_ancestor(const Fil_path &other) const
Check if m_path is the parent of other.m_path.
Definition: fil0fil.h:425
void fil_space_close(space_id_t space_id)
Close each file of a tablespace if open.
Definition: fil0fil.cc:3208
fil_space_t * fil_space_get(space_id_t space_id)
Look up a tablespace.
Definition: fil0fil.cc:1945
ulint redo_skipped_count
Reference count for operations who want to skip redo log in the file space in order to make fsp_space...
Definition: fil0fil.h:206
bool operator==(const Fil_path &lhs) const
Determine if this path is equal to the other path.
Definition: fil0fil.h:394
int64_t modification_counter
number of writes to the file since the system was started
Definition: fil0fil.h:158
const char * table_name
Definition: rules_table_service.cc:55
Fil_state fil_tablespace_path_equals(dd::Object_id dd_object_id, space_id_t space_id, const char *space_name, std::string old_path, std::string *new_path)
Lookup the tablespace ID and return the path to the file.
Definition: fil0fil.cc:8875