12
12
You should have received a copy of the GNU General Public License
13
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
#include <drizzled/server_includes.h>
17
17
#include <drizzled/error.h>
18
18
#include <drizzled/session.h>
19
19
#include <drizzled/unireg.h>
20
#include "drizzled/sql_table.h"
21
#include "drizzled/global_charset_info.h"
22
#include "drizzled/message/statement_transform.h"
24
#include "drizzled/internal/my_sys.h"
31
24
#include <drizzled/message/schema.pb.h>
32
25
#include <drizzled/message/table.pb.h>
33
26
#include <google/protobuf/io/zero_copy_stream.h>
34
27
#include <google/protobuf/io/zero_copy_stream_impl.h>
35
#include <google/protobuf/message.h>
37
#include <drizzled/table_proto.h>
38
#include <drizzled/charset.h>
40
#include "drizzled/function/time/typecast.h"
42
28
using namespace std;
46
static int fill_table_proto(message::Table &table_proto,
47
List<CreateField> &create_fields,
48
HA_CREATE_INFO *create_info,
30
int drizzle_read_table_proto(const char* path, drizzled::message::Table* table)
32
int fd= open(path, O_RDONLY);
37
google::protobuf::io::ZeroCopyInputStream* input=
38
new google::protobuf::io::FileInputStream(fd);
40
if (!table->ParseFromZeroCopyStream(input))
52
static int fill_table_proto(drizzled::message::Table *table_proto,
53
const char *table_name,
54
List<CreateField> &create_fields,
55
HA_CREATE_INFO *create_info,
52
59
CreateField *field_arg;
53
60
List_iterator<CreateField> it(create_fields);
54
message::Table::TableOptions *table_options= table_proto.mutable_options();
61
drizzled::message::Table::StorageEngine *engine= table_proto->mutable_engine();
62
drizzled::message::Table::TableOptions *table_options= table_proto->mutable_options();
56
64
if (create_fields.elements > MAX_FIELDS)
62
assert(strcmp(table_proto.engine().name().c_str(),
63
create_info->db_type->getName().c_str())==0);
66
bool use_existing_fields= table_proto.field_size() > 0;
70
engine->set_name(create_info->db_type->getName());
72
assert(strcmp(table_proto->name().c_str(),table_name)==0);
67
74
while ((field_arg= it++))
69
message::Table::Field *attribute;
71
/* some (one) code path for CREATE TABLE fills the proto
72
out more than the others, so we already have partially
73
filled out Field messages */
75
if (use_existing_fields)
76
attribute= table_proto.mutable_field(field_number++);
79
/* Other code paths still have to fill out the proto */
80
attribute= table_proto.add_field();
82
if (field_arg->flags & NOT_NULL_FLAG)
84
message::Table::Field::FieldConstraints *constraints;
86
constraints= attribute->mutable_constraints();
87
constraints->set_is_nullable(false);
90
attribute->set_name(field_arg->field_name);
93
assert((!(field_arg->flags & NOT_NULL_FLAG)) == attribute->constraints().is_nullable());
94
assert(strcmp(attribute->name().c_str(), field_arg->field_name)==0);
97
message::Table::Field::FieldType parser_type= attribute->type();
99
if (field_arg->sql_type == DRIZZLE_TYPE_NULL)
101
my_error(ER_CANT_CREATE_TABLE, MYF(ME_BELL+ME_WAITTANG), table_proto.name().c_str(), -1);
105
attribute->set_type(message::internalFieldTypeToFieldProtoType(field_arg->sql_type));
107
switch (attribute->type()) {
108
default: /* Only deal with types that need extra information */
110
case message::Table::Field::DOUBLE:
113
* For DOUBLE, we only add a specific scale and precision iff
114
* the fixed decimal point has been specified...
116
if (field_arg->decimals != NOT_FIXED_DEC)
118
message::Table::Field::NumericFieldOptions *numeric_field_options;
120
numeric_field_options= attribute->mutable_numeric_options();
122
numeric_field_options->set_precision(field_arg->length);
123
numeric_field_options->set_scale(field_arg->decimals);
127
case message::Table::Field::VARCHAR:
129
message::Table::Field::StringFieldOptions *string_field_options;
76
drizzled::message::Table::Field *attribute;
78
attribute= table_proto->add_field();
79
attribute->set_name(field_arg->field_name);
81
attribute->set_pack_flag(field_arg->pack_flag); /* TODO: MUST DIE */
83
if(f_maybe_null(field_arg->pack_flag))
85
drizzled::message::Table::Field::FieldConstraints *constraints;
87
constraints= attribute->mutable_constraints();
88
constraints->set_is_nullable(true);
91
switch (field_arg->sql_type) {
92
case DRIZZLE_TYPE_TINY:
93
attribute->set_type(drizzled::message::Table::Field::TINYINT);
95
case DRIZZLE_TYPE_LONG:
96
attribute->set_type(drizzled::message::Table::Field::INTEGER);
98
case DRIZZLE_TYPE_DOUBLE:
99
attribute->set_type(drizzled::message::Table::Field::DOUBLE);
101
case DRIZZLE_TYPE_NULL :
102
assert(1); /* Not a user definable type */
103
case DRIZZLE_TYPE_TIMESTAMP:
104
attribute->set_type(drizzled::message::Table::Field::TIMESTAMP);
106
case DRIZZLE_TYPE_LONGLONG:
107
attribute->set_type(drizzled::message::Table::Field::BIGINT);
109
case DRIZZLE_TYPE_DATETIME:
110
attribute->set_type(drizzled::message::Table::Field::DATETIME);
112
case DRIZZLE_TYPE_DATE:
113
attribute->set_type(drizzled::message::Table::Field::DATE);
115
case DRIZZLE_TYPE_VARCHAR:
117
drizzled::message::Table::Field::StringFieldOptions *string_field_options;
131
119
string_field_options= attribute->mutable_string_options();
133
if (! use_existing_fields || string_field_options->length()==0)
134
string_field_options->set_length(field_arg->length
135
/ field_arg->charset->mbmaxlen);
137
assert((uint32_t)string_field_options->length() == (uint32_t)(field_arg->length / field_arg->charset->mbmaxlen));
139
if (! string_field_options->has_collation())
141
string_field_options->set_collation_id(field_arg->charset->number);
142
string_field_options->set_collation(field_arg->charset->name);
120
attribute->set_type(drizzled::message::Table::Field::VARCHAR);
121
string_field_options->set_length(field_arg->length
122
/ field_arg->charset->mbmaxlen);
123
string_field_options->set_collation_id(field_arg->charset->number);
124
string_field_options->set_collation(field_arg->charset->name);
146
case message::Table::Field::DECIMAL:
128
case DRIZZLE_TYPE_NEWDECIMAL:
148
message::Table::Field::NumericFieldOptions *numeric_field_options;
130
drizzled::message::Table::Field::NumericFieldOptions *numeric_field_options;
132
attribute->set_type(drizzled::message::Table::Field::DECIMAL);
150
133
numeric_field_options= attribute->mutable_numeric_options();
151
134
/* This is magic, I hate magic numbers -Brian */
152
135
numeric_field_options->set_precision(field_arg->length + ( field_arg->decimals ? -2 : -1));
153
136
numeric_field_options->set_scale(field_arg->decimals);
156
case message::Table::Field::ENUM:
139
case DRIZZLE_TYPE_ENUM:
158
message::Table::Field::EnumerationValues *enumeration_options;
141
drizzled::message::Table::Field::SetFieldOptions *set_field_options;
160
143
assert(field_arg->interval);
162
enumeration_options= attribute->mutable_enumeration_values();
145
attribute->set_type(drizzled::message::Table::Field::ENUM);
146
set_field_options= attribute->mutable_set_options();
164
148
for (uint32_t pos= 0; pos < field_arg->interval->count; pos++)
166
150
const char *src= field_arg->interval->type_names[pos];
168
enumeration_options->add_field_value(src);
152
set_field_options->add_field_value(src);
170
enumeration_options->set_collation_id(field_arg->charset->number);
171
enumeration_options->set_collation(field_arg->charset->name);
154
set_field_options->set_count_elements(set_field_options->field_value_size());
155
set_field_options->set_collation_id(field_arg->charset->number);
156
set_field_options->set_collation(field_arg->charset->name);
174
case message::Table::Field::BLOB:
159
case DRIZZLE_TYPE_BLOB:
176
message::Table::Field::StringFieldOptions *string_field_options;
161
attribute->set_type(drizzled::message::Table::Field::BLOB);
163
drizzled::message::Table::Field::StringFieldOptions *string_field_options;
178
165
string_field_options= attribute->mutable_string_options();
179
166
string_field_options->set_collation_id(field_arg->charset->number);
210
if (! use_existing_fields)
211
attribute->set_comment(field_arg->comment.str);
213
assert(strcmp(attribute->comment().c_str(), field_arg->comment.str)==0);
214
attribute->set_comment(field_arg->comment.str);
216
if (field_arg->unireg_check == Field::NEXT_NUMBER)
217
if(field_arg->unireg_check == Field::NEXT_NUMBER)
218
message::Table::Field::NumericFieldOptions *field_options;
219
drizzled::message::Table::Field::NumericFieldOptions *field_options;
219
220
field_options= attribute->mutable_numeric_options();
220
221
field_options->set_is_autoincrement(true);
223
if (field_arg->unireg_check == Field::TIMESTAMP_DN_FIELD
224
|| field_arg->unireg_check == Field::TIMESTAMP_DNUN_FIELD)
226
message::Table::Field::FieldOptions *field_options;
227
field_options= attribute->mutable_options();
228
field_options->set_default_expression("CURRENT_TIMESTAMP");
231
if (field_arg->unireg_check == Field::TIMESTAMP_UN_FIELD
232
|| field_arg->unireg_check == Field::TIMESTAMP_DNUN_FIELD)
234
message::Table::Field::FieldOptions *field_options;
235
field_options= attribute->mutable_options();
236
field_options->set_update_expression("CURRENT_TIMESTAMP");
239
if (field_arg->def == NULL && attribute->constraints().is_nullable())
241
message::Table::Field::FieldOptions *field_options;
242
field_options= attribute->mutable_options();
244
field_options->set_default_null(true);
248
message::Table::Field::FieldOptions *field_options;
249
field_options= attribute->mutable_options();
251
if (field_arg->def->is_null())
224
if(field_arg->unireg_check == Field::TIMESTAMP_DN_FIELD
225
|| field_arg->unireg_check == Field::TIMESTAMP_DNUN_FIELD)
227
drizzled::message::Table::Field::FieldOptions *field_options;
228
field_options= attribute->mutable_options();
229
field_options->set_default_value("NOW()");
232
if(field_arg->unireg_check == Field::TIMESTAMP_UN_FIELD
233
|| field_arg->unireg_check == Field::TIMESTAMP_DNUN_FIELD)
235
drizzled::message::Table::Field::FieldOptions *field_options;
236
field_options= attribute->mutable_options();
237
field_options->set_update_value("NOW()");
242
drizzled::message::Table::Field::FieldOptions *field_options;
243
field_options= attribute->mutable_options();
245
if(field_arg->def->is_null())
253
247
field_options->set_default_null(true);
271
if (field_arg->sql_type == DRIZZLE_TYPE_DATE
272
|| field_arg->sql_type == DRIZZLE_TYPE_DATETIME
273
|| field_arg->sql_type == DRIZZLE_TYPE_TIMESTAMP)
277
if (field_arg->def->get_date(<ime, TIME_FUZZY_DATE))
279
my_error(ER_INVALID_DATETIME_VALUE, MYF(ME_FATALERROR),
280
default_value->c_str());
284
/* We now do the casting down to the appropriate type.
286
Yes, this implicit casting is balls.
287
It was previously done on reading the proto back in,
288
but we really shouldn't store the bogus things in the proto,
289
and instead do the casting behaviour here.
291
the timestamp errors are taken care of elsewhere.
294
if (field_arg->sql_type == DRIZZLE_TYPE_DATETIME)
296
Item *typecast= new Item_datetime_typecast(field_arg->def);
297
typecast->quick_fix_field();
298
typecast->val_str(default_value);
300
else if (field_arg->sql_type == DRIZZLE_TYPE_DATE)
302
Item *typecast= new Item_date_typecast(field_arg->def);
303
typecast->quick_fix_field();
304
typecast->val_str(default_value);
308
if ((field_arg->sql_type==DRIZZLE_TYPE_VARCHAR
265
if((field_arg->sql_type==DRIZZLE_TYPE_VARCHAR
309
266
&& field_arg->charset==&my_charset_bin)
310
267
|| (field_arg->sql_type==DRIZZLE_TYPE_BLOB
311
268
&& field_arg->charset==&my_charset_bin))
333
assert(! use_existing_fields || (field_number == table_proto.field_size()));
335
if (create_info->table_options & HA_OPTION_PACK_RECORD)
336
table_options->set_pack_record(true);
338
if (table_options->has_comment() && table_options->comment().length() == 0)
339
table_options->clear_comment();
341
if (table_options->has_comment())
297
if (create_info->used_fields & HA_CREATE_USED_PACK_KEYS)
299
if(create_info->table_options & HA_OPTION_PACK_KEYS)
300
table_options->set_pack_keys(true);
301
else if(create_info->table_options & HA_OPTION_NO_PACK_KEYS)
302
table_options->set_pack_keys(false);
305
if(create_info->table_options & HA_OPTION_PACK_KEYS)
306
table_options->set_pack_keys(true);
309
if (create_info->used_fields & HA_CREATE_USED_CHECKSUM)
311
assert(create_info->table_options & (HA_OPTION_CHECKSUM | HA_OPTION_NO_CHECKSUM));
313
if(create_info->table_options & HA_OPTION_CHECKSUM)
314
table_options->set_checksum(true);
316
table_options->set_checksum(false);
318
else if(create_info->table_options & HA_OPTION_CHECKSUM)
319
table_options->set_checksum(true);
322
if (create_info->used_fields & HA_CREATE_USED_PAGE_CHECKSUM)
324
if (create_info->page_checksum == HA_CHOICE_YES)
325
table_options->set_page_checksum(true);
326
else if (create_info->page_checksum == HA_CHOICE_NO)
327
table_options->set_page_checksum(false);
329
else if (create_info->page_checksum == HA_CHOICE_YES)
330
table_options->set_page_checksum(true);
333
if (create_info->used_fields & HA_CREATE_USED_DELAY_KEY_WRITE)
335
if(create_info->table_options & HA_OPTION_DELAY_KEY_WRITE)
336
table_options->set_delay_key_write(true);
337
else if(create_info->table_options & HA_OPTION_NO_DELAY_KEY_WRITE)
338
table_options->set_delay_key_write(false);
340
else if(create_info->table_options & HA_OPTION_DELAY_KEY_WRITE)
341
table_options->set_delay_key_write(true);
344
switch(create_info->row_type)
346
case ROW_TYPE_DEFAULT:
347
table_options->set_row_type(drizzled::message::Table::TableOptions::ROW_TYPE_DEFAULT);
350
table_options->set_row_type(drizzled::message::Table::TableOptions::ROW_TYPE_FIXED);
352
case ROW_TYPE_DYNAMIC:
353
table_options->set_row_type(drizzled::message::Table::TableOptions::ROW_TYPE_DYNAMIC);
355
case ROW_TYPE_COMPRESSED:
356
table_options->set_row_type(drizzled::message::Table::TableOptions::ROW_TYPE_COMPRESSED);
358
case ROW_TYPE_REDUNDANT:
359
table_options->set_row_type(drizzled::message::Table::TableOptions::ROW_TYPE_REDUNDANT);
361
case ROW_TYPE_COMPACT:
362
table_options->set_row_type(drizzled::message::Table::TableOptions::ROW_TYPE_COMPACT);
365
table_options->set_row_type(drizzled::message::Table::TableOptions::ROW_TYPE_PAGE);
371
table_options->set_pack_record(create_info->table_options
372
& HA_OPTION_PACK_RECORD);
374
if (create_info->comment.length)
343
376
uint32_t tmp_len;
344
377
tmp_len= system_charset_info->cset->charpos(system_charset_info,
345
table_options->comment().c_str(),
346
table_options->comment().c_str() +
347
table_options->comment().length(),
348
TABLE_COMMENT_MAXLEN);
378
create_info->comment.str,
379
create_info->comment.str +
380
create_info->comment.length,
381
TABLE_COMMENT_MAXLEN);
350
if (tmp_len < table_options->comment().length())
383
if (tmp_len < create_info->comment.length)
352
385
my_error(ER_WRONG_STRING_LENGTH, MYF(0),
353
table_options->comment().c_str(),"Table COMMENT",
354
(uint32_t) TABLE_COMMENT_MAXLEN);
386
create_info->comment.str,"Table COMMENT",
387
(uint32_t) TABLE_COMMENT_MAXLEN);
391
table_options->set_comment(create_info->comment.str);
359
393
if (create_info->default_table_charset)
361
395
table_options->set_collation_id(
363
397
table_options->set_collation(create_info->default_table_charset->name);
366
if (create_info->used_fields & HA_CREATE_USED_AUTO)
367
table_options->set_has_user_set_auto_increment_value(true);
369
table_options->set_has_user_set_auto_increment_value(false);
400
if (create_info->connect_string.length)
401
table_options->set_connect_string(create_info->connect_string.str);
403
if (create_info->data_file_name)
404
table_options->set_data_file_name(create_info->data_file_name);
406
if (create_info->index_file_name)
407
table_options->set_index_file_name(create_info->index_file_name);
409
if (create_info->max_rows)
410
table_options->set_max_rows(create_info->max_rows);
412
if (create_info->min_rows)
413
table_options->set_min_rows(create_info->min_rows);
371
415
if (create_info->auto_increment_value)
372
416
table_options->set_auto_increment_value(create_info->auto_increment_value);
374
for (uint32_t i= 0; i < keys; i++)
418
if (create_info->avg_row_length)
419
table_options->set_avg_row_length(create_info->avg_row_length);
421
if (create_info->key_block_size)
422
table_options->set_key_block_size(create_info->key_block_size);
424
if (create_info->block_size)
425
table_options->set_block_size(create_info->block_size);
427
for (unsigned int i= 0; i < keys; i++)
376
message::Table::Index *idx;
429
drizzled::message::Table::Index *idx;
378
idx= table_proto.add_indexes();
431
idx= table_proto->add_indexes();
380
433
assert(test(key_info[i].flags & HA_USES_COMMENT) ==
381
434
(key_info[i].comment.length > 0));
413
470
idx->set_is_unique(false);
415
message::Table::Index::Options *index_options= idx->mutable_options();
472
drizzled::message::Table::Index::IndexOptions *index_options= idx->mutable_options();
417
if (key_info[i].flags & HA_USES_BLOCK_SIZE)
474
if(key_info[i].flags & HA_USES_BLOCK_SIZE)
418
475
index_options->set_key_block_size(key_info[i].block_size);
420
if (key_info[i].flags & HA_PACK_KEY)
477
if(key_info[i].flags & HA_PACK_KEY)
421
478
index_options->set_pack_key(true);
423
if (key_info[i].flags & HA_BINARY_PACK_KEY)
480
if(key_info[i].flags & HA_BINARY_PACK_KEY)
424
481
index_options->set_binary_pack_key(true);
426
if (key_info[i].flags & HA_VAR_LENGTH_PART)
483
if(key_info[i].flags & HA_VAR_LENGTH_PART)
427
484
index_options->set_var_length_key(true);
429
if (key_info[i].flags & HA_NULL_PART_KEY)
486
if(key_info[i].flags & HA_NULL_PART_KEY)
430
487
index_options->set_null_part_key(true);
432
if (key_info[i].flags & HA_KEY_HAS_PART_KEY_SEG)
489
if(key_info[i].flags & HA_KEY_HAS_PART_KEY_SEG)
433
490
index_options->set_has_partial_segments(true);
435
if (key_info[i].flags & HA_GENERATED_KEY)
492
if(key_info[i].flags & HA_GENERATED_KEY)
436
493
index_options->set_auto_generated_key(true);
438
495
if (key_info[i].flags & HA_USES_COMMENT)
455
512
idx->set_comment(key_info[i].comment.str);
457
static const uint64_t unknown_index_flag= (HA_NOSAME | HA_PACK_KEY |
462
HA_KEY_HAS_PART_KEY_SEG |
465
if (key_info[i].flags & ~unknown_index_flag)
514
if(key_info[i].flags & ~(HA_NOSAME | HA_PACK_KEY | HA_USES_BLOCK_SIZE | HA_BINARY_PACK_KEY | HA_VAR_LENGTH_PART | HA_NULL_PART_KEY | HA_KEY_HAS_PART_KEY_SEG | HA_GENERATED_KEY | HA_USES_COMMENT))
466
515
abort(); // Invalid (unknown) index flag.
468
517
for(unsigned int j=0; j< key_info[i].key_parts; j++)
470
message::Table::Index::IndexPart *idxpart;
471
const int fieldnr= key_info[i].key_part[j].fieldnr;
519
drizzled::message::Table::Index::IndexPart *idxpart;
474
521
idxpart= idx->add_index_part();
476
idxpart->set_fieldnr(fieldnr);
478
if (table_proto.field(fieldnr).type() == message::Table::Field::VARCHAR
479
|| table_proto.field(fieldnr).type() == message::Table::Field::BLOB)
481
uint32_t collation_id;
483
if (table_proto.field(fieldnr).string_options().has_collation_id())
484
collation_id= table_proto.field(fieldnr).string_options().collation_id();
486
collation_id= table_proto.options().collation_id();
488
const CHARSET_INFO *cs= get_charset(collation_id);
490
mbmaxlen= cs->mbmaxlen;
493
idxpart->set_compare_length(key_info[i].key_part[j].length / mbmaxlen);
497
if (not table_proto.IsInitialized())
499
my_error(ER_CORRUPT_TABLE_DEFINITION, MYF(0), table_proto.InitializationErrorString().c_str());
504
Here we test to see if we can validate the Table Message before we continue.
505
We do this by serializing the protobuffer.
511
table_proto.SerializeToString(&tmp_string);
516
my_error(ER_CORRUPT_TABLE_DEFINITION, MYF(0),
517
table_proto.InitializationErrorString().empty() ? "": table_proto.InitializationErrorString().c_str());
523
idxpart->set_fieldnr(key_info[i].key_part[j].fieldnr);
525
idxpart->set_compare_length(key_info[i].key_part[j].length);
527
idxpart->set_key_type(key_info[i].key_part[j].key_type);
535
int copy_table_proto_file(const char *from, const char* to)
539
string file_ext = ".dfe";
541
dfesrc.append(file_ext);
542
dfedst.append(file_ext);
544
return my_copy(dfesrc.c_str(), dfedst.c_str(),
545
MYF(MY_DONT_OVERWRITE_FILE));
548
int rename_table_proto_file(const char *from, const char* to)
550
string from_path(from);
552
string file_ext = ".dfe";
554
from_path.append(file_ext);
555
to_path.append(file_ext);
557
return my_rename(from_path.c_str(),to_path.c_str(),MYF(MY_WME));
560
int delete_table_proto_file(const char *file_name)
562
string new_path(file_name);
563
string file_ext = ".dfe";
565
new_path.append(file_ext);
566
return my_delete(new_path.c_str(), MYF(0));
569
int table_proto_exists(const char *path)
571
string proto_path(path);
572
string file_ext(".dfe");
573
proto_path.append(file_ext);
575
int error= access(proto_path.c_str(), F_OK);
583
static int create_table_proto_file(const char *file_name,
585
const char *table_name,
586
drizzled::message::Table *table_proto,
587
HA_CREATE_INFO *create_info,
588
List<CreateField> &create_fields,
592
string new_path(file_name);
593
string file_ext = ".dfe";
595
if(fill_table_proto(table_proto, table_name, create_fields, create_info,
599
new_path.append(file_ext);
601
int fd= open(new_path.c_str(), O_RDWR|O_CREAT|O_TRUNC, my_umask);
606
my_error(ER_BAD_DB_ERROR,MYF(0),db);
608
my_error(ER_CANT_CREATE_TABLE,MYF(0),table_name,errno);
612
google::protobuf::io::ZeroCopyOutputStream* output=
613
new google::protobuf::io::FileOutputStream(fd);
615
if (!table_proto->SerializeToZeroCopyStream(output))
536
637
create_fields Fields to create
537
638
keys number of keys to create
538
639
key_info Keys to create
641
is_like is true for mysql_create_like_schema_frm
545
bool rea_create_table(Session *session,
546
const TableIdentifier &identifier,
547
message::Table &table_proto,
548
HA_CREATE_INFO *create_info,
549
List<CreateField> &create_fields,
550
uint32_t keys, KeyInfo *key_info)
648
int rea_create_table(Session *session, const char *path,
649
const char *db, const char *table_name,
650
drizzled::message::Table *table_proto,
651
HA_CREATE_INFO *create_info,
652
List<CreateField> &create_fields,
653
uint32_t keys, KEY *key_info,
552
assert(table_proto.has_name());
553
if (fill_table_proto(table_proto, create_fields, create_info,
557
assert(table_proto.name() == identifier.getTableName());
559
if (plugin::StorageEngine::createTable(*session,
656
/* Proto will blow up unless we give a name */
659
/* For is_like we return once the file has been created */
662
if (create_table_proto_file(path, db, table_name, table_proto,
664
create_fields, keys, key_info)!=0)
669
/* Here we need to build the full frm from the path */
672
if (create_table_proto_file(path, db, table_name, table_proto,
674
create_fields, keys, key_info))
678
// Make sure mysql_create_frm din't remove extension
679
if (session->variables.keep_files_on_create)
680
create_info->options|= HA_CREATE_KEEP_FILES;
682
if (ha_create_table(session, path, db, table_name,
688
delete_table_proto_file(path);
568
691
} /* rea_create_table */
570
} /* namespace drizzled */