~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/handler/replication_dictionary.cc

  • Committer: Daniel Nichter
  • Date: 2011-10-23 16:01:37 UTC
  • mto: This revision was merged to the branch mainline in revision 2448.
  • Revision ID: daniel@percona.com-20111023160137-7ac3blgz8z4tf8za
Add Administration Getting Started and Logging.  Capitalize SQL clause keywords.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright (C) 2010 Brian Aker
 
5
 *
 
6
 *  This program is free software; you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation; either version 2 of the License, or
 
9
 *  (at your option) any later version.
 
10
 *
 
11
 *  This program is distributed in the hope that it will be useful,
 
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 *  GNU General Public License for more details.
 
15
 *
 
16
 *  You should have received a copy of the GNU General Public License
 
17
 *  along with this program; if not, write to the Free Software
 
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
19
 */
 
20
 
 
21
#include <config.h>
 
22
 
 
23
#include "replication_dictionary.h"
 
24
#include <drizzled/current_session.h>
 
25
 
 
26
#include "univ.i"
 
27
#include "btr0sea.h"
 
28
#include "os0file.h"
 
29
#include "os0thread.h"
 
30
#include "srv0start.h"
 
31
#include "srv0srv.h"
 
32
#include "trx0roll.h"
 
33
#include "trx0trx.h"
 
34
#include "trx0sys.h"
 
35
#include "mtr0mtr.h"
 
36
#include "row0ins.h"
 
37
#include "row0mysql.h"
 
38
#include "row0sel.h"
 
39
#include "row0upd.h"
 
40
#include "log0log.h"
 
41
#include "lock0lock.h"
 
42
#include "dict0crea.h"
 
43
#include "btr0cur.h"
 
44
#include "btr0btr.h"
 
45
#include "fsp0fsp.h"
 
46
#include "sync0sync.h"
 
47
#include "fil0fil.h"
 
48
#include "trx0xa.h"
 
49
#include "row0merge.h"
 
50
#include "thr0loc.h"
 
51
#include "dict0boot.h"
 
52
#include "ha_prototypes.h"
 
53
#include "ut0mem.h"
 
54
#include "ibuf0ibuf.h"
 
55
#include "create_replication.h"
 
56
#include "read_replication.h"
 
57
#include "handler0vars.h"
 
58
 
 
59
#include <drizzled/drizzled.h>
 
60
 
 
61
#include <drizzled/replication_services.h>
 
62
 
 
63
#include <google/protobuf/io/zero_copy_stream.h>
 
64
#include <google/protobuf/io/zero_copy_stream_impl.h>
 
65
#include <google/protobuf/io/coded_stream.h>
 
66
#include <google/protobuf/text_format.h>
 
67
#include <string>
 
68
 
 
69
using namespace drizzled;
 
70
 
 
71
/*
 
72
 * Fill the dynamic table data_dictionary.INNODB_CMP and INNODB_CMP_RESET
 
73
 *
 
74
 */
 
75
InnodbReplicationTable::InnodbReplicationTable() :
 
76
  plugin::TableFunction("DATA_DICTIONARY", "INNODB_REPLICATION_LOG")
 
77
{
 
78
  add_field("TRANSACTION_ID", plugin::TableFunction::NUMBER, 0, false);
 
79
  add_field("TRANSACTION_SEGMENT_ID", plugin::TableFunction::NUMBER, 0, false);
 
80
  add_field("COMMIT_ID", plugin::TableFunction::NUMBER, 0, false);
 
81
  add_field("END_TIMESTAMP", plugin::TableFunction::NUMBER, 0, false);
 
82
  add_field("ORIGINATING_SERVER_UUID", plugin::TableFunction::STRING, 36, false);
 
83
  add_field("ORIGINATING_COMMIT_ID", plugin::TableFunction::NUMBER, 0, false);
 
84
  add_field("TRANSACTION_MESSAGE_STRING", plugin::TableFunction::STRING, transaction_message_threshold, false);
 
85
  add_field("TRANSACTION_LENGTH", plugin::TableFunction::NUMBER, 0, false);
 
86
}
 
87
 
 
88
InnodbReplicationTable::Generator::Generator(Field **arg) :
 
89
  plugin::TableFunction::Generator(arg)
 
90
{
 
91
  replication_state =replication_read_init();
 
92
}
 
93
 
 
94
InnodbReplicationTable::Generator::~Generator()
 
95
{
 
96
  replication_read_deinit(replication_state);
 
97
}
 
98
 
 
99
bool InnodbReplicationTable::Generator::populate()
 
100
{
 
101
  struct read_replication_return_st ret= replication_read_next(replication_state);
 
102
 
 
103
  if (ret.message == NULL)
 
104
    return false;
 
105
 
 
106
  /* Transaction ID */
 
107
  push(static_cast<uint64_t>(ret.id));
 
108
 
 
109
  /* Segment ID */
 
110
  push(static_cast<uint64_t>(ret.seg_id));
 
111
 
 
112
  push(static_cast<uint64_t>(ret.commit_id));
 
113
 
 
114
  push(static_cast<uint64_t>(ret.end_timestamp));
 
115
 
 
116
  push(ret.originating_server_uuid);
 
117
 
 
118
  push(static_cast<uint64_t>(ret.originating_commit_id));
 
119
  
 
120
  /* Message in viewable format */
 
121
  bool result= message.ParseFromArray(ret.message, ret.message_length);
 
122
 
 
123
  if (result == false)
 
124
  {
 
125
    fprintf(stderr, _("Unable to parse transaction. Got error: %s.\n"), message.InitializationErrorString().c_str());
 
126
    push("error");
 
127
  }
 
128
  else
 
129
  {
 
130
    google::protobuf::TextFormat::PrintToString(message, &transaction_text);
 
131
    push(transaction_text);
 
132
  }
 
133
 
 
134
  push(static_cast<int64_t>(ret.message_length));
 
135
 
 
136
  return true;
 
137
}