~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/transaction_log/info_schema.cc

  • Committer: Monty Taylor
  • Date: 2010-03-11 18:27:20 UTC
  • mfrom: (1333 staging)
  • mto: This revision was merged to the branch mainline in revision 1348.
  • Revision ID: mordred@inaugust.com-20100311182720-hd1h87y6cb1b1mp0
Merged trunk.

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) 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
 
 * Implements the INFORMATION_SCHEMA views which allows querying the
29
 
 * state of the transaction log and its entries.
30
 
 *
31
 
 * There are three views defined for the transaction log:
32
 
 *
33
 
 * CREATE TABLE INFORMATION_SCHEMA.TRANSACTION_LOG (
34
 
 *   FILE_NAME VARCHAR NOT NULL
35
 
 * , FILE_LENGTH BIGINT NOT NULL
36
 
 * , NUM_LOG_ENTRIES BIGINT NOT NULL
37
 
 * , NUM_TRANSACTIONS BIGINT NOT NULL
38
 
 * , MIN_TRANSACTION_ID BIGINT NOT NULL
39
 
 * , MAX_TRANSACTION_ID BIGINT NOT NULL
40
 
 * , MIN_END_TIMESTAMP BIGINT NOT NULL
41
 
 * , MAX_END_TIMESTAMP BIGINT NOT NULL
42
 
 * );
43
 
 * 
44
 
 * CREATE TABLE INFORMATION_SCHEMA.TRANSACTION_LOG_ENTRIES (
45
 
 *   ENTRY_OFFSET BIGINT NOT NULL
46
 
 * , ENTRY_TYPE VARCHAR NOT NULL
47
 
 * , ENTRY_LENGTH BIGINT NOT NULL
48
 
 * );
49
 
 * 
50
 
 * CREATE TABLE INFORMATION_SCHEMA.TRANSACTION_LOG_TRANSACTIONS (
51
 
 *   ENTRY_OFFSET BIGINT NOT NULL
52
 
 * , TRANSACTION_ID BIGINT NOT NULL
53
 
 * , SERVER_ID INT NOT NULL
54
 
 * , START_TIMESTAMP BIGINT NOT NULL
55
 
 * , END_TIMESTAMP BIGINT NOT NULL
56
 
 * , NUM_STATEMENTS INT NOT NULL
57
 
 * , CHECKSUM BIGINT NOT NULL // had to be BIGINT b/c we have no unsigned int.
58
 
 * );
59
 
 */
60
 
 
61
 
#include "config.h"
62
 
#include <drizzled/session.h>
63
 
#include <drizzled/show.h>
64
 
#include <drizzled/util/functors.h>
65
 
 
66
 
#include "transaction_log.h"
67
 
#include "transaction_log_entry.h"
68
 
#include "transaction_log_index.h"
69
 
#include "info_schema.h"
70
 
 
71
 
#include <fcntl.h>
72
 
#include <sys/stat.h>
73
 
 
74
 
#include <string>
75
 
#include <vector>
76
 
#include <functional>
77
 
 
78
 
using namespace std;
79
 
using namespace drizzled;
80
 
 
81
 
extern TransactionLog *transaction_log; /* the singleton transaction log */
82
 
extern TransactionLogIndex *transaction_log_index; /* the singleton transaction log index */
83
 
 
84
 
/*
85
 
 * Vectors of columns for I_S tables.
86
 
 */
87
 
static vector<const plugin::ColumnInfo *> *transaction_log_view_columns= NULL;
88
 
static vector<const plugin::ColumnInfo *> *transaction_log_entries_view_columns= NULL;
89
 
static vector<const plugin::ColumnInfo *> *transaction_log_transactions_view_columns= NULL;
90
 
 
91
 
/*
92
 
 * Methods for I_S tables.
93
 
 */
94
 
static plugin::InfoSchemaMethods *transaction_log_view_methods= NULL;
95
 
static plugin::InfoSchemaMethods *transaction_log_entries_view_methods= NULL;
96
 
static plugin::InfoSchemaMethods *transaction_log_transactions_view_methods= NULL;
97
 
 
98
 
/*
99
 
 * I_S tables.
100
 
 */
101
 
plugin::InfoSchemaTable *transaction_log_view= NULL;
102
 
