~jaypipes/drizzle/replication-to-transaction

« back to all changes in this revision

Viewing changes to plugin/schema_dictionary/show_temporary_tables.cc

  • Committer: Brian Aker
  • Date: 2010-03-09 22:58:27 UTC
  • mfrom: (1320.1.18 build)
  • Revision ID: brian@gaz-20100309225827-7igxztca4lrj3fx3
Merge in show status work.

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 "plugin/schema_dictionary/dictionary.h"
 
24
 
 
25
using namespace std;
 
26
using namespace drizzled;
 
27
 
 
28
ShowTemporaryTables::ShowTemporaryTables() :
 
29
  drizzled::plugin::TableFunction("DATA_DICTIONARY", "SHOW_TEMPORARY_TABLES")
 
30
{
 
31
  add_field("TABLE_SCHEMA");
 
32
  add_field("TABLE_NAME");
 
33
  add_field("RECORDS", plugin::TableFunction::NUMBER);
 
34
  add_field("RECORD_LENGTH", plugin::TableFunction::NUMBER);
 
35
  add_field("ENGINE");
 
36
}
 
37
 
 
38
ShowTemporaryTables::Generator::Generator(Field **arg) :
 
39
  plugin::TableFunction::Generator(arg)
 
40
{
 
41
  session= current_session;
 
42
  table= session->temporary_tables;
 
43
}
 
44
 
 
45
bool ShowTemporaryTables::Generator::populate()
 
46
{
 
47
  if (not table)
 
48
    return false;
 
49
 
 
50
  fill();
 
51
 
 
52
  table= table->next;
 
53
 
 
54
  return true;
 
55
}
 
56
 
 
57
void ShowTemporaryTables::Generator::fill()
 
58
{
 
59
  /* TABLE_SCHEMA */
 
60
  push(table->s->db.str);
 
61
 
 
62
  /* TABLE_NAME */
 
63
  push(table->s->table_name.str);
 
64
 
 
65
  /* RECORDS */
 
66
  push(static_cast<uint64_t>(table->getCursor().records()));
 
67
 
 
68
  /* RECORD_LENGTH */
 
69
  push(static_cast<uint64_t>(table->getRecordLength()));
 
70
 
 
71
  /* ENGINE */
 
72
  push(table->getEngine()->getName());
 
73
}