~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/info_schema/info_schema_columns.cc

  • Committer: Padraig O'Sullivan
  • Date: 2009-06-21 16:34:23 UTC
  • mto: (1076.2.5 info-schema-plugin)
  • mto: This revision was merged to the branch mainline in revision 1073.
  • Revision ID: osullivan.padraig@gmail.com-20090621163423-uwoismn576czwm6h
Modularized the info schema plugin. Have a separate file which contains
methods for each I_S table and a separate file for creating the columns for
each I_S table. Also, added a constructor to the InfoSchemaTable class for
taking a std::vector of columns as a parameter.

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
 *  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
/**
 
22
 * @file
 
23
 *   Contains methods for creating the various columns for 
 
24
 *   each I_S table.
 
25
 */
 
26
 
 
27
#include <drizzled/server_includes.h>
 
28
#include <drizzled/session.h>
 
29
#include <drizzled/show.h>
 
30
 
 
31
#include "info_schema_columns.h"
 
32
 
 
33
#define LIST_PROCESS_HOST_LEN 64
 
34
 
 
35
using namespace std;
 
36
 
 
37
void createProcessListColumns(vector<const ColumnInfo *>& cols)
 
38
{
 
39
  const ColumnInfo *id_col= new ColumnInfo("ID", 
 
40
                                           4,
 
41
                                           DRIZZLE_TYPE_LONGLONG,
 
42
                                           0,
 
43
                                           0,
 
44
                                           "Id",
 
45
                                           SKIP_OPEN_TABLE);
 
46
  const ColumnInfo *user_col= new ColumnInfo("USER",
 
47
                                             16,
 
48
                                             DRIZZLE_TYPE_VARCHAR,
 
49
                                             0,
 
50
                                             0,
 
51
                                             "User",
 
52
                                             SKIP_OPEN_TABLE);
 
53
  const ColumnInfo *host_col= new ColumnInfo("HOST",
 
54
                                             LIST_PROCESS_HOST_LEN,
 
55
                                             DRIZZLE_TYPE_VARCHAR,
 
56
                                             0,
 
57
                                             0,
 
58
                                             "Host",
 
59
                                             SKIP_OPEN_TABLE);
 
60
  const ColumnInfo *db_col= new ColumnInfo("DB",
 
61
                                           NAME_CHAR_LEN,
 
62
                                           DRIZZLE_TYPE_VARCHAR,
 
63
                                           0,
 
64
                                           1,
 
65
                                           "Db",
 
66
                                           SKIP_OPEN_TABLE);
 
67
  const ColumnInfo *command_col= new ColumnInfo("COMMAND",
 
68
                                                16,
 
69
                                                DRIZZLE_TYPE_VARCHAR,
 
70
                                                0,
 
71
                                                0,
 
72
                                                "Command",
 
73
                                                SKIP_OPEN_TABLE);
 
74
  const ColumnInfo *time_col= new ColumnInfo("TIME",
 
75
                                             7,
 
76
                                             DRIZZLE_TYPE_LONGLONG,
 
77
                                             0,
 
78
                                             0,
 
79
                                             "Time",
 
80
                                             SKIP_OPEN_TABLE);
 
81
  const ColumnInfo *state_col= new ColumnInfo("STATE",
 
82
                                              64,
 
83
                                              DRIZZLE_TYPE_VARCHAR,
 
84
                                              0,
 
85
                                              1,
 
86
                                              "State",
 
87
                                              SKIP_OPEN_TABLE);
 
88
  const ColumnInfo *info_col= new ColumnInfo("INFO",
 
89
                                             PROCESS_LIST_INFO_WIDTH,
 
90
                                             DRIZZLE_TYPE_VARCHAR,
 
91
                                             0,
 
92
                                             1,
 
93
                                             "Info",
 
94
                                             SKIP_OPEN_TABLE);
 
95
 
 
96
  cols.push_back(id_col);
 
97
  cols.push_back(user_col);
 
98
  cols.push_back(host_col);
 
99
  cols.push_back(db_col);
 
100
  cols.push_back(command_col);
 
101
  cols.push_back(time_col);
 
102
  cols.push_back(state_col);
 
103
  cols.push_back(info_col);
 
104
}
 
105
 
 
106
void clearColumns(vector<const ColumnInfo *>& cols)
 
107
{
 
108
  vector<const ColumnInfo *>::iterator iter= cols.begin();
 
109
 
 
110
  while (iter != cols.end())
 
111
  {
 
112
    delete (*iter);
 
113
    ++iter;
 
114
  }
 
115
 
 
116
  cols.clear();
 
117
}