plugin::InfoSchemaTable *transaction_log_entries_view= NULL;
103
 
plugin::InfoSchemaTable *transaction_log_transactions_view= NULL;
104
 
 
105
 
static bool createTransactionLogViewColumns(vector<const drizzled::plugin::ColumnInfo *> &cols);
106
 
static bool createTransactionLogEntriesViewColumns(vector<const drizzled::plugin::ColumnInfo *> &cols);
107
 
static bool createTransactionLogTransactionsViewColumns(vector<const drizzled::plugin::ColumnInfo *> &cols);
108
 
 
109
 
int TransactionLogViewISMethods::fillTable(Session *,
110
 
                                           Table *table,
111
 
                                           plugin::InfoSchemaTable *schema_table)
112
 
{
113
 
  if (transaction_log != NULL)
114
 
  {
115
 
    table->restoreRecordAsDefault();
116
 
 
117
 
    table->setWriteSet(0);
118
 
    table->setWriteSet(1);
119
 
    table->setWriteSet(2);
120
 
    table->setWriteSet(3);
121
 
    table->setWriteSet(4);
122
 
    table->setWriteSet(5);
123
 
    table->setWriteSet(6);
124
 
    table->setWriteSet(7);
125
 
 
126
 
    const string &filename= transaction_log->getLogFilename();
127
 
    table->field[0]->store(filename.c_str(), filename.length(), system_charset_info);
128
 
 
129
 
    /* Grab the file size of the log */
130
 
    struct stat file_stat;
131
 
    (void) stat(filename.c_str(), &file_stat);
132
 
 
133
 
    table->field[1]->store(static_cast<int64_t>(file_stat.st_size));
134
 
 
135
 
    table->field[2]->store(static_cast<int64_t>(transaction_log_index->getNumLogEntries()));
136
 
    table->field[3]->store(static_cast<int64_t>(transaction_log_index->getNumTransactionEntries()));
137
 
    table->field[4]->store(static_cast<int64_t>(transaction_log_index->getMinTransactionId()));
138
 
    table->field[5]->store(static_cast<int64_t>(transaction_log_index->getMaxTransactionId()));
139
 
    table->field[6]->store(static_cast<int64_t>(transaction_log_index->getMinEndTimestamp()));
140
 
    table->field[7]->store(static_cast<int64_t>(transaction_log_index->getMaxEndTimestamp()));
141
 
 
142
 
    /* store the actual record now */
143
 
    schema_table->addRow(table->record[0], table->s->reclength);
144
 
  }
145
 
  return 0;
146
 
}
147
 
 
148
 
int TransactionLogEntriesViewISMethods::fillTable(Session *,
149
 
                                                  Table *table,
150
 
                                                  plugin::InfoSchemaTable *schema_table)
151
 
{
152
 
  if (transaction_log != NULL)
153
 
  {
154
 
    /** @todo trigger indexing update here. */
155
 
    for (TransactionLog::Entries::iterator entry_iter= transaction_log_index->getEntries().begin();
156
 
         entry_iter != transaction_log_index->getEntries().end();
157
 
         ++entry_iter)
158
 
    {
159
 
      TransactionLogEntry &entry= *entry_iter;
160
 
 
161
 
      table->restoreRecordAsDefault();
162
 
 
163
 
      table->setWriteSet(0);
164
 
      table->setWriteSet(1);
165
 
      table->setWriteSet(2);
166
 
 
167
 
      table->field[0]->store(static_cast<int64_t>(entry.getOffset()));
168
 
      const char *type_string= entry.getTypeAsString();
169
 
      table->field[1]->store(type_string, strlen(type_string), system_charset_info);
170
 
      table->field[2]->store(static_cast<int64_t>(entry.getLengthInBytes()));
171
 
 
172
 
      /* store the actual record now */
173
 
      schema_table->addRow(table->record[0], table->s->reclength);
174
 
    }
175
 
  }
176
 
  return 0;
177
 
}
178
 
 
179
 
int TransactionLogTransactionsViewISMethods::fillTable(Session *,
180
 
                                                       Table *table,
181
 
                                                       plugin::InfoSchemaTable *schema_table)
182
 
