1 | /***************************************************************************** |
2 | |
3 | Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. |
4 | Copyright (c) 2017, MariaDB Corporation. |
5 | |
6 | This program is free software; you can redistribute it and/or modify it under |
7 | the terms of the GNU General Public License as published by the Free Software |
8 | Foundation; version 2 of the License. |
9 | |
10 | This program is distributed in the hope that it will be useful, but WITHOUT |
11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
12 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
13 | |
14 | You should have received a copy of the GNU General Public License along with |
15 | this program; if not, write to the Free Software Foundation, Inc., |
16 | 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA |
17 | |
18 | *****************************************************************************/ |
19 | |
20 | /**************************************************//** |
21 | @file include/srv0start.h |
22 | Starts the Innobase database server |
23 | |
24 | Created 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 |
35 | struct dict_table_t; |
36 | |
37 | /** If buffer pool is less than the size, |
38 | only 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 */ |
44 | dberr_t |
45 | srv_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 */ |
50 | dberr_t srv_start(bool create_new_db); |
51 | |
52 | /** Shut down InnoDB. */ |
53 | void innodb_shutdown(); |
54 | |
55 | /** Shut down background threads that can generate undo log. */ |
56 | void srv_shutdown_bg_undo_sources(); |
57 | |
58 | /*************************************************************//** |
59 | Copy the file path component of the physical file to parameter. It will |
60 | copy 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. */ |
63 | ulint |
64 | srv_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 |
73 | single-table tablespace. |
74 | @param[in] table table object |
75 | @param[out] filename filename |
76 | @param[in] max_len filename max length */ |
77 | void |
78 | srv_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 |
84 | single-table tablespace. |
85 | @param[in] table table object |
86 | @param[out] filename filename |
87 | @param[in] max_len filename max length */ |
88 | void |
89 | srv_get_encryption_data_filename( |
90 | dict_table_t* table, |
91 | char* filename, |
92 | ulint max_len); |
93 | |
94 | /** Log sequence number at shutdown */ |
95 | extern lsn_t srv_shutdown_lsn; |
96 | /** Log sequence number immediately after startup */ |
97 | extern lsn_t srv_start_lsn; |
98 | |
99 | /** TRUE if the server is being started */ |
100 | extern bool srv_is_being_started; |
101 | /** TRUE if SYS_TABLESPACES is available for lookups */ |
102 | extern bool srv_sys_tablespaces_open; |
103 | /** TRUE if the server is being started, before rolling back any |
104 | incomplete transactions */ |
105 | extern bool srv_startup_is_before_trx_rollback_phase; |
106 | |
107 | /** TRUE if a raw partition is in use */ |
108 | extern ibool srv_start_raw_disk_in_use; |
109 | |
110 | /** Shutdown state */ |
111 | enum 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 */ |
127 | extern bool srv_undo_sources; |
128 | |
129 | /** At a shutdown this value climbs from SRV_SHUTDOWN_NONE to |
130 | SRV_SHUTDOWN_CLEANUP and then to SRV_SHUTDOWN_LAST_PHASE, and so on */ |
131 | extern enum srv_shutdown_t srv_shutdown_state; |
132 | |
133 | /** Files comprising the system tablespace */ |
134 | extern pfs_os_file_t files[1000]; |
135 | #endif |
136 | |