25
25
int replicator_initializer(st_plugin_int *plugin)
30
if (p == NULL) return 1;
31
memset(p, 0, sizeof(replicator_t));
29
if (plugin->plugin->init)
31
if (plugin->plugin->init((void *)&p))
33
/* TRANSLATORS: The leading word "replicator" is the name
34
of the plugin api, and so should not be translated. */
35
errmsg_printf(ERRMSG_LVL_ERROR,
36
_("replicator plugin '%s' init() failed"),
33
42
plugin->data= (void *)p;
35
if (plugin->plugin->init)
37
if (plugin->plugin->init((void *)p))
39
/* TRANSLATORS: The leading word "replicator" is the name
40
of the plugin api, and so should not be translated. */
41
errmsg_printf(ERRMSG_LVL_ERROR, _("replicator plugin '%s' init() failed"),
46
43
plugin->state= PLUGIN_IS_READY;
55
48
int replicator_finalizer(st_plugin_int *plugin)
57
replicator_t *p= (replicator_t *) plugin->data;
50
Replicator *p= static_cast<Replicator *>(plugin->data);
59
52
if (plugin->plugin->deinit)
63
56
/* TRANSLATORS: The leading word "replicator" is the name
64
57
of the plugin api, and so should not be translated. */
65
errmsg_printf(ERRMSG_LVL_ERROR, _("replicator plugin '%s' deinit() failed"),
58
errmsg_printf(ERRMSG_LVL_ERROR,
59
_("replicator plugin '%s' deinit() failed"),
75
67
/* This gets called by plugin_foreach once for each loaded replicator plugin */
76
68
static bool replicator_session_iterate(Session *session, plugin_ref plugin, void *)
78
replicator_t *repl= plugin_data(plugin, replicator_t *);
70
Replicator *repl= plugin_data(plugin, Replicator *);
81
/* call this loaded replicator plugin's replicator_func1 function pointer */
82
if (repl && repl->session_init)
73
/* call this loaded replicator plugin's session_init method */
84
76
error= repl->session_init(session);
87
79
/* TRANSLATORS: The leading word "replicator" is the name
88
80
of the plugin api, and so should not be translated. */
89
errmsg_printf(ERRMSG_LVL_ERROR, _("replicator plugin '%s' session_init() failed"),
90
(char *)plugin_name(plugin));
81
errmsg_printf(ERRMSG_LVL_ERROR,
82
_("replicator plugin '%s' session_init() failed"),
83
(char *)plugin_name(plugin));
145
138
/* This gets called by plugin_foreach once for each loaded replicator plugin */
146
139
static bool replicator_do_row_iterate (Session *session, plugin_ref plugin, void *p)
148
replicator_t *repl= plugin_data(plugin, replicator_t *);
149
replicator_row_parms_st *params= (replicator_row_parms_st *) p;
141
Replicator *repl= plugin_data(plugin, Replicator *);
142
replicator_row_parms_st *params= static_cast<replicator_row_parms_st *>(p);
151
144
switch (params->type) {
152
145
case repl_insert:
153
if (repl && repl->row_insert)
155
148
if (repl->row_insert(session, params->table))
157
150
/* TRANSLATORS: The leading word "replicator" is the name
158
151
of the plugin api, and so should not be translated. */
159
errmsg_printf(ERRMSG_LVL_ERROR, _("replicator plugin '%s' row_insert() failed"),
160
(char *)plugin_name(plugin));
152
errmsg_printf(ERRMSG_LVL_ERROR,
153
_("replicator plugin '%s' row_insert() failed"),
154
(char *)plugin_name(plugin));
166
160
case repl_update:
167
if (repl && repl->row_update)
169
if (repl->row_update(session, params->table, params->before, params->after))
163
if (repl->row_update(session, params->table,
164
params->before, params->after))
171
166
/* TRANSLATORS: The leading word "replicator" is the name
172
167
of the plugin api, and so should not be translated. */
173
errmsg_printf(ERRMSG_LVL_ERROR, _("replicator plugin '%s' row_update() failed"),
174
(char *)plugin_name(plugin));
168
errmsg_printf(ERRMSG_LVL_ERROR,
169
_("replicator plugin '%s' row_update() failed"),
170
(char *)plugin_name(plugin));
180
176
case repl_delete:
181
if (repl && repl->row_delete)
183
179
if (repl->row_delete(session, params->table))
185
181
/* TRANSLATORS: The leading word "replicator" is the name
186
182
of the plugin api, and so should not be translated. */
187
errmsg_printf(ERRMSG_LVL_ERROR, _("replicator plugin '%s' row_delete() failed"),
188
(char *)plugin_name(plugin));
183
errmsg_printf(ERRMSG_LVL_ERROR,
184
_("replicator plugin '%s' row_delete() failed"),
185
(char *)plugin_name(plugin));
198
/* This is the replicator_do2 entry point.
195
/* This is the replicator_do_row entry point.
199
196
This gets called by the rest of the Drizzle server code */
200
static bool replicator_do_row (Session *session, replicator_row_parms_st *params)
197
static bool replicator_do_row (Session *session,
198
replicator_row_parms_st *params)
259
257
/* We call this to end a statement (on each registered plugin) */
260
258
static bool replicator_end_transaction_iterate (Session *session, plugin_ref plugin, void *p)
262
replicator_t *repl= plugin_data(plugin, replicator_t *);
263
replicator_row_end_st *params= (replicator_row_end_st *)p;
260
Replicator *repl= plugin_data(plugin, Replicator *);
261
replicator_row_end_st *params= static_cast<replicator_row_end_st *>(p);
265
263
/* call this loaded replicator plugin's replicator_func1 function pointer */
266
if (repl && repl->end_transaction)
268
266
if (repl->end_transaction(session, params->autocommit, params->commit))
270
268
/* TRANSLATORS: The leading word "replicator" is the name
271
269
of the plugin api, and so should not be translated. */
272
errmsg_printf(ERRMSG_LVL_ERROR, _("replicator plugin '%s' end_transaction() failed"),
273
(char *)plugin_name(plugin));
270
errmsg_printf(ERRMSG_LVL_ERROR,
271
_("replicator plugin '%s' end_transaction() failed"),
272
(char *)plugin_name(plugin));
316
315
/* We call this to end a statement (on each registered plugin) */
317
316
static bool replicator_statement_iterate(Session *session, plugin_ref plugin, void *p)
319
replicator_t *repl= plugin_data(plugin, replicator_t *);
318
Replicator *repl= plugin_data(plugin, Replicator *);
320
319
replicator_statement_st *params= (replicator_statement_st *)p;
322
321
/* call this loaded replicator plugin's replicator_func1 function pointer */
323
if (repl && repl->statement)
325
324
if (repl->statement(session, params->query, params->query_length))
327
326
/* TRANSLATORS: The leading word "replicator" is the name
328
327
of the plugin api, and so should not be translated. */
329
errmsg_printf(ERRMSG_LVL_ERROR, _("replicator plugin '%s' statement() failed"),
330
(char *)plugin_name(plugin));
328
errmsg_printf(ERRMSG_LVL_ERROR,
329
_("replicator plugin '%s' statement() failed"),
330
(char *)plugin_name(plugin));