1 /* Copyright 2014 Codership Oy <http://www.codership.com> & SkySQL Ab
2 
3    This program is free software; you can redistribute it and/or modify
4    it under the terms of the GNU General Public License as published by
5    the Free Software Foundation; version 2 of the License.
6 
7    This program is distributed in the hope that it will be useful,
8    but WITHOUT ANY WARRANTY; without even the implied warranty of
9    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10    GNU General Public License for more details.
11 
12    You should have received a copy of the GNU General Public License
13    along with this program; if not, write to the Free Software
14    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
15 
16 #ifndef WSREP_INCLUDED
17 #define WSREP_INCLUDED
18 
19 #include <my_config.h>
20 
21 #ifdef WITH_WSREP
22 #define IF_WSREP(A,B) A
23 #define DBUG_ASSERT_IF_WSREP(A) DBUG_ASSERT(A)
24 
25 #define WSREP_MYSQL_DB (char *)"mysql"
26 
27 #define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_)              \
28   if (WSREP_ON && WSREP(thd) && wsrep_to_isolation_begin(thd, db_, table_, table_list_)) \
29     goto wsrep_error_label;
30 
31 #define WSREP_TO_ISOLATION_BEGIN_ALTER(db_, table_, table_list_, alter_info_, fk_tables_) \
32   if (WSREP(thd) && wsrep_thd_is_local(thd) &&                          \
33       wsrep_to_isolation_begin(thd, db_, table_,                        \
34                                table_list_, alter_info_, fk_tables_))
35 
36 #define WSREP_TO_ISOLATION_END                                          \
37   if ((WSREP(thd) && wsrep_thd_is_local_toi(thd)) ||                    \
38       wsrep_thd_is_in_rsu(thd))                                         \
39     wsrep_to_isolation_end(thd);
40 
41 /*
42   Checks if lex->no_write_to_binlog is set for statements that use LOCAL or
43   NO_WRITE_TO_BINLOG.
44 */
45 #define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_)                   \
46   if (WSREP(thd) && !thd->lex->no_write_to_binlog                                   \
47          && wsrep_to_isolation_begin(thd, db_, table_, table_list_)) goto wsrep_error_label;
48 
49 #define WSREP_DEBUG(...)                                                \
50     if (wsrep_debug)     WSREP_LOG(sql_print_information, ##__VA_ARGS__)
51 #define WSREP_INFO(...)  WSREP_LOG(sql_print_information, ##__VA_ARGS__)
52 #define WSREP_WARN(...)  WSREP_LOG(sql_print_warning,     ##__VA_ARGS__)
53 #define WSREP_ERROR(...) WSREP_LOG(sql_print_error,       ##__VA_ARGS__)
54 
55 #define WSREP_SYNC_WAIT(thd_, before_)                                  \
56     { if (WSREP_CLIENT(thd_) &&                                         \
57           wsrep_sync_wait(thd_, before_)) goto wsrep_error_label; }
58 
59 #else /* !WITH_WSREP */
60 
61 /* These macros are needed to compile MariaDB without WSREP support
62  * (e.g. embedded) */
63 
64 #define IF_WSREP(A,B) B
65 //#define DBUG_ASSERT_IF_WSREP(A)
66 #define WSREP_DEBUG(...)
67 //#define WSREP_INFO(...)
68 //#define WSREP_WARN(...)
69 #define WSREP_ERROR(...)
70 #define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) do { } while(0)
71 #define WSREP_TO_ISOLATION_BEGIN_ALTER(db_, table_, table_list_, alter_info_, fk_tables_)
72 #define WSREP_TO_ISOLATION_END
73 #define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_)
74 #define WSREP_SYNC_WAIT(thd_, before_)
75 #endif /* WITH_WSREP */
76 
77 #endif /* WSREP_INCLUDED */
78