{
183
 
  if (transaction_log != NULL)
184
 
  {
185
 
    /** @todo trigger indexing update here. */
186
 
    for (TransactionLog::TransactionEntries::iterator entry_iter= transaction_log_index->getTransactionEntries().begin();
187
 
         entry_iter != transaction_log_index->getTransactionEntries().end();
188
 
         ++entry_iter)
189
 
    {
190
 
      TransactionLogTransactionEntry &entry= *entry_iter;
191
 
 
192
 
      table->restoreRecordAsDefault();
193
 
 
194
 
      table->setWriteSet(0);
195
 
      table->setWriteSet(1);
196
 
      table->setWriteSet(2);
197
 
      table->setWriteSet(3);
198
 
      table->setWriteSet(4);
199
 
      table->setWriteSet(5);
200
 
      table->setWriteSet(6);
201
 
 
202
 
      table->field[0]->store(static_cast<int64_t>(entry.getOffset()));
203
 
      table->field[1]->store(static_cast<int64_t>(entry.getTransactionId()));
204
 
      table->field[2]->store(static_cast<int64_t>(entry.getServerId()));
205
 
      table->field[3]->store(static_cast<int64_t>(entry.getStartTimestamp()));
206
 
      table->field[4]->store(static_cast<int64_t>(entry.getEndTimestamp()));
207
 
      table->field[5]->store(static_cast<int64_t>(entry.getNumStatements()));
208
 
      table->field[6]->store(static_cast<int64_t>(entry.getChecksum()));
209
 
 
210
 
      /* store the actual record now */
211
 
      schema_table->addRow(table->record[0], table->s->reclength);
212
 
    }
213
 
  }
214
 
  return 0;
215
 
}
216
 
 
217
 
static bool createTransactionLogViewColumns(vector<const plugin::ColumnInfo *> &cols)
218
 
{
219
 
  /*
220
 
   * Create each column for the INFORMATION_SCHEMA.TRANSACTION_LOG view
221
 
   */
222
 
  const plugin::ColumnInfo *file_name_col= 
223
 
    new (nothrow) plugin::ColumnInfo("FILE_NAME",
224
 
                                      255,
225
 
                                      DRIZZLE_TYPE_VARCHAR,
226
 
                                      0,
227
 
                                      0, 
228
 
                                      "Filename of the transaction log");
229
 
  if (file_name_col == NULL)
230
 
  {
231
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to allocate ColumnInfo %s.  Got error: %s\n"), 
232
 
                  "FILE_NAME", 
233
 
                  strerror(errno));
234
 
    return true;
235
 
  }
236
 
 
237
 
  const plugin::ColumnInfo *file_length_col= 
238
 
    new (nothrow) plugin::ColumnInfo("FILE_LENGTH",
239
 
                                      8,
240
 
                                      DRIZZLE_TYPE_LONGLONG,
241
 
                                      0,
242
 
                                      0, 
243
 
                                      "Length in bytes of the transaction log");
244
 
  if (file_length_col == NULL)
245
 
  {
246
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to allocate ColumnInfo %s.  Got error: %s\n"), 
247
 
                  "FILE_LENGTH", 
248
 
                  strerror(errno));
249
 
    return true;
250
 
  }
251
 
 
252
 
  const plugin::ColumnInfo *num_log_entries_col= 
253
 
    new (nothrow) plugin::ColumnInfo("NUM_LOG_ENTRIES",
254
 
                                      8,
255
 
                                      DRIZZLE_TYPE_LONGLONG,
256
 
                                      0,
257
 
                                      0, 
258
 
                                      "Total number of entries in the transaction log");
259
 
  if (num_log_entries_col == NULL)
260
 
  {
261
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to allocate ColumnInfo %s.  Got error: %s\n"), 
262
 
                  "NUM_LOG_ENTRIES", 
263
 
                  strerror(errno));
264
 
    return true;
265
 
  }
266
 
 
267
 
  const plugin::ColumnInfo *num_transactions_col= 
268
 
    new (nothrow) plugin::ColumnInfo("NUM_TRANSACTIONS",
269
 
                                      8,
270
 
                                      DRIZZLE_TYPE_LONGLONG,
271
 
                                      0,
272
 
                                      0, 
273
 
                                      "Total number of transaction message entries in the transaction log");
