MySQL  8.0.23
Source Code Documentation
fil0fil.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 1995, 2020, Oracle and/or its affiliates.
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 "m_ctype.h"
48 #include "sql/dd/object_id.h"
49 
50 #include <atomic>
51 #include <list>
52 #include <vector>
53 
54 /** Maximum number of tablespaces to be scanned by a thread while scanning
55 for available tablespaces during server startup. This is a hard maximum.
56 If the number of files to be scanned is more than
57 FIL_SCAN_MAX_TABLESPACES_PER_THREAD,
58 then additional threads will be spawned to scan the additional files in
59 parallel. */
60 constexpr size_t FIL_SCAN_MAX_TABLESPACES_PER_THREAD = 8000;
61 
62 /** Maximum number of threads that will be used for scanning the tablespace
63 files. This can be further adjusted depending on the number of available
64 cores. */
65 constexpr size_t FIL_SCAN_MAX_THREADS = 16;
66 
67 /** Number of threads per core. */
68 constexpr size_t FIL_SCAN_THREADS_PER_CORE = 2;
69 
70 /** Calculate the number of threads that can be spawned to scan the given
71 number of files taking into the consideration, number of cores available
72 on the machine.
73 @param[in] num_files Number of files to be scanned
74 @return number of threads to be spawned for scanning the files */
75 size_t fil_get_scan_threads(size_t num_files);
76 
77 /** This tablespace name is used internally during file discovery to open a
78 general tablespace before the data dictionary is recovered and available. */
79 static constexpr char general_space_name[] = "innodb_general";
80 
81 /** This tablespace name is used as the prefix for implicit undo tablespaces
82 and during file discovery to open an undo tablespace before the DD is
83 recovered and available. */
84 static constexpr char undo_space_name[] = "innodb_undo";
85 
86 extern volatile bool recv_recovery_on;
87 
88 #ifdef UNIV_HOTBACKUP
89 #include <unordered_set>
90 using Dir_set = std::unordered_set<std::string>;
91 extern Dir_set rem_gen_ts_dirs;
92 extern bool replay_in_datadir;
93 #endif /* UNIV_HOTBACKUP */
94 
95 // Forward declaration
96 struct trx_t;
97 class page_id_t;
98 
99 using Filenames = std::vector<std::string, ut_allocator<std::string>>;
100 using Space_ids = std::vector<space_id_t, ut_allocator<space_id_t>>;
101 
102 /** File types */
103 enum fil_type_t : uint8_t {
104  /** temporary tablespace (temporary undo log or tables) */
106  /** a tablespace that is being imported (no logging until finished) */
108  /** persistent tablespace (for system, undo log or tables) */
110  /** redo log covering changes to files of FIL_TYPE_TABLESPACE */
111  FIL_TYPE_LOG = 8
112 };
113 
114 /** Result of comparing a path. */
115 enum class Fil_state {
116  /** The path matches what was found during the scan. */
117  MATCHES,
118 
119  /** No MLOG_FILE_DELETE record and the file could not be found. */
120  MISSING,
121 
122  /** A MLOG_FILE_DELETE was found, file was deleted. */
123  DELETED,
124 
125  /** Space ID matches but the paths don't match. */
126  MOVED,
127 
128  /** Tablespace and/or filename was renamed. The DDL log will handle
129  this case. */
130  RENAMED
131 };
132 
133 /** Check if fil_type is any of FIL_TYPE_TEMPORARY, FIL_TYPE_IMPORT
134 or FIL_TYPE_TABLESPACE.
135 @param[in] type variable of type fil_type_t
136 @return true if any of FIL_TYPE_TEMPORARY, FIL_TYPE_IMPORT
137 or FIL_TYPE_TABLESPACE */
139  return (type == FIL_TYPE_TEMPORARY || type == FIL_TYPE_IMPORT ||
141 }
142 
143 struct fil_space_t;
144 
145 /** File node of a tablespace or the log data space */
146 struct fil_node_t {
148 
149  /** tablespace containing this file */
151 
152  /** file name; protected by Fil_shard::m_mutex and log_sys->mutex. */
153  char *name;
154 
155  /** whether this file is open. Note: We set the is_open flag after
156  we increase the write the MLOG_FILE_OPEN record to redo log. Therefore
157  we increment the in_use reference count before setting the OPEN flag. */
158  bool is_open;
159 
160  /** file handle (valid if is_open) */
162 
163  /** event that groups and serializes calls to fsync */
165 
166  /** whether the file actually is a raw device or disk partition */
168 
169  /** size of the file in database pages (0 if not known yet);
170  the possible last incomplete megabyte may be ignored
171  if space->id == 0 */
173 
174  /** Size of the file when last flushed, used to force the flush when file
175  grows to keep the filesystem metadata synced when using O_DIRECT_NO_FSYNC */
177 
178  /** initial size of the file in database pages;
179  FIL_IBD_FILE_INITIAL_SIZE by default */
181 
182  /** maximum size of the file in database pages */
184 
185  /** count of pending i/o's; is_open must be true if nonzero */
186  size_t n_pending;
187 
188  /** count of pending flushes; is_open must be true if nonzero */
190 
191  /** e.g., when a file is being extended or just opened. */
192  size_t in_use;
193 
194  /** number of writes to the file since the system was started */
196 
197  /** the modification_counter of the latest flush to disk */
198  int64_t flush_counter;
199 
200  /** link to the fil_system->LRU list (keeping track of open files) */
202 
203  /** whether the file system of this file supports PUNCH HOLE */
205 
206  /** block size to use for punching holes */
207  size_t block_size;
208 
209  /** whether atomic write is enabled for this file */
211 
212  /** FIL_NODE_MAGIC_N */
213  size_t magic_n;
214 };
215 
216 /* Type of (un)encryption operation in progress for Tablespace. */
218 
219 /** Tablespace or log data space */
220 struct fil_space_t {
222  using Files = std::vector<fil_node_t, ut_allocator<fil_node_t>>;
223 
224  /** Release the reserved free extents.
225  @param[in] n_reserved number of reserved extents */
226  void release_free_extents(ulint n_reserved);
227 
228  /** @return true if the instance is queued for deletion. Guarantees the space
229  is not deleted as long as the fil_shard mutex is not released. */
230  bool is_deleted() const;
231 
232  /** @return true if the instance was not queued for deletion. It does not
233  guarantee it is not queued for deletion at the moment. */
234  bool was_not_deleted() const;
235 
236  /** Marks the space object for deletion. It will bump the space object version
237  and cause all pages in buffer pool that reference to the current space
238  object version to be stale and be freed on first encounter. */
239  void set_deleted();
240 
241 #ifndef UNIV_HOTBACKUP
242  /** Returns current version of the space object. It is being bumped when the
243  space is truncated or deleted. Guarantees the version returned is up to date
244  as long as fil_shard mutex is not released.*/
245  uint32_t get_current_version() const;
246 
247  /** Returns current version of the space object. It is being bumped when the
248  space is truncated or deleted. It does not guarantee the version is current
249  one.*/
250  uint32_t get_recent_version() const;
251 
252  /** Bumps the space object version and cause all pages in buffer pool that
253  reference the current space object version to be stale and be freed on
254  first encounter. */
255  void bump_version();
256 
257  /** @return true if this space does not have any more references. Guarantees
258  the result only if true was returned. */
259  bool has_no_references() const;
260 
261  /** @return Current number of references to the space. This method
262  should be called only while shutting down the server. Only when there is no
263  background nor user session activity the returned value will be valid. */
264  size_t get_reference_count() const;
265 
266  /** Increment the page reference count. */
267  void inc_ref() noexcept {
268  const auto o = m_n_ref_count.fetch_add(1);
269  ut_a(o != std::numeric_limits<size_t>::max());
270  }
271 
272  /** Decrement the page reference count. */
273  void dec_ref() noexcept {
274  const auto o = m_n_ref_count.fetch_sub(1);
275  ut_a(o >= 1);
276  }
277 #endif /* !UNIV_HOTBACKUP */
278 
279 #ifdef UNIV_DEBUG
280  /** Print the extent descriptor pages of this tablespace into
281  the given output stream.
282  @param[in] out the output stream.
283  @return the output stream. */
284  std::ostream &print_xdes_pages(std::ostream &out) const;
285 
286  /** Print the extent descriptor pages of this tablespace into
287  the given file.
288  @param[in] filename the output file name. */
289  void print_xdes_pages(const char *filename) const;
290 #endif /* UNIV_DEBUG */
291 
292  public:
294  using FlushObservers = std::vector<Observer *, ut_allocator<Observer *>>;
295 
296  /** When the tablespace was extended last. */
298 
299  /** Extend undo tablespaces by so many pages. */
301 
302  /** Tablespace name */
303  char *name{};
304 
305  /** Tablespace ID */
307 
308  /** Initializes fields. This could be replaced by a constructor if SunPro is
309  compiling it correctly. */
310  void initialize() noexcept {
311  new (&m_last_extended) ib::Timer;
312  new (&files) fil_space_t::Files();
313 
314 #ifndef UNIV_HOTBACKUP
315  new (&m_version) std::atomic<uint32_t>;
316  new (&m_n_ref_count) std::atomic_size_t;
317  new (&m_deleted) std::atomic<bool>;
318 #endif /* !UNIV_HOTBACKUP */
319 
320  /** This is the number of pages needed extend an undo tablespace by 16 MB.
321  It is increased during aggressive growth and decreased when the growth
322  is slower. */
323  m_undo_extend = (16 * 1024 * 1024) / UNIV_PAGE_SIZE;
324  }
325 
326  private:
327 #ifndef UNIV_HOTBACKUP
328  /** All pages in the buffer pool that reference this fil_space_t instance with
329  version before this version can be lazily freed or reused as free pages.
330  They should be rejected if there is an attempt to write them to disk.
331 
332  Writes to m_version are guarded by the exclusive MDL/table lock latches
333  acquired by the caller, as stated in docs. Note that the Fil_shard mutex seems
334  to be latched in 2 of 3 usages only, so is not really an alternative.
335 
336  Existence of the space object during reads is assured during these operations:
337  1. when read by the buf_page_init_low on page read/creation - the caller must
338  have acquired shared MDL/table lock latches.
339  2. when read on buf_page_t::is_stale() on page access for a query or for purge
340  operation. The caller must have acquired shared MDL/table lock latches.
341  3. when read on buf_page_t::is_stale() on page access from LRU list, flush
342  list or whatever else. Here, the fact that the page has latched the space
343  using the reference counting system is what guards the space existence.
344 
345  When reading the value for the page being created with buf_page_init_low we
346  have the MDL latches on table that is in tablespace or the tablespace alone,
347  so we won't be able to bump m_version until they are released, so we will
348  read the current value of the version. When reading the value for the page
349  validation with buf_page_t::is_stale(), we will either:
350  a) have the MDL latches required in at least S mode in case we need to be
351  certain if the page is stale, to use it in a query or in purge operation, or
352  b) in case we don't not have the MDL latches, we may read an outdated value.
353  This happens for pages that are seen during for example LRU or flush page
354  scans. These pages are not needed for the query itself. The read is to decide
355  if the page can be safely discarded. Reading incorrect value can lead to no
356  action being executed. Reading incorrect value can't lead to page being
357  incorrectly evicted.
358  */
359  std::atomic<uint32_t> m_version{};
360 
361  /** Number of buf_page_t entries that point to this instance.
362 
363  This field is guarded by the Fil_shard mutex and the "reference
364  count system". The reference count system here is allowing to take a "latch"
365  on the space by incrementing the reference count, and release it by
366  decrementing it.
367 
368  The increments are possible from two places:
369  1. buf_page_init_low is covered by the existing MDL/table lock latches only
370  and the fact that the space it is using is a current version of the space
371  (the version itself is also guarded by these MDL/table lock latches). It
372  implicitly acquires the "reference count system" latch after this operation.
373  2. buf_page_t::buf_page_t(const buf_page_t&) copy constructor - increases the
374  value, but it assumes the page being copied from has "reference count system"
375  latch so the reference count is greater than 0 during this constructor call.
376 
377  For decrementing the reference count is itself a latch allowing for the safe
378  decrement.
379 
380  The value is checked for being 0 in Fil_shard::checkpoint under the Fil_shard
381  mutex, and only if the space is deleted.
382  Observing m_n_ref_count==0 might trigger freeing the object. No other thread
383  can be during the process of incrementing m_n_ref_count from 0 to 1 in
384  parallel to this check. This is impossible for following reasons. Recall the
385  only two places where we do increments listed above:
386  1. If the space is deleted, then MDL/table lock latches guarantee there are
387  no users that would be able to see it as the current version of space and thus
388  will not attempt to increase the reference value from 0.
389  2. The buf_page_t copy constructor can increase it, but it assumes the page
390  being copied from has "reference count system" latch so the reference count is
391  greater than 0 during this constructor call.
392 
393  There is also an opposite race possible: while we check for ref count being
394  zero, another thread may be decrementing it in parallel, and we might miss
395  that if we check too soon. This is benign, as it will result in us not
396  reclaiming the memory we could (but not have to) free, and will return to the
397  check on next checkpoint.
398  */
399  std::atomic_size_t m_n_ref_count{};
400 #endif /* !UNIV_HOTBACKUP */
401 
402  /** true if the tablespace is marked for deletion. */
403  std::atomic_bool m_deleted{};
404 
405  public:
406  /** true if we want to rename the .ibd file of tablespace and
407  want to stop temporarily posting of new i/o requests on the file */
408  bool stop_ios{};
409 
410  /** We set this true when we start deleting a single-table
411  tablespace. When this is set following new ops are not allowed:
412  * read IO request
413  * ibuf merge
414  * file flush
415  Note that we can still possibly have new write operations because we
416  don't check this flag when doing flush batches. */
417  bool stop_new_ops{};
418 
419 #ifdef UNIV_DEBUG
420  /** Reference count for operations who want to skip redo log in
421  the file space in order to make fsp_space_modify_check pass. */
423 #endif /* UNIV_DEBUG */
424 
425  /** Purpose */
427 
428  /** Files attached to this tablespace. Note: Only the system tablespace
429  can have multiple files, this is a legacy issue. */
431 
432  /** Tablespace file size in pages; 0 if not known yet */
434 
435  /** FSP_SIZE in the tablespace header; 0 if not known yet */
437 
438  /** Autoextend size */
440 
441  /** Length of the FSP_FREE list */
442  uint32_t free_len{};
443 
444  /** Contents of FSP_FREE_LIMIT */
446 
447  /** Tablespace flags; see fsp_flags_is_valid() and
448  page_size_t(ulint) (constructor).
449  This is protected by space->latch and tablespace MDL */
450  uint32_t flags{};
451 
452  /** Number of reserved free extents for ongoing operations like
453  B-tree page split */
454  uint32_t n_reserved_extents{};
455 
456  /** This is positive when flushing the tablespace to disk;
457  dropping of the tablespace is forbidden if this is positive */
458  uint32_t n_pending_flushes{};
459 
460  /** This is positive when we have pending operations against this
461  tablespace. The pending operations can be ibuf merges or lock
462  validation code trying to read a block. Dropping of the tablespace
463  is forbidden if this is positive. Protected by Fil_shard::m_mutex. */
464  uint32_t n_pending_ops{};
465 
466 #ifndef UNIV_HOTBACKUP
467  /** Latch protecting the file space storage allocation */
469 #endif /* !UNIV_HOTBACKUP */
470 
471  /** List of spaces with at least one unflushed file we have
472  written to */
474 
475  /** true if this space is currently in unflushed_spaces */
477 
478  /** Compression algorithm */
480 
481  /** Encryption algorithm */
483 
484  /** Encrypt key */
486 
487  /** Encrypt key length*/
489 
490  /** Encrypt initial vector */
492 
493  /** Encryption is in progress */
495 
496  /** Flush lsn of header page. It is used only during recovery */
498 
499  /** FIL_SPACE_MAGIC_N */
500  ulint magic_n;
501 
502  /** System tablespace */
504 
505  /** Redo log tablespace */
507 
508  /** Check if the tablespace is compressed.
509  @return true if compressed, false otherwise. */
510  bool is_compressed() const noexcept MY_ATTRIBUTE((warn_unused_result)) {
512  }
513 
514  /** Check if the tablespace is encrypted.
515  @return true if encrypted, false otherwise. */
516  bool is_encrypted() const noexcept MY_ATTRIBUTE((warn_unused_result)) {
518  }
519 
520  /** Check if the encryption details, like the encryption key, type and
521  other details, that are needed to carry out encryption are available.
522  @return true if encryption can be done, false otherwise. */
523  bool can_encrypt() const noexcept MY_ATTRIBUTE((warn_unused_result)) {
525  }
526 
527  /** Copy the encryption info from this object to the provided
528  Encryption object.
529  @param[in] en Encryption object to which info is copied. */
530  void get_encryption_info(Encryption &en) noexcept {
531  en.set_type(encryption_type);
532  en.set_key(encryption_key);
533  en.set_key_length(encryption_klen);
534  en.set_initial_vector(encryption_iv);
535  }
536 
537  public:
538  /** Get the file node corresponding to the given page number of the
539  tablespace.
540  @param[in,out] page_no Caller passes the page number within a tablespace.
541  After return, it contains the page number within
542  the returned file node. For tablespaces containing
543  only one file, the given page_no will not change.
544  @return the file node object. */
545  fil_node_t *get_file_node(page_no_t *page_no) noexcept
546  MY_ATTRIBUTE((warn_unused_result));
547 };
548 
549 /** Value of fil_space_t::magic_n */
550 constexpr size_t FIL_SPACE_MAGIC_N = 89472;
551 
552 /** Value of fil_node_t::magic_n */
553 constexpr size_t FIL_NODE_MAGIC_N = 89389;
554 
555 /** Common InnoDB file extentions */
557  NO_EXT = 0,
558  IBD = 1,
559  CFG = 2,
560  CFP = 3,
561  IBT = 4,
562  IBU = 5,
563  DWR = 6
564 };
565 
566 extern const char *dot_ext[];
567 
568 #define DOT_IBD dot_ext[IBD]
569 #define DOT_CFG dot_ext[CFG]
570 #define DOT_CFP dot_ext[CFP]
571 #define DOT_IBT dot_ext[IBT]
572 #define DOT_IBU dot_ext[IBU]
573 #define DOT_DWR dot_ext[DWR]
574 
575 #ifdef _WIN32
576 /* Initialization of m_abs_path() produces warning C4351:
577 "new behavior: elements of array '...' will be default initialized."
578 See https://msdn.microsoft.com/en-us/library/1ywe7hcy.aspx */
579 #pragma warning(disable : 4351)
580 #endif /* _WIN32 */
581 
582 /** Wrapper for a path to a directory that may or may not exist. */
583 class Fil_path {
584  public:
585  /** schema '/' table separator */
586  static constexpr auto DB_SEPARATOR = '/';
587 
588  /** OS specific path separator. */
589  static constexpr auto OS_SEPARATOR = OS_PATH_SEPARATOR;
590 
591  /** Directory separators that are supported. */
592  static constexpr auto SEPARATOR = "\\/";
593 #ifdef _WIN32
594  static constexpr auto DOT_SLASH = ".\\";
595  static constexpr auto DOT_DOT_SLASH = "..\\";
596  static constexpr auto SLASH_DOT_DOT_SLASH = "\\..\\";
597 #else
598  static constexpr auto DOT_SLASH = "./";
599  static constexpr auto DOT_DOT_SLASH = "../";
600  static constexpr auto SLASH_DOT_DOT_SLASH = "/../";
601 #endif /* _WIN32 */
602 
603  /** Various types of file paths. */
605 
606  /** Default constructor. Defaults to MySQL_datadir_path. */
607  Fil_path();
608 
609  /** Constructor
610  @param[in] path Path, not necessarily NUL terminated
611  @param[in] len Length of path
612  @param[in] normalize_path If false, it's the callers responsibility to
613  ensure that the path is normalized. */
614  explicit Fil_path(const char *path, size_t len, bool normalize_path = false);
615 
616  /** Constructor
617  @param[in] path Path, not necessarily NUL terminated
618  @param[in] normalize_path If false, it's the callers responsibility to
619  ensure that the path is normalized. */
620  explicit Fil_path(const char *path, bool normalize_path = false);
621 
622  /** Constructor
623  @param[in] path pathname (may also include the file basename)
624  @param[in] normalize_path If false, it's the callers responsibility to
625  ensure that the path is normalized. */
626  explicit Fil_path(const std::string &path, bool normalize_path = false);
627 
628  /** Implicit type conversion
629  @return pointer to m_path.c_str() */
630  operator const char *() const MY_ATTRIBUTE((warn_unused_result)) {
631  return m_path.c_str();
632  }
633 
634  /** Explicit type conversion
635  @return pointer to m_path.c_str() */
636  const char *operator()() const MY_ATTRIBUTE((warn_unused_result)) {
637  return m_path.c_str();
638  }
639 
640  /** @return the value of m_path */
641  const std::string &path() const MY_ATTRIBUTE((warn_unused_result)) {
642  return (m_path);
643  }
644 
645  /** @return the length of m_path */
646  size_t len() const MY_ATTRIBUTE((warn_unused_result)) {
647  return (m_path.length());
648  }
649 
650  /** Return the absolute path by value. If m_abs_path is null, calculate
651  it and return it by value without trying to reset this const object.
652  m_abs_path can be empty if the path did not exist when this object
653  was constructed.
654  @return the absolute path by value. */
655  const std::string abs_path() const MY_ATTRIBUTE((warn_unused_result)) {
656  if (m_abs_path.empty()) {
657  return (get_real_path(m_path));
658  }
659 
660  return (m_abs_path);
661  }
662 
663  /** @return the length of m_abs_path */
664  size_t abs_len() const MY_ATTRIBUTE((warn_unused_result)) {
665  return (m_abs_path.length());
666  }
667 
668  /** Determine if this path is equal to the other path.
669  @param[in] other path to compare to
670  @return true if the paths are the same */
671  bool operator==(const Fil_path &other) const { return (is_same_as(other)); }
672 
673  /** Check if m_path is the same as this other path.
674  @param[in] other directory path to compare to
675  @return true if m_path is the same as path */
676  bool is_same_as(const Fil_path &other) const
677  MY_ATTRIBUTE((warn_unused_result));
678 
679  /** Check if this path is the same as the other path.
680  @param[in] other directory path to compare to
681  @return true if this path is the same as the other path */
682  bool is_same_as(const std::string &other) const
683  MY_ATTRIBUTE((warn_unused_result));
684 
685  /** Check if two path strings are equal. Put them into Fil_path objects
686  so that they can be compared correctly.
687  @param[in] first first path to check
688  @param[in] second socond path to check
689  @return true if these two paths are the same */
690  static bool is_same_as(const std::string &first, const std::string &second)
691  MY_ATTRIBUTE((warn_unused_result)) {
692  if (first.empty() || second.empty()) {
693  return (false);
694  }
695 
696  Fil_path first_path(first);
697  std::string first_abs = first_path.abs_path();
698  trim_separator(first_abs);
699 
700  Fil_path second_path(second);
701  std::string second_abs = second_path.abs_path();
702  trim_separator(second_abs);
703 
704  return (first_abs == second_abs);
705  }
706 
707  /** Check if m_path is the parent of the other path.
708  @param[in] other path to compare to
709  @return true if m_path is an ancestor of name */
710  bool is_ancestor(const Fil_path &other) const
711  MY_ATTRIBUTE((warn_unused_result));
712 
713  /** Check if this Fil_path is an ancestor of the other path.
714  @param[in] other path to compare to
715  @return true if this Fil_path is an ancestor of the other path */
716  bool is_ancestor(const std::string &other) const
717  MY_ATTRIBUTE((warn_unused_result));
718 
719  /** Check if the first path is an ancestor of the second.
720  Do not assume that these paths have been converted to real paths
721  and are ready to compare. If the two paths are the same
722  we will return false.
723  @param[in] first Parent path to check
724  @param[in] second Descendent path to check
725  @return true if the first path is an ancestor of the second */
726  static bool is_ancestor(const std::string &first, const std::string &second)
727  MY_ATTRIBUTE((warn_unused_result)) {
728  if (first.empty() || second.empty()) {
729  return (false);
730  }
731 
732  Fil_path ancestor(first);
733  Fil_path descendant(second);
734 
735  return (ancestor.is_ancestor(descendant));
736  }
737 
738  /** @return true if m_path exists and is a file. */
739  bool is_file_and_exists() const MY_ATTRIBUTE((warn_unused_result));
740 
741  /** @return true if m_path exists and is a directory. */
742  bool is_directory_and_exists() const MY_ATTRIBUTE((warn_unused_result));
743 
744  /** This validation is only for ':'.
745  @return true if the path is valid. */
746  bool is_valid() const MY_ATTRIBUTE((warn_unused_result));
747 
748  /** Determine if m_path contains a circular section like "/anydir/../"
749  Fil_path::normalize() must be run before this.
750  @return true if a circular section if found, false if not */
751  bool is_circular() const MY_ATTRIBUTE((warn_unused_result));
752 
753  /** Determine if the file or directory is considered HIDDEN.
754  Most file systems identify the HIDDEN attribute by a '.' preceeding the
755  basename. On Windows, a HIDDEN path is identified by a file attribute.
756  We will use the preceeding '.' to indicate a HIDDEN attribute on ALL
757  file systems so that InnoDB tablespaces and their directory structure
758  remain portable.
759  @param[in] path The full or relative path of a file or directory.
760  @return true if the directory or path is HIDDEN. */
761  static bool is_hidden(std::string path);
762 
763 #ifdef _WIN32
764  /** Use the WIN32_FIND_DATA struncture to determine if the file or
765  directory is HIDDEN. Consider a SYSTEM attribute also as an indicator
766  that it is HIDDEN to InnoDB.
767  @param[in] dirent A directory entry obtained from a call to FindFirstFile()
768  or FindNextFile()
769  @return true if the directory or path is HIDDEN. */
770  static bool is_hidden(WIN32_FIND_DATA &dirent);
771 #endif /* WIN32 */
772 
773  /** Remove quotes e.g., 'a;b' or "a;b" -> a;b.
774  This will only remove the quotes if they are matching on the whole string.
775  This will not work if each delimited string is quoted since this is called
776  before the string is parsed.
777  @return pathspec with the quotes stripped */
778  static std::string remove_quotes(const char *pathspec) {
779  std::string path(pathspec);
780 
781  ut_ad(!path.empty());
782 
783  if (path.size() >= 2 && ((path.front() == '\'' && path.back() == '\'') ||
784  (path.front() == '"' && path.back() == '"'))) {
785  path.erase(0, 1);
786  path.erase(path.size() - 1);
787  }
788 
789  return (path);
790  }
791 
792  /** Determine if a path is a relative path or not.
793  @param[in] path OS directory or file path to evaluate
794  @retval true if the path is relative
795  @retval false if the path is absolute or file_name_only */
796  static bool is_relative_path(const std::string &path)
797  MY_ATTRIBUTE((warn_unused_result)) {
798  return (type_of_path(path) == relative);
799  }
800 
801  /** @return true if the path is an absolute path. */
802  bool is_absolute_path() const MY_ATTRIBUTE((warn_unused_result)) {
803  return (type_of_path(m_path) == absolute);
804  }
805 
806  /** Determine if a path is an absolute path or not.
807  @param[in] path OS directory or file path to evaluate
808  @retval true if the path is absolute
809  @retval false if the path is relative or file_name_only */
810  static bool is_absolute_path(const std::string &path)
811  MY_ATTRIBUTE((warn_unused_result)) {
812  return (type_of_path(path) == absolute);
813  }
814 
815  /** Determine what type of path is provided.
816  @param[in] path OS directory or file path to evaluate
817  @return the type of filepath; 'absolute', 'relative',
818  'file_name_only', or 'invalid' if the path is empty. */
819  static path_type type_of_path(const std::string &path)
820  MY_ATTRIBUTE((warn_unused_result)) {
821  if (path.empty()) {
822  return (invalid);
823  }
824 
825  /* The most likely type is a file name only with no separators. */
826  auto first_separator = path.find_first_of(SEPARATOR);
827  if (first_separator == std::string::npos) {
828  return (file_name_only);
829  }
830 
831  /* Any string that starts with an OS_SEPARATOR is
832  an absolute path. This includes any OS and even
833  paths like "\\Host\share" on Windows. */
834  if (first_separator == 0) {
835  return (absolute);
836  }
837 
838 #ifdef _WIN32
839  /* Windows may have an absolute path like 'A:\' */
840  if (path.length() >= 3 && isalpha(path.at(0)) && path.at(1) == ':' &&
841  (path.at(2) == '\\' || path.at(2) == '/')) {
842  return (absolute);
843  }
844 #endif /* _WIN32 */
845 
846  /* Since it contains separators and is not an absolute path,
847  it must be a relative path. */
848  return (relative);
849  }
850 
851  /* Check if the path is prefixed with pattern.
852  @return true if prefix matches */
853  static bool has_prefix(const std::string &path, const std::string prefix)
854  MY_ATTRIBUTE((warn_unused_result)) {
855  return (path.size() >= prefix.size() &&
856  std::equal(prefix.begin(), prefix.end(), path.begin()));
857  }
858 
859  /** Normalize a directory path for the current OS:
860  On Windows, we convert '/' to '\', else we convert '\' to '/'.
861  @param[in,out] path Directory and file path */
862  static void normalize(std::string &path) {
863  for (auto &c : path) {
864  if (c == OS_PATH_SEPARATOR_ALT) {
865  c = OS_SEPARATOR;
866  }
867  }
868  }
869 
870  /** Normalize a directory path for the current OS:
871  On Windows, we convert '/' to '\', else we convert '\' to '/'.
872  @param[in,out] path A NUL terminated path */
873  static void normalize(char *path) {
874  for (auto ptr = path; *ptr; ++ptr) {
875  if (*ptr == OS_PATH_SEPARATOR_ALT) {
876  *ptr = OS_SEPARATOR;
877  }
878  }
879  }
880 
881  /** Convert a path string to lower case using the CHARSET my_charset_filename.
882  @param[in,out] path Directory and file path */
883  static void to_lower(std::string &path) {
884  for (auto &c : path) {
886  }
887  }
888 
889  /** @return true if the path exists and is a file . */
890  static os_file_type_t get_file_type(const std::string &path)
891  MY_ATTRIBUTE((warn_unused_result));
892 
893  /** Return a string to display the file type of a path.
894  @param[in] path path name
895  @return true if the path exists and is a file . */
896  static const char *get_file_type_string(const std::string &path);
897 
898  /** Return a string to display the file type of a path.
899  @param[in] type OS file type
900  @return true if the path exists and is a file . */
901  static const char *get_file_type_string(os_file_type_t type);
902 
903  /** Get the real path for a directory or a file name. This path can be
904  used to compare with another absolute path. It will be converted to
905  lower case on case insensitive file systems and if it is a directory,
906  it will end with a directory separator. The call to my_realpath() may
907  fail on non-Windows platforms if the path does not exist. If so, the
908  parameter 'force' determines what to return.
909  @param[in] path directory or filename to convert to a real path
910  @param[in] force if true and my_realpath() fails, use the path provided.
911  if false and my_realpath() fails, return a null string.
912  @return the absolute path prepared for making comparisons with other real
913  paths. */
914  static std::string get_real_path(const std::string &path, bool force = true)
915  MY_ATTRIBUTE((warn_unused_result));
916 
917  /** Get the basename of the file path. This is the file name without any
918  directory separators. In other words, the file name after the last separator.
919  @param[in] filepath The name of a file, optionally with a path. */
920  static std::string get_basename(const std::string &filepath)
921  MY_ATTRIBUTE((warn_unused_result));
922 
923  /** Separate the portion of a directory path that exists and the portion that
924  does not exist.
925  @param[in] path Path to evaluate
926  @param[in,out] ghost The portion of the path that does not exist.
927  @return the existing portion of a path. */
928  static std::string get_existing_path(const std::string &path,
929  std::string &ghost)
930  MY_ATTRIBUTE((warn_unused_result));
931 
932  /** Check if the name is an undo tablespace name.
933  @param[in] name Tablespace name
934  @return true if it is an undo tablespace name */
935  static bool is_undo_tablespace_name(const std::string &name)
936  MY_ATTRIBUTE((warn_unused_result));
937 
938  /** Check if the file has the the specified suffix
939  @param[in] sfx suffix to look for
940  @param[in] path Filename to check
941  @return true if it has the the ".ibd" suffix. */
942  static bool has_suffix(ib_file_suffix sfx, const std::string &path) {
943  const auto suffix = dot_ext[sfx];
944  size_t len = strlen(suffix);
945 
946  return (path.size() >= len &&
947  path.compare(path.size() - len, len, suffix) == 0);
948  }
949 
950  /** Check if the file has the the specified suffix and truncate
951  @param[in] sfx suffix to look for
952  @param[in,out] path Filename to check
953  @return true if the suffix is found and truncated. */
954  static bool truncate_suffix(ib_file_suffix sfx, std::string &path) {
955  const auto suffix = dot_ext[sfx];
956  size_t len = strlen(suffix);
957 
958  if (path.size() < len ||
959  path.compare(path.size() - len, len, suffix) != 0) {
960  return (false);
961  }
962 
963  path.resize(path.size() - len);
964  return (true);
965  }
966 
967  /** Check if a character is a path separator ('\' or '/')
968  @param[in] c Character to check
969  @return true if it is a separator */
970  static bool is_separator(char c) { return (c == '\\' || c == '/'); }
971 
972  /** If the last character of a directory path is a separator ('\' or '/')
973  trim it off the string.
974  @param[in] path file system path */
975  static void trim_separator(std::string &path) {
976  if (!path.empty() && is_separator(path.back())) {
977  path.resize(path.size() - 1);
978  }
979  }
980 
981  /** If the last character of a directory path is NOT a separator,
982  append a separator to the path.
983  NOTE: We leave it up to the caller to assure that the path is a directory
984  and not a file since if that directory does not yet exist, this function
985  cannot tell the difference.
986  @param[in] path file system path */
987  static void append_separator(std::string &path) {
988  if (!path.empty() && !is_separator(path.back())) {
989  path.push_back(OS_SEPARATOR);
990  }
991  }
992 
993  /** Allocate and build a file name from a path, a table or
994  tablespace name and a suffix.
995  @param[in] path_in nullptr or the direcory path or
996  the full path and filename
997  @param[in] name_in nullptr if path is full, or
998  Table/Tablespace name
999  @param[in] ext the file extension to use
1000  @param[in] trim whether last name on the path should
1001  be trimmed
1002  @return own: file name; must be freed by ut_free() */
1003  static char *make(const std::string &path_in, const std::string &name_in,
1004  ib_file_suffix ext, bool trim = false)
1005  MY_ATTRIBUTE((warn_unused_result));
1006 
1007  /** Allocate and build a CFG file name from a path.
1008  @param[in] path_in Full path to the filename
1009  @return own: file name; must be freed by ut_free() */
1010  static char *make_cfg(const std::string &path_in)
1011  MY_ATTRIBUTE((warn_unused_result)) {
1012  return (make(path_in, "", CFG));
1013  }
1014 
1015  /** Allocate and build a CFP file name from a path.
1016  @param[in] path_in Full path to the filename
1017  @return own: file name; must be freed by ut_free() */
1018  static char *make_cfp(const std::string &path_in)
1019  MY_ATTRIBUTE((warn_unused_result)) {
1020  return (make(path_in, "", CFP));
1021  }
1022 
1023  /** Allocate and build a file name from a path, a table or
1024  tablespace name and a suffix.
1025  @param[in] path_in nullptr or the direcory path or
1026  the full path and filename
1027  @param[in] name_in nullptr if path is full, or
1028  Table/Tablespace name
1029  @return own: file name; must be freed by ut_free() */
1030  static char *make_ibd(const std::string &path_in, const std::string &name_in)
1031  MY_ATTRIBUTE((warn_unused_result)) {
1032  return (make(path_in, name_in, IBD));
1033  }
1034 
1035  /** Allocate and build a file name from a path, a table or
1036  tablespace name and a suffix.
1037  @param[in] name_in Table/Tablespace name
1038  @return own: file name; must be freed by ut_free() */
1039  static char *make_ibd_from_table_name(const std::string &name_in)
1040  MY_ATTRIBUTE((warn_unused_result)) {
1041  return (make("", name_in, IBD));
1042  }
1043 
1044  /** Create an IBD path name after replacing the basename in an old path
1045  with a new basename. The old_path is a full path name including the
1046  extension. The tablename is in the normal form "schema/tablename".
1047  @param[in] path_in Pathname
1048  @param[in] name_in Contains new base name
1049  @param[in] extn File extension
1050  @return new full pathname */
1051  static std::string make_new_path(const std::string &path_in,
1052  const std::string &name_in,
1053  ib_file_suffix extn)
1054  MY_ATTRIBUTE((warn_unused_result));
1055 
1056  /** Parse file-per-table file name and build Innodb dictionary table name.
1057  @param[in] file_path File name with complete path
1058  @param[in] extn File extension
1059  @param[out] dict_name Innodb dictionary table name
1060  @return true, if successful. */
1061  static bool parse_file_path(const std::string &file_path, ib_file_suffix extn,
1062  std::string &dict_name);
1063 
1064  /** This function reduces a null-terminated full remote path name
1065  into the path that is sent by MySQL for DATA DIRECTORY clause.
1066  It replaces the 'databasename/tablename.ibd' found at the end of the
1067  path with just 'tablename'.
1068 
1069  Since the result is always smaller than the path sent in, no new
1070  memory is allocated. The caller should allocate memory for the path
1071  sent in. This function manipulates that path in place. If the path
1072  format is not as expected, set data_dir_path to "" and return.
1073 
1074  The result is used to inform a SHOW CREATE TABLE command.
1075  @param[in,out] data_dir_path Full path/data_dir_path */
1076  static void make_data_dir_path(char *data_dir_path);
1077 
1078 #ifndef UNIV_HOTBACKUP
1079  /** Check if the filepath provided is in a valid placement.
1080  This routine is run during file discovery at startup.
1081  1) File-per-table must be in a dir named for the schema.
1082  2) File-per-table must not be in the datadir.
1083  3) General tablespace must not be under the datadir.
1084  @param[in] space_name tablespace name
1085  @param[in] space_id tablespace ID
1086  @param[in] fsp_flags tablespace flags
1087  @param[in] path scanned realpath to an existing file to validate
1088  @retval true if the filepath is a valid datafile location */
1089  static bool is_valid_location(const char *space_name, space_id_t space_id,
1090  uint32_t fsp_flags, const std::string &path);
1091 
1092  /** Check if the implicit filepath is immediately within a dir named for
1093  the schema.
1094  @param[in] space_name tablespace name
1095  @param[in] path scanned realpath to an existing file to validate
1096  @retval true if the filepath is valid */
1097  static bool is_valid_location_within_db(const char *space_name,
1098  const std::string &path);
1099 
1100  /** Convert filename to the file system charset format.
1101  @param[in,out] name Filename to convert */
1102  static void convert_to_filename_charset(std::string &name);
1103 
1104  /** Convert to lower case using the file system charset.
1105  @param[in,out] path Filepath to convert */
1106  static void convert_to_lower_case(std::string &path);
1107 
1108 #endif /* !UNIV_HOTBACKUP */
1109 
1110  protected:
1111  /** Path to a file or directory. */
1112  std::string m_path;
1113 
1114  /** A full absolute path to the same file. */
1115  std::string m_abs_path;
1116 };
1117 
1118 /** The MySQL server --datadir value */
1120 
1121 /** The MySQL server --innodb-undo-directory value */
1122 extern Fil_path MySQL_undo_path;
1123 
1124 /** The undo path is different from any other known directory. */
1125 extern bool MySQL_undo_path_is_unique;
1126 
1127 /** Initial size of a single-table tablespace in pages */
1128 constexpr size_t FIL_IBD_FILE_INITIAL_SIZE = 7;
1129 constexpr size_t FIL_IBT_FILE_INITIAL_SIZE = 5;
1130 
1131 /** An empty tablespace (CREATE TABLESPACE) has minimum
1132 of 4 pages and an empty CREATE TABLE (file_per_table) has 6 pages.
1133 Minimum of these two is 4 */
1134 constexpr size_t FIL_IBD_FILE_INITIAL_SIZE_5_7 = 4;
1135 
1136 /** 'null' (undefined) page offset in the context of file spaces */
1137 constexpr page_no_t FIL_NULL = std::numeric_limits<page_no_t>::max();
1138 
1139 /** Maximum Page Number, one less than FIL_NULL */
1140 constexpr page_no_t PAGE_NO_MAX = std::numeric_limits<page_no_t>::max() - 1;
1141 
1142 /** Unknown space id */
1143 constexpr space_id_t SPACE_UNKNOWN = std::numeric_limits<space_id_t>::max();
1144 
1145 /* Space address data type; this is intended to be used when
1146 addresses accurate to a byte are stored in file pages. If the page part
1147 of the address is FIL_NULL, the address is considered undefined. */
1148 
1149 /** 'type' definition in C: an address stored in a file page is a
1150 string of bytes */
1152 
1153 /** File space address */
1154 struct fil_addr_t {
1155  /* Default constructor */
1157 
1158  /** Constructor
1159  @param[in] p Logical page number
1160  @param[in] boff Offset within the page */
1161  fil_addr_t(page_no_t p, uint32_t boff) : page(p), boffset(boff) {}
1162 
1163  /** Compare to instances
1164  @param[in] rhs Instance to compare with
1165  @return true if the page number and page offset are equal */
1166  bool is_equal(const fil_addr_t &rhs) const {
1167  return (page == rhs.page && boffset == rhs.boffset);
1168  }
1169 
1170  /** Check if the file address is null.
1171  @return true if null */
1172  bool is_null() const { return (page == FIL_NULL && boffset == 0); }
1173 
1174  /** Print a string representation.
1175  @param[in,out] out Stream to write to */
1176  std::ostream &print(std::ostream &out) const {
1177  out << "[fil_addr_t: page=" << page << ", boffset=" << boffset << "]";
1178 
1179  return (out);
1180  }
1181 
1182  /** Page number within a space */
1184 
1185  /** Byte offset within the page */
1186  uint32_t boffset;
1187 };
1188 
1189 /* For printing fil_addr_t to a stream.
1190 @param[in,out] out Stream to write to
1191 @param[in] obj fil_addr_t instance to write */
1192 inline std::ostream &operator<<(std::ostream &out, const fil_addr_t &obj) {
1193  return (obj.print(out));
1194 }
1195 
1196 /** The null file address */
1197 extern fil_addr_t fil_addr_null;
1198 
1199 using page_type_t = uint16_t;
1200 
1201 /** File page types (values of FIL_PAGE_TYPE) @{ */
1202 /** B-tree node */
1203 constexpr page_type_t FIL_PAGE_INDEX = 17855;
1204 
1205 /** R-tree node */
1206 constexpr page_type_t FIL_PAGE_RTREE = 17854;
1207 
1208 /** Tablespace SDI Index page */
1209 constexpr page_type_t FIL_PAGE_SDI = 17853;
1210 
1211 /** Undo log page */
1213 
1214 /** Index node */
1216 
1217 /** Insert buffer free list */
1219 
1220 /* File page types introduced in MySQL/InnoDB 5.1.7 */
1221 /** Freshly allocated page */
1223 
1224 /** Insert buffer bitmap */
1226 
1227 /** System page */
1229 
1230 /** Transaction system data */
1232 
1233 /** File space header */
1235 
1236 /** Extent descriptor page */
1238 
1239 /** Uncompressed BLOB page */
1241 
1242 /** First compressed BLOB page */
1244 
1245 /** Subsequent compressed BLOB page */
1247 
1248 /** In old tablespaces, garbage in FIL_PAGE_TYPE is replaced with
1249 this value when flushing pages. */
1251 
1252 /** Compressed page */
1254 
1255 /** Encrypted page */
1257 
1258 /** Compressed and Encrypted page */
1260 
1261 /** Encrypted R-tree page */
1263 
1264 /** Uncompressed SDI BLOB page */
1266 
1267 /** Commpressed SDI BLOB page */
1269 
1270 /** Legacy doublewrite buffer page. */
1272 
1273 /** Rollback Segment Array page */
1275 
1276 /** Index pages of uncompressed LOB */
1278 
1279 /** Data pages of uncompressed LOB */
1281 
1282 /** The first page of an uncompressed LOB */
1284 
1285 /** The first page of a compressed LOB */
1287 
1288 /** Data pages of compressed LOB */
1290 
1291 /** Index pages of compressed LOB. This page contains an array of
1292 z_index_entry_t objects.*/
1294 
1295 /** Fragment pages of compressed LOB. */
1297 
1298 /** Index pages of fragment pages (compressed LOB). */
1300 
1301 /** Used by i_s.cc to index into the text description. */
1303 
1304 /** Check whether the page type is index (Btree or Rtree or SDI) type */
1305 #define fil_page_type_is_index(page_type) \
1306  (page_type == FIL_PAGE_INDEX || page_type == FIL_PAGE_SDI || \
1307  page_type == FIL_PAGE_RTREE)
1308 
1309 /** Check whether the page is index page (either regular Btree index or Rtree
1310 index */
1311 #define fil_page_index_page_check(page) \
1312  fil_page_type_is_index(fil_page_get_type(page))
1313 
1314 /** @} */
1315 
1316 /** The number of fsyncs done to the log */
1317 extern ulint fil_n_log_flushes;
1318 
1319 /** Number of pending redo log flushes */
1320 extern ulint fil_n_pending_log_flushes;
1321 /** Number of pending tablespace flushes */
1323 
1324 /** Number of files currently open */
1325 extern ulint fil_n_file_opened;
1326 
1327 /** Look up a tablespace.
1328 The caller should hold an InnoDB table lock or a MDL that prevents
1329 the tablespace from being dropped during the operation,
1330 or the caller should be in single-threaded crash recovery mode
1331 (no user connections that could drop tablespaces).
1332 If this is not the case, fil_space_acquire() and fil_space_release()
1333 should be used instead.
1334 @param[in] space_id Tablespace ID
1335 @return tablespace, or nullptr if not found */
1337  MY_ATTRIBUTE((warn_unused_result));
1338 
1339 #ifndef UNIV_HOTBACKUP
1340 /** Returns the latch of a file space.
1341 @param[in] space_id Tablespace ID
1342 @return latch protecting storage allocation */
1344  MY_ATTRIBUTE((warn_unused_result));
1345 
1346 #ifdef UNIV_DEBUG
1347 /** Gets the type of a file space.
1348 @param[in] space_id Tablespace ID
1349 @return file type */
1351  MY_ATTRIBUTE((warn_unused_result));
1352 #endif /* UNIV_DEBUG */
1353 
1354 /** Note that a tablespace has been imported.
1355 It is initially marked as FIL_TYPE_IMPORT so that no logging is
1356 done during the import process when the space ID is stamped to each page.
1357 Now we change it to FIL_SPACE_TABLESPACE to start redo and undo logging.
1358 NOTE: temporary tablespaces are never imported.
1359 @param[in] space_id Tablespace ID */
1360 void fil_space_set_imported(space_id_t space_id);
1361 #endif /* !UNIV_HOTBACKUP */
1362 
1363 /** Attach a file to a tablespace. File must be closed.
1364 @param[in] name file name (file must be closed)
1365 @param[in] size file size in database blocks, rounded
1366  downwards to an integer
1367 @param[in,out] space space where to append
1368 @param[in] is_raw true if a raw device or a raw disk partition
1369 @param[in] atomic_write true if the file has atomic write enabled
1370 @param[in] max_pages maximum number of pages in file
1371 @return pointer to the file name
1372 @retval nullptr if error */
1373 char *fil_node_create(const char *name, page_no_t size, fil_space_t *space,
1374  bool is_raw, bool atomic_write,
1375  page_no_t max_pages = PAGE_NO_MAX)
1376  MY_ATTRIBUTE((warn_unused_result));
1377 
1378 /** Create a space memory object and put it to the fil_system hash table.
1379 The tablespace name is independent from the tablespace file-name.
1380 Error messages are issued to the server log.
1381 @param[in] name Tablespace name
1382 @param[in] space_id Tablespace ID
1383 @param[in] flags Tablespace flags
1384 @param[in] purpose Tablespace purpose
1385 @return pointer to created tablespace, to be filled in with fil_node_create()
1386 @retval nullptr on failure (such as when the same tablespace exists) */
1387 fil_space_t *fil_space_create(const char *name, space_id_t space_id,
1388  uint32_t flags, fil_type_t purpose)
1389  MY_ATTRIBUTE((warn_unused_result));
1390 
1391 /** Assigns a new space id for a new single-table tablespace. This works
1392 simply by incrementing the global counter. If 4 billion id's is not enough,
1393 we may need to recycle id's.
1394 @param[out] space_id Set this to the new tablespace ID
1395 @return true if assigned, false if not */
1396 bool fil_assign_new_space_id(space_id_t *space_id)
1397  MY_ATTRIBUTE((warn_unused_result));
1398 
1399 /** Returns the path from the first fil_node_t found with this space ID.
1400 The caller is responsible for freeing the memory allocated here for the
1401 value returned.
1402 @param[in] space_id Tablespace ID
1403 @return own: A copy of fil_node_t::path, nullptr if space ID is zero
1404  or not found. */
1405 char *fil_space_get_first_path(space_id_t space_id)
1406  MY_ATTRIBUTE((warn_unused_result));
1407 
1408 /** Returns the size of the space in pages. The tablespace must be cached
1409 in the memory cache.
1410 @param[in] space_id Tablespace ID
1411 @return space size, 0 if space not found */
1413  MY_ATTRIBUTE((warn_unused_result));
1414 
1415 /** Returns the flags of the space. The tablespace must be cached
1416 in the memory cache.
1417 @param[in] space_id Tablespace ID for which to get the flags
1418 @return flags, ULINT_UNDEFINED if space not found */
1419 uint32_t fil_space_get_flags(space_id_t space_id)
1420  MY_ATTRIBUTE((warn_unused_result));
1421 
1422 /** Sets the flags of the tablespace. The tablespace must be locked
1423 in MDL_EXCLUSIVE MODE.
1424 @param[in] space tablespace in-memory struct
1425 @param[in] flags tablespace flags */
1426 void fil_space_set_flags(fil_space_t *space, uint32_t flags);
1427 
1428 /** Open each file of a tablespace if not already open.
1429 @param[in] space_id Tablespace ID
1430 @retval true if all file nodes were opened
1431 @retval false on failure */
1432 bool fil_space_open(space_id_t space_id) MY_ATTRIBUTE((warn_unused_result));
1433 
1434 /** Close each file of a tablespace if open.
1435 @param[in] space_id Tablespace ID */
1436 void fil_space_close(space_id_t space_id);
1437 
1438 /** Returns the page size of the space and whether it is compressed or not.
1439 The tablespace must be cached in the memory cache.
1440 @param[in] space_id Tablespace ID
1441 @param[out] found true if tablespace was found
1442 @return page size */
1443 const page_size_t fil_space_get_page_size(space_id_t space_id, bool *found)
1444  MY_ATTRIBUTE((warn_unused_result));
1445 
1446 /** Initializes the tablespace memory cache.
1447 @param[in] max_n_open Maximum number of open files */
1448 void fil_init(ulint max_n_open);
1449 
1450 /** Initializes the tablespace memory cache. */
1451 void fil_close();
1452 
1453 /** Opens all log files and system tablespace data files.
1454 They stay open until the database server shutdown. This should be called
1455 at a server startup after the space objects for the log and the system
1456 tablespace have been created. The purpose of this operation is to make
1457 sure we never run out of file descriptors if we need to read from the
1458 insert buffer or to write to the log. */
1460 
1461 /** Closes all open files. There must not be any pending i/o's or not flushed
1462 modifications in the files. */
1463 void fil_close_all_files();
1464 
1465 /** Closes the redo log files. There must not be any pending i/o's or not
1466 flushed modifications in the files.
1467 @param[in] free_all Whether to free the instances. */
1468 void fil_close_log_files(bool free_all);
1469 
1470 /** Iterate over the files in all the tablespaces. */
1472  public:
1473  using Function = std::function<dberr_t(fil_node_t *)>;
1474 
1475  /** For each data file, exclude redo log files.
1476  @param[in] include_log include files, if true
1477  @param[in] f Callback */
1478  template <typename F>
1479  static dberr_t for_each_file(bool include_log, F &&f) {
1480  return (iterate(include_log, [=](fil_node_t *file) { return (f(file)); }));
1481  }
1482 
1483  /** Iterate through all persistent tablespace files (FIL_TYPE_TABLESPACE)
1484  returning the nodes via callback function cbk.
1485  @param[in] include_log include log files, if true
1486  @param[in] f Callback
1487  @return any error returned by the callback function. */
1488  static dberr_t iterate(bool include_log, Function &&f);
1489 };
1490 
1491 /** Sets the max tablespace id counter if the given number is bigger than the
1492 previous value.
1493 @param[in] max_id Maximum known tablespace ID */
1495 
1496 #ifndef UNIV_HOTBACKUP
1497 
1498 /** Write the flushed LSN to the page header of the first page in the
1499 system tablespace.
1500 @param[in] lsn Flushed LSN
1501 @return DB_SUCCESS or error number */
1502 dberr_t fil_write_flushed_lsn(lsn_t lsn) MY_ATTRIBUTE((warn_unused_result));
1503 
1504 #else /* !UNIV_HOTBACKUP */
1505 /** Frees a space object from the tablespace memory cache.
1506 Closes a tablespaces' files but does not delete them.
1507 There must not be any pending i/o's or flushes on the files.
1508 @param[in] space_id Tablespace ID
1509 @return true if success */
1510 bool meb_fil_space_free(space_id_t space_id);
1511 
1512 /** Extends all tablespaces to the size stored in the space header. During the
1513 mysqlbackup --apply-log phase we extended the spaces on-demand so that log
1514 records could be applied, but that may have left spaces still too small
1515 compared to the size stored in the space header. */
1516 void meb_extend_tablespaces_to_stored_len();
1517 
1518 /** Process a file name passed as an input
1519 @param[in] name absolute path of tablespace file
1520 @param[in] space_id the tablespace ID */
1521 void meb_fil_name_process(const char *name, space_id_t space_id);
1522 
1523 #endif /* !UNIV_HOTBACKUP */
1524 
1525 /** Acquire a tablespace when it could be dropped concurrently.
1526 Used by background threads that do not necessarily hold proper locks
1527 for concurrency control.
1528 @param[in] space_id Tablespace ID
1529 @return the tablespace, or nullptr if missing or being deleted */
1531  MY_ATTRIBUTE((warn_unused_result));
1532 
1533 /** Acquire a tablespace that may not exist.
1534 Used by background threads that do not necessarily hold proper locks
1535 for concurrency control.
1536 @param[in] space_id Tablespace ID
1537 @return the tablespace, or nullptr if missing or being deleted */
1539  MY_ATTRIBUTE((warn_unused_result));
1540 
1541 /** Release a tablespace acquired with fil_space_acquire().
1542 @param[in,out] space Tablespace to release */
1543 void fil_space_release(fil_space_t *space);
1544 
1545 /** Fetch the file name opened for a space_id from the file map.
1546 @param[in] space_id tablespace ID
1547 @param[out] name the scanned filename
1548 @return true if the space_id is found. The name is set to an
1549 empty string if the space_id is not found. */
1550 bool fil_system_get_file_by_space_id(space_id_t space_id, std::string &name);
1551 
1552 /** Fetch the file name opened for an undo space number from the file map.
1553 @param[in] space_num Undo tablespace Number
1554 @param[out] space_id Undo tablespace ID
1555 @param[out] name the scanned filename
1556 @return true if the space_num was found. The name is set to an
1557 empty string if the space_num is not found. */
1559  space_id_t &space_id, std::string &name);
1560 
1561 /** Truncate the tablespace to needed size.
1562 @param[in] space_id Tablespace ID to truncate
1563 @param[in] size_in_pages Truncate size.
1564 @return true if truncate was successful. */
1565 bool fil_truncate_tablespace(space_id_t space_id, page_no_t size_in_pages)
1566  MY_ATTRIBUTE((warn_unused_result));
1567 
1568 /** Drop and create an UNDO tablespace.
1569 @param[in] old_space_id Tablespace ID to truncate
1570 @param[in] new_space_id Tablespace ID to for the new file
1571 @param[in] size_in_pages Truncate size.
1572 @return true if truncate was successful. */
1573 bool fil_replace_tablespace(space_id_t old_space_id, space_id_t new_space_id,
1574  page_no_t size_in_pages)
1575  MY_ATTRIBUTE((warn_unused_result));
1576 
1577 /** Closes a single-table tablespace. The tablespace must be cached in the
1578 memory cache. Free all pages used by the tablespace.
1579 @param[in,out] trx Transaction covering the close
1580 @param[in] space_id Tablespace ID
1581 @return DB_SUCCESS or error */
1583  MY_ATTRIBUTE((warn_unused_result));
1584 
1585 /** Discards a single-table tablespace. The tablespace must be cached in the
1586 memory cache. Discarding is like deleting a tablespace, but
1587 
1588  1. We do not drop the table from the data dictionary;
1589 
1590  2. We remove all insert buffer entries for the tablespace immediately;
1591  in DROP TABLE they are only removed gradually in the background;
1592 
1593  3. When the user does IMPORT TABLESPACE, the tablespace will have the
1594  same id as it originally had.
1595 
1596  4. Free all the pages in use by the tablespace if rename=true.
1597 @param[in] space_id Tablespace ID
1598 @return DB_SUCCESS or error */
1600  MY_ATTRIBUTE((warn_unused_result));
1601 
1602 /** Test if a tablespace file can be renamed to a new filepath by checking
1603 if that the old filepath exists and the new filepath does not exist.
1604 @param[in] space_id Tablespace ID
1605 @param[in] old_path Old filepath
1606 @param[in] new_path New filepath
1607 @param[in] is_discarded Whether the tablespace is discarded
1608 @return innodb error code */
1609 dberr_t fil_rename_tablespace_check(space_id_t space_id, const char *old_path,
1610  const char *new_path, bool is_discarded)
1611  MY_ATTRIBUTE((warn_unused_result));
1612 
1613 /** Rename a single-table tablespace.
1614 The tablespace must exist in the memory cache.
1615 @param[in] space_id Tablespace ID
1616 @param[in] old_path Old file name
1617 @param[in] new_name New tablespace name in the schema/name format
1618 @param[in] new_path_in New file name, or nullptr if it is located in
1619 the normal data directory
1620 @return InnoDB error code */
1621 dberr_t fil_rename_tablespace(space_id_t space_id, const char *old_path,
1622  const char *new_name, const char *new_path_in)
1623  MY_ATTRIBUTE((warn_unused_result));
1624 
1625 /** Create an IBD tablespace file.
1626 @param[in] space_id Tablespace ID
1627 @param[in] name Tablespace name in dbname/tablename format.
1628  For general tablespaces, the 'dbname/' part
1629  may be missing.
1630 @param[in] path Path and filename of the datafile to create.
1631 @param[in] flags Tablespace flags
1632 @param[in] size Initial size of the tablespace file in pages,
1633  must be >= FIL_IBD_FILE_INITIAL_SIZE
1634 @return DB_SUCCESS or error code */
1635 dberr_t fil_ibd_create(space_id_t space_id, const char *name, const char *path,
1636  uint32_t flags, page_no_t size)
1637  MY_ATTRIBUTE((warn_unused_result));
1638 
1639 /** Create a session temporary tablespace (IBT) file.
1640 @param[in] space_id Tablespace ID
1641 @param[in] name Tablespace name
1642 @param[in] path Path and filename of the datafile to create.
1643 @param[in] flags Tablespace flags
1644 @param[in] size Initial size of the tablespace file in pages,
1645  must be >= FIL_IBT_FILE_INITIAL_SIZE
1646 @return DB_SUCCESS or error code */
1647 dberr_t fil_ibt_create(space_id_t space_id, const char *name, const char *path,
1648  uint32_t flags, page_no_t size)
1649  MY_ATTRIBUTE((warn_unused_result));
1650 
1651 /** Deletes an IBD or IBU tablespace.
1652 The tablespace must be cached in the memory cache. This will delete the
1653 datafile, fil_space_t & fil_node_t entries from the file_system_t cache.
1654 @param[in] space_id Tablespace ID
1655 @param[in] buf_remove Specify the action to take on the pages
1656 for this table in the buffer pool.
1657 @return DB_SUCCESS, DB_TABLESPCE_NOT_FOUND or DB_IO_ERROR */
1659  MY_ATTRIBUTE((warn_unused_result));
1660 
1661 /** Open a single-table tablespace and optionally check the space id is
1662 right in it. If not successful, print an error message to the error log. This
1663 function is used to open a tablespace when we start up mysqld, and also in
1664 IMPORT TABLESPACE.
1665 NOTE that we assume this operation is used either at the database startup
1666 or under the protection of the dictionary mutex, so that two users cannot
1667 race here.
1668 
1669 The fil_node_t::handle will not be left open.
1670 
1671 @param[in] validate whether we should validate the tablespace
1672  (read the first page of the file and
1673  check that the space id in it matches id)
1674 @param[in] purpose FIL_TYPE_TABLESPACE or FIL_TYPE_TEMPORARY
1675 @param[in] space_id Tablespace ID
1676 @param[in] flags tablespace flags
1677 @param[in] space_name tablespace name of the datafile
1678  If file-per-table, it is the table name in the
1679  databasename/tablename format
1680 @param[in] table_name table name in case need to build filename
1681 from it
1682 @param[in] path_in expected filepath, usually read from dictionary
1683 @param[in] strict whether to report error when open ibd failed
1684 @param[in] old_space whether it is a 5.7 tablespace opening
1685  by upgrade
1686 @return DB_SUCCESS or error code */
1687 dberr_t fil_ibd_open(bool validate, fil_type_t purpose, space_id_t space_id,
1688  uint32_t flags, const char *space_name,
1689  const char *table_name, const char *path_in, bool strict,
1690  bool old_space) MY_ATTRIBUTE((warn_unused_result));
1691 
1692 /** Returns true if a matching tablespace exists in the InnoDB tablespace
1693 memory cache.
1694 @param[in] space_id Tablespace ID
1695 @param[in] name Tablespace name used in space_create().
1696 @param[in] print_err Print detailed error information to the
1697  error log if a matching tablespace is
1698  not found from memory.
1699 @param[in] adjust_space Whether to adjust space id on mismatch
1700 @param[in] heap Heap memory
1701 @param[in] table_id table ID
1702 @return true if a matching tablespace exists in the memory cache */
1703 bool fil_space_exists_in_mem(space_id_t space_id, const char *name,
1704  bool print_err, bool adjust_space,
1705  mem_heap_t *heap, table_id_t table_id)
1706  MY_ATTRIBUTE((warn_unused_result));
1707 
1708 /** Extends all tablespaces to the size stored in the space header. During the
1709 mysqlbackup --apply-log phase we extended the spaces on-demand so that log
1710 records could be appllied, but that may have left spaces still too small
1711 compared to the size stored in the space header. */
1713 
1714 /** Try to extend a tablespace if it is smaller than the specified size.
1715 @param[in,out] space Tablespace ID
1716 @param[in] size desired size in pages
1717 @return whether the tablespace is at least as big as requested */
1718 bool fil_space_extend(fil_space_t *space, page_no_t size)
1719  MY_ATTRIBUTE((warn_unused_result));
1720 
1721 /** Tries to reserve free extents in a file space.
1722 @param[in] space_id Tablespace ID
1723 @param[in] n_free_now Number of free extents now
1724 @param[in] n_to_reserve How many one wants to reserve
1725 @return true if succeed */
1726 bool fil_space_reserve_free_extents(space_id_t space_id, ulint n_free_now,
1727  ulint n_to_reserve)
1728  MY_ATTRIBUTE((warn_unused_result));
1729 
1730 /** Releases free extents in a file space.
1731 @param[in] space_id Tablespace ID
1732 @param[in] n_reserved How many were reserved */
1733 void fil_space_release_free_extents(space_id_t space_id, ulint n_reserved);
1734 
1735 /** Gets the number of reserved extents. If the database is silent, this
1736 number should be zero.
1737 @param[in] space_id Tablespace ID
1738 @return the number of reserved extents */
1740  MY_ATTRIBUTE((warn_unused_result));
1741 
1742 /** Read or write redo log data (synchronous buffered IO).
1743 @param[in] type IO context
1744 @param[in] page_id where to read or write
1745 @param[in] page_size page size
1746 @param[in] byte_offset remainder of offset in bytes
1747 @param[in] len this must not cross a file boundary;
1748 @param[in,out] buf buffer where to store read data or from where
1749  to write
1750 @retval DB_SUCCESS if all OK */
1751 dberr_t fil_redo_io(const IORequest &type, const page_id_t &page_id,
1752  const page_size_t &page_size, ulint byte_offset, ulint len,
1753  void *buf) MY_ATTRIBUTE((warn_unused_result));
1754 
1755 /** Read or write data from a file.
1756 @param[in] type IO context
1757 @param[in] sync If true then do synchronous IO
1758 @param[in] page_id page id
1759 @param[in] page_size page size
1760 @param[in] byte_offset remainder of offset in bytes; in aio this
1761  must be divisible by the OS block size
1762 @param[in] len how many bytes to read or write; this must
1763  not cross a file boundary; in AIO this must
1764  be a block size multiple
1765 @param[in,out] buf buffer where to store read data or from where
1766  to write; in AIO this must be appropriately
1767  aligned
1768 @param[in] message message for AIO handler if !sync, else ignored
1769 @return error code
1770 @retval DB_SUCCESS on success
1771 @retval DB_TABLESPACE_DELETED if the tablespace does not exist */
1772 dberr_t fil_io(const IORequest &type, bool sync, const page_id_t &page_id,
1773  const page_size_t &page_size, ulint byte_offset, ulint len,
1774  void *buf, void *message) MY_ATTRIBUTE((warn_unused_result));
1775 
1776 /** Waits for an AIO operation to complete. This function is used to write the
1777 handler for completed requests. The aio array of pending requests is divided
1778 into segments (see os0file.cc for more info). The thread specifies which
1779 segment it wants to wait for.
1780 @param[in] segment The number of the segment in the AIO array
1781  to wait for */
1782 void fil_aio_wait(ulint segment);
1783 
1784 /** Flushes to disk possible writes cached by the OS. If the space does
1785 not exist or is being dropped, does not do anything.
1786 @param[in] space_id Tablespace ID (this can be a group of log files
1787  or a tablespace of the database) */
1788 void fil_flush(space_id_t space_id);
1789 
1790 /** Flush to disk the writes in file spaces of the given type
1791 possibly cached by the OS. */
1792 void fil_flush_file_redo();
1793 
1794 /** Flush to disk the writes in file spaces of the given type
1795 possibly cached by the OS.
1796 @param[in] purpose FIL_TYPE_TABLESPACE or FIL_TYPE_LOG, can be
1797 ORred. */
1798 void fil_flush_file_spaces(uint8_t purpose);
1799 
1800 #ifdef UNIV_DEBUG
1801 /** Checks the consistency of the tablespace cache.
1802 @return true if ok */
1803 bool fil_validate();
1804 #endif /* UNIV_DEBUG */
1805 
1806 /** Returns true if file address is undefined.
1807 @param[in] addr File address to check
1808 @return true if undefined */
1809 bool fil_addr_is_null(const fil_addr_t &addr)
1810  MY_ATTRIBUTE((warn_unused_result));
1811 
1812 /** Get the predecessor of a file page.
1813 @param[in] page File page
1814 @return FIL_PAGE_PREV */
1815 page_no_t fil_page_get_prev(const byte *page)
1816  MY_ATTRIBUTE((warn_unused_result));
1817 
1818 /** Get the successor of a file page.
1819 @param[in] page File page
1820 @return FIL_PAGE_NEXT */
1821 page_no_t fil_page_get_next(const byte *page)
1822  MY_ATTRIBUTE((warn_unused_result));
1823 
1824 /** Sets the file page type.
1825 @param[in,out] page File page
1826 @param[in] type File page type to set */
1827 void fil_page_set_type(byte *page, ulint type);
1828 
1829 /** Reset the page type.
1830 Data files created before MySQL 5.1 may contain garbage in FIL_PAGE_TYPE.
1831 In MySQL 3.23.53, only undo log pages and index pages were tagged.
1832 Any other pages were written with uninitialized bytes in FIL_PAGE_TYPE.
1833 @param[in] page_id Page number
1834 @param[in,out] page Page with invalid FIL_PAGE_TYPE
1835 @param[in] type Expected page type
1836 @param[in,out] mtr Mini-transaction */
1837 void fil_page_reset_type(const page_id_t &page_id, byte *page, ulint type,
1838  mtr_t *mtr);
1839 
1840 /** Get the file page type.
1841 @param[in] page File page
1842 @return page type */
1843 inline page_type_t fil_page_get_type(const byte *page) {
1844  return (static_cast<page_type_t>(mach_read_from_2(page + FIL_PAGE_TYPE)));
1845 }
1846 /** Check (and if needed, reset) the page type.
1847 Data files created before MySQL 5.1 may contain
1848 garbage in the FIL_PAGE_TYPE field.
1849 In MySQL 3.23.53, only undo log pages and index pages were tagged.
1850 Any other pages were written with uninitialized bytes in FIL_PAGE_TYPE.
1851 @param[in] page_id Page number
1852 @param[in,out] page Page with possibly invalid FIL_PAGE_TYPE
1853 @param[in] type Expected page type
1854 @param[in,out] mtr Mini-transaction */
1855 inline void fil_page_check_type(const page_id_t &page_id, byte *page,
1856  ulint type, mtr_t *mtr) {
1857  ulint page_type = fil_page_get_type(page);
1858 
1859  if (page_type != type) {
1860  fil_page_reset_type(page_id, page, type, mtr);
1861  }
1862 }
1863 
1864 /** Check (and if needed, reset) the page type.
1865 Data files created before MySQL 5.1 may contain
1866 garbage in the FIL_PAGE_TYPE field.
1867 In MySQL 3.23.53, only undo log pages and index pages were tagged.
1868 Any other pages were written with uninitialized bytes in FIL_PAGE_TYPE.
1869 @param[in,out] block Block with possibly invalid FIL_PAGE_TYPE
1870 @param[in] type Expected page type
1871 @param[in,out] mtr Mini-transaction */
1872 #define fil_block_check_type(block, type, mtr) \
1873  fil_page_check_type(block->page.id, block->frame, type, mtr)
1874 
1875 #ifdef UNIV_DEBUG
1876 /** Increase redo skipped count for a tablespace.
1877 @param[in] space_id Tablespace ID */
1879 
1880 /** Decrease redo skipped count for a tablespace.
1881 @param[in] space_id Tablespace ID */
1883 
1884 /** Check whether a single-table tablespace is redo skipped.
1885 @param[in] space_id Tablespace ID
1886 @return true if redo skipped */
1888  MY_ATTRIBUTE((warn_unused_result));
1889 #endif /* UNIV_DEBUG */
1890 
1891 /** Delete the tablespace file and any related files like .cfg.
1892 This should not be called for temporary tables.
1893 @param[in] path File path of the IBD tablespace
1894 @return true on success */
1895 bool fil_delete_file(const char *path) MY_ATTRIBUTE((warn_unused_result));
1896 
1897 /** Callback functor. */
1899  /** Default constructor */
1900  PageCallback() : m_page_size(0, 0, false), m_filepath() UNIV_NOTHROW {}
1901 
1902  virtual ~PageCallback() UNIV_NOTHROW {}
1903 
1904  /** Called for page 0 in the tablespace file at the start.
1905  @param file_size size of the file in bytes
1906  @param block contents of the first page in the tablespace file
1907  @retval DB_SUCCESS or error code. */
1909  MY_ATTRIBUTE((warn_unused_result)) UNIV_NOTHROW = 0;
1910 
1911  /** Called for every page in the tablespace. If the page was not
1912  updated then its state must be set to BUF_PAGE_NOT_USED. For
1913  compressed tables the page descriptor memory will be at offset:
1914  block->frame + UNIV_PAGE_SIZE;
1915  @param offset physical offset within the file
1916  @param block block read from file, note it is not from the buffer pool
1917  @retval DB_SUCCESS or error code. */
1918  virtual dberr_t operator()(os_offset_t offset, buf_block_t *block)
1919  MY_ATTRIBUTE((warn_unused_result)) UNIV_NOTHROW = 0;
1920 
1921  /** Set the name of the physical file and the file handle that is used
1922  to open it for the file that is being iterated over.
1923  @param filename then physical name of the tablespace file.
1924  @param file OS file handle */
1925  void set_file(const char *filename, pfs_os_file_t file) UNIV_NOTHROW {
1926  m_file = file;
1927  m_filepath = filename;
1928  }
1929 
1930  /** @return the space id of the tablespace */
1931  virtual space_id_t get_space_id() const
1932  MY_ATTRIBUTE((warn_unused_result)) UNIV_NOTHROW = 0;
1933 
1934  /**
1935  @retval the space flags of the tablespace being iterated over */
1936  virtual ulint get_space_flags() const
1937  MY_ATTRIBUTE((warn_unused_result)) UNIV_NOTHROW = 0;
1938 
1939  /** Set the tablespace table size.
1940  @param[in] page a page belonging to the tablespace */
1941  void set_page_size(const buf_frame_t *page) UNIV_NOTHROW;
1942 
1943  /** The compressed page size
1944  @return the compressed page size */
1945  const page_size_t &get_page_size() const MY_ATTRIBUTE((warn_unused_result)) {
1946  return (m_page_size);
1947  }
1948 
1949  /** The tablespace page size. */
1951 
1952  /** File handle to the tablespace */
1954 
1955  /** Physical file path. */
1956  const char *m_filepath;
1957 
1958  // Disable copying
1960  PageCallback(const PageCallback &) = delete;
1962 };
1963 
1964 /** Iterate over all the pages in the tablespace.
1965 @param[in] table the table definiton in the server
1966 @param[in] n_io_buffers number of blocks to read and write together
1967 @param[in] compression_type compression type if compression is enabled,
1968 else Compression::Type::NONE
1969 @param[in,out] callback functor that will do the page updates
1970 @return DB_SUCCESS or error code */
1971 dberr_t fil_tablespace_iterate(dict_table_t *table, ulint n_io_buffers,
1972  Compression::Type compression_type,
1973  PageCallback &callback)
1974  MY_ATTRIBUTE((warn_unused_result));
1975 
1976 /** Looks for a pre-existing fil_space_t with the given tablespace ID
1977 and, if found, returns the name and filepath in newly allocated buffers
1978 that the caller must free.
1979 @param[in] space_id The tablespace ID to search for.
1980 @param[out] name Name of the tablespace found.
1981 @param[out] filepath The filepath of the first datafile for the
1982 tablespace.
1983 @return true if tablespace is found, false if not. */
1984 bool fil_space_read_name_and_filepath(space_id_t space_id, char **name,
1985  char **filepath)
1986  MY_ATTRIBUTE((warn_unused_result));
1987 
1988 /** Convert a file name to a tablespace name. Strip the file name
1989 prefix and suffix, leaving only databasename/tablename.
1990 @param[in] filename directory/databasename/tablename.ibd
1991 @return database/tablename string, to be freed with ut_free() */
1992 char *fil_path_to_space_name(const char *filename)
1993  MY_ATTRIBUTE((warn_unused_result));
1994 
1995 /** Returns the space ID based on the tablespace name.
1996 The tablespace must be found in the tablespace memory cache.
1997 This call is made from external to this module, so the mutex is not owned.
1998 @param[in] name Tablespace name
1999 @return space ID if tablespace found, SPACE_UNKNOWN if space not. */
2001  MY_ATTRIBUTE((warn_unused_result));
2002 
2003 /** Check if swapping two .ibd files can be done without failure
2004 @param[in] old_table old table
2005 @param[in] new_table new table
2006 @param[in] tmp_name temporary table name
2007 @return innodb error code */
2008 dberr_t fil_rename_precheck(const dict_table_t *old_table,
2009  const dict_table_t *new_table, const char *tmp_name)
2010  MY_ATTRIBUTE((warn_unused_result));
2011 
2012 /** Set the compression type for the tablespace
2013 @param[in] space_id Space ID of the tablespace
2014 @param[in] algorithm Text representation of the algorithm
2015 @return DB_SUCCESS or error code */
2016 dberr_t fil_set_compression(space_id_t space_id, const char *algorithm)
2017  MY_ATTRIBUTE((warn_unused_result));
2018 
2019 /** Get the compression algorithm for a tablespace.
2020 @param[in] space_id Space ID to check
2021 @return the compression algorithm */
2023  MY_ATTRIBUTE((warn_unused_result));
2024 
2025 /** Set encryption information for IORequest.
2026 @param[in,out] req_type IO request
2027 @param[in] page_id page id
2028 @param[in] space table space */
2029 void fil_io_set_encryption(IORequest &req_type, const page_id_t &page_id,
2030  fil_space_t *space);
2031 
2032 /** Set the encryption type for the tablespace
2033 @param[in] space_id Space ID of tablespace for which to set
2034 @param[in] algorithm Encryption algorithm
2035 @param[in] key Encryption key
2036 @param[in] iv Encryption iv
2037 @return DB_SUCCESS or error code */
2039  byte *key, byte *iv)
2040  MY_ATTRIBUTE((warn_unused_result));
2041 
2042 /** Set the autoextend_size attribute for the tablespace
2043 @param[in] space_id Space ID of tablespace for which to set
2044 @param[in] autoextend_size Value of autoextend_size attribute
2045 @return DB_SUCCESS or error code */
2046 dberr_t fil_set_autoextend_size(space_id_t space_id, uint64_t autoextend_size);
2047 
2048 /** Reset the encryption type for the tablespace
2049 @param[in] space_id Space ID of tablespace for which to set
2050 @return DB_SUCCESS or error code */
2052  MY_ATTRIBUTE((warn_unused_result));
2053 
2054 /** Rotate the tablespace keys by new master key.
2055 @return the number of tablespaces that failed to rotate. */
2056 size_t fil_encryption_rotate() MY_ATTRIBUTE((warn_unused_result));
2057 
2058 /** During crash recovery, open a tablespace if it had not been opened
2059 yet, to get valid size and flags.
2060 @param[in,out] space Tablespace instance */
2062  if (space->size == 0) {
2063  /* Initially, size and flags will be set to 0,
2064  until the files are opened for the first time.
2065  fil_space_get_size() will open the file
2066  and adjust the size and flags. */
2067  page_no_t size = fil_space_get_size(space->id);
2068 
2069  ut_a(size == space->size);
2070  }
2071 }
2072 
2073 #if !defined(NO_FALLOCATE) && defined(UNIV_LINUX)
2074 /**
2075 Try and enable FusionIO atomic writes.
2076 @param[in] file OS file handle
2077 @return true if successful */
2078 bool fil_fusionio_enable_atomic_write(pfs_os_file_t file)
2079  MY_ATTRIBUTE((warn_unused_result));
2080 #endif /* !NO_FALLOCATE && UNIV_LINUX */
2081 
2082 /** Note that the file system where the file resides doesn't support PUNCH HOLE.
2083 Called from AIO handlers when IO returns DB_IO_NO_PUNCH_HOLE
2084 @param[in,out] file file to set */
2086 
2087 #ifdef UNIV_ENABLE_UNIT_TEST_MAKE_FILEPATH
2088 void test_make_filepath();
2089 #endif /* UNIV_ENABLE_UNIT_TEST_MAKE_FILEPATH */
2090 
2091 /** @return the system tablespace instance */
2092 #define fil_space_get_sys_space() (fil_space_t::s_sys_space)
2094 /** Redo a tablespace create.
2095 @param[in] ptr redo log record
2096 @param[in] end end of the redo log buffer
2097 @param[in] page_id Tablespace Id and first page in file
2098 @param[in] parsed_bytes Number of bytes parsed so far
2099 @param[in] parse_only Don't apply, parse only
2100 @return pointer to next redo log record
2101 @retval nullptr if this log record was truncated */
2102 byte *fil_tablespace_redo_create(byte *ptr, const byte *end,
2103  const page_id_t &page_id, ulint parsed_bytes,
2104  bool parse_only)
2105  MY_ATTRIBUTE((warn_unused_result));
2106 
2107 /** Redo a tablespace delete.
2108 @param[in] ptr redo log record
2109 @param[in] end end of the redo log buffer
2110 @param[in] page_id Tablespace Id and first page in file
2111 @param[in] parsed_bytes Number of bytes parsed so far
2112 @param[in] parse_only Don't apply, parse only
2113 @return pointer to next redo log record
2114 @retval nullptr if this log record was truncated */
2115 byte *fil_tablespace_redo_delete(byte *ptr, const byte *end,
2116  const page_id_t &page_id, ulint parsed_bytes,
2117  bool parse_only)
2118  MY_ATTRIBUTE((warn_unused_result));
2119 
2120 /** Redo a tablespace rename.
2121 This function doesn't do anything, simply parses the redo log record.
2122 @param[in] ptr redo log record
2123 @param[in] end end of the redo log buffer
2124 @param[in] page_id Tablespace Id and first page in file
2125 @param[in] parsed_bytes Number of bytes parsed so far
2126 @param[in] parse_only Don't apply, parse only
2127 @return pointer to next redo log record
2128 @retval nullptr if this log record was truncated */
2129 byte *fil_tablespace_redo_rename(byte *ptr, const byte *end,
2130  const page_id_t &page_id, ulint parsed_bytes,
2131  bool parse_only)
2132  MY_ATTRIBUTE((warn_unused_result));
2133 
2134 /** Redo a tablespace extend
2135 @param[in] ptr redo log record
2136 @param[in] end end of the redo log buffer
2137 @param[in] page_id Tablespace Id and first page in file
2138 @param[in] parsed_bytes Number of bytes parsed so far
2139 @param[in] parse_only Don't apply the log if true
2140 @return pointer to next redo log record
2141 @retval nullptr if this log record was truncated */
2142 byte *fil_tablespace_redo_extend(byte *ptr, const byte *end,
2143  const page_id_t &page_id, ulint parsed_bytes,
2144  bool parse_only)
2145  MY_ATTRIBUTE((warn_unused_result));
2146 
2147 /** Parse and process an encryption redo record.
2148 @param[in] ptr redo log record
2149 @param[in] end end of the redo log buffer
2150 @param[in] space_id the tablespace ID
2151 @param[in] lsn lsn for REDO record
2152 @return log record end, nullptr if not a complete record */
2153 byte *fil_tablespace_redo_encryption(byte *ptr, const byte *end,
2154  space_id_t space_id, lsn_t lsn)
2155  MY_ATTRIBUTE((warn_unused_result));
2156 
2157 /** Read the tablespace id to path mapping from the file
2158 @param[in] recovery true if called from crash recovery */
2160 
2161 /** Lookup the tablespace ID.
2162 @param[in] space_id Tablespace ID to lookup
2163 @return true if the space ID is known. */
2165  MY_ATTRIBUTE((warn_unused_result));
2166 
2167 /** Compare and update space name and dd path for partitioned table. Uniformly
2168 converts partition separators and names to lower case.
2169 @param[in] space_id tablespace ID
2170 @param[in] fsp_flags tablespace flags
2171 @param[in] update_space update space name
2172 @param[in,out] space_name tablespace name
2173 @param[in,out] dd_path file name with complete path
2174 @return true, if names are updated. */
2175 bool fil_update_partition_name(space_id_t space_id, uint32_t fsp_flags,
2176  bool update_space, std::string &space_name,
2177  std::string &dd_path);
2178 
2179 /** Add tablespace to the set of tablespaces to be updated in DD.
2180 @param[in] dd_object_id Server DD tablespace ID
2181 @param[in] space_id Innodb tablespace ID
2182 @param[in] space_name New tablespace name
2183 @param[in] old_path Old Path in the data dictionary
2184 @param[in] new_path New path to be update in dictionary */
2185 void fil_add_moved_space(dd::Object_id dd_object_id, space_id_t space_id,
2186  const char *space_name, const std::string &old_path,
2187  const std::string &new_path);
2188 
2189 /** Lookup the tablespace ID and return the path to the file. The filename
2190 is ignored when testing for equality. Only the path up to the file name is
2191 considered for matching: e.g. ./test/a.ibd == ./test/b.ibd.
2192 @param[in] dd_object_id server DD tablespace ID
2193 @param[in] space_id tablespace ID to lookup
2194 @param[in] space_name tablespace name
2195 @param[in] fsp_flags tablespace flags
2196 @param[in] old_path the path found in dd:Tablespace_files
2197 @param[out] new_path the scanned path for this space_id
2198 @return status of the match. */
2200  space_id_t space_id,
2201  const char *space_name, ulint fsp_flags,
2202  std::string old_path,
2203  std::string *new_path)
2204  MY_ATTRIBUTE((warn_unused_result));
2205 
2206 /** This function should be called after recovery has completed.
2207 Check for tablespace files for which we did not see any MLOG_FILE_DELETE
2208 or MLOG_FILE_RENAME record. These could not be recovered
2209 @return true if there were some filenames missing for which we had to
2210 ignore redo log records during the apply phase */
2211 bool fil_check_missing_tablespaces() MY_ATTRIBUTE((warn_unused_result));
2212 
2213 /** Normalize and save a directory to scan for datafiles.
2214 @param[in] directory directory to scan for ibd and ibu files
2215 @param[in] is_undo_dir true for an undo directory */
2216 void fil_set_scan_dir(const std::string &directory, bool is_undo_dir = false);
2217 
2218 /** Normalize and save a list of directories to scan for datafiles.
2219 @param[in] directories Directories to scan for ibd and ibu files
2220  in the form: "dir1;dir2; ... dirN" */
2221 void fil_set_scan_dirs(const std::string &directories);
2222 
2223 /** Discover tablespaces by reading the header from .ibd files.
2224 @return DB_SUCCESS if all goes well */
2226 
2227 /** Open the tabelspace and also get the tablespace filenames, space_id must
2228 already be known.
2229 @param[in] space_id Tablespace ID to lookup
2230 @return true if open was successful */
2232  MY_ATTRIBUTE((warn_unused_result));
2233 
2234 /** Replay a file rename operation for ddl replay.
2235 @param[in] page_id Space ID and first page number in the file
2236 @param[in] old_name old file name
2237 @param[in] new_name new file name
2238 @return whether the operation was successfully applied
2239 (the name did not exist, or new_name did not exist and
2240 name was successfully renamed to new_name) */
2241 bool fil_op_replay_rename_for_ddl(const page_id_t &page_id,
2242  const char *old_name, const char *new_name);
2243 
2244 /** Free the Tablespace_files instance.
2245 @param[in] read_only_mode true if InnoDB is started in read only mode.
2246 @return DB_SUCCESS if all OK */
2247 dberr_t fil_open_for_business(bool read_only_mode)
2248  MY_ATTRIBUTE((warn_unused_result));
2249 
2250 /** Check if a path is known to InnoDB meaning that it is in or under
2251 one of the four path settings scanned at startup for file discovery.
2252 @param[in] path Path to check
2253 @return true if path is known to InnoDB */
2254 bool fil_path_is_known(const std::string &path)
2255  MY_ATTRIBUTE((warn_unused_result));
2256 
2257 /** Get the list of directories that datafiles can reside in.
2258 @return the list of directories 'dir1;dir2;....;dirN' */
2259 std::string fil_get_dirs() MY_ATTRIBUTE((warn_unused_result));
2260 
2261 /** Rename a tablespace. Use the space_id to find the shard.
2262 @param[in] space_id tablespace ID
2263 @param[in] old_name old tablespace name
2264 @param[in] new_name new tablespace name
2265 @return DB_SUCCESS on success */
2266 dberr_t fil_rename_tablespace_by_id(space_id_t space_id, const char *old_name,
2267  const char *new_name)
2268  MY_ATTRIBUTE((warn_unused_result));
2269 
2270 /** Free the data structures required for recovery. */
2271 void fil_free_scanned_files();
2272 
2273 /** Update the tablespace name. In case, the new name
2274 and old name are same, no update done.
2275 @param[in,out] space tablespace object on which name
2276  will be updated
2277 @param[in] name new name for tablespace */
2278 void fil_space_update_name(fil_space_t *space, const char *name);
2279 
2280 /** Adjust file name for import for partition files in different letter case.
2281 @param[in] table Innodb dict table
2282 @param[in] path file path to open
2283 @param[in] extn file extension */
2284 void fil_adjust_name_import(dict_table_t *table, const char *path,
2285  ib_file_suffix extn);
2286 
2287 #ifndef UNIV_HOTBACKUP
2288 
2289 /** Allows fil system to do periodical cleanup. */
2290 void fil_purge();
2291 
2292 /** Count how many truncated undo space IDs are still tracked in
2293 the buffer pool and the file_system cache.
2294 @param[in] undo_num undo tablespace number.
2295 @return number of undo tablespaces that are still in memory. */
2296 size_t fil_count_undo_deleted(space_id_t undo_num);
2297 
2298 #endif /* !UNIV_HOTBACKUP */
2299 
2300 /** Get the page type as a string.
2301 @param[in] type page type to be converted to string.
2302 @return the page type as a string. */
2303 const char *fil_get_page_type_str(page_type_t type) noexcept
2304  MY_ATTRIBUTE((warn_unused_result));
2305 
2306 /** Check if the given page type is valid.
2307 @param[in] type the page type to be checked for validity.
2308 @return true if it is valid page type, false otherwise. */
2310  MY_ATTRIBUTE((warn_unused_result));
2311 
2312 #endif /* fil0fil_h */
page_no_t
uint32 page_no_t
Page number.
Definition: api0api.h:57
Encryption::Type
Type
Algorithm types supported.
Definition: os0enc.h:42
fil_set_autoextend_size
dberr_t fil_set_autoextend_size(space_id_t space_id, uint64_t autoextend_size)
Set the autoextend_size attribute for the tablespace.
Definition: fil0fil.cc:9322
lsn_t
uint64_t lsn_t
Type used for all log sequence number storage and arithmetics.
Definition: log0types.h:60
FIL_PAGE_ENCRYPTED_RTREE
constexpr page_type_t FIL_PAGE_ENCRYPTED_RTREE
Encrypted R-tree page.
Definition: fil0fil.h:1262
fil_aio_wait
void fil_aio_wait(ulint segment)
Waits for an AIO operation to complete.
Definition: fil0fil.cc:8184
Fil_path::is_hidden
static bool is_hidden(std::string path)
Determine if the file or directory is considered HIDDEN.
Definition: fil0fil.cc:9630
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:5468
lsn
static uint64_t lsn
Definition: xcom_base.cc:429
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:810
fil_space_t::encryption_klen
ulint encryption_klen
Encrypt key length.
Definition: fil0fil.h:488
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:671
fil_node_t::name
char * name
file name; protected by Fil_shard::m_mutex and log_sys->mutex.
Definition: fil0fil.h:153
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:558
fil_node_t::LRU
List_node LRU
link to the fil_system->LRU list (keeping track of open files)
Definition: fil0fil.h:201
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:1039
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:4738
fil_space_t::get_encryption_info
void get_encryption_info(Encryption &en) noexcept
Copy the encryption info from this object to the provided Encryption object.
Definition: fil0fil.h:530
filepath
static const char * filepath
Definition: myisamlog.cc:93
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:8160
dict0types.h
fil_node_t::handle
pfs_os_file_t handle
file handle (valid if is_open)
Definition: fil0fil.h:161
Fil_path::OS_SEPARATOR
static constexpr auto OS_SEPARATOR
OS specific path separator.
Definition: fil0fil.h:589
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:1134
fil_space_t::purpose
fil_type_t purpose
Purpose.
Definition: fil0fil.h:426
FIL_PAGE_TYPE_LOB_INDEX
constexpr page_type_t FIL_PAGE_TYPE_LOB_INDEX
Index pages of uncompressed LOB.
Definition: fil0fil.h:1277
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
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:6518
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:458
ENCRYPTION
@ ENCRYPTION
Definition: fil0fil.h:217
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:2061
Fil_path::is_valid_location_within_db
static bool is_valid_location_within_db(const char *space_name, const std::string &path)
Check if the implicit filepath is immediately within a dir named for the schema.
Definition: fil0fil.cc:11918
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:3542
FIL_PAGE_RTREE
constexpr page_type_t FIL_PAGE_RTREE
R-tree node.
Definition: fil0fil.h:1206
fil_addr_t::is_equal
bool is_equal(const fil_addr_t &rhs) const
Compare to instances.
Definition: fil0fil.h:1166
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:7480
fil_delete_tablespace
dberr_t fil_delete_tablespace(space_id_t space_id, buf_remove_t buf_remove)
Deletes an IBD or IBU tablespace.
Definition: fil0fil.cc:4662
FIL_PAGE_TYPE_ZLOB_FRAG
constexpr page_type_t FIL_PAGE_TYPE_ZLOB_FRAG
Fragment pages of compressed LOB.
Definition: fil0fil.h:1296
fil_space_t::name
char * name
Tablespace name.
Definition: fil0fil.h:303
fil_space_t::is_compressed
bool is_compressed() const noexcept
Check if the tablespace is compressed.
Definition: fil0fil.h:510
FIL_PAGE_TYPE_ZLOB_DATA
constexpr page_type_t FIL_PAGE_TYPE_ZLOB_DATA
Data pages of compressed LOB.
Definition: fil0fil.h:1289
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:65
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:690
IBU
@ IBU
Definition: fil0fil.h:562
Fil_state
Fil_state
Result of comparing a path.
Definition: fil0fil.h:115
Compression::Type
Type
Algorithm types supported.
Definition: file.h:52
ut_a
#define ut_a(EXPR)
Abort execution if EXPR does not evaluate to nonzero.
Definition: ut0dbg.h:54
Fil_path::path
const std::string & path() const
Definition: fil0fil.h:641
fil_get_page_type_str
const char * fil_get_page_type_str(page_type_t type) noexcept
Get the page type as a string.
Definition: fil0fil.cc:12022
ut_ad
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:66
Fil_iterator
Iterate over the files in all the tablespaces.
Definition: fil0fil.h:1471
fil_flush
void fil_flush(space_id_t space_id)
Flushes to disk possible writes cached by the OS.
Definition: fil0fil.cc:8524
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:1151
fil_get_compression
Compression::Type fil_get_compression(space_id_t space_id)
Get the compression algorithm for a tablespace.
Definition: fil0fil.cc:9312
MySQL_undo_path_is_unique
bool MySQL_undo_path_is_unique
The undo path is different from any other known directory.
Definition: fil0fil.cc:283
FIL_PAGE_SDI
constexpr page_type_t FIL_PAGE_SDI
Tablespace SDI Index page.
Definition: fil0fil.h:1209
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:8593
fil_space_t::has_no_references
bool has_no_references() const
Definition: fil0fil.cc:12172
Fil_path::relative
@ relative
Definition: fil0fil.h:604
fil_space_t::encryption_type
Encryption::Type encryption_type
Encryption algorithm.
Definition: fil0fil.h:482
fil_close_tablespace
dberr_t fil_close_tablespace(trx_t *trx, space_id_t space_id)
Closes a single-table tablespace.
Definition: fil0fil.cc:4375
fil_space_t::magic_n
ulint magic_n
FIL_SPACE_MAGIC_N.
Definition: fil0fil.h:500
FIL_PAGE_IBUF_BITMAP
constexpr page_type_t FIL_PAGE_IBUF_BITMAP
Insert buffer bitmap.
Definition: fil0fil.h:1225
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:3982
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:79
PageCallback::set_page_size
void set_page_size(const buf_frame_t *page) 1
Set the tablespace table size.
Definition: fil0fil.cc:9133
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:7499
PAGE_NO_MAX
constexpr page_no_t PAGE_NO_MAX
Maximum Page Number, one less than FIL_NULL.
Definition: fil0fil.h:1140
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:8637
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:1302
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:2202
fil_system_get_file_by_space_num
bool fil_system_get_file_by_space_num(space_id_t space_num, space_id_t &space_id, std::string &name)
Fetch the file name opened for an undo space number from the file map.
Definition: fil0fil.cc:4504
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:3468
FIL_PAGE_COMPRESSED
constexpr page_type_t FIL_PAGE_COMPRESSED
Compressed page.
Definition: fil0fil.h:1253
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:1115
Fil_path::path_type
path_type
Various types of file paths.
Definition: fil0fil.h:604
fil_space_t::m_last_extended
ib::Timer m_last_extended
When the tablespace was extended last.
Definition: fil0fil.h:297
Space_ids
std::vector< space_id_t, ut_allocator< space_id_t > > Space_ids
Definition: fil0fil.h:100
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, ulint fsp_flags, std::string old_path, std::string *new_path)
Lookup the tablespace ID and return the path to the file.
Definition: fil0fil.cc:10256
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:7454
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:454
fil_space_t::is_deleted
bool is_deleted() const
Definition: fil0fil.cc:12149
IBT
@ IBT
Definition: fil0fil.h:561
fil_space_t::get_reference_count
size_t get_reference_count() const
Definition: fil0fil.cc:12176
fil_space_dec_redo_skipped_count
void fil_space_dec_redo_skipped_count(space_id_t space_id)
Decrease redo skipped count for a tablespace.
Definition: fil0fil.cc:4763
FIL_PAGE_TYPE_XDES
constexpr page_type_t FIL_PAGE_TYPE_XDES
Extent descriptor page.
Definition: fil0fil.h:1237
fil_space_t::size
page_no_t size
Tablespace file size in pages; 0 if not known yet.
Definition: fil0fil.h:433
fil_space_update_name
void fil_space_update_name(fil_space_t *space, const char *name)
Update the tablespace name.
Definition: fil0fil.cc:11859
FIL_PAGE_SDI_ZBLOB
constexpr page_type_t FIL_PAGE_SDI_ZBLOB
Commpressed SDI BLOB page.
Definition: fil0fil.h:1268
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:5816
Fil_path::operator()
const char * operator()() const
Explicit type conversion.
Definition: fil0fil.h:636
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:264
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:1925
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:5074
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:2340
fil_page_get_next
page_no_t fil_page_get_next(const byte *page)
Get the successor of a file page.
Definition: fil0fil.cc:8618
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:6885
CFG
@ CFG
Definition: fil0fil.h:559
fil_close_log_files
void fil_close_log_files(bool free_all)
Closes the redo log files.
Definition: fil0fil.cc:3915
fil_n_file_opened
ulint fil_n_file_opened
Number of files currently open.
Definition: fil0fil.cc:298
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:5387
FIL_IBT_FILE_INITIAL_SIZE
constexpr size_t FIL_IBT_FILE_INITIAL_SIZE
Definition: fil0fil.h:1129
DWR
@ DWR
Definition: fil0fil.h:563
Fil_path::trim_separator
static void trim_separator(std::string &path)
If the last character of a directory path is a separator ('\' or '/') trim it off the string.
Definition: fil0fil.h:975
dict_table_t
Data structure for a database table.
Definition: dict0mem.h:1525
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:10252
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:473
FIL_PAGE_INDEX
constexpr page_type_t FIL_PAGE_INDEX
File page types (values of FIL_PAGE_TYPE)
Definition: fil0fil.h:1203
fil_space_t::latch
rw_lock_t latch
Latch protecting the file space storage allocation.
Definition: fil0fil.h:468
name
case opt name
Definition: sslopt-case.h:32
buf_block_t
The buffer control block structure.
Definition: buf0buf.h:1544
fil_type_t
fil_type_t
File types.
Definition: fil0fil.h:103
fil_validate
bool fil_validate()
Checks the consistency of the tablespace cache.
Definition: fil0fil.cc:2016
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:138
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.cc:9599
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:9667
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:180
fil_space_get_flags
uint32_t fil_space_get_flags(space_id_t space_id)
Returns the flags of the space.
Definition: fil0fil.cc:3584
Fil_path::append_separator
static void append_separator(std::string &path)
If the last character of a directory path is NOT a separator, append a separator to the path.
Definition: fil0fil.h:987
fil_node_t::punch_hole
bool punch_hole
whether the file system of this file supports PUNCH HOLE
Definition: fil0fil.h:204
fil_addr_t::print
std::ostream & print(std::ostream &out) const
Print a string representation.
Definition: fil0fil.h:1176
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:9766
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:1286
os_file_type_t
os_file_type_t
Definition: os0file.h:669
fil_count_undo_deleted
size_t fil_count_undo_deleted(space_id_t undo_num)
Count how many truncated undo space IDs are still tracked in the buffer pool and the file_system cach...
Definition: fil0fil.cc:12012
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:3731
fil_node_t::sync_event
os_event_t sync_event
event that groups and serializes calls to fsync
Definition: fil0fil.h:164
Fil_path::DB_SEPARATOR
static constexpr auto DB_SEPARATOR
schema '/' table separator
Definition: fil0fil.h:586
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:726
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:4072
ib::Timer
For measuring time elapsed.
Definition: ut0ut.h:852
fil_io_set_encryption
void fil_io_set_encryption(IORequest &req_type, const page_id_t &page_id, fil_space_t *space)
Set encryption information for IORequest.
Definition: fil0fil.cc:7664
mem_block_info_t
The info structure stored at the beginning of a heap block.
Definition: mem0mem.h:343
Fil_path::type_of_path
static path_type type_of_path(const std::string &path)
Determine what type of path is provided.
Definition: fil0fil.h:819
Fil_path::is_file_and_exists
bool is_file_and_exists() const
Definition: fil0fil.cc:9698
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:5105
fil_space_t
Tablespace or log data space.
Definition: fil0fil.h:220
object_id.h
FIL_PAGE_TYPE_LOB_FIRST
constexpr page_type_t FIL_PAGE_TYPE_LOB_FIRST
The first page of an uncompressed LOB.
Definition: fil0fil.h:1283
Fil_path::is_valid_location
static bool is_valid_location(const char *space_name, space_id_t space_id, uint32_t fsp_flags, const std::string &path)
Check if the filepath provided is in a valid placement.
Definition: fil0fil.cc:11874
fil_space_t::m_deleted
std::atomic_bool m_deleted
true if the tablespace is marked for deletion.
Definition: fil0fil.h:403
fil_space_t::encryption_iv
byte encryption_iv[Encryption::KEY_LEN]
Encrypt initial vector.
Definition: fil0fil.h:491
os_offset_t
ib_uint64_t os_offset_t
File offset in bytes.
Definition: os0file.h:83
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:10379
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:3622
fil_node_t::modification_counter
int64_t modification_counter
number of writes to the file since the system was started
Definition: fil0fil.h:195
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:1855
FSP_FLAGS_GET_ENCRYPTION
#define FSP_FLAGS_GET_ENCRYPTION(flags)
Return the contents of the ENCRYPTION field.
Definition: fsp0types.h:346
fil_page_set_type
void fil_page_set_type(byte *page, ulint type)
Sets the file page type.
Definition: fil0fil.cc:8625
fil_open_for_business
dberr_t fil_open_for_business(bool read_only_mode)
Free the Tablespace_files instance.
Definition: fil0fil.cc:10138
FIL_PAGE_TYPE_BLOB
constexpr page_type_t FIL_PAGE_TYPE_BLOB
Uncompressed BLOB page.
Definition: fil0fil.h:1240
FIL_PAGE_TYPE_FSP_HDR
constexpr page_type_t FIL_PAGE_TYPE_FSP_HDR
File space header.
Definition: fil0fil.h:1234
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:11998
FIL_PAGE_INODE
constexpr page_type_t FIL_PAGE_INODE
Index node.
Definition: fil0fil.h:1215
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:778
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:1030
Fil_path
Wrapper for a path to a directory that may or may not exist.
Definition: fil0fil.h:583
Fil_path::get_basename
static std::string get_basename(const std::string &filepath)
Get the basename of the file path.
Definition: fil0fil.cc:4355
fil_space_t::inc_ref
void inc_ref() noexcept
Increment the page reference count.
Definition: fil0fil.h:267
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:10149
fil_tablespace_iterate
dberr_t fil_tablespace_iterate(dict_table_t *table, ulint n_io_buffers, Compression::Type compression_type, PageCallback &callback)
Iterate over all the pages in the tablespace.
Definition: fil0fil.cc:8944
Fil_path::has_prefix
static bool has_prefix(const std::string &path, const std::string prefix)
Definition: fil0fil.h:853
fil_space_t::flags
uint32_t flags
Tablespace flags; see fsp_flags_is_valid() and page_size_t(ulint) (constructor).
Definition: fil0fil.h:450
fil_space_t::id
space_id_t id
Tablespace ID.
Definition: fil0fil.h:306
Fil_path::Fil_path
Fil_path()
Default constructor.
Definition: fil0fil.cc:9572
CFP
@ CFP
Definition: fil0fil.h:560
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:60
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:417
fil_space_release
void fil_space_release(fil_space_t *space)
Release a tablespace acquired with fil_space_acquire().
Definition: fil0fil.cc:4078
NONE
@ NONE
Definition: fil0fil.h:217
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:1259
fil_addr_null
fil_addr_t fil_addr_null
The null file address.
Definition: fil0fil.cc:329
fil_addr_t::fil_addr_t
fil_addr_t(page_no_t p, uint32_t boff)
Constructor.
Definition: fil0fil.h:1161
fil_check_missing_tablespaces
bool fil_check_missing_tablespaces()
This function should be called after recovery has completed.
Definition: fil0fil.cc:10491
fil_space_t::autoextend_size_in_bytes
uint64_t autoextend_size_in_bytes
Autoextend size.
Definition: fil0fil.h:439
m_ctype.h
fil_node_t::is_raw_disk
bool is_raw_disk
whether the file actually is a raw device or disk partition
Definition: fil0fil.h:167
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:3994
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:4245
fil_space_t::FlushObservers
std::vector< Observer *, ut_allocator< Observer * > > FlushObservers
Definition: fil0fil.h:294
FIL_PAGE_TYPE_LOB_DATA
constexpr page_type_t FIL_PAGE_TYPE_LOB_DATA
Data pages of uncompressed LOB.
Definition: fil0fil.h:1280
page_size_t
Page size descriptor.
Definition: page0size.h:49
reference_caching::channel::validate
static mysql_service_status_t validate(reference_caching_channel channel) noexcept
Definition: component.cc:66
Fil_path::to_lower
static void to_lower(std::string &path)
Convert a path string to lower case using the CHARSET my_charset_filename.
Definition: fil0fil.h:883
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)
Drop and create an UNDO tablespace.
Definition: fil0fil.cc:5764
Fil_path::SLASH_DOT_DOT_SLASH
static constexpr auto SLASH_DOT_DOT_SLASH
Definition: fil0fil.h:600
page0size.h
fil_scan_for_tablespaces
dberr_t fil_scan_for_tablespaces()
Discover tablespaces by reading the header from .ibd files.
Definition: fil0fil.cc:11837
fil_node_t::is_open
bool is_open
whether this file is open.
Definition: fil0fil.h:158
fil_reset_encryption
dberr_t fil_reset_encryption(space_id_t space_id)
Reset the encryption type for the tablespace.
Definition: fil0fil.cc:9392
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:11827
Fil_path::SEPARATOR
static constexpr auto SEPARATOR
Directory separators that are supported.
Definition: fil0fil.h:592
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:1479
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:3359
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:10503
FIL_PAGE_IBUF_FREE_LIST
constexpr page_type_t FIL_PAGE_IBUF_FREE_LIST
Insert buffer free list.
Definition: fil0fil.h:1218
fil_space_t::m_header_page_flush_lsn
lsn_t m_header_page_flush_lsn
Flush lsn of header page.
Definition: fil0fil.h:497
fil_init
void fil_init(ulint max_n_open)
Initializes the tablespace memory cache.
Definition: fil0fil.cc:3666
PageCallback::m_file
pfs_os_file_t m_file
File handle to the tablespace.
Definition: fil0fil.h:1953
PageCallback
Callback functor.
Definition: fil0fil.h:1898
fil_space_t::can_encrypt
bool can_encrypt() const noexcept
Check if the encryption details, like the encryption key, type and other details, that are needed to ...
Definition: fil0fil.h:523
PageCallback::PageCallback
PageCallback(PageCallback &&)=delete
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:10614
Fil_path::DOT_DOT_SLASH
static constexpr auto DOT_DOT_SLASH
Definition: fil0fil.h:599
FIL_PAGE_TYPE_LEGACY_DBLWR
constexpr page_type_t FIL_PAGE_TYPE_LEGACY_DBLWR
Legacy doublewrite buffer page.
Definition: fil0fil.h:1271
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:172
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:862
page
int page
Definition: ctype-mb.cc:1234
recv_recovery_on
volatile bool recv_recovery_on
true when applying redo log records during crash recovery; false otherwise.
Definition: log0recv.cc:96
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:8599
pfs_os_file_t
Common file descriptor for file IO instrumentation with PFS on windows and other platforms.
Definition: os0file.h:160
fil_space_t::Files
std::vector< fil_node_t, ut_allocator< fil_node_t > > Files
Definition: fil0fil.h:222
Encryption
Encryption algorithm.
Definition: os0enc.h:39
fil_page_get_type
page_type_t fil_page_get_type(const byte *page)
Get the file page type.
Definition: fil0fil.h:1843
fil_node_t::List_node
UT_LIST_NODE_T(fil_node_t) List_node
Definition: fil0fil.h:147
fil_addr_t::fil_addr_t
fil_addr_t()
Definition: fil0fil.h:1156
fil_space_t::get_current_version
uint32_t get_current_version() const
Returns current version of the space object.
Definition: fil0fil.cc:12162
FIL_PAGE_TYPE_ZLOB_INDEX
constexpr page_type_t FIL_PAGE_TYPE_ZLOB_INDEX
Index pages of compressed LOB.
Definition: fil0fil.h:1293
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:873
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:5757
FIL_SCAN_THREADS_PER_CORE
constexpr size_t FIL_SCAN_THREADS_PER_CORE
Number of threads per core.
Definition: fil0fil.h:68
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:81
fil_space_t::get_file_node
fil_node_t * get_file_node(page_no_t *page_no) noexcept
Get the file node corresponding to the given page number of the tablespace.
Definition: fil0fil.cc:12119
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:1018
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 from a file.
Definition: fil0fil.cc:8258
fil_addr_is_null
bool fil_addr_is_null(const fil_addr_t &addr)
Returns true if file address is undefined.
Definition: fil0fil.cc:8604
Encryption::KEY_LEN
static constexpr size_t KEY_LEN
Encryption key length.
Definition: os0enc.h:83
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:1250
my_charset_filename
MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_filename
Definition: ctype-utf8.cc:7040
fil_space_t::s_sys_space
static fil_space_t * s_sys_space
System tablespace.
Definition: fil0fil.h:503
encryption_op_type
encryption_op_type
Definition: fil0fil.h:217
ut0new.h
fil_node_t::space
fil_space_t * space
tablespace containing this file
Definition: fil0fil.h:150
FIL_TYPE_LOG
@ FIL_TYPE_LOG
redo log covering changes to files of FIL_TYPE_TABLESPACE
Definition: fil0fil.h:111
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:99
fil_space_t::bump_version
void bump_version()
Bumps the space object version and cause all pages in buffer pool that reference the current space ob...
Definition: fil0fil.cc:12198
fil_space_t::m_n_ref_count
std::atomic_size_t m_n_ref_count
Number of buf_page_t entries that point to this instance.
Definition: fil0fil.h:399
fil_addr_t::boffset
uint32_t boffset
Byte offset within the page.
Definition: fil0fil.h:1186
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:6024
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:1274
Fil_path::abs_len
size_t abs_len() const
Definition: fil0fil.h:664
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:2357
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:84
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:422
fil_space_t::release_free_extents
void release_free_extents(ulint n_reserved)
Release the reserved free extents.
Definition: fil0fil.cc:9849
fil_space_t::encryption_key
byte encryption_key[Encryption::KEY_LEN]
Encrypt key.
Definition: fil0fil.h:485
FIL_TYPE_IMPORT
@ FIL_TYPE_IMPORT
a tablespace that is being imported (no logging until finished)
Definition: fil0fil.h:107
fil_space_t::initialize
void initialize() noexcept
Initializes fields.
Definition: fil0fil.h:310
FIL_PAGE_ENCRYPTED
constexpr page_type_t FIL_PAGE_ENCRYPTED
Encrypted page.
Definition: fil0fil.h:1256
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:4781
fil_space_set_imported
void fil_space_set_imported(space_id_t space_id)
Note that a tablespace has been imported.
Definition: fil0fil.cc:2377
operator<<
std::ostream & operator<<(std::ostream &out, const fil_addr_t &obj)
Definition: fil0fil.h:1192
FIL_PAGE_TYPE_ALLOCATED
constexpr page_type_t FIL_PAGE_TYPE_ALLOCATED
Freshly allocated page.
Definition: fil0fil.h:1222
fil_space_t::files
Files files
Files attached to this tablespace.
Definition: fil0fil.h:430
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)
Attach a file to a tablespace.
Definition: fil0fil.cc:2535
FIL_TYPE_TABLESPACE
@ FIL_TYPE_TABLESPACE
persistent tablespace (for system, undo log or tables)
Definition: fil0fil.h:109
fil_space_t::m_undo_extend
page_no_t m_undo_extend
Extend undo tablespaces by so many pages.
Definition: fil0fil.h:300
FIL_TYPE_TEMPORARY
@ FIL_TYPE_TEMPORARY
temporary tablespace (temporary undo log or tables)
Definition: fil0fil.h:105
fil_node_t::max_size
page_no_t max_size
maximum size of the file in database pages
Definition: fil0fil.h:183
fil_tablespace_lookup_for_recovery
bool fil_tablespace_lookup_for_recovery(space_id_t space_id)
Lookup the tablespace ID.
Definition: fil0fil.cc:10201
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 through all persistent tablespace files (FIL_TYPE_TABLESPACE) returning the nodes via callbac...
Definition: fil0fil.cc:3975
buf
Definition: buf0block_hint.cc:29
fil_n_log_flushes
ulint fil_n_log_flushes
The number of fsyncs done to the log.
Definition: fil0fil.cc:289
fil_n_pending_tablespace_flushes
ulint fil_n_pending_tablespace_flushes
Number of pending tablespace flushes.
Definition: fil0fil.cc:295
page_id_t
Page identifier.
Definition: buf0types.h:168
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.cc:9575
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:5003
path
static char * path
Definition: mysqldump.cc:132
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:954
fil_space_t::compression_type
Compression::Type compression_type
Compression algorithm.
Definition: fil0fil.h:479
fil_is_page_type_valid
bool fil_is_page_type_valid(page_type_t type) noexcept
Check if the given page type is valid.
Definition: fil0fil.cc:12061
NO_EXT
@ NO_EXT
Definition: fil0fil.h:557
dd::Object_id
unsigned long long Object_id
Definition: object_id.h:30
fil_space_t::dec_ref
void dec_ref() noexcept
Decrement the page reference count.
Definition: fil0fil.h:273
fil_node_t::atomic_write
bool atomic_write
whether atomic write is enabled for this file
Definition: fil0fil.h:210
PageCallback::m_filepath
const char * m_filepath
Physical file path.
Definition: fil0fil.h:1956
page_type_t
uint16_t page_type_t
Definition: fil0fil.h:1199
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:10372
dict_name
Innodb data dictionary name.
Definition: dict0dd.cc:6419
fil_addr_t::is_null
bool is_null() const
Check if the file address is null.
Definition: fil0fil.h:1172
Fil_path::is_absolute_path
bool is_absolute_path() const
Definition: fil0fil.h:802
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 delete.
Definition: fil0fil.cc:10889
dot_ext
const char * dot_ext[]
Common InnoDB file extentions.
Definition: fil0fil.cc:286
fil_path_is_known
bool fil_path_is_known(const std::string &path)
Check if a path is known to InnoDB meaning that it is in or under one of the four path settings scann...
Definition: fil0fil.cc:11843
FIL_PAGE_TYPE_ZBLOB
constexpr page_type_t FIL_PAGE_TYPE_ZBLOB
First compressed BLOB page.
Definition: fil0fil.h:1243
Fil_path::is_separator
static bool is_separator(char c)
Check if a character is a path separator ('\' or '/')
Definition: fil0fil.h:970
fil_free_scanned_files
void fil_free_scanned_files()
Free the data structures required for recovery.
Definition: fil0fil.cc:11852
Fil_path::m_path
std::string m_path
Path to a file or directory.
Definition: fil0fil.h:1112
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:5035
Fil_iterator::Function
std::function< dberr_t(fil_node_t *)> Function
Definition: fil0fil.h:1473
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:942
Fil_path::absolute
@ absolute
Definition: fil0fil.h:604
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:9172
Fil_path::is_valid
bool is_valid() const
This validation is only for ':'.
Definition: fil0fil.cc:9709
PageCallback::m_page_size
page_size_t m_page_size
The tablespace page size.
Definition: fil0fil.h:1950
DECRYPTION
@ DECRYPTION
Definition: fil0fil.h:217
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:1299
fil_node_t::flush_counter
int64_t flush_counter
the modification_counter of the latest flush to disk
Definition: fil0fil.h:198
Fil_path::file_name_only
@ file_name_only
Definition: fil0fil.h:604
PageCallback::get_page_size
const page_size_t & get_page_size() const
The compressed page size.
Definition: fil0fil.h:1945
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:1010
std
Definition: varlen_sort.h:182
PageCallback::PageCallback
PageCallback(const PageCallback &)=delete
fil_node_t::in_use
size_t in_use
e.g., when a file is being extended or just opened.
Definition: fil0fil.h:192
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:4063
fil_space_t::get_recent_version
uint32_t get_recent_version() const
Returns current version of the space object.
Definition: fil0fil.cc:12166
fil_space_t::is_encrypted
bool is_encrypted() const noexcept
Check if the tablespace is encrypted.
Definition: fil0fil.h:516
fil_space_t::was_not_deleted
bool was_not_deleted() const
Definition: fil0fil.cc:12154
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:3566
file
Definition: os0file.h:85
fil_n_pending_log_flushes
ulint fil_n_pending_log_flushes
Number of pending redo log flushes.
Definition: fil0fil.cc:292
UT_LIST_NODE_T
#define UT_LIST_NODE_T(t)
Macro used for legacy reasons.
Definition: ut0lst.h:62
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:436
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:9348
equal
static bool equal(const Item *i1, const Item *i2, const Field *f2)
Definition: sql_select.cc:3668
FIL_NULL
constexpr page_no_t FIL_NULL
'null' (undefined) page offset in the context of file spaces
Definition: fil0fil.h:1137
FIL_PAGE_SDI_BLOB
constexpr page_type_t FIL_PAGE_SDI_BLOB
Uncompressed SDI BLOB page.
Definition: fil0fil.h:1265
Fil_path::get_existing_path
static std::string get_existing_path(const std::string &path, std::string &ghost)
Separate the portion of a directory path that exists and the portion that does not exist.
Definition: fil0fil.cc:4215
FIL_NODE_MAGIC_N
constexpr size_t FIL_NODE_MAGIC_N
Value of fil_node_t::magic_n.
Definition: fil0fil.h:553
space_id_t
uint32 space_id_t
Tablespace identifier.
Definition: api0api.h:59
fil_system_get_file_by_space_id
bool fil_system_get_file_by_space_id(space_id_t space_id, std::string &name)
Fetch the file name opened for a space_id from the file map.
Definition: fil0fil.cc:4498
rw_lock_t
The structure used in the spin lock implementation of a read-write lock.
Definition: sync0rw.h:568
Fil_path::is_directory_and_exists
bool is_directory_and_exists() const
Definition: fil0fil.cc:9703
fil_space_t::free_limit
page_no_t free_limit
Contents of FSP_FREE_LIMIT.
Definition: fil0fil.h:445
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:11831
fil_delete_file
bool fil_delete_file(const char *path)
Delete the tablespace file and any related files like .cfg.
Definition: fil0fil.cc:9141
SPACE_UNKNOWN
constexpr space_id_t SPACE_UNKNOWN
Unknown space id.
Definition: fil0fil.h:1143
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:9253
fil_space_inc_redo_skipped_count
void fil_space_inc_redo_skipped_count(space_id_t space_id)
Increase redo skipped count for a tablespace.
Definition: fil0fil.cc:4747
Fil_path::abs_path
const std::string abs_path() const
Return the absolute path by value.
Definition: fil0fil.h:655
fil_space_t::encryption_op_in_progress
encryption_op_type encryption_op_in_progress
Encryption is in progress.
Definition: fil0fil.h:494
fil_close_all_files
void fil_close_all_files()
Closes all open files.
Definition: fil0fil.cc:3860
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:176
fil_discard_tablespace
dberr_t fil_discard_tablespace(space_id_t space_id)
Discards a single-table tablespace.
Definition: fil0fil.cc:4814
fil_tablespace_redo_encryption
byte * fil_tablespace_redo_encryption(byte *ptr, const byte *end, space_id_t space_id, lsn_t lsn)
Parse and process an encryption redo record.
Definition: fil0fil.cc:10977
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:5994
fil0types.h
FIL_PAGE_TYPE_TRX_SYS
constexpr page_type_t FIL_PAGE_TYPE_TRX_SYS
Transaction system data.
Definition: fil0fil.h:1231
fil_addr_t::page
page_no_t page
Page number within a space.
Definition: fil0fil.h:1183
PageCallback::~PageCallback
virtual ~PageCallback() 1
Definition: fil0fil.h:1902
FIL_SPACE_MAGIC_N
constexpr size_t FIL_SPACE_MAGIC_N
Value of fil_space_t::magic_n.
Definition: fil0fil.h:550
fil_space_t::set_deleted
void set_deleted()
Marks the space object for deletion.
Definition: fil0fil.cc:12184
fil_close
void fil_close()
Initializes the tablespace memory cache.
Definition: fil0fil.cc:8645
Fil_path::DOT_SLASH
static constexpr auto DOT_SLASH
Definition: fil0fil.h:598
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:9876
fil_tablespace_redo_extend
byte * fil_tablespace_redo_extend(byte *ptr, const byte *end, const page_id_t &page_id, ulint parsed_bytes, bool parse_only)
Redo a tablespace extend.
Definition: fil0fil.cc:10724
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:8865
FlushObserver
We use FlushObserver to track flushing of non-redo logged pages in bulk create index(BtrBulk....
Definition: buf0flu.h:266
fil_space_t::is_in_unflushed_spaces
bool is_in_unflushed_spaces
true if this space is currently in unflushed_spaces
Definition: fil0fil.h:476
fil_space_t::s_redo_space
static fil_space_t * s_redo_space
Redo log tablespace.
Definition: fil0fil.h:506
Fil_path::invalid
@ invalid
Definition: fil0fil.h:604
fil_page_get_prev
page_no_t fil_page_get_prev(const byte *page)
Get the predecessor of a file page.
Definition: fil0fil.cc:8611
fil_space_t::free_len
uint32_t free_len
Length of the FSP_FREE list.
Definition: fil0fil.h:442
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:189
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:11981
fil_addr_t
File space address.
Definition: fil0fil.h:1154
my_tolower
#define my_tolower(s, c)
Definition: m_ctype.h:648
binary_log::transaction::compression::type
type
Definition: base.h:36
fil_space_close
void fil_space_close(space_id_t space_id)
Close each file of a tablespace if open.
Definition: fil0fil.cc:3636
fil_space_get
fil_space_t * fil_space_get(space_id_t space_id)
Look up a tablespace.
Definition: fil0fil.cc:2323
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:464
p
const char * p
Definition: ctype-mb.cc:1235
fil_space_t::m_version
std::atomic< uint32_t > m_version
All pages in the buffer pool that reference this fil_space_t instance with version before this versio...
Definition: fil0fil.h:359
fil_encryption_rotate
size_t fil_encryption_rotate()
Rotate the tablespace keys by new master key.
Definition: fil0fil.cc:9528
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:6503
FIL_PAGE_UNDO_LOG
constexpr page_type_t FIL_PAGE_UNDO_LOG
Undo log page.
Definition: fil0fil.h:1212
fil_space_t::List_node
UT_LIST_NODE_T(fil_space_t) List_node
Definition: fil0fil.h:221
PageCallback::PageCallback
PageCallback()
Default constructor.
Definition: fil0fil.h:1900
fil_node_t::block_size
size_t block_size
block size to use for punching holes
Definition: fil0fil.h:207
fil_get_dirs
std::string fil_get_dirs()
Get the list of directories that datafiles can reside in.
Definition: fil0fil.cc:11849
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 an IBD tablespace file.
Definition: fil0fil.cc:5741
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:4923
Compression::NONE
@ NONE
No compression.
Definition: file.h:58
fil_node_t
File node of a tablespace or the log data space.
Definition: fil0fil.h:146
Fil_path::is_relative_path
static bool is_relative_path(const std::string &path)
Determine if a path is a relative path or not.
Definition: fil0fil.h:796
fil_purge
void fil_purge()
Allows fil system to do periodical cleanup.
Definition: fil0fil.cc:12010
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:3651
Fil_path::get_file_type
static os_file_type_t get_file_type(const std::string &path)
Definition: fil0fil.cc:9656
trx_t
Definition: trx0trx.h:836
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:1128
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:186
fil_set_compression
dberr_t fil_set_compression(space_id_t space_id, const char *algorithm)
Set the compression type for the tablespace.
Definition: fil0fil.cc:9255
Fil_path::len
size_t len() const
Definition: fil0fil.h:646
FIL_PAGE_TYPE_SYS
constexpr page_type_t FIL_PAGE_TYPE_SYS
System page.
Definition: fil0fil.h:1228
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:9733
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:1246
log0recv.h
ib_file_suffix
ib_file_suffix
Common InnoDB file extentions.
Definition: fil0fil.h:556
ibuf0types.h
fil_node_t::magic_n
size_t magic_n
FIL_NODE_MAGIC_N.
Definition: fil0fil.h:213
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:408