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,
52
CreateField *field_arg;
53
List_iterator<CreateField> it(create_fields);
54
message::Table::TableOptions *table_options= table_proto.mutable_options();
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<Create_field> &create_fields,
55
HA_CREATE_INFO *create_info,
59
Create_field *field_arg;
60
List_iterator<Create_field> it(create_fields);
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
table_proto->set_name(table_name);
73
table_proto->set_type(drizzled::message::Table::STANDARD);
67
75
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;
77
drizzled::message::Table::Field *attribute;
79
attribute= table_proto->add_field();
80
attribute->set_name(field_arg->field_name);
82
attribute->set_pack_flag(field_arg->pack_flag); /* TODO: MUST DIE */
84
if(f_maybe_null(field_arg->pack_flag))
86
drizzled::message::Table::Field::FieldConstraints *constraints;
88
constraints= attribute->mutable_constraints();
89
constraints->set_is_nullable(true);
92
switch (field_arg->sql_type) {
93
case DRIZZLE_TYPE_TINY:
94
attribute->set_type(drizzled::message::Table::Field::TINYINT);
96
case DRIZZLE_TYPE_LONG:
97
attribute->set_type(drizzled::message::Table::Field::INTEGER);
99
case DRIZZLE_TYPE_DOUBLE:
100
attribute->set_type(drizzled::message::Table::Field::DOUBLE);
102
case DRIZZLE_TYPE_NULL :
103
assert(1); /* Not a user definable type */
104
case DRIZZLE_TYPE_TIMESTAMP:
105
attribute->set_type(drizzled::message::Table::Field::TIMESTAMP);
107
case DRIZZLE_TYPE_LONGLONG:
108
attribute->set_type(drizzled::message::Table::Field::BIGINT);
110
case DRIZZLE_TYPE_DATETIME:
111
attribute->set_type(drizzled::message::Table::Field::DATETIME);
113
case DRIZZLE_TYPE_DATE:
114
attribute->set_type(drizzled::message::Table::Field::DATE);
116
case DRIZZLE_TYPE_VARCHAR:
118
drizzled::message::Table::Field::StringFieldOptions *string_field_options;
131
120
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);
121
attribute->set_type(drizzled::message::Table::Field::VARCHAR);
122
string_field_options->set_length(field_arg->length
123
/ field_arg->charset->mbmaxlen);
124
string_field_options->set_collation_id(field_arg->charset->number);
125
string_field_options->set_collation(field_arg->charset->name);
146
case message::Table::Field::DECIMAL:
129
case DRIZZLE_TYPE_NEWDECIMAL:
148
message::Table::Field::NumericFieldOptions *numeric_field_options;
131
drizzled::message::Table::Field::NumericFieldOptions *numeric_field_options;
133
attribute->set_type(drizzled::message::Table::Field::DECIMAL);
150
134
numeric_field_options= attribute->mutable_numeric_options();
151
135
/* This is magic, I hate magic numbers -Brian */
152
136
numeric_field_options->set_precision(field_arg->length + ( field_arg->decimals ? -2 : -1));
153
137
numeric_field_options->set_scale(field_arg->decimals);
156
case message::Table::Field::ENUM:
140
case DRIZZLE_TYPE_ENUM:
158
message::Table::Field::EnumerationValues *enumeration_options;
142
drizzled::message::Table::Field::SetFieldOptions *set_field_options;
160
144
assert(field_arg->interval);
162
enumeration_options= attribute->mutable_enumeration_values();
146
attribute->set_type(drizzled::message::Table::Field::ENUM);
147
set_field_options= attribute->mutable_set_options();
164
149
for (uint32_t pos= 0; pos < field_arg->interval->count; pos++)
166
151
const char *src= field_arg->interval->type_names[pos];
168
enumeration_options->add_field_value(src);
153
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);
155
set_field_options->set_count_elements(set_field_options->field_value_size());
156
set_field_options->set_collation_id(field_arg->charset->number);
157
set_field_options->set_collation(field_arg->charset->name);
174
case message::Table::Field::BLOB:
160
case DRIZZLE_TYPE_BLOB:
176
message::Table::Field::StringFieldOptions *string_field_options;
162
attribute->set_type(drizzled::message::Table::Field::BLOB);
164
drizzled::message::Table::Field::StringFieldOptions *string_field_options;
178
166
string_field_options= attribute->mutable_string_options();
179
167
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);
215
attribute->set_comment(field_arg->comment.str);
216
if (field_arg->unireg_check == Field::NEXT_NUMBER)
218
if(field_arg->unireg_check == Field::NEXT_NUMBER)
218
message::Table::Field::NumericFieldOptions *field_options;
220
drizzled::message::Table::Field::NumericFieldOptions *field_options;
219
221
field_options= attribute->mutable_numeric_options();
220
222
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())
225
if(field_arg->unireg_check == Field::TIMESTAMP_DN_FIELD
226
|| field_arg->unireg_check == Field::TIMESTAMP_DNUN_FIELD)
228
drizzled::message::Table::Field::FieldOptions *field_options;
229
field_options= attribute->mutable_options();
230
field_options->set_default_value("NOW()");
233
if(field_arg->unireg_check == Field::TIMESTAMP_UN_FIELD
234
|| field_arg->unireg_check == Field::TIMESTAMP_DNUN_FIELD)
236
drizzled::message::Table::Field::FieldOptions *field_options;
237
field_options= attribute->mutable_options();
238
field_options->set_update_value("NOW()");
243
drizzled::message::Table::Field::FieldOptions *field_options;
244
field_options= attribute->mutable_options();
246
if(field_arg->def->is_null())
253
248
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
266
if((field_arg->sql_type==DRIZZLE_TYPE_VARCHAR
309
267
&& field_arg->charset==&my_charset_bin)
310
268
|| (field_arg->sql_type==DRIZZLE_TYPE_BLOB
311
269
&& 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())
298
if (create_info->used_fields & HA_CREATE_USED_PACK_KEYS)
300
if(create_info->table_options & HA_OPTION_PACK_KEYS)
301
table_options->set_pack_keys(true);
302
else if(create_info->table_options & HA_OPTION_NO_PACK_KEYS)
303
table_options->set_pack_keys(false);
306
if(create_info->table_options & HA_OPTION_PACK_KEYS)
307
table_options->set_pack_keys(true);
310
if (create_info->used_fields & HA_CREATE_USED_CHECKSUM)
312
assert(create_info->table_options & (HA_OPTION_CHECKSUM | HA_OPTION_NO_CHECKSUM));
314
if(create_info->table_options & HA_OPTION_CHECKSUM)
315
table_options->set_checksum(true);
317
table_options->set_checksum(false);
319
else if(create_info->table_options & HA_OPTION_CHECKSUM)
320
table_options->set_checksum(true);
323
if (create_info->used_fields & HA_CREATE_USED_PAGE_CHECKSUM)
325
if (create_info->page_checksum == HA_CHOICE_YES)
326
table_options->set_page_checksum(true);
327
else if (create_info->page_checksum == HA_CHOICE_NO)
328
table_options->set_page_checksum(false);
330
else if (create_info->page_checksum == HA_CHOICE_YES)
331
table_options->set_page_checksum(true);
334
if (create_info->used_fields & HA_CREATE_USED_DELAY_KEY_WRITE)
336
if(create_info->table_options & HA_OPTION_DELAY_KEY_WRITE)
337
table_options->set_delay_key_write(true);
338
else if(create_info->table_options & HA_OPTION_NO_DELAY_KEY_WRITE)
339
table_options->set_delay_key_write(false);
341
else if(create_info->table_options & HA_OPTION_DELAY_KEY_WRITE)
342
table_options->set_delay_key_write(true);
345
switch(create_info->row_type)
347
case ROW_TYPE_DEFAULT:
348
table_options->set_row_type(drizzled::message::Table::TableOptions::ROW_TYPE_DEFAULT);
351
table_options->set_row_type(drizzled::message::Table::TableOptions::ROW_TYPE_FIXED);
353
case ROW_TYPE_DYNAMIC:
354
table_options->set_row_type(drizzled::message::Table::TableOptions::ROW_TYPE_DYNAMIC);
356
case ROW_TYPE_COMPRESSED:
357
table_options->set_row_type(drizzled::message::Table::TableOptions::ROW_TYPE_COMPRESSED);
359
case ROW_TYPE_REDUNDANT:
360
table_options->set_row_type(drizzled::message::Table::TableOptions::ROW_TYPE_REDUNDANT);
362
case ROW_TYPE_COMPACT:
363
table_options->set_row_type(drizzled::message::Table::TableOptions::ROW_TYPE_COMPACT);
366
table_options->set_row_type(drizzled::message::Table::TableOptions::ROW_TYPE_PAGE);
372
table_options->set_pack_record(create_info->table_options
373
& HA_OPTION_PACK_RECORD);
375
if (create_info->comment.length)
343
377
uint32_t tmp_len;
344
378
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);
379
create_info->comment.str,
380
create_info->comment.str +
381
create_info->comment.length,
382
TABLE_COMMENT_MAXLEN);
350
if (tmp_len < table_options->comment().length())
384
if (tmp_len < create_info->comment.length)
352
386
my_error(ER_WRONG_STRING_LENGTH, MYF(0),
353
table_options->comment().c_str(),"Table COMMENT",
354
(uint32_t) TABLE_COMMENT_MAXLEN);
387
create_info->comment.str,"Table COMMENT",
388
(uint32_t) TABLE_COMMENT_MAXLEN);
392
table_options->set_comment(create_info->comment.str);
359
394
if (create_info->default_table_charset)
361
396
table_options->set_collation_id(
363
398
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);
401
if (create_info->connect_string.length)
402
table_options->set_connect_string(create_info->connect_string.str);
404
if (create_info->data_file_name)
405
table_options->set_data_file_name(create_info->data_file_name);
407
if (create_info->index_file_name)
408
table_options->set_index_file_name(create_info->index_file_name);
410
if (create_info->max_rows)
411
table_options->set_max_rows(create_info->max_rows);
413
if (create_info->min_rows)
414
table_options->set_min_rows(create_info->min_rows);
371
416
if (create_info->auto_increment_value)
372
417
table_options->set_auto_increment_value(create_info->auto_increment_value);
374
for (uint32_t i= 0; i < keys; i++)
419
if (create_info->avg_row_length)
420
table_options->set_avg_row_length(create_info->avg_row_length);
422
if (create_info->key_block_size)
423
table_options->set_key_block_size(create_info->key_block_size);
425
if (create_info->block_size)
426
table_options->set_block_size(create_info->block_size);
428
for (unsigned int i= 0; i < keys; i++)
376
message::Table::Index *idx;
430
drizzled::message::Table::Index *idx;
378
idx= table_proto.add_indexes();
432
idx= table_proto->add_indexes();
380
434
assert(test(key_info[i].flags & HA_USES_COMMENT) ==
381
435
(key_info[i].comment.length > 0));
413
471
idx->set_is_unique(false);
415
message::Table::Index::Options *index_options= idx->mutable_options();
473
drizzled::message::Table::Index::IndexOptions *index_options= idx->mutable_options();
417
if (key_info[i].flags & HA_USES_BLOCK_SIZE)
475
if(key_info[i].flags & HA_USES_BLOCK_SIZE)
418
476
index_options->set_key_block_size(key_info[i].block_size);
420
if (key_info[i].flags & HA_PACK_KEY)
478
if(key_info[i].flags & HA_PACK_KEY)
421
479
index_options->set_pack_key(true);
423
if (key_info[i].flags & HA_BINARY_PACK_KEY)
481
if(key_info[i].flags & HA_BINARY_PACK_KEY)
424
482
index_options->set_binary_pack_key(true);
426
if (key_info[i].flags & HA_VAR_LENGTH_PART)
484
if(key_info[i].flags & HA_VAR_LENGTH_PART)
427
485
index_options->set_var_length_key(true);
429
if (key_info[i].flags & HA_NULL_PART_KEY)
487
if(key_info[i].flags & HA_NULL_PART_KEY)
430
488
index_options->set_null_part_key(true);
432
if (key_info[i].flags & HA_KEY_HAS_PART_KEY_SEG)
490
if(key_info[i].flags & HA_KEY_HAS_PART_KEY_SEG)
433
491
index_options->set_has_partial_segments(true);
435
if (key_info[i].flags & HA_GENERATED_KEY)
493
if(key_info[i].flags & HA_GENERATED_KEY)
436
494
index_options->set_auto_generated_key(true);
438
496
if (key_info[i].flags & HA_USES_COMMENT)
455
513
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)
515
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
516
abort(); // Invalid (unknown) index flag.
468
518
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;
520
drizzled::message::Table::Index::IndexPart *idxpart;
474
522
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());
524
idxpart->set_fieldnr(key_info[i].key_part[j].fieldnr);
526
idxpart->set_compare_length(key_info[i].key_part[j].length);
528
idxpart->set_key_type(key_info[i].key_part[j].key_type);
536
int copy_table_proto_file(const char *from, const char* to)
540
string file_ext = ".dfe";
542
dfesrc.append(file_ext);
543
dfedst.append(file_ext);
545
return my_copy(dfesrc.c_str(), dfedst.c_str(),
546
MYF(MY_DONT_OVERWRITE_FILE));
549
int rename_table_proto_file(const char *from, const char* to)
551
string from_path(from);
553
string file_ext = ".dfe";
555
from_path.append(file_ext);
556
to_path.append(file_ext);
558
return my_rename(from_path.c_str(),to_path.c_str(),MYF(MY_WME));
561
int delete_table_proto_file(const char *file_name)
563
string new_path(file_name);
564
string file_ext = ".dfe";
566
new_path.append(file_ext);
567
return my_delete(new_path.c_str(), MYF(0));
570
int table_proto_exists(const char *path)
572
string proto_path(path);
573
string file_ext(".dfe");
574
proto_path.append(file_ext);
576
int error= access(proto_path.c_str(), F_OK);
584
static int create_table_proto_file(const char *file_name,
586
const char *table_name,
587
HA_CREATE_INFO *create_info,
588
List<Create_field> &create_fields,
592
drizzled::message::Table table_proto;
593
string new_path(file_name);
594
string file_ext = ".dfe";
596
if(fill_table_proto(&table_proto, table_name, create_fields, create_info,
600
new_path.append(file_ext);
602
int fd= open(new_path.c_str(), O_RDWR|O_CREAT|O_TRUNC, my_umask);
607
my_error(ER_BAD_DB_ERROR,MYF(0),db);
609
my_error(ER_CANT_CREATE_TABLE,MYF(0),table_name,errno);
613
google::protobuf::io::ZeroCopyOutputStream* output=
614
new google::protobuf::io::FileOutputStream(fd);
616
if (!table_proto.SerializeToZeroCopyStream(output))
536
638
create_fields Fields to create
537
639
keys number of keys to create
538
640
key_info Keys to create
642
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)
649
int rea_create_table(Session *session, const char *path,
650
const char *db, const char *table_name,
651
HA_CREATE_INFO *create_info,
652
List<Create_field> &create_fields,
653
uint32_t keys, KEY *key_info, handler *file,
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, create_info,
663
create_fields, keys, key_info)!=0)
668
/* Here we need to build the full frm from the path */
671
if (create_table_proto_file(path, db, table_name, create_info,
672
create_fields, keys, key_info))
676
// Make sure mysql_create_frm din't remove extension
677
if (session->variables.keep_files_on_create)
678
create_info->options|= HA_CREATE_KEEP_FILES;
679
if (file->ha_create_handler_files(path, NULL, CHF_CREATE_FLAG, create_info))
681
if (ha_create_table(session, path, db, table_name,
687
file->ha_create_handler_files(path, NULL, CHF_DELETE_FLAG, create_info);
689
delete_table_proto_file(path);
568
692
} /* rea_create_table */
570
} /* namespace drizzled */