274
 
  if (num_transactions_col == NULL)
275
 
  {
276
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to allocate ColumnInfo %s.  Got error: %s\n"), 
277
 
                  "NUM_TRANSACTIONS", 
278
 
                  strerror(errno));
279
 
    return true;
280
 
  }
281
 
 
282
 
  const plugin::ColumnInfo *min_transaction_id_col= 
283
 
    new (nothrow) plugin::ColumnInfo("MIN_TRANSACTION_ID",
284
 
                                      8,
285
 
                                      DRIZZLE_TYPE_LONGLONG,
286
 
                                      0,
287
 
                                      0, 
288
 
                                      "Minimum transaction ID in the transaction log");
289
 
  if (min_transaction_id_col == NULL)
290
 
  {
291
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to allocate ColumnInfo %s.  Got error: %s\n"), 
292
 
                  "MIN_TRANSACTION_ID", 
293
 
                  strerror(errno));
294
 
    return true;
295
 
  }
296
 
 
297
 
  const plugin::ColumnInfo *max_transaction_id_col= 
298
 
    new (nothrow) plugin::ColumnInfo("MAX_TRANSACTION_ID",
299
 
                                      8,
300
 
                                      DRIZZLE_TYPE_LONGLONG,
301
 
                                      0,
302
 
                                      0, 
303
 
                                      "Maximum transaction ID in the transaction log");
304
 
  if (max_transaction_id_col == NULL)
305
 
  {
306
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to allocate ColumnInfo %s.  Got error: %s\n"), 
307
 
                  "MAX_TRANSACTION_ID", 
308
 
                  strerror(errno));
309
 
    return true;
310
 
  }
311
 
 
312
 
  const plugin::ColumnInfo *min_timestamp_col= 
313
 
    new (nothrow) plugin::ColumnInfo("MIN_END_TIMESTAMP",
314
 
                                      8,
315
 
                                      DRIZZLE_TYPE_LONGLONG,
316
 
                                      0,
317
 
                                      0, 
318
 
                                      "Minimum end timestamp for a transaction in the transaction log");
319
 
  if (min_timestamp_col == NULL)
320
 
  {
321
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to allocate ColumnInfo %s.  Got error: %s\n"), 
322
 
                  "MIN_END_TIMESTAMP", 
323
 
                  strerror(errno));
324
 
    return true;
325
 
  }
326
 
 
327
 
  const plugin::ColumnInfo *max_timestamp_col= 
328
 
    new (nothrow) plugin::ColumnInfo("MAX_END_TIMESTAMP",
329
 
                                      8,
330
 
                                      DRIZZLE_TYPE_LONGLONG,
331
 
                                      0,
332
 
                                      0, 
333
 
                                      "Maximum end timestamp for a transaction in the transaction log");
334
 
  if (max_timestamp_col == NULL)
335
 
  {
336
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to allocate ColumnInfo %s.  Got error: %s\n"), 
337
 
                  "MAX_END_TIMESTAMP", 
338
 
                  strerror(errno));
339
 
    return true;
340
 
  }
341
 
 
342
 
  cols.push_back(file_name_col);
343
 
  cols.push_back(file_length_col);
344
 
  cols.push_back(num_log_entries_col);
345
 
  cols.push_back(num_transactions_col);
346
 
  cols.push_back(min_transaction_id_col);
347
 
  cols.push_back(max_transaction_id_col);
348
 
  cols.push_back(min_timestamp_col);
349
 
  cols.push_back(max_timestamp_col);
350
 
 
351
 
  return false;
352
 
}
353
 
 
354
 
static bool createTransactionLogEntriesViewColumns(vector<const plugin::ColumnInfo *> &cols)
355
 
{
356
 
  /*
357
 
   * Create each column for the INFORMATION_SCHEMA.TRANSACTION_LOG_ENTRIES view
358
 
   */
359
 
  const plugin::ColumnInfo *entry_offset_col= 
360
 
    new (nothrow) plugin::ColumnInfo("ENTRY_OFFSET",
361
 
                                      8,
362
 
                                      DRIZZLE_TYPE_LONGLONG,
363
 
                                      0,
364
 
                                      0, 
365
 
                                      "Offset of this entry into the transaction log");
366
 
  if (entry_offset_col == NULL)
367
 
  {
368
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to allocate ColumnInfo %s.  Got error: %s\n"), 
369
 
                  "ENTRY_OFFSET", 
370
 
                  strerror(errno));
371
 
    return true;
372
 
  }
