MySQL  8.0.19
Source Code Documentation
fil0fil.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 1995, 2019, Oracle and/or its affiliates. All Rights Reserved.
4 
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License, version 2.0, as published by the
7 Free Software Foundation.
8 
9 This program is also distributed with certain software (including but not
10 limited to OpenSSL) that is licensed under separate terms, as designated in a
11 particular file or component or in included license documentation. The authors
12 of MySQL hereby grant you an additional permission to link the program and
13 your derivative works with the separately licensed software that they have
14 included with MySQL.
15 
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
19 for more details.
20 
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc.,
23 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 
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 /** Maximum number of tablespaces to be scanned by a thread while scanning
53 for available tablespaces during server startup. This is a hard maximum.
54 If the number of files to be scanned is more than
55 FIL_SCAN_MAX_TABLESPACES_PER_THREAD,
56 then additional threads will be spawned to scan the additional files in
57 parallel. */
58 constexpr size_t FIL_SCAN_MAX_TABLESPACES_PER_THREAD = 8000;
59 
60 /** Maximum number of threads that will be used for scanning the tablespace
61 files. This can be further adjusted depending on the number of available
62 cores. */
63 constexpr size_t FIL_SCAN_MAX_THREADS = 16;
64 
65 /** Number of threads per core. */
66 constexpr size_t FIL_SCAN_THREADS_PER_CORE = 2;
67 
68 /** Calculate the number of threads that can be spawned to scan the given
69 number of files taking into the consideration, number of cores available
70 on the machine.
71 @param[in] num_files Number of files to be scanned
72 @return number of threads to be spawned for scanning the files */
73 size_t fil_get_scan_threads(size_t num_files);
74 
75 /** This tablespace name is used internally during file discovery to open a
76 general tablespace before the data dictionary is recovered and available. */
77 static constexpr char general_space_name[] = "innodb_general";
78 
79 /** This tablespace name is used as the prefix for implicit undo tablespaces
80 and during file discovery to open an undo tablespace before the DD is
81 recovered and available. */
82 static constexpr char undo_space_name[] = "innodb_undo";
83 
84 extern volatile bool recv_recovery_on;
85 
86 #ifdef UNIV_HOTBACKUP
87 #include <unordered_set>
88 using Dir_set = std::unordered_set<std::string>;
89 extern Dir_set rem_gen_ts_dirs;
90 extern bool replay_in_datadir;
91 #endif /* UNIV_HOTBACKUP */
92 
93 // Forward declaration
94 struct trx_t;
95 class page_id_t;
96 
97 using Filenames = std::vector<std::string, ut_allocator<std::string>>;
98 using Space_ids = std::vector<space_id_t, ut_allocator<space_id_t>>;
99 
100 /** File types */
101 enum fil_type_t : uint8_t {
102  /** temporary tablespace (temporary undo log or tables) */
104  /** a tablespace that is being imported (no logging until finished) */
106  /** persistent tablespace (for system, undo log or tables) */
108  /** redo log covering changes to files of FIL_TYPE_TABLESPACE */
110 };
111 
112 /** Result of comparing a path. */
113 enum class Fil_state {
114  /** The path matches what was found during the scan. */
115  MATCHES,
116 
117  /** No MLOG_FILE_DELETE record and the file could not be found. */
118  MISSING,
119 
120  /** A MLOG_FILE_DELETE was found, file was deleted. */
121  DELETED,
122 
123  /** Space ID matches but the paths don't match. */
124  MOVED,
125 
126  /** Tablespace and/or filename was renamed. The DDL log will handle
127  this case. */
128  RENAMED
129 };
130 
131 /** Check if fil_type is any of FIL_TYPE_TEMPORARY, FIL_TYPE_IMPORT
132 or FIL_TYPE_TABLESPACE.
133 @param[in] type variable of type fil_type_t
134 @return true if any of FIL_TYPE_TEMPORARY, FIL_TYPE_IMPORT
135 or FIL_TYPE_TABLESPACE */
137  return (type == FIL_TYPE_TEMPORARY || type == FIL_TYPE_IMPORT ||
139 }
140 
141 struct fil_space_t;
142 
143 /** File node of a tablespace or the log data space */
144 struct fil_node_t {
146 
147  /** tablespace containing this file */
149 
150  /** file name; protected by Fil_shard::m_mutex and log_sys->mutex. */
151  char *name;
152 
153  /** whether this file is open. Note: We set the is_open flag after
154  we increase the write the MLOG_FILE_OPEN record to redo log. Therefore
155  we increment the in_use reference count before setting the OPEN flag. */
156  bool is_open;
157 
158  /** file handle (valid if is_open) */
160 
161  /** event that groups and serializes calls to fsync */
163 
164  /** whether the file actually is a raw device or disk partition */
166 
167  /** size of the file in database pages (0 if not known yet);
168  the possible last incomplete megabyte may be ignored
169  if space->id == 0 */
171 
172  /** Size of the file when last flushed, used to force the flush when file
173  grows to keep the filesystem metadata synced when using O_DIRECT_NO_FSYNC */
175 
176  /** initial size of the file in database pages;
177  FIL_IBD_FILE_INITIAL_SIZE by default */
179 
180  /** maximum size of the file in database pages */
182 
183  /** count of pending i/o's; is_open must be true if nonzero */
184  size_t n_pending;
185 
186  /** count of pending flushes; is_open must be true if nonzero */
188 
189  /** e.g., when a file is being extended or just opened. */
190  size_t in_use;
191 
192  /** number of writes to the file since the system was started */
194 
195  /** the modification_counter of the latest flush to disk */
196  int64_t flush_counter;
197 
198  /** link to the fil_system->LRU list (keeping track of open files) */
200 
201  /** whether the file system of this file supports PUNCH HOLE */
203 
204  /** block size to use for punching holes */
205  size_t block_size;
206 
207  /** whether atomic write is enabled for this file */
209 
210  /** FIL_NODE_MAGIC_N */
211  size_t magic_n;
212 };
213 
214 /* Type of (un)encryption operation in progress for Tablespace. */
216 
217 /** Tablespace or log data space */
218 struct fil_space_t {
220  using Files = std::vector<fil_node_t, ut_allocator<fil_node_t>>;
221 
222  /** Tablespace name */
223  char *name;
224 
225  /** Tablespace ID */
227 
228  /** true if we want to rename the .ibd file of tablespace and
229  want to stop temporarily posting of new i/o requests on the file */
230  bool stop_ios;
231 
232  /** We set this true when we start deleting a single-table
233  tablespace. When this is set following new ops are not allowed:
234  * read IO request
235  * ibuf merge
236  * file flush
237  Note that we can still possibly have new write operations because we
238  don't check this flag when doing flush batches. */
240 
241 #ifdef UNIV_DEBUG
242  /** Reference count for operations who want to skip redo log in
243  the file space in order to make fsp_space_modify_check pass. */
245 #endif /* UNIV_DEBUG */
246 
247  /** Purpose */
249 
250  /** Files attached to this tablespace. Note: Only the system tablespace
251  can have multiple files, this is a legacy issue. */
253 
254  /** Tablespace file size in pages; 0 if not known yet */
256 
257  /** FSP_SIZE in the tablespace header; 0 if not known yet */
259 
260  /** Length of the FSP_FREE list */
261  uint32_t free_len;
262 
263  /** Contents of FSP_FREE_LIMIT */
265 
266  /** Tablespace flags; see fsp_flags_is_valid() and
267  page_size_t(ulint) (constructor).
268  This is protected by space->latch and tablespace MDL */
269  uint32_t flags;
270 
271  /** Number of reserved free extents for ongoing operations like
272  B-tree page split */
274 
275  /** This is positive when flushing the tablespace to disk;
276  dropping of the tablespace is forbidden if this is positive */
278 
279  /** This is positive when we have pending operations against this
280  tablespace. The pending operations can be ibuf merges or lock
281  validation code trying to read a block. Dropping of the tablespace
282  is forbidden if this is positive. Protected by Fil_shard::m_mutex. */
283  uint32_t n_pending_ops;
284 
285 #ifndef UNIV_HOTBACKUP
286  /** Latch protecting the file space storage allocation */
288 #endif /* !UNIV_HOTBACKUP */
289 
290  /** List of spaces with at least one unflushed file we have
291  written to */
293 
294  /** true if this space is currently in unflushed_spaces */
296 
297  /** Compression algorithm */
299 
300  /** Encryption algorithm */
302 
303  /** Encrypt key */
305 
306  /** Encrypt key length*/
308 
309  /** Encrypt initial vector */
311 
312  /** Encryption is in progress */
314 
315  /** Release the reserved free extents.
316  @param[in] n_reserved number of reserved extents */
317  void release_free_extents(ulint n_reserved);
318 
319  /** FIL_SPACE_MAGIC_N */
320  ulint magic_n;
321 
322  /** System tablespace */
324 
325  /** Redo log tablespace */
327 
328 #ifdef UNIV_DEBUG
329  /** Print the extent descriptor pages of this tablespace into
330  the given output stream.
331  @param[in] out the output stream.
332  @return the output stream. */
333  std::ostream &print_xdes_pages(std::ostream &out) const;
334 
335  /** Print the extent descriptor pages of this tablespace into
336  the given file.
337  @param[in] filename the output file name. */
338  void print_xdes_pages(const char *filename) const;
339 #endif /* UNIV_DEBUG */
340 };
341 
342 /** Value of fil_space_t::magic_n */
343 constexpr size_t FIL_SPACE_MAGIC_N = 89472;
344 
345 /** Value of fil_node_t::magic_n */
346 constexpr size_t FIL_NODE_MAGIC_N = 89389;
347 
348 /** Common InnoDB file extentions */
349 enum ib_file_suffix { NO_EXT = 0, IBD = 1, CFG = 2, CFP = 3, IBT = 4, IBU = 5 };
350 
351 extern const char *dot_ext[];
352 
353 #define DOT_IBD dot_ext[IBD]
354 #define DOT_CFG dot_ext[CFG]
355 #define DOT_CFP dot_ext[CFP]
356 #define DOT_IBT dot_ext[IBT]
357 #define DOT_IBU dot_ext[IBU]
358 
359 #ifdef _WIN32
360 /* Initialization of m_abs_path() produces warning C4351:
361 "new behavior: elements of array '...' will be default initialized."
362 See https://msdn.microsoft.com/en-us/library/1ywe7hcy.aspx */
363 #pragma warning(disable : 4351)
364 #endif /* _WIN32 */
365 
366 /** Wrapper for a path to a directory that may or may not exist. */
367 class Fil_path {
368  public:
369  /** schema '/' table separator */
370  static constexpr auto DB_SEPARATOR = '/';
371 
372  /** OS specific path separator. */
373  static constexpr auto OS_SEPARATOR = OS_PATH_SEPARATOR;
374 
375  /** Directory separators that are supported. */
376  static constexpr auto SEPARATOR = "\\/";
377 #ifdef _WIN32
378  static constexpr auto DOT_SLASH = ".\\";
379  static constexpr auto DOT_DOT_SLASH = "..\\";
380  static constexpr auto SLASH_DOT_DOT_SLASH = "\\..\\";
381 #else
382  static constexpr auto DOT_SLASH = "./";
383  static constexpr auto DOT_DOT_SLASH = "../";
384  static constexpr auto SLASH_DOT_DOT_SLASH = "/../";
385 #endif /* _WIN32 */
386 
387  /** Various types of file paths. */
389 
390  /** Default constructor. Defaults to MySQL_datadir_path. */
391  Fil_path();
392 
393  /** Constructor
394  @param[in] path Path, not necessarily NUL terminated
395  @param[in] len Length of path
396  @param[in] normalize_path If false, it's the callers responsibility to
397  ensure that the path is normalized. */
398  explicit Fil_path(const char *path, size_t len, bool normalize_path = false);
399 
400  /** Constructor
401  @param[in] path Path, not necessarily NUL terminated
402  @param[in] normalize_path If false, it's the callers responsibility to
403  ensure that the path is normalized. */
404  explicit Fil_path(const char *path, bool normalize_path = false);
405 
406  /** Constructor
407  @param[in] path pathname (may also include the file basename)
408  @param[in] normalize_path If false, it's the callers responsibility to
409  ensure that the path is normalized. */
410  explicit Fil_path(const std::string &path, bool normalize_path = false);
411 
412  /** Implicit type conversion
413  @return pointer to m_path.c_str() */
414  operator const char *() const { return (m_path.c_str()); }
415 
416  /** Explicit type conversion
417  @return pointer to m_path.c_str() */
418  const char *operator()() const { return (m_path.c_str()); }
419 
420  /** @return the value of m_path */
421  const std::string &path() const MY_ATTRIBUTE((warn_unused_result)) {
422  return (m_path);
423  }
424 
425  /** @return the length of m_path */
426  size_t len() const MY_ATTRIBUTE((warn_unused_result)) {
427  return (m_path.length());
428  }
429 
430  /** Return the absolute path by value. If m_abs_path is null, calculate
431  it and return it by value without trying to reset this const object.
432  m_abs_path can be empty if the path did not exist when this object
433  was constructed.
434  @return the absolute path by value. */
435  const std::string abs_path() const MY_ATTRIBUTE((warn_unused_result)) {
436  if (m_abs_path.empty()) {
437  return (get_real_path(m_path));
438  }
439 
440  return (m_abs_path);
441  }
442 
443  /** @return the length of m_abs_path */
444  size_t abs_len() const MY_ATTRIBUTE((warn_unused_result)) {
445  return (m_abs_path.length());
446  }
447 
448  /** Check if m_path is the same as this other path.
449  @param[in] other directory path to compare to
450  @return true if m_path is the same as path */
451  bool is_same_as(const Fil_path &other) const
452  MY_ATTRIBUTE((warn_unused_result)) {
453  if (path().empty() || other.path().empty()) {
454  return (false);
455  }
456 
457  return (abs_path() == other.abs_path());
458  }
459 
460  /** Determine if this path is equal to the other path.
461  @param[in] other path to compare to
462  @return true if the paths are the same */
463  bool operator==(const Fil_path &other) const { return (is_same_as(other)); }
464 
465  /** Check if this path is the same as the other path.
466  @param[in] other directory path to compare to
467  @return true if this path is the same as the other path */
468  bool is_same_as(const std::string &other) const
469  MY_ATTRIBUTE((warn_unused_result)) {
470  if (path().empty() || other.empty()) {
471  return (false);
472  }
473 
474  Fil_path other_path(other);
475 
476  return (abs_path() == other_path.abs_path());
477  }
478 
479  /** Check if two path strings are equal. Put them into Fil_path objects
480  so that they can be compared correctly.
481  @param[in] first first path to check
482  @param[in] second socond path to check
483  @return true if these two paths are the same */
484  static bool is_same_as(const std::string &first, const std::string &second)
485  MY_ATTRIBUTE((warn_unused_result)) {
486  if (first.empty() || second.empty()) {
487  return (false);
488  }
489 
490  Fil_path first_path(first);
491  Fil_path second_path(second);
492 
493  return (first_path == second_path);
494  }
495 
496  /** Check if m_path is the parent of the other path.
497  @param[in] other path to compare to
498  @return true if m_path is an ancestor of name */
499  bool is_ancestor(const Fil_path &other) const
500  MY_ATTRIBUTE((warn_unused_result)) {
501  if (path().empty() || other.path().empty()) {
502  return (false);
503  }
504 
505  const std::string ancestor = abs_path();
506  const std::string descendant = other.abs_path();
507 
508  if (descendant.length() <= ancestor.length()) {
509  return (false);
510  }
511 
512  return (std::equal(ancestor.begin(), ancestor.end(), descendant.begin()));
513  }
514 
515  /** Check if this Fil_path is an ancestor of the other path.
516  @param[in] other path to compare to
517  @return true if this Fil_path is an ancestor of the other path */
518  bool is_ancestor(const std::string &other) const
519  MY_ATTRIBUTE((warn_unused_result)) {
520  if (path().empty() || other.empty()) {
521  return (false);
522  }
523 
524  Fil_path descendant(other);
525 
526  return (is_ancestor(descendant));
527  }
528 
529  /** Check if the first path is an ancestor of the second.
530  Do not assume that these paths have been converted to real paths
531  and are ready to compare. If the two paths are the same
532  we will return false.
533  @param[in] first Parent path to check
534  @param[in] second Descendent path to check
535  @return true if the first path is an ancestor of the second */
536  static bool is_ancestor(const std::string &first, const std::string &second)
537  MY_ATTRIBUTE((warn_unused_result)) {
538  if (first.empty() || second.empty()) {
539  return (false);
540  }
541 
542  Fil_path ancestor(first);
543  Fil_path descendant(second);
544 
545  return (ancestor.is_ancestor(descendant));
546  }
547 
548  /** @return true if m_path exists and is a file. */
549  bool is_file_and_exists() const MY_ATTRIBUTE((warn_unused_result));
550 
551  /** @return true if m_path exists and is a directory. */
552  bool is_directory_and_exists() const MY_ATTRIBUTE((warn_unused_result));
553 
554  /** This validation is only for ':'.
555  @return true if the path is valid. */
556  bool is_valid() const MY_ATTRIBUTE((warn_unused_result));
557 
558  /** Determine if m_path contains a circular section like "/anydir/../"
559  Fil_path::normalize() must be run before this.
560  @return true if a circular section if found, false if not */
561  bool is_circular() const MY_ATTRIBUTE((warn_unused_result));
562 
563  /** Determine if the file or directory is considered HIDDEN.
564  Most file systems identify the HIDDEN attribute by a '.' preceeding the
565  basename. On Windows, a HIDDEN path is identified by a file attribute.
566  We will use the preceeding '.' to indicate a HIDDEN attribute on ALL
567  file systems so that InnoDB tablespaces and their directory structure
568  remain portable.
569  @param[in] path The full or relative path of a file or directory.
570  @return true if the directory or path is HIDDEN. */
571  static bool is_hidden(std::string path);
572 
573 #ifdef _WIN32
574  /** Use the WIN32_FIND_DATA struncture to determine if the file or
575  directory is HIDDEN. Consider a SYSTEM attribute also as an indicator
576  that it is HIDDEN to InnoDB.
577  @param[in] dirent A directory entry obtained from a call to FindFirstFile()
578  or FindNextFile()
579  @return true if the directory or path is HIDDEN. */
580  static bool is_hidden(WIN32_FIND_DATA &dirent);
581 #endif /* WIN32 */
582 
583  /** Remove quotes e.g., 'a;b' or "a;b" -> a;b.
584  This will only remove the quotes if they are matching on the whole string.
585  This will not work if each delimited string is quoted since this is called
586  before the string is parsed.
587  @return pathspec with the quotes stripped */
588  static std::string remove_quotes(const char *pathspec) {
589  std::string path(pathspec);
590 
591  ut_ad(!path.empty());
592 
593  if (path.size() >= 2 && ((path.front() == '\'' && path.back() == '\'') ||
594  (path.front() == '"' && path.back() == '"'))) {
595  path.erase(0, 1);
596  path.erase(path.size() - 1);
597  }
598 
599  return (path);
600  }
601 
602  /** @return true if the path is an absolute path. */
603  bool is_relative_path() const MY_ATTRIBUTE((warn_unused_result)) {
604  return (type_of_path(m_path) == relative);
605  }
606 
607  /** @return true if the path is an absolute path. */
608  bool is_absolute_path() const MY_ATTRIBUTE((warn_unused_result)) {
609  return (type_of_path(m_path) == absolute);
610  }
611 
612  /** Determine if a path is an absolute path or not.
613  @param[in] path OS directory or file path to evaluate
614  @retval true if an absolute path
615  @retval false if a relative path */
616  static bool is_absolute_path(const std::string &path) {
617  return (type_of_path(path) == absolute);
618  }
619 
620  /** Determine if a path is an absolute path or not.
621  @param[in] path OS directory or file path to evaluate
622  @retval true if an absolute path
623  @retval false if a relative path */
624  static path_type type_of_path(const std::string &path)
625  MY_ATTRIBUTE((warn_unused_result)) {
626  if (path.empty()) {
627  return (invalid);
628  }
629 
630  /* The most likely type is a file name only with no separators. */
631  if (path.find('\\', 0) == std::string::npos &&
632  path.find('/', 0) == std::string::npos) {
633  return (file_name_only);
634  }
635 
636  /* Any string that starts with an OS_SEPARATOR is
637  an absolute path. This includes any OS and even
638  paths like "\\Host\share" on Windows. */
639  if (path.at(0) == '\\' || path.at(0) == '/') {
640  return (absolute);
641  }
642 
643 #ifdef _WIN32
644  /* Windows may have an absolute path like 'A:\' */
645  if (path.length() >= 3 && isalpha(path.at(0)) && path.at(1) == ':' &&
646  (path.at(2) == '\\' || path.at(2) == '/')) {
647  return (absolute);
648  }
649 #endif /* _WIN32 */
650 
651  /* Since it contains separators and is not an absolute path,
652  it must be a relative path. */
653  return (relative);
654  }
655 
656  /* Check if the path is prefixed with pattern.
657  @return true if prefix matches */
658  static bool has_prefix(const std::string &path, const std::string prefix)
659  MY_ATTRIBUTE((warn_unused_result)) {
660  return (path.size() >= prefix.size() &&
661  std::equal(prefix.begin(), prefix.end(), path.begin()));
662  }
663 
664  /** Normalize a directory path for the current OS:
665  On Windows, we convert '/' to '\', else we convert '\' to '/'.
666  @param[in,out] path Directory and file path */
667  static void normalize(std::string &path) {
668  for (auto &c : path) {
669  if (c == OS_PATH_SEPARATOR_ALT) {
670  c = OS_SEPARATOR;
671  }
672  }
673  }
674 
675  /** Normalize a directory path for the current OS:
676  On Windows, we convert '/' to '\', else we convert '\' to '/'.
677  @param[in,out] path A NUL terminated path */
678  static void normalize(char *path) {
679  for (auto ptr = path; *ptr; ++ptr) {
680  if (*ptr == OS_PATH_SEPARATOR_ALT) {
681  *ptr = OS_SEPARATOR;
682  }
683  }
684  }
685 
686  /** @return true if the path exists and is a file . */
687  static os_file_type_t get_file_type(const std::string &path)
688  MY_ATTRIBUTE((warn_unused_result));
689 
690  /** Return a string to display the file type of a path.
691  @param[in] path path name
692  @return true if the path exists and is a file . */
693  static const char *get_file_type_string(const std::string &path);
694 
695  /** Return a string to display the file type of a path.
696  @param[in] type OS file type
697  @return true if the path exists and is a file . */
698  static const char *get_file_type_string(os_file_type_t type);
699 
700  /** Get the real path for a directory or a file name. This path can be
701  used to compare with another absolute path. It will be converted to
702  lower case on case insensitive file systems and if it is a directory,
703  it will end with a directory separator. The call to my_realpath() may
704  fail on non-Windows platforms if the path does not exist. If so, the
705  parameter 'force' determines what to return.
706  @param[in] path directory or filename to convert to a real path
707  @param[in] force if true and my_realpath() fails, use the path provided.
708  if false and my_realpath() fails, return a null string.
709  @return the absolute path prepared for making comparisons with other real
710  paths. */
711  static std::string get_real_path(const std::string &path, bool force = true)
712  MY_ATTRIBUTE((warn_unused_result));
713 
714  /** Check if the name is an undo tablespace name.
715  @param[in] name Tablespace name
716  @return true if it is an undo tablespace name */
717  static bool is_undo_tablespace_name(const std::string &name)
718  MY_ATTRIBUTE((warn_unused_result));
719 
720  /** Check if the file has the the specified suffix
721  @param[in] sfx suffix to look for
722  @param[in] path Filename to check
723  @return true if it has the the ".ibd" suffix. */
724  static bool has_suffix(ib_file_suffix sfx, const std::string &path) {
725  const auto suffix = dot_ext[sfx];
726  size_t len = strlen(suffix);
727 
728  return (path.size() >= len &&
729  path.compare(path.size() - len, len, suffix) == 0);
730  }
731 
732  /** Check if the file has the the specified suffix and truncate
733  @param[in] sfx suffix to look for
734  @param[in,out] path Filename to check
735  @return true if the suffix is found and truncated. */
736  static bool truncate_suffix(ib_file_suffix sfx, std::string &path) {
737  const auto suffix = dot_ext[sfx];
738  size_t len = strlen(suffix);
739 
740  if (path.size() < len ||
741  path.compare(path.size() - len, len, suffix) != 0) {
742  return (false);
743  }
744 
745  path.resize(path.size() - len);
746  return (true);
747  }
748 
749  /** Check if a character is a path separator ('\' or '/')
750  @param[in] c Character to check
751  @return true if it is a separator */
752  static bool is_separator(char c) { return (c == '\\' || c == '/'); }
753 
754  /** Allocate and build a file name from a path, a table or
755  tablespace name and a suffix.
756  @param[in] path_in nullptr or the direcory path or
757  the full path and filename
758  @param[in] name_in nullptr if path is full, or
759  Table/Tablespace name
760  @param[in] ext the file extension to use
761  @param[in] trim whether last name on the path should
762  be trimmed
763  @return own: file name; must be freed by ut_free() */
764  static char *make(const std::string &path_in, const std::string &name_in,
765  ib_file_suffix ext, bool trim = false)
766  MY_ATTRIBUTE((warn_unused_result));
767 
768  /** Allocate and build a CFG file name from a path.
769  @param[in] path_in Full path to the filename
770  @return own: file name; must be freed by ut_free() */
771  static char *make_cfg(const std::string &path_in)
772  MY_ATTRIBUTE((warn_unused_result)) {
773  return (make(path_in, "", CFG));
774  }
775 
776  /** Allocate and build a CFP file name from a path.
777  @param[in] path_in Full path to the filename
778  @return own: file name; must be freed by ut_free() */
779  static char *make_cfp(const std::string &path_in)
780  MY_ATTRIBUTE((warn_unused_result)) {
781  return (make(path_in, "", CFP));
782  }
783 
784  /** Allocate and build a file name from a path, a table or
785  tablespace name and a suffix.
786  @param[in] path_in nullptr or the direcory path or
787  the full path and filename
788  @param[in] name_in nullptr if path is full, or
789  Table/Tablespace name
790  @return own: file name; must be freed by ut_free() */
791  static char *make_ibd(const std::string &path_in, const std::string &name_in)
792  MY_ATTRIBUTE((warn_unused_result)) {
793  return (make(path_in, name_in, IBD));
794  }
795 
796  /** Allocate and build a file name from a path, a table or
797  tablespace name and a suffix.
798  @param[in] name_in Table/Tablespace name
799  @return own: file name; must be freed by ut_free() */
800  static char *make_ibd_from_table_name(const std::string &name_in)
801  MY_ATTRIBUTE((warn_unused_result)) {
802  return (make("", name_in, IBD));
803  }
804 
805  /** Create an IBD path name after replacing the basename in an old path
806  with a new basename. The old_path is a full path name including the
807  extension. The tablename is in the normal form "schema/tablename".
808  @param[in] path_in Pathname
809  @param[in] name_in Contains new base name
810  @param[in] extn File extension
811  @return new full pathname */
812  static std::string make_new_path(const std::string &path_in,
813  const std::string &name_in,
814  ib_file_suffix extn)
815  MY_ATTRIBUTE((warn_unused_result));
816 
817  /** Parse file-per-table file name and build Innodb dictionary table name.
818  @param[in] file_path File name with complete path
819  @param[in] extn File extension
820  @param[out] dict_name Innodb dictionary table name
821  @return true, if successful. */
822  static bool parse_file_path(const std::string &file_path, ib_file_suffix extn,
823  std::string &dict_name);
824 
825  /** This function reduces a null-terminated full remote path name
826  into the path that is sent by MySQL for DATA DIRECTORY clause.
827  It replaces the 'databasename/tablename.ibd' found at the end of the
828  path with just 'tablename'.
829 
830  Since the result is always smaller than the path sent in, no new
831  memory is allocated. The caller should allocate memory for the path
832  sent in. This function manipulates that path in place. If the path
833  format is not as expected, set data_dir_path to "" and return.
834 
835  The result is used to inform a SHOW CREATE TABLE command.
836  @param[in,out] data_dir_path Full path/data_dir_path */
837  static void make_data_dir_path(char *data_dir_path);
838 
839 #ifndef UNIV_HOTBACKUP
840  /** Check if the filepath provided is in a valid placement.
841  1) File-per-table must be in a dir named for the schema.
842  2) File-per-table must not be in the datadir.
843  3) General tablespace must no be under the datadir.
844  @param[in] space_name tablespace name
845  @param[in] path filepath to validate
846  @retval true if the filepath is a valid datafile location */
847  static bool is_valid_location(const char *space_name,
848  const std::string &path);
849 
850  /** Convert filename to the file system charset format.
851  @param[in,out] name Filename to convert */
852  static void convert_to_filename_charset(std::string &name);
853 
854  /** Convert to lower case using the file system charset.
855  @param[in,out] path Filepath to convert */
856  static void convert_to_lower_case(std::string &path);
857 
858 #endif /* !UNIV_HOTBACKUP */
859 
860  protected:
861  /** Path to a file or directory. */
862  std::string m_path;
863 
864  /** A full absolute path to the same file. */
865  std::string m_abs_path;
866 };
867 
868 /** The MySQL server --datadir value */
870 
871 /** The MySQL server --innodb-undo-directory value */
873 
874 /** Initial size of a single-table tablespace in pages */
875 constexpr size_t FIL_IBD_FILE_INITIAL_SIZE = 7;
876 constexpr size_t FIL_IBT_FILE_INITIAL_SIZE = 5;
877 
878 /** An empty tablespace (CREATE TABLESPACE) has minimum
879 of 4 pages and an empty CREATE TABLE (file_per_table) has 6 pages.
880 Minimum of these two is 4 */
881 constexpr size_t FIL_IBD_FILE_INITIAL_SIZE_5_7 = 4;
882 
883 /** 'null' (undefined) page offset in the context of file spaces */
884 constexpr page_no_t FIL_NULL = std::numeric_limits<page_no_t>::max();
885 
886 /** Maximum Page Number, one less than FIL_NULL */
887 constexpr page_no_t PAGE_NO_MAX = std::numeric_limits<page_no_t>::max() - 1;
888 
889 /** Unknown space id */
890 constexpr space_id_t SPACE_UNKNOWN = std::numeric_limits<space_id_t>::max();
891 
892 /* Space address data type; this is intended to be used when
893 addresses accurate to a byte are stored in file pages. If the page part
894 of the address is FIL_NULL, the address is considered undefined. */
895 
896 /** 'type' definition in C: an address stored in a file page is a
897 string of bytes */
899 
900 /** File space address */
901 struct fil_addr_t {
902  /* Default constructor */
904 
905  /** Constructor
906  @param[in] p Logical page number
907  @param[in] boff Offset within the page */
908  fil_addr_t(page_no_t p, uint32_t boff) : page(p), boffset(boff) {}
909 
910  /** Compare to instances
911  @param[in] rhs Instance to compare with
912  @return true if the page number and page offset are equal */
913  bool is_equal(const fil_addr_t &rhs) const {
914  return (page == rhs.page && boffset == rhs.boffset);
915  }
916 
917  /** Check if the file address is null.
918  @return true if null */
919  bool is_null() const { return (page == FIL_NULL && boffset == 0); }
920 
921  /** Print a string representation.
922  @param[in,out] out Stream to write to */
923  std::ostream &print(std::ostream &out) const {
924  out << "[fil_addr_t: page=" << page << ", boffset=" << boffset << "]";
925 
926  return (out);
927  }
928 
929  /** Page number within a space */
931 
932  /** Byte offset within the page */
933  uint32_t boffset;
934 };
935 
936 /* For printing fil_addr_t to a stream.
937 @param[in,out] out Stream to write to
938 @param[in] obj fil_addr_t instance to write */
939 inline std::ostream &operator<<(std::ostream &out, const fil_addr_t &obj) {
940  return (obj.print(out));
941 }
942 
943 /** The null file address */
945 
946 using page_type_t = uint16_t;
947 
948 /** File page types (values of FIL_PAGE_TYPE) @{ */
949 /** B-tree node */
950 constexpr page_type_t FIL_PAGE_INDEX = 17855;
951 
952 /** R-tree node */
953 constexpr page_type_t FIL_PAGE_RTREE = 17854;
954 
955 /** Tablespace SDI Index page */
956 constexpr page_type_t FIL_PAGE_SDI = 17853;
957 
958 /** Undo log page */
960 
961 /** Index node */
963 
964 /** Insert buffer free list */
966 
967 /* File page types introduced in MySQL/InnoDB 5.1.7 */
968 /** Freshly allocated page */
970 
971 /** Insert buffer bitmap */
973 
974 /** System page */
976 
977 /** Transaction system data */
979 
980 /** File space header */
982 
983 /** Extent descriptor page */
985 
986 /** Uncompressed BLOB page */
988 
989 /** First compressed BLOB page */
991 
992 /** Subsequent compressed BLOB page */
994 
995 /** In old tablespaces, garbage in FIL_PAGE_TYPE is replaced with
996 this value when flushing pages. */
998 
999 /** Compressed page */
1001 
1002 /** Encrypted page */
1004 
1005 /** Compressed and Encrypted page */
1007 
1008 /** Encrypted R-tree page */
1010 
1011 /** Uncompressed SDI BLOB page */
1013 
1014 /** Commpressed SDI BLOB page */
1016 
1017 /** Available for future use */
1019 
1020 /** Rollback Segment Array page */
1022 
1023 /** Index pages of uncompressed LOB */
1025 
1026 /** Data pages of uncompressed LOB */
1028 
1029 /** The first page of an uncompressed LOB */
1031 
1032 /** The first page of a compressed LOB */
1034 
1035 /** Data pages of compressed LOB */
1037 
1038 /** Index pages of compressed LOB. This page contains an array of
1039 z_index_entry_t objects.*/
1041 
1042 /** Fragment pages of compressed LOB. */
1044 
1045 /** Index pages of fragment pages (compressed LOB). */
1047 
1048 /** Used by i_s.cc to index into the text description. */
1050 
1051 /** Check whether the page type is index (Btree or Rtree or SDI) type */
1052 #define fil_page_type_is_index(page_type) \
1053  (page_type == FIL_PAGE_INDEX || page_type == FIL_PAGE_SDI || \
1054  page_type == FIL_PAGE_RTREE)
1055 
1056 /** Check whether the page is index page (either regular Btree index or Rtree
1057 index */
1058 #define fil_page_index_page_check(page) \
1059  fil_page_type_is_index(fil_page_get_type(page))
1060 
1061 /** The number of fsyncs done to the log */
1062 extern ulint fil_n_log_flushes;
1063 
1064 /** Number of pending redo log flushes */
1065 extern ulint fil_n_pending_log_flushes;
1066 /** Number of pending tablespace flushes */
1068 
1069 /** Number of files currently open */
1070 extern ulint fil_n_file_opened;
1071 
1072 /** Look up a tablespace.
1073 The caller should hold an InnoDB table lock or a MDL that prevents
1074 the tablespace from being dropped during the operation,
1075 or the caller should be in single-threaded crash recovery mode
1076 (no user connections that could drop tablespaces).
1077 If this is not the case, fil_space_acquire() and fil_space_release()
1078 should be used instead.
1079 @param[in] space_id Tablespace ID
1080 @return tablespace, or nullptr if not found */
1082  MY_ATTRIBUTE((warn_unused_result));
1083 
1084 #ifndef UNIV_HOTBACKUP
1085 /** Returns the latch of a file space.
1086 @param[in] space_id Tablespace ID
1087 @return latch protecting storage allocation */
1089  MY_ATTRIBUTE((warn_unused_result));
1090 
1091 #ifdef UNIV_DEBUG
1092 /** Gets the type of a file space.
1093 @param[in] space_id Tablespace ID
1094 @return file type */
1096  MY_ATTRIBUTE((warn_unused_result));
1097 #endif /* UNIV_DEBUG */
1098 
1099 /** Note that a tablespace has been imported.
1100 It is initially marked as FIL_TYPE_IMPORT so that no logging is
1101 done during the import process when the space ID is stamped to each page.
1102 Now we change it to FIL_SPACE_TABLESPACE to start redo and undo logging.
1103 NOTE: temporary tablespaces are never imported.
1104 @param[in] space_id Tablespace ID */
1105 void fil_space_set_imported(space_id_t space_id);
1106 #endif /* !UNIV_HOTBACKUP */
1107 
1108 /** Append a file to the chain of files of a space.
1109 @param[in] name file name of a file that is not open
1110 @param[in] size file size in entire database blocks
1111 @param[in,out] space tablespace from fil_space_create()
1112 @param[in] is_raw whether this is a raw device or partition
1113 @param[in] atomic_write true if atomic write enabled
1114 @param[in] max_pages maximum number of pages in file
1115 @return pointer to the file name
1116 @retval nullptr if error */
1117 char *fil_node_create(const char *name, page_no_t size, fil_space_t *space,
1118  bool is_raw, bool atomic_write,
1119  page_no_t max_pages = PAGE_NO_MAX)
1120  MY_ATTRIBUTE((warn_unused_result));
1121 
1122 /** Create a space memory object and put it to the fil_system hash table.
1123 The tablespace name is independent from the tablespace file-name.
1124 Error messages are issued to the server log.
1125 @param[in] name Tablespace name
1126 @param[in] space_id Tablespace ID
1127 @param[in] flags tablespace flags
1128 @param[in] purpose tablespace purpose
1129 @return pointer to created tablespace, to be filled in with fil_node_create()
1130 @retval nullptr on failure (such as when the same tablespace exists) */
1131 fil_space_t *fil_space_create(const char *name, space_id_t space_id,
1132  uint32_t flags, fil_type_t purpose)
1133  MY_ATTRIBUTE((warn_unused_result));
1134 
1135 /** Assigns a new space id for a new single-table tablespace.
1136 This works simply by incrementing the global counter. If 4 billion id's
1137 is not enough, we may need to recycle id's.
1138 @param[in,out] space_id New space ID
1139 @return true if assigned, false if not */
1140 bool fil_assign_new_space_id(space_id_t *space_id)
1141  MY_ATTRIBUTE((warn_unused_result));
1142 
1143 /** Returns the path from the first fil_node_t found with this space ID.
1144 The caller is responsible for freeing the memory allocated here for the
1145 value returned.
1146 @param[in] space_id Tablespace ID
1147 @return own: A copy of fil_node_t::path, nullptr if space ID is zero
1148  or not found. */
1149 char *fil_space_get_first_path(space_id_t space_id)
1150  MY_ATTRIBUTE((warn_unused_result));
1151 
1152 /** Returns the size of the space in pages. The tablespace must be cached
1153 in the memory cache.
1154 @param[in] space_id Tablespace ID
1155 @return space size, 0 if space not found */
1157  MY_ATTRIBUTE((warn_unused_result));
1158 
1159 /** Returns the flags of the space. The tablespace must be cached
1160 in the memory cache.
1161 @param[in] space_id Tablespace ID for which to get the flags
1162 @return flags, ULINT_UNDEFINED if space not found */
1163 uint32_t fil_space_get_flags(space_id_t space_id)
1164  MY_ATTRIBUTE((warn_unused_result));
1165 
1166 /** Sets the flags of the tablespace. The tablespace must be locked
1167 in MDL_EXCLUSIVE MODE.
1168 @param[in] space tablespace in-memory struct
1169 @param[in] flags tablespace flags */
1170 void fil_space_set_flags(fil_space_t *space, uint32_t flags);
1171 
1172 /** Open each file of a tablespace if not already open.
1173 @param[in] space_id Tablespace ID
1174 @retval true if all file nodes were opened
1175 @retval false on failure */
1176 bool fil_space_open(space_id_t space_id) MY_ATTRIBUTE((warn_unused_result));
1177 
1178 /** Close each file of a tablespace if open.
1179 @param[in] space_id Tablespace ID */
1180 void fil_space_close(space_id_t space_id);
1181 
1182 /** Returns the page size of the space and whether it is compressed or not.
1183 The tablespace must be cached in the memory cache.
1184 @param[in] space_id Tablespace ID
1185 @param[out] found true if tablespace was found
1186 @return page size */
1187 const page_size_t fil_space_get_page_size(space_id_t space_id, bool *found)
1188  MY_ATTRIBUTE((warn_unused_result));
1189 
1190 /** Initializes the tablespace memory cache.
1191 @param[in] max_n_open Max number of open files. */
1192 void fil_init(ulint max_n_open);
1193 
1194 /** Initializes the tablespace memory cache. */
1195 void fil_close();
1196 
1197 /** Opens all log files and system tablespace data files.
1198 They stay open until the database server shutdown. This should be called
1199 at a server startup after the space objects for the log and the system
1200 tablespace have been created. The purpose of this operation is to make
1201 sure we never run out of file descriptors if we need to read from the
1202 insert buffer or to write to the log. */
1204 
1205 /** Closes all open files. There must not be any pending i/o's or not flushed
1206 modifications in the files. */
1207 void fil_close_all_files();
1208 
1209 /** Closes the redo log files. There must not be any pending i/o's or not
1210 flushed modifications in the files.
1211 @param[in] free_all Whether to free the instances. */
1212 void fil_close_log_files(bool free_all);
1213 
1214 /** Iterate over the files in all the tablespaces. */
1216  public:
1217  using Function = std::function<dberr_t(fil_node_t *)>;
1218 
1219  /** For each data file, exclude redo log files.
1220  @param[in] include_log include files, if true
1221  @param[in] f Callback */
1222  template <typename F>
1223  static dberr_t for_each_file(bool include_log, F &&f) {
1224  return (iterate(include_log, [=](fil_node_t *file) { return (f(file)); }));
1225  }
1226 
1227  /** Iterate over the spaces and file lists.
1228  @param[in] include_log if true then fetch log files too
1229  @param[in,out] f Callback */
1230  static dberr_t iterate(bool include_log, Function &&f);
1231 };
1232 
1233 /** Sets the max tablespace id counter if the given number is bigger than the
1234 previous value.
1235 @param[in] max_id Maximum known tablespace ID */
1237 
1238 #ifndef UNIV_HOTBACKUP
1239 /** Write the flushed LSN to the page header of the first page in the
1240 system tablespace.
1241 @param[in] lsn Flushed LSN
1242 @return DB_SUCCESS or error number */
1243 dberr_t fil_write_flushed_lsn(lsn_t lsn) MY_ATTRIBUTE((warn_unused_result));
1244 
1245 #else /* !UNIV_HOTBACKUP */
1246 /** Frees a space object from the tablespace memory cache.
1247 Closes a tablespaces' files but does not delete them.
1248 There must not be any pending i/o's or flushes on the files.
1249 @param[in] space_id Tablespace ID
1250 @return true if success */
1251 bool meb_fil_space_free(space_id_t space_id);
1252 
1253 /** Extends all tablespaces to the size stored in the space header. During the
1254 mysqlbackup --apply-log phase we extended the spaces on-demand so that log
1255 records could be applied, but that may have left spaces still too small
1256 compared to the size stored in the space header. */
1257 void meb_extend_tablespaces_to_stored_len();
1258 
1259 /** Process a file name passed as an input
1260 @param[in] name absolute path of tablespace file
1261 @param[in] space_id the tablespace ID */
1262 void meb_fil_name_process(const char *name, space_id_t space_id);
1263 
1264 #endif /* !UNIV_HOTBACKUP */
1265 
1266 /** Acquire a tablespace when it could be dropped concurrently.
1267 Used by background threads that do not necessarily hold proper locks
1268 for concurrency control.
1269 @param[in] space_id Tablespace ID
1270 @return the tablespace, or nullptr if missing or being deleted */
1272  MY_ATTRIBUTE((warn_unused_result));
1273 
1274 /** Acquire a tablespace that may not exist.
1275 Used by background threads that do not necessarily hold proper locks
1276 for concurrency control.
1277 @param[in] space_id Tablespace ID
1278 @return the tablespace, or nullptr if missing or being deleted */
1280  MY_ATTRIBUTE((warn_unused_result));
1281 
1282 /** Release a tablespace acquired with fil_space_acquire().
1283 @param[in,out] space Tablespace to release */
1284 void fil_space_release(fil_space_t *space);
1285 
1286 /** Fetch the file name opened for a space_id during recovery
1287 from the file map.
1288 @param[in] space_id Undo tablespace ID
1289 @return file name that was opened, empty string if space ID not found. */
1290 std::string fil_system_open_fetch(space_id_t space_id)
1291  MY_ATTRIBUTE((warn_unused_result));
1292 
1293 /** Truncate the tablespace to needed size.
1294 @param[in] space_id Id of tablespace to truncate
1295 @param[in] size_in_pages Truncate size.
1296 @return true if truncate was successful. */
1297 bool fil_truncate_tablespace(space_id_t space_id, page_no_t size_in_pages)
1298  MY_ATTRIBUTE((warn_unused_result));
1299 
1300 /** Truncate the tablespace to needed size with a new space_id.
1301 @param[in] old_space_id Tablespace ID to truncate
1302 @param[in] new_space_id Tablespace ID to for the new file
1303 @param[in] size_in_pages Truncate size.
1304 @return true if truncate was successful. */
1305 bool fil_replace_tablespace(space_id_t old_space_id, space_id_t new_space_id,
1306  page_no_t size_in_pages)
1307  MY_ATTRIBUTE((warn_unused_result));
1308 
1309 /** Closes a single-table tablespace. The tablespace must be cached in the
1310 memory cache. Free all pages used by the tablespace.
1311 @param[in,out] trx Transaction covering the close
1312 @param[in] space_id Tablespace ID
1313 @return DB_SUCCESS or error */
1315  MY_ATTRIBUTE((warn_unused_result));
1316 
1317 /** Discards a single-table tablespace. The tablespace must be cached in the
1318 memory cache. Discarding is like deleting a tablespace, but
1319 
1320  1. We do not drop the table from the data dictionary;
1321 
1322  2. We remove all insert buffer entries for the tablespace immediately;
1323  in DROP TABLE they are only removed gradually in the background;
1324 
1325  3. When the user does IMPORT TABLESPACE, the tablespace will have the
1326  same id as it originally had.
1327 
1328  4. Free all the pages in use by the tablespace if rename=true.
1329 @param[in] space_id Tablespace ID
1330 @return DB_SUCCESS or error */
1332  MY_ATTRIBUTE((warn_unused_result));
1333 
1334 /** Test if a tablespace file can be renamed to a new filepath by checking
1335 if that the old filepath exists and the new filepath does not exist.
1336 @param[in] space_id Tablespace ID
1337 @param[in] old_path Old filepath
1338 @param[in] new_path New filepath
1339 @param[in] is_discarded Whether the tablespace is discarded
1340 @return innodb error code */
1341 dberr_t fil_rename_tablespace_check(space_id_t space_id, const char *old_path,
1342  const char *new_path, bool is_discarded)
1343  MY_ATTRIBUTE((warn_unused_result));
1344 
1345 /** Rename a single-table tablespace.
1346 The tablespace must exist in the memory cache.
1347 @param[in] space_id Tablespace ID
1348 @param[in] old_path Old file name
1349 @param[in] new_name New tablespace name in the schema/name format
1350 @param[in] new_path_in New file name, or nullptr if it is located in
1351  The normal data directory
1352 @return InnoDB error code */
1353 dberr_t fil_rename_tablespace(space_id_t space_id, const char *old_path,
1354  const char *new_name, const char *new_path_in)
1355  MY_ATTRIBUTE((warn_unused_result));
1356 
1357 /** Create a tablespace file.
1358 @param[in] space_id Tablespace ID
1359 @param[in] name Tablespace name in dbname/tablename format.
1360  For general tablespaces, the 'dbname/' part
1361  may be missing.
1362 @param[in] path Path and filename of the datafile to create.
1363 @param[in] flags Tablespace flags
1364 @param[in] size Initial size of the tablespace file in pages,
1365  must be >= FIL_IBD_FILE_INITIAL_SIZE
1366 @return DB_SUCCESS or error code */
1367 dberr_t fil_ibd_create(space_id_t space_id, const char *name, const char *path,
1368  uint32_t flags, page_no_t size)
1369  MY_ATTRIBUTE((warn_unused_result));
1370 
1371 /** Create a session temporary tablespace (IBT) file.
1372 @param[in] space_id Tablespace ID
1373 @param[in] name Tablespace name
1374 @param[in] path Path and filename of the datafile to create.
1375 @param[in] flags Tablespace flags
1376 @param[in] size Initial size of the tablespace file in pages,
1377  must be >= FIL_IBT_FILE_INITIAL_SIZE
1378 @return DB_SUCCESS or error code */
1379 dberr_t fil_ibt_create(space_id_t space_id, const char *name, const char *path,
1380  uint32_t flags, page_no_t size)
1381  MY_ATTRIBUTE((warn_unused_result));
1382 
1383 /** Deletes an IBD tablespace, either general or single-table.
1384 The tablespace must be cached in the memory cache. This will delete the
1385 datafile, fil_space_t & fil_node_t entries from the file_system_t cache.
1386 @param[in] space_id Tablespace ID
1387 @param[in] buf_remove Specify the action to take on the pages
1388 for this table in the buffer pool.
1389 @return DB_SUCCESS, DB_TABLESPCE_NOT_FOUND or DB_IO_ERROR */
1391  MY_ATTRIBUTE((warn_unused_result));
1392 
1393 /** Open a single-table tablespace and optionally check the space id is
1394 right in it. If not successful, print an error message to the error log. This
1395 function is used to open a tablespace when we start up mysqld, and also in
1396 IMPORT TABLESPACE.
1397 NOTE that we assume this operation is used either at the database startup
1398 or under the protection of the dictionary mutex, so that two users cannot
1399 race here.
1400 
1401 The fil_node_t::handle will not be left open.
1402 
1403 @param[in] validate whether we should validate the tablespace
1404  (read the first page of the file and
1405  check that the space id in it matches id)
1406 @param[in] purpose FIL_TYPE_TABLESPACE or FIL_TYPE_TEMPORARY
1407 @param[in] space_id Tablespace ID
1408 @param[in] flags tablespace flags
1409 @param[in] space_name tablespace name of the datafile
1410  If file-per-table, it is the table name in the
1411  databasename/tablename format
1412 @param[in] table_name table name in case need to build filename
1413 from it
1414 @param[in] path_in expected filepath, usually read from dictionary
1415 @param[in] strict whether to report error when open ibd failed
1416 @param[in] old_space whether it is a 5.7 tablespace opening
1417  by upgrade
1418 @return DB_SUCCESS or error code */
1419 dberr_t fil_ibd_open(bool validate, fil_type_t purpose, space_id_t space_id,
1420  uint32_t flags, const char *space_name,
1421  const char *table_name, const char *path_in, bool strict,
1422  bool old_space) MY_ATTRIBUTE((warn_unused_result));
1423 
1424 /** Returns true if a matching tablespace exists in the InnoDB tablespace
1425 memory cache.
1426 @param[in] space_id Tablespace ID
1427 @param[in] name Tablespace name used in
1428  fil_space_create().
1429 @param[in] print_err detailed error information to the
1430  error log if a matching tablespace is
1431  not found from memory.
1432 @param[in] adjust_space Whether to adjust spaceid on mismatch
1433 @param[in] heap Heap memory
1434 @param[in] table_id table id
1435 @return true if a matching tablespace exists in the memory cache */
1436 bool fil_space_exists_in_mem(space_id_t space_id, const char *name,
1437  bool print_err, bool adjust_space,
1438  mem_heap_t *heap, table_id_t table_id)
1439  MY_ATTRIBUTE((warn_unused_result));
1440 
1441 /** Extends all tablespaces to the size stored in the space header. During the
1442 mysqlbackup --apply-log phase we extended the spaces on-demand so that log
1443 records could be appllied, but that may have left spaces still too small
1444 compared to the size stored in the space header. */
1446 
1447 /** Try to extend a tablespace if it is smaller than the specified size.
1448 @param[in,out] space Tablespace ID
1449 @param[in] size desired size in pages
1450 @return whether the tablespace is at least as big as requested */
1451 bool fil_space_extend(fil_space_t *space, page_no_t size)
1452  MY_ATTRIBUTE((warn_unused_result));
1453 
1454 /** Tries to reserve free extents in a file space.
1455 @param[in] space_id Tablespace ID
1456 @param[in] n_free_now Number of free extents now
1457 @param[in] n_to_reserve How many one wants to reserve
1458 @return true if succeed */
1459 bool fil_space_reserve_free_extents(space_id_t space_id, ulint n_free_now,
1460  ulint n_to_reserve)
1461  MY_ATTRIBUTE((warn_unused_result));
1462 
1463 /** Releases free extents in a file space.
1464 @param[in] space_id Tablespace ID
1465 @param[in] n_reserved How many were reserved */
1466 void fil_space_release_free_extents(space_id_t space_id, ulint n_reserved);
1467 
1468 /** Gets the number of reserved extents. If the database is silent, this
1469 number should be zero.
1470 @param[in] space_id Tablespace ID
1471 @return the number of reserved extents */
1473  MY_ATTRIBUTE((warn_unused_result));
1474 
1475 /** Read or write redo log data (synchronous buffered IO).
1476 @param[in] type IO context
1477 @param[in] page_id where to read or write
1478 @param[in] page_size page size
1479 @param[in] byte_offset remainder of offset in bytes
1480 @param[in] len this must not cross a file boundary;
1481 @param[in,out] buf buffer where to store read data or from where
1482  to write
1483 @retval DB_SUCCESS if all OK */
1484 dberr_t fil_redo_io(const IORequest &type, const page_id_t &page_id,
1485  const page_size_t &page_size, ulint byte_offset, ulint len,
1486  void *buf) MY_ATTRIBUTE((warn_unused_result));
1487 
1488 /** Read or write data.
1489 @param[in] type IO context
1490 @param[in] sync If true then do synchronous IO
1491 @param[in] page_id page id
1492 @param[in] page_size page size
1493 @param[in] byte_offset remainder of offset in bytes; in aio this
1494  must be divisible by the OS block size
1495 @param[in] len how many bytes to read or write; this must
1496  not cross a file boundary; in aio this must
1497  be a block size multiple
1498 @param[in,out] buf buffer where to store read data or from where
1499  to write; in aio this must be appropriately
1500  aligned
1501 @param[in] message message for aio handler if !sync, else ignored
1502 @return error code
1503 @retval DB_SUCCESS on success
1504 @retval DB_TABLESPACE_DELETED if the tablespace does not exist */
1505 dberr_t fil_io(const IORequest &type, bool sync, const page_id_t &page_id,
1506  const page_size_t &page_size, ulint byte_offset, ulint len,
1507  void *buf, void *message) MY_ATTRIBUTE((warn_unused_result));
1508 
1509 /** Waits for an aio operation to complete. This function is used to write the
1510 handler for completed requests. The aio array of pending requests is divided
1511 into segments (see os0file.cc for more info). The thread specifies which
1512 segment it wants to wait for.
1513 @param[in] segment The number of the segment in the AIO array
1514  to wait for */
1515 void fil_aio_wait(ulint segment);
1516 
1517 /** Flushes to disk possible writes cached by the OS. If the space does
1518 not exist or is being dropped, does not do anything.
1519 @param[in] space_id Tablespace ID (this can be a group of log files
1520  or a tablespace of the database) */
1521 void fil_flush(space_id_t space_id);
1522 
1523 /** Flush to disk the writes in file spaces of the given type
1524 possibly cached by the OS. */
1525 void fil_flush_file_redo();
1526 
1527 /** Flush to disk the writes in file spaces of the given type
1528 possibly cached by the OS.
1529 @param[in] purpose FIL_TYPE_TABLESPACE or FIL_TYPE_LOG, can
1530  be ORred. */
1531 void fil_flush_file_spaces(uint8_t purpose);
1532 
1533 #ifdef UNIV_DEBUG
1534 /** Checks the consistency of the tablespace cache.
1535 @return true if ok */
1536 bool fil_validate();
1537 #endif /* UNIV_DEBUG */
1538 
1539 /** Returns true if file address is undefined.
1540 @param[in] addr File address to check
1541 @return true if undefined */
1542 bool fil_addr_is_null(const fil_addr_t &addr)
1543  MY_ATTRIBUTE((warn_unused_result));
1544 
1545 /** Get the predecessor of a file page.
1546 @param[in] page File page
1547 @return FIL_PAGE_PREV */
1548 page_no_t fil_page_get_prev(const byte *page)
1549  MY_ATTRIBUTE((warn_unused_result));
1550 
1551 /** Get the successor of a file page.
1552 @param[in] page File page
1553 @return FIL_PAGE_NEXT */
1554 page_no_t fil_page_get_next(const byte *page)
1555  MY_ATTRIBUTE((warn_unused_result));
1556 
1557 /** Sets the file page type.
1558 @param[in,out] page File page
1559 @param[in] type File page type to set */
1560 void fil_page_set_type(byte *page, ulint type);
1561 
1562 /** Reset the page type.
1563 Data files created before MySQL 5.1 may contain garbage in FIL_PAGE_TYPE.
1564 In MySQL 3.23.53, only undo log pages and index pages were tagged.
1565 Any other pages were written with uninitialized bytes in FIL_PAGE_TYPE.
1566 @param[in] page_id page number
1567 @param[in,out] page page with invalid FIL_PAGE_TYPE
1568 @param[in] type expected page type
1569 @param[in,out] mtr mini-transaction */
1570 void fil_page_reset_type(const page_id_t &page_id, byte *page, ulint type,
1571  mtr_t *mtr);
1572 
1573 /** Get the file page type.
1574 @param[in] page File page
1575 @return page type */
1576 inline page_type_t fil_page_get_type(const byte *page) {
1577  return (static_cast<page_type_t>(mach_read_from_2(page + FIL_PAGE_TYPE)));
1578 }
1579 /** Check (and if needed, reset) the page type.
1580 Data files created before MySQL 5.1 may contain
1581 garbage in the FIL_PAGE_TYPE field.
1582 In MySQL 3.23.53, only undo log pages and index pages were tagged.
1583 Any other pages were written with uninitialized bytes in FIL_PAGE_TYPE.
1584 @param[in] page_id page number
1585 @param[in,out] page page with possibly invalid FIL_PAGE_TYPE
1586 @param[in] type expected page type
1587 @param[in,out] mtr mini-transaction */
1588 inline void fil_page_check_type(const page_id_t &page_id, byte *page,
1589  ulint type, mtr_t *mtr) {
1590  ulint page_type = fil_page_get_type(page);
1591 
1592  if (page_type != type) {
1593  fil_page_reset_type(page_id, page, type, mtr);
1594  }
1595 }
1596 
1597 /** Check (and if needed, reset) the page type.
1598 Data files created before MySQL 5.1 may contain
1599 garbage in the FIL_PAGE_TYPE field.
1600 In MySQL 3.23.53, only undo log pages and index pages were tagged.
1601 Any other pages were written with uninitialized bytes in FIL_PAGE_TYPE.
1602 @param[in,out] block block with possibly invalid FIL_PAGE_TYPE
1603 @param[in] type expected page type
1604 @param[in,out] mtr mini-transaction */
1605 #define fil_block_check_type(block, type, mtr) \
1606  fil_page_check_type(block->page.id, block->frame, type, mtr)
1607 
1608 #ifdef UNIV_DEBUG
1609 /** Increase redo skipped of a tablespace.
1610 @param[in] space_id Tablespace ID */
1612 
1613 /** Decrease redo skipped of a tablespace.
1614 @param[in] space_id Tablespace ID */
1616 
1617 /** Check whether a single-table tablespace is redo skipped.
1618 @param[in] space_id Tablespace ID
1619 @return true if redo skipped */
1621  MY_ATTRIBUTE((warn_unused_result));
1622 #endif /* UNIV_DEBUG */
1623 
1624 /** Delete the tablespace file and any related files like .cfg.
1625 This should not be called for temporary tables.
1626 @param[in] path File path of the tablespace
1627 @return true on success */
1628 bool fil_delete_file(const char *path) MY_ATTRIBUTE((warn_unused_result));
1629 
1630 /** Callback functor. */
1632  /** Default constructor */
1633  PageCallback() : m_page_size(0, 0, false), m_filepath() UNIV_NOTHROW {}
1634 
1635  virtual ~PageCallback() UNIV_NOTHROW {}
1636 
1637  /** Called for page 0 in the tablespace file at the start.
1638  @param file_size size of the file in bytes
1639  @param block contents of the first page in the tablespace file
1640  @retval DB_SUCCESS or error code. */
1641  virtual dberr_t init(os_offset_t file_size, const buf_block_t *block)
1642  MY_ATTRIBUTE((warn_unused_result)) UNIV_NOTHROW = 0;
1643 
1644  /** Called for every page in the tablespace. If the page was not
1645  updated then its state must be set to BUF_PAGE_NOT_USED. For
1646  compressed tables the page descriptor memory will be at offset:
1647  block->frame + UNIV_PAGE_SIZE;
1648  @param offset physical offset within the file
1649  @param block block read from file, note it is not from the buffer pool
1650  @retval DB_SUCCESS or error code. */
1651  virtual dberr_t operator()(os_offset_t offset, buf_block_t *block)
1652  MY_ATTRIBUTE((warn_unused_result)) UNIV_NOTHROW = 0;
1653 
1654  /** Set the name of the physical file and the file handle that is used
1655  to open it for the file that is being iterated over.
1656  @param filename then physical name of the tablespace file.
1657  @param file OS file handle */
1658  void set_file(const char *filename, pfs_os_file_t file) UNIV_NOTHROW {
1659  m_file = file;
1660  m_filepath = filename;
1661  }
1662 
1663  /** @return the space id of the tablespace */
1664  virtual space_id_t get_space_id() const
1665  MY_ATTRIBUTE((warn_unused_result)) UNIV_NOTHROW = 0;
1666 
1667  /**
1668  @retval the space flags of the tablespace being iterated over */
1669  virtual ulint get_space_flags() const
1670  MY_ATTRIBUTE((warn_unused_result)) UNIV_NOTHROW = 0;
1671 
1672  /** Set the tablespace table size.
1673  @param[in] page a page belonging to the tablespace */
1674  void set_page_size(const buf_frame_t *page) UNIV_NOTHROW;
1675 
1676  /** The compressed page size
1677  @return the compressed page size */
1678  const page_size_t &get_page_size() const MY_ATTRIBUTE((warn_unused_result)) {
1679  return (m_page_size);
1680  }
1681 
1682  /** The tablespace page size. */
1684 
1685  /** File handle to the tablespace */
1687 
1688  /** Physical file path. */
1689  const char *m_filepath;
1690 
1691  // Disable copying
1692  PageCallback(PageCallback &&) = delete;
1693  PageCallback(const PageCallback &) = delete;
1694  PageCallback &operator=(const PageCallback &) = delete;
1695 };
1696 
1697 /** Iterate over all the pages in the tablespace.
1698 @param table the table definiton in the server
1699 @param n_io_buffers number of blocks to read and write together
1700 @param callback functor that will do the page updates
1701 @return DB_SUCCESS or error code */
1702 dberr_t fil_tablespace_iterate(dict_table_t *table, ulint n_io_buffers,
1703  PageCallback &callback)
1704  MY_ATTRIBUTE((warn_unused_result));
1705 
1706 /** Looks for a pre-existing fil_space_t with the given tablespace ID
1707 and, if found, returns the name and filepath in newly allocated buffers that
1708 the caller must free.
1709 @param[in] space_id The tablespace ID to search for.
1710 @param[out] name Name of the tablespace found.
1711 @param[out] filepath The filepath of the first datafile for thtablespace found.
1712 @return true if tablespace is found, false if not. */
1713 bool fil_space_read_name_and_filepath(space_id_t space_id, char **name,
1714  char **filepath)
1715  MY_ATTRIBUTE((warn_unused_result));
1716 
1717 /** Convert a file name to a tablespace name.
1718 @param[in] filename directory/databasename/tablename.ibd
1719 @return database/tablename string, to be freed with ut_free() */
1720 char *fil_path_to_space_name(const char *filename)
1721  MY_ATTRIBUTE((warn_unused_result));
1722 
1723 /** Returns the space ID based on the tablespace name.
1724 The tablespace must be found in the tablespace memory cache.
1725 This call is made from external to this module, so the mutex is not owned.
1726 @param[in] name Tablespace name
1727 @return space ID if tablespace found, SPACE_UNKNOWN if space not. */
1729  MY_ATTRIBUTE((warn_unused_result));
1730 
1731 /** Check if swapping two .ibd files can be done without failure
1732 @param[in] old_table old table
1733 @param[in] new_table new table
1734 @param[in] tmp_name temporary table name
1735 @return innodb error code */
1736 dberr_t fil_rename_precheck(const dict_table_t *old_table,
1737  const dict_table_t *new_table, const char *tmp_name)
1738  MY_ATTRIBUTE((warn_unused_result));
1739 
1740 /** Set the compression type for the tablespace of a table
1741 @param[in] table Table that should be compressesed
1742 @param[in] algorithm Text representation of the algorithm
1743 @return DB_SUCCESS or error code */
1744 dberr_t fil_set_compression(dict_table_t *table, const char *algorithm)
1745  MY_ATTRIBUTE((warn_unused_result));
1746 
1747 /** Get the compression type for the tablespace
1748 @param[in] space_id Space ID to check
1749 @return the compression algorithm */
1751  MY_ATTRIBUTE((warn_unused_result));
1752 
1753 /** Set encryption.
1754 @param[in,out] req_type IO request
1755 @param[in] page_id Page address for IO
1756 @param[in,out] space Tablespace instance */
1757 void fil_io_set_encryption(IORequest &req_type, const page_id_t &page_id,
1758  fil_space_t *space);
1759 
1760 /** Set the encryption type for the tablespace
1761 @param[in] space_id Space ID of tablespace for which to set
1762 @param[in] algorithm Encryption algorithm
1763 @param[in] key Encryption key
1764 @param[in] iv Encryption iv
1765 @return DB_SUCCESS or error code */
1767  byte *key, byte *iv)
1768  MY_ATTRIBUTE((warn_unused_result));
1769 
1770 /** Reset the encryption type for the tablespace
1771 @param[in] space_id Space ID of tablespace for which to set
1772 @return DB_SUCCESS or error code */
1774  MY_ATTRIBUTE((warn_unused_result));
1775 /** @return true if the re-encrypt success */
1776 bool fil_encryption_rotate() MY_ATTRIBUTE((warn_unused_result));
1777 
1778 /** During crash recovery, open a tablespace if it had not been opened
1779 yet, to get valid size and flags.
1780 @param[in,out] space Tablespace instance */
1782  if (space->size == 0) {
1783  /* Initially, size and flags will be set to 0,
1784  until the files are opened for the first time.
1785  fil_space_get_size() will open the file
1786  and adjust the size and flags. */
1787  page_no_t size = fil_space_get_size(space->id);
1788 
1789  ut_a(size == space->size);
1790  }
1791 }
1792 
1793 #if !defined(NO_FALLOCATE) && defined(UNIV_LINUX)
1794 /**
1795 Try and enable FusionIO atomic writes.
1796 @param[in] file OS file handle
1797 @return true if successful */
1798 bool fil_fusionio_enable_atomic_write(pfs_os_file_t file)
1799  MY_ATTRIBUTE((warn_unused_result));
1800 #endif /* !NO_FALLOCATE && UNIV_LINUX */
1801 
1802 /** Note that the file system where the file resides doesn't support PUNCH HOLE
1803 @param[in,out] file File node to set */
1804 void fil_no_punch_hole(fil_node_t *file);
1805 
1806 #ifdef UNIV_ENABLE_UNIT_TEST_MAKE_FILEPATH
1807 void test_make_filepath();
1808 #endif /* UNIV_ENABLE_UNIT_TEST_MAKE_FILEPATH */
1809 
1810 /** @return the system tablespace instance */
1811 #define fil_space_get_sys_space() (fil_space_t::s_sys_space)
1812 
1813 /** Redo a tablespace create
1814 @param[in] ptr redo log record
1815 @param[in] end end of the redo log buffer
1816 @param[in] page_id Tablespace Id and first page in file
1817 @param[in] parsed_bytes Number of bytes parsed so far
1818 @param[in] parse_only Don't apply the log if true
1819 @return pointer to next redo log record
1820 @retval nullptr if this log record was truncated */
1821 byte *fil_tablespace_redo_create(byte *ptr, const byte *end,
1822  const page_id_t &page_id, ulint parsed_bytes,
1823  bool parse_only)
1824  MY_ATTRIBUTE((warn_unused_result));
1825 
1826 /** Redo a tablespace drop
1827 @param[in] ptr redo log record
1828 @param[in] end end of the redo log buffer
1829 @param[in] page_id Tablespace Id and first page in file
1830 @param[in] parsed_bytes Number of bytes parsed so far
1831 @param[in] parse_only Don't apply the log if true
1832 @return pointer to next redo log record
1833 @retval nullptr if this log record was truncated */
1834 byte *fil_tablespace_redo_delete(byte *ptr, const byte *end,
1835  const page_id_t &page_id, ulint parsed_bytes,
1836  bool parse_only)
1837  MY_ATTRIBUTE((warn_unused_result));
1838 
1839 /** Redo a tablespace rename
1840 @param[in] ptr redo log record
1841 @param[in] end end of the redo log buffer
1842 @param[in] page_id Tablespace Id and first page in file
1843 @param[in] parsed_bytes Number of bytes parsed so far
1844 @param[in] parse_only Don't apply the log if true
1845 @return pointer to next redo log record
1846 @retval nullptr if this log record was truncated */
1847 byte *fil_tablespace_redo_rename(byte *ptr, const byte *end,
1848  const page_id_t &page_id, ulint parsed_bytes,
1849  bool parse_only)
1850  MY_ATTRIBUTE((warn_unused_result));
1851 
1852 /** Parse and process an encryption redo record.
1853 @param[in] ptr redo log record
1854 @param[in] end end of the redo log buffer
1855 @param[in] space_id the tablespace ID
1856 @return log record end, nullptr if not a complete record */
1857 byte *fil_tablespace_redo_encryption(byte *ptr, const byte *end,
1858  space_id_t space_id)
1859  MY_ATTRIBUTE((warn_unused_result));
1860 
1861 /** Read the tablespace id to path mapping from the file
1862 @param[in] recovery true if called from crash recovery */
1863 void fil_tablespace_open_init_for_recovery(bool recovery);
1864 
1865 /** Lookup the space ID.
1866 @param[in] space_id Tablespace ID to lookup
1867 @return true if space ID is known and open */
1869  MY_ATTRIBUTE((warn_unused_result));
1870 
1871 /** Compare and update space name and dd path for partitioned table. Uniformly
1872 converts partition separators and names to lower case.
1873 @param[in] space_id tablespace ID
1874 @param[in] fsp_flags tablespace flags
1875 @param[in] update_space update space name
1876 @param[in,out] space_name tablespace name
1877 @param[in,out] dd_path file name with complete path
1878 @return true, if names are updated. */
1879 bool fil_update_partition_name(space_id_t space_id, uint32_t fsp_flags,
1880  bool update_space, std::string &space_name,
1881  std::string &dd_path);
1882 
1883 /** Add tablespace to the set of tablespaces to be updated in DD.
1884 @param[in] dd_object_id Server DD tablespace ID
1885 @param[in] space_id Innodb tablespace ID
1886 @param[in] space_name New tablespace name
1887 @param[in] old_path Old Path in the data dictionary
1888 @param[in] new_path New path to be update in dictionary */
1889 void fil_add_moved_space(dd::Object_id dd_object_id, space_id_t space_id,
1890  const char *space_name, const std::string &old_path,
1891  const std::string &new_path);
1892 
1893 /** Lookup the tablespace ID and return the path to the file. The filename
1894 is ignored when testing for equality. Only the path up to the file name is
1895 considered for matching: e.g. ./test/a.ibd == ./test/b.ibd.
1896 @param[in] dd_object_id Server DD tablespace ID
1897 @param[in] space_id Tablespace ID to lookup
1898 @param[in] space_name Tablespace name
1899 @param[in] old_path Path in the data dictionary
1900 @param[out] new_path New path if scanned path not equal to path
1901 @return status of the match. */
1903  space_id_t space_id,
1904  const char *space_name,
1905  std::string old_path,
1906  std::string *new_path)
1907  MY_ATTRIBUTE((warn_unused_result));
1908 
1909 /** This function should be called after recovery has completed.
1910 Check for tablespace files for which we did not see any MLOG_FILE_DELETE
1911 or MLOG_FILE_RENAME record. These could not be recovered
1912 @return true if there were some filenames missing for which we had to
1913 ignore redo log records during the apply phase */
1914 bool fil_check_missing_tablespaces() MY_ATTRIBUTE((warn_unused_result));
1915 
1916 /** Normalize and save a directory to scan for datafiles.
1917 @param[in] directory directory to scan for ibd and ibu files
1918 @param[in] is_undo_dir true for an undo directory */
1919 void fil_set_scan_dir(const std::string &directory, bool is_undo_dir = false);
1920 
1921 /** Normalize and save a list of directories to scan for datafiles.
1922 @param[in] directories Directories to scan for ibd and ibu files
1923  in the form: "dir1;dir2; ... dirN" */
1924 void fil_set_scan_dirs(const std::string &directories);
1925 
1926 /** Discover tablespaces by reading the header from .ibd files.
1927 @return DB_SUCCESS if all goes well */
1929 
1930 /** Open the tabelspace and also get the tablespace filenames, space_id must
1931 already be known.
1932 @param[in] space_id Tablespace ID to lookup
1933 @return true if open was successful */
1935  MY_ATTRIBUTE((warn_unused_result));
1936 
1937 /** Replay a file rename operation for ddl replay.
1938 @param[in] page_id Space ID and first page number in the file
1939 @param[in] old_name old file name
1940 @param[in] new_name new file name
1941 @return whether the operation was successfully applied
1942 (the name did not exist, or new_name did not exist and
1943 name was successfully renamed to new_name) */
1944 bool fil_op_replay_rename_for_ddl(const page_id_t &page_id,
1945  const char *old_name, const char *new_name);
1946 
1947 /** Free the Tablespace_files instance.
1948 @param[in] read_only_mode true if InnoDB is started in read only mode.
1949 @return DB_SUCCESS if all OK */
1950 dberr_t fil_open_for_business(bool read_only_mode)
1951  MY_ATTRIBUTE((warn_unused_result));
1952 
1953 /** Check if a path is known to InnoDB.
1954 @param[in] path Path to check
1955 @return true if path is known to InnoDB */
1956 bool fil_check_path(const std::string &path) MY_ATTRIBUTE((warn_unused_result));
1957 
1958 /** Get the list of directories that datafiles can reside in.
1959 @return the list of directories 'dir1;dir2;....;dirN' */
1960 std::string fil_get_dirs() MY_ATTRIBUTE((warn_unused_result));
1961 
1962 /** Rename a tablespace. Use the space_id to find the shard.
1963 @param[in] space_id tablespace ID
1964 @param[in] old_name old tablespace name
1965 @param[in] new_name new tablespace name
1966 @return DB_SUCCESS on success */
1967 dberr_t fil_rename_tablespace_by_id(space_id_t space_id, const char *old_name,
1968  const char *new_name)
1969  MY_ATTRIBUTE((warn_unused_result));
1970 
1971 /** Free the data structures required for recovery. */
1972 void fil_free_scanned_files();
1973 
1974 /** Update the tablespace name. Incase, the new name
1975 and old name are same, no update done.
1976 @param[in,out] space tablespace object on which name
1977  will be updated
1978 @param[in] name new name for tablespace */
1979 void fil_space_update_name(fil_space_t *space, const char *name);
1980 
1981 /** Adjust file name for import for partition files in different letter case.
1982 @param[in] table Innodb dict table
1983 @param[in] path file path to open
1984 @param[in] extn file extension */
1985 void fil_adjust_name_import(dict_table_t *table, const char *path,
1986  ib_file_suffix extn);
1987 #endif /* fil0fil_h */
lsn
static uint64_t lsn
Definition: xcom_base.c:406
page_no_t
uint32 page_no_t
Page number.
Definition: api0api.h:57
fil_tablespace_iterate
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:8455
lsn_t
uint64_t lsn_t
Type used for all log sequence number storage and arithmetics.
Definition: log0types.h:59
FIL_PAGE_ENCRYPTED_RTREE
constexpr page_type_t FIL_PAGE_ENCRYPTED_RTREE
Encrypted R-tree page.
Definition: fil0fil.h:1009
fil_aio_wait
void fil_aio_wait(ulint segment)
Waits for an aio operation to complete.
Definition: fil0fil.cc:7710
Fil_path::is_hidden
static bool is_hidden(std::string path)
Determine if the file or directory is considered HIDDEN.
Definition: fil0fil.cc:9038
fil_rename_tablespace_by_id
dberr_t fil_rename_tablespace_by_id(space_id_t space_id, const char *old_name, const char *new_name)
Rename a tablespace.
Definition: fil0fil.cc:5091
Fil_state::MOVED
@ MOVED
Space ID matches but the paths don't match.
Fil_path::is_absolute_path
static bool is_absolute_path(const std::string &path)
Determine if a path is an absolute path or not.
Definition: fil0fil.h:616
fil_space_t::encryption_klen
ulint encryption_klen
Encrypt key length.
Definition: fil0fil.h:307
PageCallback::get_space_flags
virtual ulint get_space_flags() const 1=0
Fil_path::operator==
bool operator==(const Fil_path &other) const
Determine if this path is equal to the other path.
Definition: fil0fil.h:463
fil_node_t::name
char * name
file name; protected by Fil_shard::m_mutex and log_sys->mutex.
Definition: fil0fil.h:151
fil_tablespace_open_init_for_recovery
void fil_tablespace_open_init_for_recovery(bool recovery)
Read the tablespace id to path mapping from the file.
IBD
@ IBD
Definition: fil0fil.h:349
fil_node_t::LRU
List_node LRU
link to the fil_system->LRU list (keeping track of open files)
Definition: fil0fil.h:199
Fil_path::make_ibd_from_table_name
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:800
fil_truncate_tablespace
bool fil_truncate_tablespace(space_id_t space_id, page_no_t size_in_pages)
Truncate the tablespace to needed size.
Definition: fil0fil.cc:4332
filepath
static const char * filepath
Definition: myisamlog.cc:91
fil_redo_io
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:7687
dict0types.h
fil_node_t::handle
pfs_os_file_t handle
file handle (valid if is_open)
Definition: fil0fil.h:159
Fil_path::OS_SEPARATOR
static constexpr auto OS_SEPARATOR
OS specific path separator.
Definition: fil0fil.h:373
FIL_IBD_FILE_INITIAL_SIZE_5_7
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:881
fil_space_t::purpose
fil_type_t purpose
Purpose.
Definition: fil0fil.h:248
FIL_PAGE_TYPE_LOB_INDEX
constexpr page_type_t FIL_PAGE_TYPE_LOB_INDEX
Index pages of uncompressed LOB.
Definition: fil0fil.h:1024
Compression::Type
Type
Algorithm types supported.
Definition: file.h:52
Fil_state::MATCHES
@ MATCHES
The path matches what was found during the scan.
rules_table_service::table_name
const char * table_name
Definition: rules_table_service.cc:55
ENCRYPTION_KEY_LEN
static const ulint ENCRYPTION_KEY_LEN
Encryption key length.
Definition: os0file.h:227
fil_space_get_id_by_name
space_id_t fil_space_get_id_by_name(const char *name)
Returns the space ID based on the tablespace name.
Definition: fil0fil.cc:6113
fil_space_t::n_pending_flushes
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:277
ENCRYPTION
@ ENCRYPTION
Definition: fil0fil.h:215
fil_space_open_if_needed
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:1781
Fil_path::is_ancestor
bool is_ancestor(const std::string &other) const
Check if this Fil_path is an ancestor of the other path.
Definition: fil0fil.h:518
fil_space_get_first_path
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:3316
FIL_PAGE_RTREE
constexpr page_type_t FIL_PAGE_RTREE
R-tree node.
Definition: fil0fil.h:953
fil_addr_t::is_equal
bool is_equal(const fil_addr_t &rhs) const
Compare to instances.
Definition: fil0fil.h:913
fil_space_release_free_extents
void fil_space_release_free_extents(space_id_t space_id, ulint n_reserved)
Releases free extents in a file space.
Definition: fil0fil.cc:7022
fil_delete_tablespace
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:4251
FIL_PAGE_TYPE_ZLOB_FRAG
constexpr page_type_t FIL_PAGE_TYPE_ZLOB_FRAG
Fragment pages of compressed LOB.
Definition: fil0fil.h:1043
fil_space_t::name
char * name
Tablespace name.
Definition: fil0fil.h:223
fil_space_t::encryption_iv
byte encryption_iv[ENCRYPTION_KEY_LEN]
Encrypt initial vector.
Definition: fil0fil.h:310
FIL_PAGE_TYPE_ZLOB_DATA
constexpr page_type_t FIL_PAGE_TYPE_ZLOB_DATA
Data pages of compressed LOB.
Definition: fil0fil.h:1036
fil_tablespace_redo_encryption
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:10285
FIL_SCAN_MAX_THREADS
constexpr size_t FIL_SCAN_MAX_THREADS
Maximum number of threads that will be used for scanning the tablespace files.
Definition: fil0fil.h:63
Fil_path::is_same_as
static bool is_same_as(const std::string &first, const std::string &second)
Check if two path strings are equal.
Definition: fil0fil.h:484
IBU
@ IBU
Definition: fil0fil.h:349
Fil_state
Fil_state
Result of comparing a path.
Definition: fil0fil.h:113
ut_a
#define ut_a(EXPR)
Abort execution if EXPR does not evaluate to nonzero.
Definition: ut0dbg.h:53
Fil_path::path
const std::string & path() const
Definition: fil0fil.h:421
ut_ad
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:65
Fil_iterator
Iterate over the files in all the tablespaces.
Definition: fil0fil.h:1215
fil_flush
void fil_flush(space_id_t space_id)
Flushes to disk possible writes cached by the OS.
Definition: fil0fil.cc:8047
fil_faddr_t
byte fil_faddr_t
'type' definition in C: an address stored in a file page is a string of bytes
Definition: fil0fil.h:898
fil_get_compression
Compression::Type fil_get_compression(space_id_t space_id)
Get the compression type for the tablespace.
Definition: fil0fil.cc:8819
UT_LIST_NODE_T
#define UT_LIST_NODE_T(TYPE)
Definition: innodb_utility.h:40
fil_tablespace_path_equals
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:9671
FIL_PAGE_SDI
constexpr page_type_t FIL_PAGE_SDI
Tablespace SDI Index page.
Definition: fil0fil.h:956
fil_flush_file_spaces
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:8116
Fil_path::relative
@ relative
Definition: fil0fil.h:388
fil_space_t::encryption_type
Encryption::Type encryption_type
Encryption algorithm.
Definition: fil0fil.h:301
fil_close_tablespace
dberr_t fil_close_tablespace(trx_t *trx, space_id_t space_id)
Closes a single-table tablespace.
Definition: fil0fil.cc:3964
fil_space_t::magic_n
ulint magic_n
FIL_SPACE_MAGIC_N.
Definition: fil0fil.h:320
FIL_PAGE_IBUF_BITMAP
constexpr page_type_t FIL_PAGE_IBUF_BITMAP
Insert buffer bitmap.
Definition: fil0fil.h:972
PageCallback::operator()
virtual dberr_t operator()(os_offset_t offset, buf_block_t *block) 1=0
Called for every page in the tablespace.
fil_set_max_space_id_if_bigger
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:3686
mtr_t
Mini-transaction handle and buffer.
Definition: mtr0mtr.h:169
general_space_name
static constexpr char general_space_name[]
This tablespace name is used internally during file discovery to open a general tablespace before the...
Definition: fil0fil.h:77
PageCallback::set_page_size
void set_page_size(const buf_frame_t *page) 1
Set the tablespace table size.
Definition: fil0fil.cc:8629
fil_system_open_fetch
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:4102
os_event
InnoDB condition variable.
Definition: os0event.cc:66
fil_space_get_n_reserved_extents
ulint fil_space_get_n_reserved_extents(space_id_t space_id)
Gets the number of reserved extents.
Definition: fil0fil.cc:7041
PAGE_NO_MAX
constexpr page_no_t PAGE_NO_MAX
Maximum Page Number, one less than FIL_NULL.
Definition: fil0fil.h:887
fil_page_reset_type
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:8160
FIL_PAGE_TYPE_LAST
constexpr page_type_t FIL_PAGE_TYPE_LAST
Used by i_s.cc to index into the text description.
Definition: fil0fil.h:1049
Fil_path::is_undo_tablespace_name
static bool is_undo_tablespace_name(const std::string &name)
Check if the name is an undo tablespace name.
Definition: fil0fil.cc:1951
fil_assign_new_space_id
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:3240
FIL_PAGE_COMPRESSED
constexpr page_type_t FIL_PAGE_COMPRESSED
Compressed page.
Definition: fil0fil.h:1000
fil_get_scan_threads
size_t fil_get_scan_threads(size_t num_files)
Calculate the number of threads that can be spawned to scan the given number of files taking into the...
Definition: fil0fil.cc:129
Fil_path::m_abs_path
std::string m_abs_path
A full absolute path to the same file.
Definition: fil0fil.h:865
Fil_path::path_type
path_type
Various types of file paths.
Definition: fil0fil.h:388
Space_ids
std::vector< space_id_t, ut_allocator< space_id_t > > Space_ids
Definition: fil0fil.h:98
fil_space_reserve_free_extents
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:6996
fil_space_t::n_reserved_extents
uint32_t n_reserved_extents
Number of reserved free extents for ongoing operations like B-tree page split.
Definition: fil0fil.h:273
IBT
@ IBT
Definition: fil0fil.h:349
fil_space_dec_redo_skipped_count
void fil_space_dec_redo_skipped_count(space_id_t space_id)
Decrease redo skipped of a tablespace.
Definition: fil0fil.cc:4430
FIL_PAGE_TYPE_XDES
constexpr page_type_t FIL_PAGE_TYPE_XDES
Extent descriptor page.
Definition: fil0fil.h:984
fil_space_t::size
page_no_t size
Tablespace file size in pages; 0 if not known yet.
Definition: fil0fil.h:255
fil_space_update_name
void fil_space_update_name(fil_space_t *space, const char *name)
Update the tablespace name.
Definition: fil0fil.cc:11188
FIL_PAGE_SDI_ZBLOB
constexpr page_type_t FIL_PAGE_SDI_ZBLOB
Commpressed SDI BLOB page.
Definition: fil0fil.h:1015
fil_ibd_open
dberr_t fil_ibd_open(bool validate, fil_type_t purpose, space_id_t space_id, uint32_t 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:5410
Fil_path::operator()
const char * operator()() const
Explicit type conversion.
Definition: fil0fil.h:418
PageCallback::get_space_id
virtual space_id_t get_space_id() const 1=0
IORequest
The IO Context that is passed down to the low level IO code.
Definition: os0file.h:516
PageCallback::set_file
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:1658
Fil_path::make_data_dir_path
static void make_data_dir_path(char *data_dir_path)
This function reduces a null-terminated full remote path name into the path that is sent by MySQL for...
Definition: fil0fil.cc:4695
fil_space_get_latch
rw_lock_t * fil_space_get_latch(space_id_t space_id)
Returns the latch of a file space.
Definition: fil0fil.cc:2089
fil_page_get_next
page_no_t fil_page_get_next(const byte *page)
Get the successor of a file page.
Definition: fil0fil.cc:8141
fil_space_extend
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:6425
CFG
@ CFG
Definition: fil0fil.h:349
fil_close_log_files
void fil_close_log_files(bool free_all)
Closes the redo log files.
Definition: fil0fil.cc:3619
fil_n_file_opened
ulint fil_n_file_opened
Number of files currently open.
Definition: fil0fil.cc:295
normalize_path
static duk_ret_t normalize_path(duk_context *ctx, duk_idx_t obj_idx)
Definition: duk_module_shim.c:75
dberr_t
dberr_t
Definition: db0err.h:38
fil_rename_tablespace
dberr_t 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:5010
FIL_IBT_FILE_INITIAL_SIZE
constexpr size_t FIL_IBT_FILE_INITIAL_SIZE
Definition: fil0fil.h:876
dict_table_t
Data structure for a database table.
Definition: dict0mem.h:1510
fil_tablespace_open_for_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:9658
fil_space_t::unflushed_spaces
List_node unflushed_spaces
List of spaces with at least one unflushed file we have written to.
Definition: fil0fil.h:292
FIL_PAGE_INDEX
constexpr page_type_t FIL_PAGE_INDEX
File page types (values of FIL_PAGE_TYPE)
Definition: fil0fil.h:950
fil_space_t::latch
rw_lock_t latch
Latch protecting the file space storage allocation.
Definition: fil0fil.h:287
Fil_path::is_relative_path
bool is_relative_path() const
Definition: fil0fil.h:603
buf_block_t
The buffer control block structure.
Definition: buf0buf.h:1318
fil_type_t
fil_type_t
File types.
Definition: fil0fil.h:101
fil_validate
bool fil_validate()
Checks the consistency of the tablespace cache.
Definition: fil0fil.cc:1765
fil_type_is_data
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:136
fil_set_compression
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:8755
Fil_path::is_ancestor
bool is_ancestor(const Fil_path &other) const
Check if m_path is the parent of the other path.
Definition: fil0fil.h:499
Fil_path::get_file_type_string
static const char * get_file_type_string(const std::string &path)
Return a string to display the file type of a path.
Definition: fil0fil.cc:9094
mach_read_from_2
UNIV_INLINE uint16_t mach_read_from_2(const byte *b)
The following function is used to fetch data from 2 consecutive bytes.
fil_node_t::init_size
page_no_t init_size
initial size of the file in database pages; FIL_IBD_FILE_INITIAL_SIZE by default
Definition: fil0fil.h:178
fil_space_get_flags
uint32_t fil_space_get_flags(space_id_t space_id)
Returns the flags of the space.
Definition: fil0fil.cc:3360
fil_node_t::punch_hole
bool punch_hole
whether the file system of this file supports PUNCH HOLE
Definition: fil0fil.h:202
fil_addr_t::print
std::ostream & print(std::ostream &out) const
Print a string representation.
Definition: fil0fil.h:923
fil_space_set_flags
void fil_space_set_flags(fil_space_t *space, uint32_t flags)
Sets the flags of the tablespace.
Definition: fil0fil.cc:9193
key
static const char * key
Definition: suite_stubs.c:14
FIL_PAGE_TYPE_ZLOB_FIRST
constexpr page_type_t FIL_PAGE_TYPE_ZLOB_FIRST
The first page of a compressed LOB.
Definition: fil0fil.h:1033
os_file_type_t
os_file_type_t
Definition: os0file.h:822
fil_open_log_and_system_tablespace_files
void fil_open_log_and_system_tablespace_files()
Opens all log files and system tablespace data files.
Definition: fil0fil.cc:3507
fil_node_t::sync_event
os_event_t sync_event
event that groups and serializes calls to fsync
Definition: fil0fil.h:162
Fil_path::DB_SEPARATOR
static constexpr auto DB_SEPARATOR
schema '/' table separator
Definition: fil0fil.h:370
Fil_path::is_ancestor
static bool is_ancestor(const std::string &first, const std::string &second)
Check if the first path is an ancestor of the second.
Definition: fil0fil.h:536
fil_space_acquire_silent
fil_space_t * fil_space_acquire_silent(space_id_t space_id)
Acquire a tablespace that may not exist.
Definition: fil0fil.cc:3765
fil_io_set_encryption
void fil_io_set_encryption(IORequest &req_type, const page_id_t &page_id, fil_space_t *space)
Set encryption.
Definition: fil0fil.cc:7207
Encryption::Type
Type
Algorithm types supported.
Definition: os0file.h:288
mem_block_info_t
The info structure stored at the beginning of a heap block.
Definition: mem0mem.h:337
Fil_path::type_of_path
static path_type type_of_path(const std::string &path)
Determine if a path is an absolute path or not.
Definition: fil0fil.h:624
Fil_path::is_file_and_exists
bool is_file_and_exists() const
Definition: fil0fil.cc:9125
fil_rename_tablespace_check
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:4726
fil_space_t
Tablespace or log data space.
Definition: fil0fil.h:218
object_id.h
fil_encryption_rotate
bool fil_encryption_rotate()
Rotate the tablespace keys by new master key.
Definition: fil0fil.cc:8991
FIL_PAGE_TYPE_LOB_FIRST
constexpr page_type_t FIL_PAGE_TYPE_LOB_FIRST
The first page of an uncompressed LOB.
Definition: fil0fil.h:1030
os_offset_t
ib_uint64_t os_offset_t
File offset in bytes.
Definition: os0file.h:81
fil_update_partition_name
bool fil_update_partition_name(space_id_t space_id, uint32_t fsp_flags, bool update_space, std::string &space_name, std::string &dd_path)
Compare and update space name and dd path for partitioned table.
Definition: fil0fil.cc:9791
fil_space_open
bool fil_space_open(space_id_t space_id)
Open each file of a tablespace if not already open.
Definition: fil0fil.cc:3398
fil_node_t::modification_counter
int64_t modification_counter
number of writes to the file since the system was started
Definition: fil0fil.h:193
fil_page_check_type
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:1588
fil_page_set_type
void fil_page_set_type(byte *page, ulint type)
Sets the file page type.
Definition: fil0fil.cc:8148
fil_open_for_business
dberr_t fil_open_for_business(bool read_only_mode)
Free the Tablespace_files instance.
Definition: fil0fil.cc:9550
FIL_PAGE_TYPE_BLOB
constexpr page_type_t FIL_PAGE_TYPE_BLOB
Uncompressed BLOB page.
Definition: fil0fil.h:987
FIL_PAGE_TYPE_FSP_HDR
constexpr page_type_t FIL_PAGE_TYPE_FSP_HDR
File space header.
Definition: fil0fil.h:981
Fil_path::convert_to_lower_case
static void convert_to_lower_case(std::string &path)
Convert to lower case using the file system charset.
Definition: fil0fil.cc:11314
FIL_PAGE_INODE
constexpr page_type_t FIL_PAGE_INODE
Index node.
Definition: fil0fil.h:962
Fil_path::remove_quotes
static std::string remove_quotes(const char *pathspec)
Remove quotes e.g., 'a;b' or "a;b" -> a;b.
Definition: fil0fil.h:588
Fil_path::make_ibd
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:791
Fil_path
Wrapper for a path to a directory that may or may not exist.
Definition: fil0fil.h:367
buf_frame_t
byte buf_frame_t
A buffer frame.
Definition: buf0types.h:59
fil_op_replay_rename_for_ddl
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:9561
Fil_path::has_prefix
static bool has_prefix(const std::string &path, const std::string prefix)
Definition: fil0fil.h:658
fil_space_t::flags
uint32_t flags
Tablespace flags; see fsp_flags_is_valid() and page_size_t(ulint) (constructor).
Definition: fil0fil.h:269
fil_space_t::id
space_id_t id
Tablespace ID.
Definition: fil0fil.h:226
Fil_path::Fil_path
Fil_path()
Default constructor.
Definition: fil0fil.cc:9035
CFP
@ CFP
Definition: fil0fil.h:349
FIL_SCAN_MAX_TABLESPACES_PER_THREAD
constexpr size_t FIL_SCAN_MAX_TABLESPACES_PER_THREAD
Maximum number of tablespaces to be scanned by a thread while scanning for available tablespaces duri...
Definition: fil0fil.h:58
fil_space_t::stop_new_ops
bool stop_new_ops
We set this true when we start deleting a single-table tablespace.
Definition: fil0fil.h:239
fil_space_release
void fil_space_release(fil_space_t *space)
Release a tablespace acquired with fil_space_acquire().
Definition: fil0fil.cc:3771
NONE
@ NONE
Definition: fil0fil.h:215
PageCallback::init
virtual dberr_t init(os_offset_t file_size, const buf_block_t *block) 1=0
Called for page 0 in the tablespace file at the start.
FIL_PAGE_COMPRESSED_AND_ENCRYPTED
constexpr page_type_t FIL_PAGE_COMPRESSED_AND_ENCRYPTED
Compressed and Encrypted page.
Definition: fil0fil.h:1006
fil_addr_null
fil_addr_t fil_addr_null
The null file address.
Definition: fil0fil.cc:326
fil_addr_t::fil_addr_t
fil_addr_t(page_no_t p, uint32_t boff)
Constructor.
Definition: fil0fil.h:908
fil_check_missing_tablespaces
bool fil_check_missing_tablespaces()
This function should be called after recovery has completed.
Definition: fil0fil.cc:9941
fil_node_t::is_raw_disk
bool is_raw_disk
whether the file actually is a raw device or disk partition
Definition: fil0fil.h:165
fil_write_flushed_lsn
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:3698
Fil_path::get_real_path
static std::string get_real_path(const std::string &path, bool force=true)
Get the real path for a directory or a file name.
Definition: fil0fil.cc:3909
FIL_PAGE_TYPE_LOB_DATA
constexpr page_type_t FIL_PAGE_TYPE_LOB_DATA
Data pages of uncompressed LOB.
Definition: fil0fil.h:1027
page_size_t
Page size descriptor.
Definition: page0size.h:50
MySQL_datadir_path
Fil_path MySQL_datadir_path
The MySQL server –datadir value.
Definition: fil0fil.cc:277
fil_replace_tablespace
bool fil_replace_tablespace(space_id_t old_space_id, space_id_t new_space_id, page_no_t size_in_pages)
Truncate the tablespace to needed size with a new space_id.
Definition: fil0fil.cc:4343
Fil_path::SLASH_DOT_DOT_SLASH
static constexpr auto SLASH_DOT_DOT_SLASH
Definition: fil0fil.h:384
page0size.h
fil_scan_for_tablespaces
dberr_t fil_scan_for_tablespaces()
Discover tablespaces by reading the header from .ibd files.
Definition: fil0fil.cc:11167
fil_node_t::is_open
bool is_open
whether this file is open.
Definition: fil0fil.h:156
fil_reset_encryption
dberr_t fil_reset_encryption(space_id_t space_id)
Reset the encryption type for the tablespace.
Definition: fil0fil.cc:8875
fil_set_scan_dir
void fil_set_scan_dir(const std::string &directory, bool is_undo_dir=false)
Normalize and save a directory to scan for datafiles.
Definition: fil0fil.cc:11157
Fil_path::SEPARATOR
static constexpr auto SEPARATOR
Directory separators that are supported.
Definition: fil0fil.h:376
Fil_iterator::for_each_file
static dberr_t for_each_file(bool include_log, F &&f)
For each data file, exclude redo log files.
Definition: fil0fil.h:1223
fil_space_create
fil_space_t * fil_space_create(const char *name, space_id_t space_id, uint32_t flags, fil_type_t purpose)
Create a space memory object and put it to the fil_system hash table.
Definition: fil0fil.cc:3131
fil_tablespace_redo_create
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:9953
FIL_PAGE_IBUF_FREE_LIST
constexpr page_type_t FIL_PAGE_IBUF_FREE_LIST
Insert buffer free list.
Definition: fil0fil.h:965
FIL_PAGE_TYPE_UNUSED
constexpr page_type_t FIL_PAGE_TYPE_UNUSED
Available for future use.
Definition: fil0fil.h:1018
fil_init
void fil_init(ulint max_n_open)
Initializes the tablespace memory cache.
Definition: fil0fil.cc:3442
PageCallback::m_file
pfs_os_file_t m_file
File handle to the tablespace.
Definition: fil0fil.h:1686
PageCallback
Callback functor.
Definition: fil0fil.h:1631
fil_tablespace_redo_rename
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:10062
Fil_path::DOT_DOT_SLASH
static constexpr auto DOT_DOT_SLASH
Definition: fil0fil.h:383
fil_node_t::size
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:170
table_id_t
ib_id_t table_id_t
Table or partition identifier (unique within an InnoDB instance).
Definition: dict0types.h:215
Fil_path::normalize
static void normalize(std::string &path)
Normalize a directory path for the current OS: On Windows, we convert '/' to '\', else we convert '\'...
Definition: fil0fil.h:667
page
int page
Definition: ctype-mb.cc:1232
recv_recovery_on
volatile bool recv_recovery_on
true when applying redo log records during crash recovery; false otherwise.
Definition: log0recv.cc:101
fil_flush_file_redo
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:8122
pfs_os_file_t
Common file descriptor for file IO instrumentation with PFS on windows and other platforms.
Definition: os0file.h:136
fil_space_t::Files
std::vector< fil_node_t, ut_allocator< fil_node_t > > Files
Definition: fil0fil.h:220
fil_page_get_type
page_type_t fil_page_get_type(const byte *page)
Get the file page type.
Definition: fil0fil.h:1576
fil_node_t::List_node
UT_LIST_NODE_T(fil_node_t) List_node
Definition: fil0fil.h:145
fil_addr_t::fil_addr_t
fil_addr_t()
Definition: fil0fil.h:903
FIL_PAGE_TYPE_ZLOB_INDEX
constexpr page_type_t FIL_PAGE_TYPE_ZLOB_INDEX
Index pages of compressed LOB.
Definition: fil0fil.h:1040
Fil_path::normalize
static void normalize(char *path)
Normalize a directory path for the current OS: On Windows, we convert '/' to '\', else we convert '\'...
Definition: fil0fil.h:678
fil_ibt_create
dberr_t fil_ibt_create(space_id_t space_id, const char *name, const char *path, uint32_t flags, page_no_t size)
Create a session temporary tablespace (IBT) file.
Definition: fil0fil.cc:5376
FIL_SCAN_THREADS_PER_CORE
constexpr size_t FIL_SCAN_THREADS_PER_CORE
Number of threads per core.
Definition: fil0fil.h:66
Fil_state::MISSING
@ MISSING
No MLOG_FILE_DELETE record and the file could not be found.
buf_remove_t
buf_remove_t
Algorithm to remove the pages for a tablespace from the buffer pool.
Definition: buf0types.h:76
Fil_path::make_cfp
static char * make_cfp(const std::string &path_in)
Allocate and build a CFP file name from a path.
Definition: fil0fil.h:779
fil_io
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:7781
fil_addr_is_null
bool fil_addr_is_null(const fil_addr_t &addr)
Returns true if file address is undefined.
Definition: fil0fil.cc:8127
FIL_PAGE_TYPE_UNKNOWN
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:997
fil_space_t::s_sys_space
static fil_space_t * s_sys_space
System tablespace.
Definition: fil0fil.h:323
encryption_op_type
encryption_op_type
Definition: fil0fil.h:215
ut0new.h
fil_node_t::space
fil_space_t * space
tablespace containing this file
Definition: fil0fil.h:148
FIL_TYPE_LOG
@ FIL_TYPE_LOG
redo log covering changes to files of FIL_TYPE_TABLESPACE
Definition: fil0fil.h:109
Fil_state::DELETED
@ DELETED
A MLOG_FILE_DELETE was found, file was deleted.
Fil_state::RENAMED
@ RENAMED
Tablespace and/or filename was renamed.
rules_table_service::end
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:188
Filenames
std::vector< std::string, ut_allocator< std::string > > Filenames
Definition: fil0fil.h:97
fil_addr_t::boffset
uint32_t boffset
Byte offset within the page.
Definition: fil0fil.h:933
fil_path_to_space_name
char * fil_path_to_space_name(const char *filename)
Convert a file name to a tablespace name.
Definition: fil0fil.cc:5620
byte
unsigned char byte
Blob class.
Definition: common.h:159
FIL_PAGE_TYPE_RSEG_ARRAY
constexpr page_type_t FIL_PAGE_TYPE_RSEG_ARRAY
Rollback Segment Array page.
Definition: fil0fil.h:1021
Fil_path::abs_len
size_t abs_len() const
Definition: fil0fil.h:444
fil_space_get_type
fil_type_t fil_space_get_type(space_id_t space_id)
Gets the type of a file space.
Definition: fil0fil.cc:2106
trim
static char * trim(char *ptr)
Definition: testapp.c:546
FIL_PAGE_TYPE
#define FIL_PAGE_TYPE
file page type: FIL_PAGE_INDEX,..., 2 bytes.
Definition: fil0types.h:75
undo_space_name
static constexpr char undo_space_name[]
This tablespace name is used as the prefix for implicit undo tablespaces and during file discovery to...
Definition: fil0fil.h:82
fil_space_t::redo_skipped_count
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:244
fil_space_t::release_free_extents
void release_free_extents(ulint n_reserved)
Release the reserved free extents.
Definition: fil0fil.cc:9276
FIL_TYPE_IMPORT
@ FIL_TYPE_IMPORT
a tablespace that is being imported (no logging until finished)
Definition: fil0fil.h:105
Fil_path::is_same_as
bool is_same_as(const std::string &other) const
Check if this path is the same as the other path.
Definition: fil0fil.h:468
FIL_PAGE_ENCRYPTED
constexpr page_type_t FIL_PAGE_ENCRYPTED
Encrypted page.
Definition: fil0fil.h:1003
UNENCRYPTION
@ UNENCRYPTION
Definition: fil0fil.h:215
fil_space_is_redo_skipped
bool fil_space_is_redo_skipped(space_id_t space_id)
Check whether a single-table tablespace is redo skipped.
Definition: fil0fil.cc:4448
fil_space_set_imported
void fil_space_set_imported(space_id_t space_id)
Note that a tablespace has been imported.
Definition: fil0fil.cc:2126
operator<<
std::ostream & operator<<(std::ostream &out, const fil_addr_t &obj)
Definition: fil0fil.h:939
FIL_PAGE_TYPE_ALLOCATED
constexpr page_type_t FIL_PAGE_TYPE_ALLOCATED
Freshly allocated page.
Definition: fil0fil.h:969
fil_space_t::files
Files files
Files attached to this tablespace.
Definition: fil0fil.h:252
fil_node_create
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:2284
FIL_TYPE_TABLESPACE
@ FIL_TYPE_TABLESPACE
persistent tablespace (for system, undo log or tables)
Definition: fil0fil.h:107
FIL_TYPE_TEMPORARY
@ FIL_TYPE_TEMPORARY
temporary tablespace (temporary undo log or tables)
Definition: fil0fil.h:103
fil_node_t::max_size
page_no_t max_size
maximum size of the file in database pages
Definition: fil0fil.h:181
fil_tablespace_lookup_for_recovery
bool fil_tablespace_lookup_for_recovery(space_id_t space_id)
Lookup the space ID.
Definition: fil0fil.cc:9613
fil_extend_tablespaces_to_stored_len
void fil_extend_tablespaces_to_stored_len()
Extends all tablespaces to the size stored in the space header.
PageCallback::operator=
PageCallback & operator=(const PageCallback &)=delete
Fil_iterator::iterate
static dberr_t iterate(bool include_log, Function &&f)
Iterate over the spaces and file lists.
Definition: fil0fil.cc:3679
fil_n_log_flushes
ulint fil_n_log_flushes
The number of fsyncs done to the log.
Definition: fil0fil.cc:286
fil_n_pending_tablespace_flushes
ulint fil_n_pending_tablespace_flushes
Number of pending tablespace flushes.
Definition: fil0fil.cc:292
page_id_t
Page identifier.
Definition: buf0types.h:153
Fil_path::is_same_as
bool is_same_as(const Fil_path &other) const
Check if m_path is the same as this other path.
Definition: fil0fil.h:451
Fil_path::parse_file_path
static bool parse_file_path(const std::string &file_path, ib_file_suffix extn, std::string &dict_name)
Parse file-per-table file name and build Innodb dictionary table name.
Definition: fil0fil.cc:4624
path
static char * path
Definition: mysqldump.cc:130
name
const string name("\"Name\"")
Fil_path::truncate_suffix
static bool truncate_suffix(ib_file_suffix sfx, std::string &path)
Check if the file has the the specified suffix and truncate.
Definition: fil0fil.h:736
fil_space_t::compression_type
Compression::Type compression_type
Compression algorithm.
Definition: fil0fil.h:298
NO_EXT
@ NO_EXT
Definition: fil0fil.h:349
dd::Object_id
unsigned long long Object_id
Definition: object_id.h:30
fil_node_t::atomic_write
bool atomic_write
whether atomic write is enabled for this file
Definition: fil0fil.h:208
PageCallback::m_filepath
const char * m_filepath
Physical file path.
Definition: fil0fil.h:1689
page_type_t
uint16_t page_type_t
Definition: fil0fil.h:946
fil_add_moved_space
void fil_add_moved_space(dd::Object_id dd_object_id, space_id_t space_id, const char *space_name, const std::string &old_path, const std::string &new_path)
Add tablespace to the set of tablespaces to be updated in DD.
Definition: fil0fil.cc:9784
dict_name
Innodb data dictionary name.
Definition: dict0dd.cc:6152
fil_addr_t::is_null
bool is_null() const
Check if the file address is null.
Definition: fil0fil.h:919
Fil_path::is_absolute_path
bool is_absolute_path() const
Definition: fil0fil.h:608
fil_tablespace_redo_delete
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:10190
dot_ext
const char * dot_ext[]
Common InnoDB file extentions.
Definition: fil0fil.cc:283
FIL_PAGE_TYPE_ZBLOB
constexpr page_type_t FIL_PAGE_TYPE_ZBLOB
First compressed BLOB page.
Definition: fil0fil.h:990
fil_check_path
bool fil_check_path(const std::string &path)
Check if a path is known to InnoDB.
Definition: fil0fil.cc:11172
Fil_path::is_separator
static bool is_separator(char c)
Check if a character is a path separator ('\' or '/')
Definition: fil0fil.h:752
fil_free_scanned_files
void fil_free_scanned_files()
Free the data structures required for recovery.
Definition: fil0fil.cc:11181
Fil_path::m_path
std::string m_path
Path to a file or directory.
Definition: fil0fil.h:862
Fil_path::make_new_path
static std::string make_new_path(const std::string &path_in, const std::string &name_in, ib_file_suffix extn)
Create an IBD path name after replacing the basename in an old path with a new basename.
Definition: fil0fil.cc:4656
Fil_iterator::Function
std::function< dberr_t(fil_node_t *)> Function
Definition: fil0fil.h:1217
Fil_path::has_suffix
static bool has_suffix(ib_file_suffix sfx, const std::string &path)
Check if the file has the the specified suffix.
Definition: fil0fil.h:724
Fil_path::absolute
@ absolute
Definition: fil0fil.h:388
fil_rename_precheck
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:8668
Fil_path::is_valid
bool is_valid() const
This validation is only for ':'.
Definition: fil0fil.cc:9136
PageCallback::m_page_size
page_size_t m_page_size
The tablespace page size.
Definition: fil0fil.h:1683
FIL_PAGE_TYPE_ZLOB_FRAG_ENTRY
constexpr page_type_t FIL_PAGE_TYPE_ZLOB_FRAG_ENTRY
Index pages of fragment pages (compressed LOB).
Definition: fil0fil.h:1046
fil_node_t::flush_counter
int64_t flush_counter
the modification_counter of the latest flush to disk
Definition: fil0fil.h:196
Fil_path::file_name_only
@ file_name_only
Definition: fil0fil.h:388
PageCallback::get_page_size
const page_size_t & get_page_size() const
The compressed page size.
Definition: fil0fil.h:1678
Fil_path::make_cfg
static char * make_cfg(const std::string &path_in)
Allocate and build a CFG file name from a path.
Definition: fil0fil.h:771
std
Definition: varlen_sort.h:182
fil_node_t::in_use
size_t in_use
e.g., when a file is being extended or just opened.
Definition: fil0fil.h:190
fil_space_acquire
fil_space_t * fil_space_acquire(space_id_t space_id)
Acquire a tablespace when it could be dropped concurrently.
Definition: fil0fil.cc:3756
HttpMethod::type
int type
Definition: http_common.h:411
fil_space_get_size
page_no_t fil_space_get_size(space_id_t space_id)
Returns the size of the space in pages.
Definition: fil0fil.cc:3342
fil_n_pending_log_flushes
ulint fil_n_pending_log_flushes
Number of pending redo log flushes.
Definition: fil0fil.cc:289
fil_space_t::size_in_header
page_no_t size_in_header
FSP_SIZE in the tablespace header; 0 if not known yet.
Definition: fil0fil.h:258
fil_set_encryption
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:8831
equal
static bool equal(const Item *i1, const Item *i2, const Field *f2)
Definition: sql_select.cc:3548
FIL_NULL
constexpr page_no_t FIL_NULL
'null' (undefined) page offset in the context of file spaces
Definition: fil0fil.h:884
FIL_PAGE_SDI_BLOB
constexpr page_type_t FIL_PAGE_SDI_BLOB
Uncompressed SDI BLOB page.
Definition: fil0fil.h:1012
FIL_NODE_MAGIC_N
constexpr size_t FIL_NODE_MAGIC_N
Value of fil_node_t::magic_n.
Definition: fil0fil.h:346
space_id_t
uint32 space_id_t
Tablespace identifier.
Definition: api0api.h:59
rw_lock_t
The structure used in the spin lock implementation of a read-write lock.
Definition: sync0rw.h:555
Fil_path::is_directory_and_exists
bool is_directory_and_exists() const
Definition: fil0fil.cc:9130
fil_space_t::free_limit
page_no_t free_limit
Contents of FSP_FREE_LIMIT.
Definition: fil0fil.h:264
fil_set_scan_dirs
void fil_set_scan_dirs(const std::string &directories)
Normalize and save a list of directories to scan for datafiles.
Definition: fil0fil.cc:11161
fil_space_t::encryption_key
byte encryption_key[ENCRYPTION_KEY_LEN]
Encrypt key.
Definition: fil0fil.h:304
fil_delete_file
bool fil_delete_file(const char *path)
Delete the tablespace file and any related files like .cfg.
Definition: fil0fil.cc:8637
SPACE_UNKNOWN
constexpr space_id_t SPACE_UNKNOWN
Unknown space id.
Definition: fil0fil.h:890
file_size
static size_t file_size
Definition: mysql_config_editor.cc:70
fil_no_punch_hole
void fil_no_punch_hole(fil_node_t *file)
Note that the file system where the file resides doesn't support PUNCH HOLE.
Definition: fil0fil.cc:8749
fil_space_inc_redo_skipped_count
void fil_space_inc_redo_skipped_count(space_id_t space_id)
Increase redo skipped of a tablespace.
Definition: fil0fil.cc:4414
Fil_path::abs_path
const std::string abs_path() const
Return the absolute path by value.
Definition: fil0fil.h:435
fil_space_t::encryption_op_in_progress
encryption_op_type encryption_op_in_progress
Encryption is in progress.
Definition: fil0fil.h:313
fil_close_all_files
void fil_close_all_files()
Closes all open files.
Definition: fil0fil.cc:3564
fil_node_t::flush_size
page_no_t flush_size
Size of the file when last flushed, used to force the flush when file grows to keep the filesystem me...
Definition: fil0fil.h:174
fil_discard_tablespace
dberr_t fil_discard_tablespace(space_id_t space_id)
Discards a single-table tablespace.
Definition: fil0fil.cc:4477
fil_space_read_name_and_filepath
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:5590
fil0types.h
FIL_PAGE_TYPE_TRX_SYS
constexpr page_type_t FIL_PAGE_TYPE_TRX_SYS
Transaction system data.
Definition: fil0fil.h:978
fil_addr_t::page
page_no_t page
Page number within a space.
Definition: fil0fil.h:930
PageCallback::~PageCallback
virtual ~PageCallback() 1
Definition: fil0fil.h:1635
FIL_SPACE_MAGIC_N
constexpr size_t FIL_SPACE_MAGIC_N
Value of fil_space_t::magic_n.
Definition: fil0fil.h:343
fil_close
void fil_close()
Initializes the tablespace memory cache.
Definition: fil0fil.cc:8168
Fil_path::DOT_SLASH
static constexpr auto DOT_SLASH
Definition: fil0fil.h:382
fil_space_t::print_xdes_pages
std::ostream & print_xdes_pages(std::ostream &out) const
Print the extent descriptor pages of this tablespace into the given output stream.
Definition: fil0fil.cc:9303
fil_adjust_name_import
void fil_adjust_name_import(dict_table_t *table, const char *path, ib_file_suffix extn)
Adjust file name for import for partition files in different letter case.
Definition: fil0fil.cc:8366
fil_space_t::is_in_unflushed_spaces
bool is_in_unflushed_spaces
true if this space is currently in unflushed_spaces
Definition: fil0fil.h:295
fil_space_t::s_redo_space
static fil_space_t * s_redo_space
Redo log tablespace.
Definition: fil0fil.h:326
Fil_path::invalid
@ invalid
Definition: fil0fil.h:388
fil_page_get_prev
page_no_t fil_page_get_prev(const byte *page)
Get the predecessor of a file page.
Definition: fil0fil.cc:8134
fil_space_t::free_len
uint32_t free_len
Length of the FSP_FREE list.
Definition: fil0fil.h:261
fil_node_t::n_pending_flushes
size_t n_pending_flushes
count of pending flushes; is_open must be true if nonzero
Definition: fil0fil.h:187
Fil_path::convert_to_filename_charset
static void convert_to_filename_charset(std::string &name)
Convert filename to the file system charset format.
Definition: fil0fil.cc:11297
fil_addr_t
File space address.
Definition: fil0fil.h:901
Fil_path::is_valid_location
static bool is_valid_location(const char *space_name, const std::string &path)
Check if the filepath provided is in a valid placement.
Definition: fil0fil.cc:11210
fil_space_close
void fil_space_close(space_id_t space_id)
Close each file of a tablespace if open.
Definition: fil0fil.cc:3412
fil_space_get
fil_space_t * fil_space_get(space_id_t space_id)
Look up a tablespace.
Definition: fil0fil.cc:2072
fil_space_t::n_pending_ops
uint32_t n_pending_ops
This is positive when we have pending operations against this tablespace.
Definition: fil0fil.h:283
p
const char * p
Definition: ctype-mb.cc:1233
fil_space_exists_in_mem
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:6099
FIL_PAGE_UNDO_LOG
constexpr page_type_t FIL_PAGE_UNDO_LOG
Undo log page.
Definition: fil0fil.h:959
fil_space_t::List_node
UT_LIST_NODE_T(fil_space_t) List_node
Definition: fil0fil.h:219
PageCallback::PageCallback
PageCallback()
Default constructor.
Definition: fil0fil.h:1633
fil_node_t::block_size
size_t block_size
block size to use for punching holes
Definition: fil0fil.h:205
fil_get_dirs
std::string fil_get_dirs()
Get the list of directories that datafiles can reside in.
Definition: fil0fil.cc:11178
fil_ibd_create
dberr_t fil_ibd_create(space_id_t space_id, const char *name, const char *path, uint32_t flags, page_no_t size)
Create a tablespace file.
Definition: fil0fil.cc:5360
Fil_path::make
static char * make(const std::string &path_in, const std::string &name_in, ib_file_suffix ext, bool trim=false)
Allocate and build a file name from a path, a table or tablespace name and a suffix.
Definition: fil0fil.cc:4542
fil_node_t
File node of a tablespace or the log data space.
Definition: fil0fil.h:144
fil_space_get_page_size
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:3427
Fil_path::get_file_type
static os_file_type_t get_file_type(const std::string &path)
Definition: fil0fil.cc:9064
trx_t
Definition: trx0trx.h:780
FIL_IBD_FILE_INITIAL_SIZE
constexpr size_t FIL_IBD_FILE_INITIAL_SIZE
Initial size of a single-table tablespace in pages.
Definition: fil0fil.h:875
fil_node_t::n_pending
size_t n_pending
count of pending i/o's; is_open must be true if nonzero
Definition: fil0fil.h:184
Fil_path::len
size_t len() const
Definition: fil0fil.h:426
FIL_PAGE_TYPE_SYS
constexpr page_type_t FIL_PAGE_TYPE_SYS
System page.
Definition: fil0fil.h:975
Fil_path::is_circular
bool is_circular() const
Determine if m_path contains a circular section like "/anydir/../" Fil_path::normalize() must be run ...
Definition: fil0fil.cc:9160
flags
static int flags[50]
Definition: hp_test1.cc:39
filename
const char * filename
Definition: pfs_example_component_population.cc:64
MySQL_undo_path
Fil_path MySQL_undo_path
The MySQL server –innodb-undo-directory value.
Definition: fil0fil.cc:280
FIL_PAGE_TYPE_ZBLOB2
constexpr page_type_t FIL_PAGE_TYPE_ZBLOB2
Subsequent compressed BLOB page.
Definition: fil0fil.h:993
log0recv.h
ib_file_suffix
ib_file_suffix
Common InnoDB file extentions.
Definition: fil0fil.h:349
ibuf0types.h
fil_node_t::magic_n
size_t magic_n
FIL_NODE_MAGIC_N.
Definition: fil0fil.h:211
false
#define false
Definition: config_static.h:43
fil_space_t::stop_ios
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:230