~linuxjedi/drizzle/usability-cli-port

« back to all changes in this revision

Viewing changes to plugin/replicator/replicator.cc

  • Committer: Brian Aker
  • Date: 2008-12-08 06:44:37 UTC
  • Revision ID: brian@tangent.org-20081208064437-cxc5pfg0vu9f13rd
Partial fix (more of replication flushed out)

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
#include <drizzled/session.h>
19
19
#include <drizzled/error.h>
20
20
#include <drizzled/item/strfunc.h>
 
21
#include <drizzled/plugin_replicator.h>
 
22
 
 
23
static char anchor[100];
 
24
 
 
25
static bool statement(Session *, const char *query, size_t query_length)
 
26
{
 
27
  fprintf(stderr, "STATEMENT: %.*s\n", (uint32_t)query_length, query);
 
28
 
 
29
  return false;
 
30
}
 
31
 
 
32
static bool session_init(Session *session)
 
33
{
 
34
  fprintf(stderr, "Starting Session\n");
 
35
  session->setReplicationData(anchor);
 
36
 
 
37
  return false;
 
38
}
 
39
 
 
40
static bool row_insert(Session *session, Table *)
 
41
{
 
42
  fprintf(stderr, "INSERT: %.*s\n", (uint32_t)session->query_length, session->query);
 
43
 
 
44
  return false;
 
45
}
 
46
 
 
47
static bool row_update(Session *session, Table *, 
 
48
                          const unsigned char *, 
 
49
                          const unsigned char *)
 
50
{
 
51
  fprintf(stderr, "UPDATE: %.*s\n", (uint32_t)session->query_length, session->query);
 
52
 
 
53
  return false;
 
54
}
 
55
 
 
56
static bool row_delete(Session *session, Table *)
 
57
{
 
58
  fprintf(stderr, "DELETE: %.*s\n", (uint32_t)session->query_length, session->query);
 
59
 
 
60
  return false;
 
61
}
 
62
 
 
63
static bool end_transaction(Session *session, bool autocommit, bool commit)
 
64
{
 
65
  if (commit)
 
66
  {
 
67
    if (autocommit)
 
68
      fprintf(stderr, "COMMIT\n");
 
69
    else
 
70
      fprintf(stderr, "AUTOCOMMIT\n");
 
71
  }
 
72
  else
 
73
    fprintf(stderr, "ROLLBACK\n");
 
74
 
 
75
  session->setReplicationData(NULL);
 
76
 
 
77
  return false;
 
78
}
 
79
 
 
80
static int init(void *p)
 
81
{
 
82
  replicator_t *repl = (replicator_t *)p;
 
83
 
 
84
  repl->statement= statement;
 
85
  repl->session_init= session_init;
 
86
  repl->row_insert= row_insert;
 
87
  repl->row_delete= row_delete;
 
88
  repl->row_update= row_update;
 
89
  repl->end_transaction= end_transaction;
 
90
 
 
91
  return 0;
 
92
}
21
93
 
22
94
mysql_declare_plugin(replicator)
23
95
{
27
99
  "Brian Aker",
28
100
  "Basic replication module",
29
101
  PLUGIN_LICENSE_GPL,
30
 
  NULL, /* Plugin Init */
 
102
  init, /* Plugin Init */
31
103
  NULL, /* Plugin Deinit */
32
104
  NULL,   /* status variables */
33
105
  NULL,   /* system variables */