1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2010 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
22
#include "plugin/schema_dictionary/dictionary.h"
25
using namespace drizzled;
28
ColumnsTool::ColumnsTool() :
31
add_field("TABLE_SCHEMA");
32
add_field("TABLE_NAME");
34
add_field("COLUMN_NAME");
35
add_field("ORDINAL_POSITION", plugin::TableFunction::NUMBER);
36
add_field("COLUMN_DEFAULT");
37
add_field("IS_NULLABLE", plugin::TableFunction::BOOLEAN);
38
add_field("DATA_TYPE");
40
add_field("CHARACTER_MAXIMUM_LENGTH", plugin::TableFunction::NUMBER);
41
add_field("CHARACTER_OCTET_LENGTH", plugin::TableFunction::NUMBER);
42
add_field("NUMERIC_PRECISION", plugin::TableFunction::NUMBER);
43
add_field("NUMERIC_SCALE", plugin::TableFunction::NUMBER);
45
add_field("COLLATION_NAME");
47
add_field("COLUMN_KEY", plugin::TableFunction::BOOLEAN);
48
add_field("EXTRA", 20);
49
add_field("COLUMN_COMMENT", 1024);
53
ColumnsTool::Generator::Generator(Field **arg) :
54
TablesTool::Generator(arg),
56
is_columns_primed(false)
61
bool ColumnsTool::Generator::nextColumnCore()
63
if (is_columns_primed)
69
if (not isTablesPrimed())
73
is_columns_primed= true;
76
if (column_iterator >= getTableProto().field_size())
79
column= getTableProto().field(column_iterator);
85
bool ColumnsTool::Generator::nextColumn()
87
while (not nextColumnCore())
91
is_columns_primed= false;
97
bool ColumnsTool::Generator::populate()
107
void ColumnsTool::Generator::fill()
118
/* ORDINAL_POSITION */
119
push(static_cast<int64_t>(column_iterator));
122
push(column.options().default_value());
125
push(column.constraints().is_nullable());
128
pushType(column.type());
130
/* "CHARACTER_MAXIMUM_LENGTH" */
131
push(static_cast<int64_t>(column.string_options().length()));
133
/* "CHARACTER_OCTET_LENGTH" */
134
push(static_cast<int64_t>(column.string_options().length()) * 4);
136
/* "NUMERIC_PRECISION" */
137
push(static_cast<int64_t>(column.numeric_options().precision()));
139
/* "NUMERIC_SCALE" */
140
push(static_cast<int64_t>(column.numeric_options().scale()));
142
/* "COLLATION_NAME" */
143
push(column.string_options().collation());
151
/* "COLUMN_COMMENT" */
152
push(column.comment());