373
 
 
374
 
  const plugin::ColumnInfo *entry_type_col= 
375
 
    new (nothrow) plugin::ColumnInfo("ENTRY_TYPE",
376
 
                                      32,
377
 
                                      DRIZZLE_TYPE_VARCHAR,
378
 
                                      0,
379
 
                                      0, 
380
 
                                      "Type of this entry");
381
 
  if (entry_type_col == NULL)
382
 
  {
383
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to allocate ColumnInfo %s.  Got error: %s\n"), 
384
 
                  "ENTRY_TYPE", 
385
 
                  strerror(errno));
386
 
    return true;
387
 
  }
388
 
 
389
 
  const plugin::ColumnInfo *entry_length_col= 
390
 
    new (nothrow) plugin::ColumnInfo("ENTRY_LENGTH",
391
 
                                      8,
392
 
                                      DRIZZLE_TYPE_LONGLONG,
393
 
                                      0,
394
 
                                      0, 
395
 
                                      "Length in bytes of this entry");
396
 
  if (entry_length_col == NULL)
397
 
  {
398
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to allocate ColumnInfo %s.  Got error: %s\n"), 
399
 
                  "ENTRY_LENGTH", 
400
 
                  strerror(errno));
401
 
    return true;
402
 
  }
403
 
 
404
 
  cols.push_back(entry_offset_col);
405
 
  cols.push_back(entry_type_col);
406
 
  cols.push_back(entry_length_col);
407
 
 
408
 
  return false;
409
 
}
410
 
 
411
 
static bool createTransactionLogTransactionsViewColumns(vector<const plugin::ColumnInfo *> &cols)
412
 
{
413
 
  /*
414
 
   * Create each column for the INFORMATION_SCHEMA.TRANSACTION_LOG_TRANSACTIONS view
415
 
   */
416
 
  const plugin::ColumnInfo *entry_offset_col= 
417
 
    new (nothrow) plugin::ColumnInfo("ENTRY_OFFSET",
418
 
                                      8,
419
 
                                      DRIZZLE_TYPE_LONGLONG,
420
 
                                      0,
421
 
                                      0, 
422
 
                                      "Offset of this entry into the transaction log");
423
 
  if (entry_offset_col == NULL)
424
 
  {
425
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to allocate ColumnInfo %s.  Got error: %s\n"), 
426
 
                  "ENTRY_OFFSET", 
427
 
                  strerror(errno));
428
 
    return true;
429
 
  }
430
 
 
431
 
  const plugin::ColumnInfo *transaction_id_col= 
432
 
    new (nothrow) plugin::ColumnInfo("TRANSACTION_ID",
433
 
                                      8,
434
 
                                      DRIZZLE_TYPE_LONGLONG,
435
 
                                      0,
436
 
                                      0, 
437
 
                                      "Transaction ID for this entry");
438
 
  if (transaction_id_col == NULL)
439
 
  {
440
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to allocate ColumnInfo %s.  Got error: %s\n"), 
441
 
                  "TRANSACTION_ID", 
442
 
                  strerror(errno));
443
 
    return true;
444
 
  }
445
 
 
446
 
  const plugin::ColumnInfo *server_id_col= 
447
 
    new (nothrow) plugin::ColumnInfo("SERVER_ID",
448
 
                                      8,
449
 
                                      DRIZZLE_TYPE_LONGLONG,
450
 
                                      0,
451
 
                                      0, 
452
 
                                      "Server ID for this entry");
453
 
  if (server_id_col == NULL)
454
 
  {
455
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to allocate ColumnInfo %s.  Got error: %s\n"), 
456
 
                  "SERVER_ID", 
457
 
                  strerror(errno));
458
 
    return true;
459
 
  }
460
 
 
461
 
  const plugin::ColumnInfo *start_timestamp_col= 
462
 
    new (nothrow) plugin::ColumnInfo("START_TIMESTAMP",
463
 
                                      8,
464
 
                                      DRIZZLE_TYPE_LONGLONG,
465
 
                                      0,
466
 
                                      0, 
467
 
                                      "Start timestamp for this transaction");
