1/*****************************************************************************
2
3Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
4Copyright (c) 2017, MariaDB Corporation.
5
6This program is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free Software
8Foundation; version 2 of the License.
9
10This program is distributed in the hope that it will be useful, but WITHOUT
11ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License along with
15this program; if not, write to the Free Software Foundation, Inc.,
1651 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
17
18*****************************************************************************/
19
20/**************************************************//**
21@file include/srv0start.h
22Starts the Innobase database server
23
24Created 10/10/1995 Heikki Tuuri
25*******************************************************/
26
27#ifndef srv0start_h
28#define srv0start_h
29
30#include "univ.i"
31#include "log0log.h"
32#include "ut0byte.h"
33
34// Forward declaration
35struct dict_table_t;
36
37/** If buffer pool is less than the size,
38only one buffer pool instance is used. */
39#define BUF_POOL_SIZE_THRESHOLD (1024 * 1024 * 1024)
40
41/** Open the configured number of dedicated undo tablespaces.
42@param[in] create_new_db whether the database is being initialized
43@return DB_SUCCESS or error code */
44dberr_t
45srv_undo_tablespaces_init(bool create_new_db);
46
47/** Start InnoDB.
48@param[in] create_new_db whether to create a new database
49@return DB_SUCCESS or error code */
50dberr_t srv_start(bool create_new_db);
51
52/** Shut down InnoDB. */
53void innodb_shutdown();
54
55/** Shut down background threads that can generate undo log. */
56void srv_shutdown_bg_undo_sources();
57
58/*************************************************************//**
59Copy the file path component of the physical file to parameter. It will
60copy up to and including the terminating path separator.
61@return number of bytes copied or ULINT_UNDEFINED if destination buffer
62 is smaller than the path to be copied. */
63ulint
64srv_path_copy(
65/*==========*/
66 char* dest, /*!< out: destination buffer */
67 ulint dest_len, /*!< in: max bytes to copy */
68 const char* basedir, /*!< in: base directory */
69 const char* table_name) /*!< in: source table name */
70 MY_ATTRIBUTE((nonnull, warn_unused_result));
71
72/** Get the meta-data filename from the table name for a
73single-table tablespace.
74@param[in] table table object
75@param[out] filename filename
76@param[in] max_len filename max length */
77void
78srv_get_meta_data_filename(
79 dict_table_t* table,
80 char* filename,
81 ulint max_len);
82
83/** Get the encryption-data filename from the table name for a
84single-table tablespace.
85@param[in] table table object
86@param[out] filename filename
87@param[in] max_len filename max length */
88void
89srv_get_encryption_data_filename(
90 dict_table_t* table,
91 char* filename,
92 ulint max_len);
93
94/** Log sequence number at shutdown */
95extern lsn_t srv_shutdown_lsn;
96/** Log sequence number immediately after startup */
97extern lsn_t srv_start_lsn;
98
99/** TRUE if the server is being started */
100extern bool srv_is_being_started;
101/** TRUE if SYS_TABLESPACES is available for lookups */
102extern bool srv_sys_tablespaces_open;
103/** TRUE if the server is being started, before rolling back any
104incomplete transactions */
105extern bool srv_startup_is_before_trx_rollback_phase;
106
107/** TRUE if a raw partition is in use */
108extern ibool srv_start_raw_disk_in_use;
109
110/** Shutdown state */
111enum srv_shutdown_t {
112 SRV_SHUTDOWN_NONE = 0, /*!< Database running normally */
113 SRV_SHUTDOWN_CLEANUP, /*!< Cleaning up in
114 logs_empty_and_mark_files_at_shutdown() */
115 SRV_SHUTDOWN_FLUSH_PHASE,/*!< At this phase the master and the
116 purge threads must have completed their
117 work. Once we enter this phase the
118 page_cleaner can clean up the buffer
119 pool and exit */
120 SRV_SHUTDOWN_LAST_PHASE,/*!< Last phase after ensuring that
121 the buffer pool can be freed: flush
122 all file spaces and close all files */
123 SRV_SHUTDOWN_EXIT_THREADS/*!< Exit all threads */
124};
125
126/** Whether any undo log records can be generated */
127extern bool srv_undo_sources;
128
129/** At a shutdown this value climbs from SRV_SHUTDOWN_NONE to
130SRV_SHUTDOWN_CLEANUP and then to SRV_SHUTDOWN_LAST_PHASE, and so on */
131extern enum srv_shutdown_t srv_shutdown_state;
132
133/** Files comprising the system tablespace */
134extern pfs_os_file_t files[1000];
135#endif
136