323
326
path.reserve(FN_REFLEN);
324
327
path.append(share->normalized_path.str);
328
string proto_path= path;
325
330
path.append(reg_ext);
332
proto_path.append(".dfe");
334
drizzle::Table table;
336
if(drizzle_read_table_proto(proto_path.c_str(), &table)==0)
339
LEX_STRING engine_name= { (char*)table.engine().name().c_str(),
340
strlen(table.engine().name().c_str()) };
341
share->db_plugin= ha_resolve_by_name(session, &engine_name);
344
// share->db_create_options FAIL
345
// share->db_options_in_use FAIL
346
share->mysql_version= DRIZZLE_VERSION_ID; // TODO: remove
347
share->null_field_first= 0;
349
drizzle::Table::TableOptions table_options;
351
if(table.has_options())
352
table_options= table.options();
354
share->avg_row_length= table_options.has_avg_row_length() ?
355
table_options.avg_row_length() : 0;
357
share->page_checksum= table_options.has_page_checksum() ?
358
(table_options.page_checksum()?HA_CHOICE_YES:HA_CHOICE_NO)
361
share->row_type= table_options.has_row_type() ?
362
(enum row_type) table_options.row_type() : ROW_TYPE_DEFAULT;
364
share->block_size= table_options.has_block_size() ?
365
table_options.block_size() : 0;
367
share->table_charset= get_charset(table_options.has_collation_id()?
368
table_options.collation_id() : 0,
371
if (!share->table_charset)
373
/* unknown charset in head[38] or pre-3.23 frm */
374
if (use_mb(default_charset_info))
376
/* Warn that we may be changing the size of character columns */
377
errmsg_printf(ERRMSG_LVL_WARN,
378
_("'%s' had no or invalid character set, "
379
"and default character set is multi-byte, "
380
"so character column sizes may have changed"),
383
share->table_charset= default_charset_info;
386
share->null_field_first= 1;
388
share->db_record_offset= 1;
390
share->blob_ptr_size= portable_sizeof_char_ptr; // more bonghits.
392
share->db_low_byte_first= true;
394
share->max_rows= table_options.has_max_rows() ?
395
table_options.max_rows() : 0;
397
share->min_rows= table_options.has_min_rows() ?
398
table_options.min_rows() : 0;
400
share->keys= table.indexes_size();
403
for(int indx= 0; indx < table.indexes_size(); indx++)
404
share->key_parts+= table.indexes(indx).index_part_size();
406
share->keys_for_keyread.init(0);
407
share->keys_in_use.init(share->keys);
409
if(table_options.has_connect_string())
411
size_t len= table_options.connect_string().length();
412
const char* str= table_options.connect_string().c_str();
414
share->connect_string.length= len;
415
share->connect_string.str= strmake_root(&share->mem_root, str, len);
418
if(table_options.has_comment())
420
size_t len= table_options.comment().length();
421
const char* str= table_options.comment().c_str();
423
share->comment.length= len;
424
share->comment.str= strmake_root(&share->mem_root, str, len);
427
share->key_block_size= table_options.has_key_block_size() ?
428
table_options.key_block_size() : 0;
326
433
if ((file= open(path.c_str(), O_RDONLY)) < 0)
469
575
if (my_read(file,forminfo,288,MYF(MY_NABP)))
472
legacy_db_type= DB_TYPE_FIRST_DYNAMIC;
473
assert(share->db_plugin == NULL);
475
if the storage engine is dynamic, no point in resolving it by its
476
dynamically allocated legacy_db_type. We will resolve it later by name.
478
if (legacy_db_type > DB_TYPE_UNKNOWN &&
479
legacy_db_type < DB_TYPE_FIRST_DYNAMIC)
480
share->db_plugin= ha_lock_engine(NULL,
481
ha_checktype(session, legacy_db_type, 0, 0));
482
578
share->db_create_options= db_create_options= uint2korr(head+30);
483
579
share->db_options_in_use= share->db_create_options;
484
share->mysql_version= uint4korr(head+51);
485
share->null_field_first= 0;
486
if (!head[32]) // New frm file in 3.23
488
share->avg_row_length= uint4korr(head+34);
489
share->transactional= (ha_choice) (head[39] & 3);
490
share->page_checksum= (ha_choice) ((head[39] >> 2) & 3);
491
share->row_type= (row_type) head[40];
492
share->block_size= uint4korr(head+43);
493
share->table_charset= get_charset((uint) head[38],MYF(0));
494
share->null_field_first= 1;
496
if (!share->table_charset)
498
/* unknown charset in head[38] or pre-3.23 frm */
499
if (use_mb(default_charset_info))
501
/* Warn that we may be changing the size of character columns */
502
errmsg_printf(ERRMSG_LVL_WARN, _("'%s' had no or invalid character set, "
503
"and default character set is multi-byte, "
504
"so character column sizes may have changed"),
507
share->table_charset= default_charset_info;
509
share->db_record_offset= 1;
510
if (db_create_options & HA_OPTION_LONG_BLOB_PTR)
511
share->blob_ptr_size= portable_sizeof_char_ptr;
512
/* Set temporarily a good value for db_low_byte_first */
513
share->db_low_byte_first= true;
515
share->max_rows= uint4korr(head+18);
516
share->min_rows= uint4korr(head+22);
518
583
/* Read keyinformation */
519
584
key_info_length= (uint) uint2korr(head+28);
625
share->connect_string.length= uint2korr(buff);
626
if (!(share->connect_string.str= strmake_root(&share->mem_root,
627
(char*) next_chunk + 2,
628
share->connect_string.
633
next_chunk+= share->connect_string.length + 2;
691
uint32_t connect_str_length= uint2korr(buff);
692
next_chunk+= connect_str_length + 2;
634
694
buff_end= buff + n_length;
635
695
if (next_chunk + 2 < buff_end)
637
697
uint32_t str_db_type_length= uint2korr(next_chunk);
639
name.str= (char*) next_chunk + 2;
640
name.length= str_db_type_length;
642
plugin_ref tmp_plugin= ha_resolve_by_name(session, &name);
643
if (tmp_plugin != NULL && !plugin_equals(tmp_plugin, share->db_plugin))
645
if (legacy_db_type > DB_TYPE_UNKNOWN &&
646
legacy_db_type < DB_TYPE_FIRST_DYNAMIC &&
647
legacy_db_type != ha_legacy_type(
648
plugin_data(tmp_plugin, handlerton *)))
650
/* bad file, legacy_db_type did not match the name */
655
tmp_plugin is locked with a local lock.
656
we unlock the old value of share->db_plugin before
657
replacing it with a globally locked version of tmp_plugin
659
plugin_unlock(NULL, share->db_plugin);
660
share->db_plugin= my_plugin_lock(NULL, &tmp_plugin);
662
else if (!tmp_plugin)
664
/* purecov: begin inspected */
666
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), name.str);
671
698
next_chunk+= str_db_type_length + 2;
673
700
if (share->mysql_version >= 50110)