~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/replicator.cc

  • Committer: Brian Aker
  • Date: 2009-03-22 21:27:04 UTC
  • mfrom: (960.2.22 mordred)
  • Revision ID: brian@tangent.org-20090322212704-ysn4mkkjg2u9kv22
Merge Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
int replicator_initializer(st_plugin_int *plugin)
26
26
{
27
 
  replicator_t *p;
 
27
  Replicator *p= NULL;
28
28
 
29
 
  p= new replicator_t;
30
 
  if (p == NULL) return 1;
31
 
  memset(p, 0, sizeof(replicator_t));
 
29
  if (plugin->plugin->init)
 
30
  {
 
31
    if (plugin->plugin->init((void *)&p))
 
32
    {
 
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"),
 
37
                    plugin->name.str);
 
38
      return 1;
 
39
    }
 
40
  }
32
41
 
33
42
  plugin->data= (void *)p;
34
 
 
35
 
  if (plugin->plugin->init)
36
 
  {
37
 
    if (plugin->plugin->init((void *)p))
38
 
    {
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"),
42
 
                      plugin->name.str);
43
 
      goto err;
44
 
    }
45
 
  }
46
43
  plugin->state= PLUGIN_IS_READY;
47
44
 
48
45
  return 0;
49
 
 
50
 
 err:
51
 
  delete p;
52
 
  return 1;
53
46
}
54
47
 
55
48
int replicator_finalizer(st_plugin_int *plugin)
56
49
{
57
 
  replicator_t *p= (replicator_t *) plugin->data;
 
50
  Replicator *p= static_cast<Replicator *>(plugin->data);
58
51
 
59
52
  if (plugin->plugin->deinit)
60
53
    {
62
55
        {
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"),
66
 
                          plugin->name.str);
 
58
          errmsg_printf(ERRMSG_LVL_ERROR,
 
59
                        _("replicator plugin '%s' deinit() failed"),
 
60
                        plugin->name.str);
67
61
        }
68
62
    }
69
63
 
70
 
  if (p) delete p;
71
 
 
72
64
  return 0;
73
65
}
74
66
 
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 *)
77
69
{
78
 
  replicator_t *repl= plugin_data(plugin, replicator_t *);
 
70
  Replicator *repl= plugin_data(plugin, Replicator *);
79
71
  bool error;
80
72
 
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 */
 
74
  if (repl)
83
75
  {
84
76
    error= repl->session_init(session);
85
77
    if (error)
86
78
    {
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));
91
84
      return true;
92
85
    }
93
86
  }
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)
147
140
{
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);
150
143
 
151
144
  switch (params->type) {
152
145
  case repl_insert:
153
 
    if (repl && repl->row_insert)
 
146
    if (repl)
154
147
    {
155
148
      if (repl->row_insert(session, params->table))
156
149
      {
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));
161
155
 
162
156
        return true;
163
157
      }
164
158
    }
165
159
    break;
166
160
  case repl_update:
167
 
    if (repl && repl->row_update)
 
161
    if (repl)
168
162
    {
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))
170
165
      {
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));
175
171
 
176
172
        return true;
177
173
      }
178
174
    }
179
175
    break;
180
176
  case repl_delete:
181
 
    if (repl && repl->row_delete)
 
177
    if (repl)
182
178
    {
183
179
      if (repl->row_delete(session, params->table))
184
180
      {
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));
189
186
 
190
187
        return true;
191
188
      }
195
192
  return false;
196
193
}
197
194
 
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)
201
199
{
202
200
  bool foreach_rv;
203
201
 
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)
261
259
{
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);
264
262
 
265
263
  /* call this loaded replicator plugin's replicator_func1 function pointer */
266
 
  if (repl && repl->end_transaction)
 
264
  if (repl)
267
265
  {
268
266
    if (repl->end_transaction(session, params->autocommit, params->commit))
269
267
    {
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));
274
273
      return true;
275
274
    }
276
275
  }
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)
318
317
{
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;
321
320
 
322
321
  /* call this loaded replicator plugin's replicator_func1 function pointer */
323
 
  if (repl && repl->statement)
 
322
  if (repl)
324
323
  {
325
324
    if (repl->statement(session, params->query, params->query_length))
326
325
    {
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));
331
331
      return true;
332
332
    }
333
333
  }