~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table_proto_write.cc

MergeĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#include <drizzled/unireg.h>
20
20
#include "drizzled/sql_table.h"
21
21
#include "drizzled/global_charset_info.h"
 
22
#include "drizzled/message/statement_transform.h"
22
23
 
23
24
#include "drizzled/internal/my_sys.h"
24
25
 
94
95
 
95
96
    message::Table::Field::FieldType parser_type= attribute->type();
96
97
 
97
 
    switch (field_arg->sql_type) {
98
 
    case DRIZZLE_TYPE_LONG:
99
 
      attribute->set_type(message::Table::Field::INTEGER);
 
98
    attribute->set_type(message::internalFieldTypeToFieldProtoType(field_arg->sql_type));
 
99
 
 
100
    switch (attribute->type()) {
 
101
    default: /* Only deal with types that need extra information */
100
102
      break;
101
 
    case DRIZZLE_TYPE_DOUBLE:
 
103
    case message::Table::Field::DOUBLE:
102
104
      {
103
 
        attribute->set_type(message::Table::Field::DOUBLE);
104
 
 
105
 
        /* 
 
105
        /*
106
106
         * For DOUBLE, we only add a specific scale and precision iff
107
107
         * the fixed decimal point has been specified...
108
108
         */
117
117
        }
118
118
      }
119
119
      break;
120
 
    case DRIZZLE_TYPE_NULL  :
121
 
      assert(1); /* Not a user definable type */
122
 
    case DRIZZLE_TYPE_TIMESTAMP:
123
 
      attribute->set_type(message::Table::Field::TIMESTAMP);
124
 
      break;
125
 
    case DRIZZLE_TYPE_LONGLONG:
126
 
      attribute->set_type(message::Table::Field::BIGINT);
127
 
      break;
128
 
    case DRIZZLE_TYPE_DATETIME:
129
 
      attribute->set_type(message::Table::Field::DATETIME);
130
 
      break;
131
 
    case DRIZZLE_TYPE_DATE:
132
 
      attribute->set_type(message::Table::Field::DATE);
133
 
      break;
134
 
    case DRIZZLE_TYPE_VARCHAR:
 
120
    case message::Table::Field::VARCHAR:
135
121
      {
136
122
        message::Table::Field::StringFieldOptions *string_field_options;
137
123
 
138
124
        string_field_options= attribute->mutable_string_options();
139
 
        attribute->set_type(message::Table::Field::VARCHAR);
 
125
 
140
126
        if (! use_existing_fields || string_field_options->length()==0)
141
127
          string_field_options->set_length(field_arg->length
142
128
                                           / field_arg->charset->mbmaxlen);
150
136
        }
151
137
        break;
152
138
      }
153
 
    case DRIZZLE_TYPE_DECIMAL:
 
139
    case message::Table::Field::DECIMAL:
154
140
      {
155
141
        message::Table::Field::NumericFieldOptions *numeric_field_options;
156
142
 
157
 
        attribute->set_type(message::Table::Field::DECIMAL);
158
143
        numeric_field_options= attribute->mutable_numeric_options();
159
144
        /* This is magic, I hate magic numbers -Brian */
160
145
        numeric_field_options->set_precision(field_arg->length + ( field_arg->decimals ? -2 : -1));
161
146
        numeric_field_options->set_scale(field_arg->decimals);
162
147
        break;
163
148
      }
164
 
    case DRIZZLE_TYPE_ENUM:
 
149
    case message::Table::Field::ENUM:
165
150
      {
166
151
        message::Table::Field::SetFieldOptions *set_field_options;
167
152
 
168
153
        assert(field_arg->interval);
169
154
 
170
 
        attribute->set_type(message::Table::Field::ENUM);
171
155
        set_field_options= attribute->mutable_set_options();
172
156
 
173
157
        for (uint32_t pos= 0; pos < field_arg->interval->count; pos++)
181
165
        set_field_options->set_collation(field_arg->charset->name);
182
166
        break;
183
167
      }
184
 
    case DRIZZLE_TYPE_BLOB:
 
168
    case message::Table::Field::BLOB:
185
169
      {
186
 
        attribute->set_type(message::Table::Field::BLOB);
187
 
 
188
170
        message::Table::Field::StringFieldOptions *string_field_options;
189
171
 
190
172
        string_field_options= attribute->mutable_string_options();
193
175
      }
194
176
 
195
177
      break;
196
 
    default:
197
 
      assert(0); /* Tell us, since this shouldn't happend */
198
178
    }
199
179
 
200
180
    assert (!use_existing_fields || parser_type == attribute->type());
591
571
} /* rea_create_table */
592
572
 
593
573
} /* namespace drizzled */
 
574