468
 
  if (start_timestamp_col == NULL)
469
 
  {
470
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to allocate ColumnInfo %s.  Got error: %s\n"), 
471
 
                  "START_TIMESTAMP", 
472
 
                  strerror(errno));
473
 
    return true;
474
 
  }
475
 
 
476
 
  const plugin::ColumnInfo *end_timestamp_col= 
477
 
    new (nothrow) plugin::ColumnInfo("END_TIMESTAMP",
478
 
                                      8,
479
 
                                      DRIZZLE_TYPE_LONGLONG,
480
 
                                      0,
481
 
                                      0, 
482
 
                                      "End timestamp for this transaction");
483
 
  if (end_timestamp_col == NULL)
484
 
  {
485
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to allocate ColumnInfo %s.  Got error: %s\n"), 
486
 
                  "END_TIMESTAMP", 
487
 
                  strerror(errno));
488
 
    return true;
489
 
  }
490
 
 
491
 
  const plugin::ColumnInfo *num_statements_col= 
492
 
    new (nothrow) plugin::ColumnInfo("NUM_STATEMENTS",
493
 
                                      8,
494
 
                                      DRIZZLE_TYPE_LONGLONG,
495
 
                                      0,
496
 
                                      0, 
497
 
                                      "Number of statements in this transaction");
498
 
  if (num_statements_col == NULL)
499
 
  {
500
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to allocate ColumnInfo %s.  Got error: %s\n"), 
501
 
                  "NUM_STATEMENTS", 
502
 
                  strerror(errno));
503
 
    return true;
504
 
  }
505
 
 
506
 
  const plugin::ColumnInfo *checksum_col= 
507
 
    new (nothrow) plugin::ColumnInfo("CHECKSUM",
508
 
                                      8,
509
 
                                      DRIZZLE_TYPE_LONGLONG,
510
 
                                      0,
511
 
                                      0, 
512
 
                                      "Checksum of this transaction");
513
 
  if (checksum_col == NULL)
514
 
  {
515
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to allocate ColumnInfo %s.  Got error: %s\n"), 
516
 
                  "CHECKSUM", 
517
 
                  strerror(errno));
518
 
    return true;
519
 
  }
520
 
 
521
 
  cols.push_back(entry_offset_col);
522
 
  cols.push_back(transaction_id_col);
523
 
  cols.push_back(server_id_col);
524
 
  cols.push_back(start_timestamp_col);
525
 
  cols.push_back(end_timestamp_col);
526
 
  cols.push_back(num_statements_col);
527
 
  cols.push_back(checksum_col);
528
 
 
529
 
  return false;
530
 
}
531
 
 
532
 
bool initViewColumns()
533
 
{
534
 
  transaction_log_view_columns= new (nothrow) vector<const plugin::ColumnInfo *>;
535
 
  if (transaction_log_view_columns == NULL)
536
 
  {
537
 
    return true;
538
 
  }
539
 
  transaction_log_entries_view_columns= new (nothrow) vector<const plugin::ColumnInfo *>;
540
 
  if (transaction_log_entries_view_columns == NULL)
541
 
  {
542
 
    return true;
543
 
  }
544
 
  transaction_log_transactions_view_columns= new (nothrow) vector<const plugin::ColumnInfo *>;
545
 
  if (transaction_log_transactions_view_columns == NULL)
546
 
  {
547
 
    return true;
548
 
  }
549
 
 
550
 
  if (createTransactionLogViewColumns(*transaction_log_view_columns))
551
 
  {
552
 
    return true;
553
 
  }
554
 
 
555
 
  if (createTransactionLogEntriesViewColumns(*transaction_log_entries_view_columns))
556
 
  {
557
 
    return true;
558
 
  }
559
 
 
560
 
  if (createTransactionLogTransactionsViewColumns(*transaction_log_transactions_view_columns))
561
 
  {
562
 
    return true;
563
 
  }
564
 
 
565
 
  return false;
566
 
}
567
 
 
568
 
static void clearViewColumns(vector<const plugin::ColumnInfo *> &cols)
569
 
