CUBRID Engine  latest
replication.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 
20 /*
21  * replication.h - the header file of replication module
22  *
23  */
24 
25 #ifndef _REPLICATION_H_
26 #define _REPLICATION_H_
27 
28 #ident "$Id$"
29 
30 #include "config.h"
31 #include "error_manager.h"
32 #if defined(SERVER_MODE) || defined(SA_MODE)
33 #include "log_impl.h"
34 #endif /* defined(SERVER_MODE) || defined(SA_MODE) */
35 #include "log_lsa.hpp"
36 #include "memory_alloc.h"
37 #include "oid.h"
38 #include "system_parameter.h"
39 #if defined(SERVER_MODE) || defined(SA_MODE)
40 #include "thread_compat.hpp"
41 #endif /* defined(SERVER_MODE) || defined(SA_MODE) */
42 
43 typedef enum
44 {
45  REPL_INFO_TYPE_SBR, /* statement-based */
46  REPL_INFO_TYPE_RBR_START, /* row-based start */
47  REPL_INFO_TYPE_RBR_NORMAL, /* row-based normal */
48  REPL_INFO_TYPE_RBR_END /* row-based end */
50 
51 typedef struct repl_info REPL_INFO;
52 struct repl_info
53 {
54  char *info;
57 };
58 
61 {
63  char *name;
64  char *stmt_text;
65  char *db_user;
67 };
68 
69 #if defined(SERVER_MODE) || defined(SA_MODE)
70 enum log_repl_flush
71 {
72  LOG_REPL_DONT_NEED_FLUSH = -1, /* no flush */
73  LOG_REPL_COMMIT_NEED_FLUSH = 0, /* log must be flushed at commit */
74  LOG_REPL_NEED_FLUSH = 1 /* log must be flushed at commit and rollback */
75 };
76 typedef enum log_repl_flush LOG_REPL_FLUSH;
77 
78 typedef struct log_repl LOG_REPL_RECORD;
79 struct log_repl
80 {
81  LOG_RECTYPE repl_type; /* LOG_REPLICATION_DATA or LOG_REPLICATION_SCHEMA */
82  LOG_RCVINDEX rcvindex;
83  OID inst_oid;
84  LOG_LSA lsa;
85  char *repl_data; /* the content of the replication log record */
86  int length;
87  LOG_REPL_FLUSH must_flush;
88  bool tde_encrypted; /* if it contains user data of tde-class */
89 };
90 #endif
91 
92 /*
93  * STATES OF TRANSACTIONS
94  */
95 
96 #if defined(SERVER_MODE) || defined(SA_MODE)
97 /* for replication, declare replication log dump function */
98 extern void repl_data_insert_log_dump (FILE * fp, int length, void *data);
99 #if defined (ENABLE_UNUSED_FUNCTION)
100 extern void repl_data_udpate_log_dump (FILE * fp, int length, void *data);
101 extern void repl_data_delete_log_dump (FILE * fp, int length, void *data);
102 #endif
103 extern void repl_schema_log_dump (FILE * fp, int length, void *data);
104 extern void repl_log_send (void);
105 extern int repl_add_update_lsa (THREAD_ENTRY * thread_p, const OID * inst_oid);
106 extern int repl_log_insert (THREAD_ENTRY * thread_p, const OID * class_oid, const OID * inst_oid, LOG_RECTYPE log_type,
107  LOG_RCVINDEX rcvindex, DB_VALUE * key_dbvalue, REPL_INFO_TYPE repl_type);
108 extern int repl_log_insert_statement (THREAD_ENTRY * thread_p, REPL_INFO_SBR * repl_info);
109 extern void repl_start_flush_mark (THREAD_ENTRY * thread_p);
110 extern void repl_end_flush_mark (THREAD_ENTRY * thread_p, bool need_undo);
111 extern int repl_log_abort_after_lsa (LOG_TDES * tdes, LOG_LSA * start_lsa);
112 #if defined(CUBRID_DEBUG)
113 extern void repl_debug_info ();
114 #endif /* CUBRID_DEBUG */
115 #endif /* SERVER_MODE || SA_MODE */
116 
117 #endif /* _REPLICATION_H_ */
bool need_replication
Definition: replication.h:56
REPL_INFO_TYPE
Definition: replication.h:43
LOG_RCVINDEX
Definition: recovery.h:36
char * info
Definition: replication.h:54
void THREAD_ENTRY
enum log_rectype LOG_RECTYPE
Definition: log_record.hpp:138
int repl_info_type
Definition: replication.h:55