~drizzle-trunk/drizzle/development

1143.3.4 by Jay Pipes
Adds INFORMATION_SCHEMA views for the transaction log:
1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
4
 *  Copyright (C) 2008-2009 Sun Microsystems
5
 *
6
 *  Authors:
7
 *
8
 *  Jay Pipes <joinfu@sun.com>
9
 *
10
 *  This program is free software; you can redistribute it and/or modify
11
 *  it under the terms of the GNU General Public License as published by
12
 *  the Free Software Foundation; either version 2 of the License, or
13
 *  (at your option) any later version.
14
 *
15
 *  This program is distributed in the hope that it will be useful,
16
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 *  GNU General Public License for more details.
19
 *
20
 *  You should have received a copy of the GNU General Public License
21
 *  along with this program; if not, write to the Free Software
22
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
23
 */
24
25
/**
26
 * @file
27
 *
28
 * Defines a simple structure representing a transaction log entry.
29
 */
30
31
#ifndef PLUGIN_TRANSACTION_LOG_TRANSACTION_LOG_ENTRY_H
32
#define PLUGIN_TRANSACTION_LOG_TRANSACTION_LOG_ENTRY_H
33
34
#include <drizzled/replication_services.h>
35
36
#include <string>
37
38
/**
39
 * Represents a single entry in the transaction log.
40
 */
41
class TransactionLogEntry
42
{
43
public:
44
  TransactionLogEntry(drizzled::ReplicationServices::MessageType in_type,
45
                      off_t in_offset,
46
                      size_t length);
47
  ~TransactionLogEntry();
48
  /**
49
   * Returns a string representation of the entry type
50
   */
51
  const char *getTypeAsString() const;
52
  /**
53
   * Returns the entry's offset in the log
54
   */
55
  off_t getOffset() const;
56
  /**
57
   * Returns the length of the entry in bytes
58
   */
59
  size_t getLengthInBytes() const;
60
private:
61
  enum drizzled::ReplicationServices::MessageType type; ///< The type of the entry
62
  off_t offset; ///< Offset into the log file
63
  size_t length; ///< Length in bytes of the entry
64
};
65
66
class TransactionLogTransactionEntry
67
{
68
public:
69
  TransactionLogTransactionEntry(off_t in_offset,
70
                                 const drizzled::message::Transaction &transaction,
71
                                 uint32_t in_checksum);
72
  ~TransactionLogTransactionEntry();
73
  /**
74
   * Returns the entry's offset in the log
75
   */
76
  off_t getOffset() const;
77
  /**
78
   * Returns the transaction's server ID
79
   */
80
  uint32_t getServerId() const;
81
  /**
82
   * Returns the transaction's start timestamp
83
   */
84
  uint64_t getStartTimestamp() const;
85
  /**
86
   * Returns the transaction's end timestamp
87
   */
88
  uint64_t getEndTimestamp() const;
89
  /**
90
   * Returns the transaction's ID
91
   */
92
  uint64_t getTransactionId() const;
93
  /**
94
   * Returns the number of statements in the transaction
95
   */
96
  uint64_t getNumStatements() const;
97
  /**
98
   * Returns the checksum for the transaction message bytes
99
   */
100
  uint32_t getChecksum() const;
101
private:
102
  off_t offset; ///< Offset into the log file
103
  uint32_t server_id; ///< The server ID that this transaction came from
104
  uint64_t transaction_id; ///< The transaction's ID
105
  uint64_t start_timestamp; ///< The transaction's start timestamp
106
  uint64_t end_timestamp; ///< The transaction's end timestamp
107
  uint32_t num_statements; ///< Number of Statements in the transaction
108
  uint32_t checksum; ///< Checksum of the transaction message bytes
109
};
110
111
#endif /* PLUGIN_TRANSACTION_LOG_TRANSACTION_LOG_ENTRY_H */