{
570
 
  for_each(cols.begin(), cols.end(), DeletePtr());
571
 
  cols.clear();
572
 
}
573
 
 
574
 
void cleanupViewColumns()
575
 
{
576
 
  clearViewColumns(*transaction_log_view_columns);
577
 
  delete transaction_log_view_columns;
578
 
  clearViewColumns(*transaction_log_entries_view_columns);
579
 
  delete transaction_log_entries_view_columns;
580
 
  clearViewColumns(*transaction_log_transactions_view_columns);
581
 
  delete transaction_log_transactions_view_columns;
582
 
}
583
 
 
584
 
bool initViewMethods()
585
 
{
586
 
  transaction_log_view_methods= new (nothrow) TransactionLogViewISMethods();
587
 
  if (transaction_log_view_methods == NULL)
588
 
  {
589
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to allocate TransactionLogViewISMethods.  Got error: %s\n"), 
590
 
                  strerror(errno));
591
 
    return true;
592
 
  }
593
 
 
594
 
  transaction_log_entries_view_methods= new (nothrow) TransactionLogEntriesViewISMethods();
595
 
  if (transaction_log_entries_view_methods == NULL)
596
 
  {
597
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to allocate TransactionLogEntriesViewISMethods.  Got error: %s\n"), 
598
 
                  strerror(errno));
599
 
    return true;
600
 
  }
601
 
 
602
 
  transaction_log_transactions_view_methods= new (nothrow) TransactionLogTransactionsViewISMethods();
603
 
  if (transaction_log_transactions_view_methods == NULL)
604
 
  {
605
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to allocate TransactionLogTransactionsViewISMethods.  Got error: %s\n"), 
606
 
                  strerror(errno));
607
 
    return true;
608
 
  }
609
 
 
610
 
  return false;
611
 
}
612
 
 
613
 
void cleanupViewMethods()
614
 
{
615
 
  delete transaction_log_view_methods;
616
 
  delete transaction_log_entries_view_methods;
617
 
  delete transaction_log_transactions_view_methods;
618
 
}
619
 
 
620
 
bool initViews()
621
 
{
622
 
  transaction_log_view= 
623
 
    new (nothrow) plugin::InfoSchemaTable("TRANSACTION_LOG",
624
 
                                          *transaction_log_view_columns,
625
 
                                          -1, -1, false, false, 0,
626
 
                                          transaction_log_view_methods);
627
 
  if (transaction_log_view == NULL)
628
 
  {
629
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to allocate InfoSchemaTable for %s.  Got error: %s\n"), 
630
 
                  "TRANSACTION_LOG",
631
 
                  strerror(errno));
632
 
    return true;
633
 
  }
634
 
 
635
 
  transaction_log_entries_view= 
636
 
    new (nothrow) plugin::InfoSchemaTable("TRANSACTION_LOG_ENTRIES",
637
 
                                          *transaction_log_entries_view_columns,
638
 
                                          -1, -1, false, false, 0,
639
 
                                          transaction_log_entries_view_methods);
640
 
  if (transaction_log_entries_view == NULL)
641
 
  {
642
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to allocate InfoSchemaTable for %s.  Got error: %s\n"), 
643
 
                  "TRANSACTION_LOG_ENTRIES",
644
 
                  strerror(errno));
645
 
    return true;
646
 
  }
647
 
 
648
 
  transaction_log_transactions_view= 
649
 
    new (nothrow) plugin::InfoSchemaTable("TRANSACTION_LOG_TRANSACTIONS",
650
 
                                          *transaction_log_transactions_view_columns,
651
 
                                          -1, -1, false, false, 0,
652
 
                                          transaction_log_transactions_view_methods);
653
 
  if (transaction_log_transactions_view == NULL)
654
 
  {
655
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to allocate InfoSchemaTable for %s.  Got error: %s\n"), 
656
 
                  "TRANSACTION_LOG_TRANSACTIONS",
657
 
                  strerror(errno));
658
 
    return true;
659
 
  }
660
 
 
661
 
  return false;
662
 
}
663
 
 
664
 
void cleanupViews()
665
 
{
666
 
  delete transaction_log_view;
667
 
  delete transaction_log_entries_view;
668
 
  delete transaction_log_transactions_view;
669
 
}