1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2009 Sun Microsystems
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.
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.
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
23
* Contains methods for creating the various columns for
27
#include <drizzled/server_includes.h>
28
#include <drizzled/session.h>
29
#include <drizzled/show.h>
31
#include "info_schema_columns.h"
33
#define LIST_PROCESS_HOST_LEN 64
37
bool createCharSetColumns(vector<const ColumnInfo *>& cols)
40
* Create each column for the CHARACTER_SET table.
42
const ColumnInfo *name_col= new(std::nothrow) ColumnInfo("CHARACTER_SET_NAME",
54
const ColumnInfo *collate_col= new(std::nothrow) ColumnInfo("DEFAULT_COLLATE_NAME",
61
if (collate_col == NULL)
66
const ColumnInfo *descrip_col= new(std::nothrow) ColumnInfo("DESCRIPTION",
73
if (descrip_col == NULL)
78
const ColumnInfo *len_col= new(std::nothrow) ColumnInfo("MAXLEN",
80
DRIZZLE_TYPE_LONGLONG,
91
* Add the columns to the vector.
93
cols.push_back(name_col);
94
cols.push_back(collate_col);
95
cols.push_back(descrip_col);
96
cols.push_back(len_col);
101
bool createCollationColumns(vector<const ColumnInfo *>& cols)
104
* Create each column for the COLLATION table.
106
const ColumnInfo *name_col= new(std::nothrow) ColumnInfo("COLLATION_NAME",
108
DRIZZLE_TYPE_VARCHAR,
113
if (name_col == NULL)
118
const ColumnInfo *char_set_col= new(std::nothrow) ColumnInfo("CHARACTER_SET_NAME",
120
DRIZZLE_TYPE_VARCHAR,
125
if (char_set_col == NULL)
130
const ColumnInfo *descrip_col= new(std::nothrow) ColumnInfo("DESCRIPTION",
132
DRIZZLE_TYPE_VARCHAR,
137
if (descrip_col == NULL)
142
const ColumnInfo *id_col= new(std::nothrow) ColumnInfo("ID",
143
MY_INT32_NUM_DECIMAL_DIGITS,
144
DRIZZLE_TYPE_LONGLONG,
154
const ColumnInfo *default_col= new(std::nothrow) ColumnInfo("IS_DEFAULT",
156
DRIZZLE_TYPE_VARCHAR,
161
if (default_col == NULL)
166
const ColumnInfo *compiled_col= new(std::nothrow) ColumnInfo("IS_COMPILED",
168
DRIZZLE_TYPE_VARCHAR,
173
if (compiled_col == NULL)
178
const ColumnInfo *sortlen_col= new(std::nothrow) ColumnInfo("SORTLEN",
180
DRIZZLE_TYPE_LONGLONG,
185
if (sortlen_col == NULL)
191
* Add the columns to the vector.
193
cols.push_back(name_col);
194
cols.push_back(char_set_col);
195
cols.push_back(descrip_col);
196
cols.push_back(id_col);
197
cols.push_back(default_col);
198
cols.push_back(compiled_col);
199
cols.push_back(sortlen_col);
204
bool createCollCharSetColumns(vector<const ColumnInfo *>& cols)
207
* Create each column for the table.
209
const ColumnInfo *name_col= new(std::nothrow) ColumnInfo("COLLATION_NAME",
211
DRIZZLE_TYPE_VARCHAR,
216
if (name_col == NULL)
221
const ColumnInfo *char_set_col= new(std::nothrow) ColumnInfo("CHARACTER_SET_NAME",
223
DRIZZLE_TYPE_VARCHAR,
228
if (char_set_col == NULL)
234
* Add the columns to the vector.
236
cols.push_back(name_col);
237
cols.push_back(char_set_col);
242
bool createKeyColUsageColumns(vector<const ColumnInfo *>& cols)
244
const ColumnInfo *cat= new(std::nothrow) ColumnInfo("CONSTRAINT_CATALOG",
246
DRIZZLE_TYPE_VARCHAR,
256
const ColumnInfo *sch= new(std::nothrow) ColumnInfo("CONSTRAINT_SCHEMA",
258
DRIZZLE_TYPE_VARCHAR,
268
const ColumnInfo *name= new(std::nothrow) ColumnInfo("CONSTRAINT_NAME",
270
DRIZZLE_TYPE_VARCHAR,
280
const ColumnInfo *tab_cat= new(std::nothrow) ColumnInfo("TABLE_CATALOG",
282
DRIZZLE_TYPE_VARCHAR,
292
const ColumnInfo *tab_sch= new(std::nothrow) ColumnInfo("TABLE_SCHEMA",
294
DRIZZLE_TYPE_VARCHAR,
304
const ColumnInfo *tab_name= new(std::nothrow) ColumnInfo("TABLE_NAME",
306
DRIZZLE_TYPE_VARCHAR,
311
if (tab_name == NULL)
316
const ColumnInfo *col_name= new(std::nothrow) ColumnInfo("COLUMN_NAME",
318
DRIZZLE_TYPE_VARCHAR,
323
if (col_name == NULL)
327
const ColumnInfo *ord_pos= new(std::nothrow) ColumnInfo("ORDINAL_POSITION",
329
DRIZZLE_TYPE_LONGLONG,
339
const ColumnInfo *pos_in_uniq= new(std::nothrow) ColumnInfo("POSITION_IN_UNIQUE_CONSTRAINT",
341
DRIZZLE_TYPE_LONGLONG,
346
if (pos_in_uniq == NULL)
351
const ColumnInfo *ref_tab_sch= new(std::nothrow) ColumnInfo("REFERENCED_TABLE_SCHEMA",
353
DRIZZLE_TYPE_VARCHAR,
358
if (ref_tab_sch == NULL)
363
const ColumnInfo *ref_tab_name= new(std::nothrow) ColumnInfo("REFERENCED_TABLE_NAME",
365
DRIZZLE_TYPE_VARCHAR,
370
if (ref_tab_name == NULL)
375
const ColumnInfo *ref_col_name= new(std::nothrow) ColumnInfo("REFERENCED_COLUMN_NAME",
377
DRIZZLE_TYPE_VARCHAR,
382
if (ref_col_name == NULL)
389
cols.push_back(name);
390
cols.push_back(tab_cat);
391
cols.push_back(tab_sch);
392
cols.push_back(tab_name);
393
cols.push_back(col_name);
394
cols.push_back(ord_pos);
395
cols.push_back(pos_in_uniq);
396
cols.push_back(ref_tab_sch);
397
cols.push_back(ref_tab_name);
398
cols.push_back(ref_col_name);
403
bool createPluginsColumns(vector<const ColumnInfo *>& cols)
405
const ColumnInfo *name= new(std::nothrow) ColumnInfo("PLUGIN_NAME",
407
DRIZZLE_TYPE_VARCHAR,
417
const ColumnInfo *ver= new(std::nothrow) ColumnInfo("PLUGIN_VERSION",
419
DRIZZLE_TYPE_VARCHAR,
429
const ColumnInfo *stat= new(std::nothrow) ColumnInfo("PLUGIN_STATUS",
431
DRIZZLE_TYPE_VARCHAR,
441
const ColumnInfo *aut= new(std::nothrow) ColumnInfo("PLUGIN_AUTHOR",
443
DRIZZLE_TYPE_VARCHAR,
453
const ColumnInfo *descrip= new(std::nothrow) ColumnInfo("PLUGIN_DESCRIPTION",
455
DRIZZLE_TYPE_VARCHAR,
465
const ColumnInfo *lic= new(std::nothrow) ColumnInfo("PLUGIN_LICENSE",
467
DRIZZLE_TYPE_VARCHAR,
477
cols.push_back(name);
479
cols.push_back(stat);
481
cols.push_back(descrip);
487
bool createProcessListColumns(vector<const ColumnInfo *>& cols)
490
* Create each column for the PROCESSLIST table.
492
const ColumnInfo *id_col= new(std::nothrow) ColumnInfo("ID",
494
DRIZZLE_TYPE_LONGLONG,
504
const ColumnInfo *user_col= new(std::nothrow) ColumnInfo("USER",
506
DRIZZLE_TYPE_VARCHAR,
511
if (user_col == NULL)
516
const ColumnInfo *host_col= new(std::nothrow) ColumnInfo("HOST",
517
LIST_PROCESS_HOST_LEN,
518
DRIZZLE_TYPE_VARCHAR,
523
if (host_col == NULL)
528
const ColumnInfo *db_col= new(std::nothrow) ColumnInfo("DB",
530
DRIZZLE_TYPE_VARCHAR,
540
const ColumnInfo *command_col= new(std::nothrow) ColumnInfo("COMMAND",
542
DRIZZLE_TYPE_VARCHAR,
547
if (command_col == NULL)
552
const ColumnInfo *time_col= new(std::nothrow) ColumnInfo("TIME",
554
DRIZZLE_TYPE_LONGLONG,
559
if (time_col == NULL)
564
const ColumnInfo *state_col= new(std::nothrow) ColumnInfo("STATE",
566
DRIZZLE_TYPE_VARCHAR,
571
if (state_col == NULL)
576
const ColumnInfo *info_col= new(std::nothrow) ColumnInfo("INFO",
577
PROCESS_LIST_INFO_WIDTH,
578
DRIZZLE_TYPE_VARCHAR,
583
if (info_col == NULL)
589
* Add the columns to the vector.
591
cols.push_back(id_col);
592
cols.push_back(user_col);
593
cols.push_back(host_col);
594
cols.push_back(db_col);
595
cols.push_back(command_col);
596
cols.push_back(time_col);
597
cols.push_back(state_col);
598
cols.push_back(info_col);
603
bool createRefConstraintColumns(vector<const ColumnInfo *>& cols)
606
* Create the columns for the table.
608
const ColumnInfo *cat= new(std::nothrow) ColumnInfo("CONSTRAINT_CATALOG",
610
DRIZZLE_TYPE_VARCHAR,
621
const ColumnInfo *sch= new(std::nothrow) ColumnInfo("CONSTRAINT_SCHEMA",
623
DRIZZLE_TYPE_VARCHAR,
633
const ColumnInfo *name= new(std::nothrow) ColumnInfo("CONSTRAINT_NAME",
635
DRIZZLE_TYPE_VARCHAR,
645
const ColumnInfo *uniq_cat= new(std::nothrow) ColumnInfo("UNIQUE_CONSTRAINT_CATALOG",
647
DRIZZLE_TYPE_VARCHAR,
652
if (uniq_cat == NULL)
657
const ColumnInfo *uniq_sch= new(std::nothrow) ColumnInfo("UNIQUE_CONSTRAINT_SCHEMA",
659
DRIZZLE_TYPE_VARCHAR,
664
if (uniq_sch == NULL)
669
const ColumnInfo *uniq_name= new(std::nothrow) ColumnInfo("UNIQUE_CONSTRAINT_NAME",
671
DRIZZLE_TYPE_VARCHAR,
676
if (uniq_name == NULL)
681
const ColumnInfo *match= new(std::nothrow) ColumnInfo("MATCH_OPTION",
683
DRIZZLE_TYPE_VARCHAR,
693
const ColumnInfo *update= new(std::nothrow) ColumnInfo("UPDATE_RULE",
695
DRIZZLE_TYPE_VARCHAR,
705
const ColumnInfo *del_rule= new(std::nothrow) ColumnInfo("DELETE_RULE",
707
DRIZZLE_TYPE_VARCHAR,
712
if (del_rule == NULL)
717
const ColumnInfo *tab_name= new(std::nothrow) ColumnInfo("TABLE_NAME",
719
DRIZZLE_TYPE_VARCHAR,
724
if (tab_name == NULL)
729
const ColumnInfo *ref_name= new(std::nothrow) ColumnInfo("REFERENCED_TABLE_NAME",
731
DRIZZLE_TYPE_VARCHAR,
736
if (ref_name == NULL)
742
* Add the columns to the vector.
746
cols.push_back(name);
747
cols.push_back(uniq_cat);
748
cols.push_back(uniq_sch);
749
cols.push_back(uniq_name);
750
cols.push_back(match);
751
cols.push_back(update);
752
cols.push_back(del_rule);
753
cols.push_back(tab_name);
754
cols.push_back(ref_name);
759
bool createTabConstraintsColumns(vector<const ColumnInfo *>& cols)
761
const ColumnInfo *cat= new(std::nothrow) ColumnInfo("CONSTRAINT_CATALOG",
763
DRIZZLE_TYPE_VARCHAR,
773
const ColumnInfo *sch= new(std::nothrow) ColumnInfo("CONSTRAINT_SCHEMA",
775
DRIZZLE_TYPE_VARCHAR,
785
const ColumnInfo *name= new(std::nothrow) ColumnInfo("CONSTRAINT_NAME",
787
DRIZZLE_TYPE_VARCHAR,
797
const ColumnInfo *tab_sch= new(std::nothrow) ColumnInfo("TABLE_SCHEMA",
799
DRIZZLE_TYPE_VARCHAR,
809
const ColumnInfo *tab_name= new(std::nothrow) ColumnInfo("TABLE_NAME",
811
DRIZZLE_TYPE_VARCHAR,
816
if (tab_name == NULL)
821
const ColumnInfo *type= new(std::nothrow) ColumnInfo("CONSTRAINT_TYPE",
823
DRIZZLE_TYPE_VARCHAR,
835
cols.push_back(name);
836
cols.push_back(tab_sch);
837
cols.push_back(tab_name);
838
cols.push_back(type);
844
* Function object used for deleting the memory allocated
845
* for the columns contained with the vector of columns.
851
inline void operator()(const T *ptr) const
857
void clearColumns(vector<const ColumnInfo *>& cols)
859
for_each(cols.begin(), cols.end(), DeleteColumns());