~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/show_dictionary/show_columns.cc

Updated pandora-build files to version 0.133

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
#include "config.h"
22
22
#include "plugin/show_dictionary/dictionary.h"
23
 
#include "drizzled/identifier.h"
24
 
#include <string>
 
23
#include "drizzled/table_identifier.h"
 
24
 
25
25
 
26
26
using namespace std;
27
27
using namespace drizzled;
28
28
 
29
29
static const string VARCHAR("VARCHAR");
30
 
/* VARBINARY already defined elsewhere */
31
 
static const string VARBIN("VARBINARY");
32
30
static const string DOUBLE("DOUBLE");
33
31
static const string BLOB("BLOB");
34
 
static const string TEXT("TEXT");
35
32
static const string ENUM("ENUM");
36
33
static const string INTEGER("INTEGER");
37
34
static const string BIGINT("BIGINT");
41
38
static const string DATETIME("DATETIME");
42
39
 
43
40
ShowColumns::ShowColumns() :
44
 
  show_dictionary::Show("SHOW_COLUMNS")
 
41
  plugin::TableFunction("DATA_DICTIONARY", "SHOW_COLUMNS")
45
42
{
46
43
  add_field("Field");
47
44
  add_field("Type");
48
 
  add_field("Null", plugin::TableFunction::BOOLEAN, 0 , false);
 
45
  add_field("Null", plugin::TableFunction::BOOLEAN);
49
46
  add_field("Default");
50
 
  add_field("Default_is_NULL", plugin::TableFunction::BOOLEAN, 0, false);
 
47
  add_field("Default_is_NULL", plugin::TableFunction::BOOLEAN);
51
48
  add_field("On_Update");
52
49
}
53
50
 
54
51
ShowColumns::Generator::Generator(Field **arg) :
55
 
  show_dictionary::Show::Generator(arg),
 
52
  plugin::TableFunction::Generator(arg),
56
53
  is_tables_primed(false),
57
54
  is_columns_primed(false),
58
55
  column_iterator(0)
59
56
{
60
 
  if (not isShowQuery())
61
 
   return;
62
 
 
63
 
  statement::Show *select= static_cast<statement::Show *>(getSession().lex->statement);
 
57
  statement::Select *select= static_cast<statement::Select *>(getSession().lex->statement);
64
58
 
65
59
  if (not select->getShowTable().empty() && not select->getShowSchema().empty())
66
60
  {
67
61
    table_name.append(select->getShowTable().c_str());
68
 
    identifier::Table identifier(select->getShowSchema().c_str(), select->getShowTable().c_str());
 
62
    TableIdentifier identifier(select->getShowSchema().c_str(), select->getShowTable().c_str());
69
63
 
70
64
    is_tables_primed= plugin::StorageEngine::getTableDefinition(getSession(),
71
65
                                                                identifier,
88
82
    is_columns_primed= true;
89
83
  }
90
84
 
91
 
  if (column_iterator >= getTableProto()->field_size())
 
85
  if (column_iterator >= getTableProto().field_size())
92
86
    return false;
93
87
 
94
 
  column= getTableProto()->field(column_iterator);
 
88
  column= getTableProto().field(column_iterator);
95
89
 
96
90
  return true;
97
91
}
118
112
  return true;
119
113
}
120
114
 
121
 
void ShowColumns::Generator::pushType(message::Table::Field::FieldType type, const string collation)
 
115
void ShowColumns::Generator::pushType(message::Table::Field::FieldType type)
122
116
{
123
117
  switch (type)
124
118
  {
125
119
  default:
126
120
  case message::Table::Field::VARCHAR:
127
 
    push(collation.compare("binary") ? VARCHAR : VARBIN);
 
121
    push(VARCHAR);
128
122
    break;
129
123
  case message::Table::Field::DOUBLE:
130
124
    push(DOUBLE);
131
125
    break;
132
126
  case message::Table::Field::BLOB:
133
 
    push(collation.compare("binary") ? TEXT : BLOB);
 
127
    push(BLOB);
134
128
    break;
135
129
  case message::Table::Field::ENUM:
136
130
    push(ENUM);
147
141
  case message::Table::Field::DATE:
148
142
    push(DATE);
149
143
    break;
150
 
  case message::Table::Field::EPOCH:
 
144
  case message::Table::Field::TIMESTAMP:
151
145
    push(TIMESTAMP);
152
146
    break;
153
147
  case message::Table::Field::DATETIME:
163
157
  push(column.name());
164
158
 
165
159
  /* Type */
166
 
  pushType(column.type(), column.string_options().collation());
 
160
  pushType(column.type());
167
161
 
168
162
  /* Null */
169
 
  push(not column.constraints().is_notnull());
 
163
  push(column.constraints().is_nullable());
170
164
 
171
165
  /* Default */
172
 
  if (column.options().has_default_value())
173
 
    push(column.options().default_value());
174
 
  else if (column.options().has_default_expression())
175
 
    push(column.options().default_expression());
176
 
  else
177
 
    push(column.options().default_bin_value());
 
166
  push(column.options().default_value());
178
167
 
179
168
  /* Default_is_NULL */
180
169
  push(column.options().default_null());
181
170
 
182
171
  /* On_Update */
183
 
  push(column.options().update_expression());
 
172
  push(column.options().update_value());
184
173
}