1 /*****************************************************************************
2 
3 Copyright (c) 2018, 2020, Oracle and/or its affiliates. All Rights Reserved.
4 
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License, version 2.0,
7 as published by the Free Software Foundation.
8 
9 This program is also distributed with certain software (including
10 but not limited to OpenSSL) that is licensed under separate terms,
11 as designated in a particular file or component or in included license
12 documentation.  The authors of MySQL hereby grant you an additional
13 permission to link the program and your derivative works with the
14 separately licensed software that they have included with MySQL.
15 
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 GNU General Public License, version 2.0, for more details.
20 
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
24 
25 *****************************************************************************/
26 #ifndef log0meb_h
27 #define log0meb_h
28 
29 #include "univ.i"
30 
31 class THD;
32 struct SYS_VAR;
33 struct st_mysql_value;
34 class innodb_session_t;
35 
36 namespace meb {
37 
38 /** Performance schema key for the log consumer thread. */
39 extern mysql_pfs_key_t redo_log_archive_consumer_thread_key;
40 
41 /** Performance schema key for the redo log archive file. */
42 extern mysql_pfs_key_t redo_log_archive_file_key;
43 
44 /* The innodb_redo_log_archive_dirs plugin variable value. */
45 extern char *redo_log_archive_dirs;
46 
47 /**
48   Check whether a valid value is given to innodb_redo_log_archive_dirs.
49   This function is registered as a callback with MySQL.
50   @param[in]	thd       thread handle
51   @param[in]	var       pointer to system variable
52   @param[out]	save      immediate result for update function
53   @param[in]	value     incoming string
54   @return 0 for valid contents
55 */
56 int validate_redo_log_archive_dirs(THD *thd MY_ATTRIBUTE((unused)),
57                                    SYS_VAR *var MY_ATTRIBUTE((unused)),
58                                    void *save, st_mysql_value *value);
59 
60 /**
61   Initialize redo log archiving.
62   To be called when the InnoDB handlerton is initialized.
63 */
64 extern void redo_log_archive_init();
65 
66 /**
67   De-initialize redo log archiving.
68   To be called when the InnoDB handlerton is de-initialized.
69 */
70 extern void redo_log_archive_deinit();
71 
72 /**
73   Security function to be called when the current session ends. This
74   function invokes the stop implementation if this session has started
75   the redo log archiving. It is a safe-guard against an infinitely
76   active redo log archiving if the client goes away without
77   deactivating the logging explicitly.
78 
79   @param[in]      session       the current ending session
80 */
81 extern void redo_log_archive_session_end(innodb_session_t *session);
82 
83 /**
84   The producer produces full QUEUE_BLOCK_SIZE redo log blocks. These
85   log blocks are enqueued, and are later fetched by the consumer
86   thread.
87 
88   This function does nothing, if redo log archiving is not active.
89 
90   In order to produce full QUEUE_BLOCK_SIZE redo log blocks, the
91   producer scans each OS_FILE_LOG_BLOCK_SIZE log block (written by the
92   server) to check if they are,
93 
94   1. empty
95   2. incomplete
96 
97   The producer skips empty and incomplete log blocks, unless they
98   belong to the last flush, when the contents of its buffer are
99   completely enqueued for flushing.
100 
101   @param[in]      write_buf     The write buffer that is being written
102                                 to the redo log archive file.
103   @param[in]      write_size    The size of the data being written.
104 */
105 extern void redo_log_archive_produce(const byte *write_buf,
106                                      const size_t write_size);
107 
108 /**
109   @return true iff redo log archiving is active.
110 */
111 extern bool redo_log_archive_is_active();
112 
113 /**
114   Register a privilege. We should move this function and other UDF
115   registration functions to some common utility file later.
116   @param[in]      priv_name     privilege name
117   @return         status
118     @retval       false         success
119     @retval       true          failure
120 */
121 extern bool register_privilege(const char *priv_name);
122 
123 }  // namespace meb
124 
125 #endif /* !log0meb_h */
126