~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2009-01-18 01:49:40 UTC
  • Revision ID: brian@gir-3.local-20090118014940-co9651fk7hla6gqg
Removed unused session param from list_open_tables()

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
 
extern "C" {
27
 
#include "univ.i"
28
 
#include "btr0sea.h"
29
 
#include "os0file.h"
30
 
#include "os0thread.h"
31
 
#include "srv0start.h"
32
 
#include "srv0srv.h"
33
 
#include "trx0roll.h"
34
 
#include "trx0trx.h"
35
 
#include "trx0sys.h"
36
 
#include "mtr0mtr.h"
37
 
#include "row0ins.h"
38
 
#include "row0mysql.h"
39
 
#include "row0sel.h"
40
 
#include "row0upd.h"
41
 
#include "log0log.h"
42
 
#include "lock0lock.h"
43
 
#include "dict0crea.h"
44
 
#include "btr0cur.h"
45
 
#include "btr0btr.h"
46
 
#include "fsp0fsp.h"
47
 
#include "sync0sync.h"
48
 
#include "fil0fil.h"
49
 
#include "trx0xa.h"
50
 
#include "row0merge.h"
51
 
#include "thr0loc.h"
52
 
#include "dict0boot.h"
53
 
#include "ha_prototypes.h"
54
 
#include "ut0mem.h"
55
 
#include "ibuf0ibuf.h"
56
 
#include "mysql_addons.h"
57
 
#include "create_replication.h"
58
 
#include "read_replication.h"
59
 
}
60
 
#include "handler0vars.h"
61
 
 
62
 
#include "drizzled/replication_services.h"
63
 
 
64
 
#include <google/protobuf/io/zero_copy_stream.h>
65
 
#include <google/protobuf/io/zero_copy_stream_impl.h>
66
 
#include <google/protobuf/io/coded_stream.h>
67
 
#include <google/protobuf/text_format.h>
68
 
#include <string>
69
 
 
70
 
using namespace drizzled;
71
 
 
72
 
/*
73
 
 * Fill the dynamic table data_dictionary.INNODB_CMP and INNODB_CMP_RESET
74
 
 *
75
 
 */
76
 
InnodbReplicationTable::InnodbReplicationTable() :
77
 
  plugin::TableFunction("DATA_DICTIONARY", "INNODB_REPLICATION_LOG")
78
 
{
79
 
  add_field("TRANSACTION_ID", plugin::TableFunction::NUMBER, 0, false);
80
 
  add_field("TRANSACTION_MESSAGE_STRING", plugin::TableFunction::STRING, 2048, false);
81
 
  add_field("TRANSACTION_MESSAGE_BINARY", plugin::TableFunction::VARBINARY, 2048, false);
82
 
  add_field("TRANSACTION_LENGTH", plugin::TableFunction::NUMBER, 0, false);
83
 
}
84
 
 
85
 
InnodbReplicationTable::Generator::Generator(Field **arg) :
86
 
  plugin::TableFunction::Generator(arg)
87
 
{
88
 
  replication_state =replication_read_init();
89
 
}
90
 
 
91
 
InnodbReplicationTable::Generator::~Generator()
92
 
{
93
 
  replication_read_deinit(replication_state);
94
 
}
95
 
 
96
 
bool InnodbReplicationTable::Generator::populate()
97
 
{
98
 
  struct read_replication_return_st ret= replication_read_next(replication_state);
99
 
 
100
 
  if (ret.message == NULL)
101
 
    return false;
102
 
 
103
 
  /* TABLE_NAME */
104
 
  push(static_cast<int64_t>(ret.id));
105
 
 
106
 
  /* Message in viewable format */
107
 
  bool result= message.ParseFromArray(ret.message, ret.message_length);
108
 
 
109
 
  if (result == false)
110
 
  {
111
 
    fprintf(stderr, _("Unable to parse transaction. Got error: %s.\n"), message.InitializationErrorString().c_str());
112
 
    push("error");
113
 
    push("error");
114
 
  }
115
 
  else
116
 
  {
117
 
    google::protobuf::TextFormat::PrintToString(message, &transaction_text);
118
 
    push(transaction_text);
119
 
    push(ret.message, ret.message_length);
120
 
  }
121
 
 
122
 
  push(static_cast<int64_t>(ret.message_length));
123
 
 
124
 
  return true;
125
 
}