370
370
table_category= TABLE_CATEGORY_TEMPORARY;
371
371
tmp_table= message::Table::INTERNAL;
373
db.str= const_cast<char *>(private_key_for_cache.vector());
374
db.length= strlen(private_key_for_cache.vector());
373
db= str_ref(private_key_for_cache.vector());
376
table_name.str= const_cast<char *>(private_key_for_cache.vector()) + strlen(private_key_for_cache.vector()) + 1;
377
table_name.length= strlen(table_name.str);
378
path.str= (char *)"";
379
normalized_path.str= path.str;
380
path.length= normalized_path.length= 0;
375
table_name= str_ref(private_key_for_cache.vector() + strlen(private_key_for_cache.vector()) + 1);
377
normalized_path= str_ref("");
382
379
std::string tb_name(identifier.getTableName());
383
380
boost::to_lower(tb_name);
384
assert(strcmp(tb_name.c_str(), table_name.str) == 0);
385
assert(strcmp(identifier.getSchemaName().c_str(), db.str) == 0);
381
assert(strcmp(tb_name.c_str(), table_name.data()) == 0);
382
assert(strcmp(identifier.getSchemaName().c_str(), db.data()) == 0);
389
385
TableShare::TableShare(const identifier::Table &identifier) : // Just used during createTable()
390
386
table_category(TABLE_UNKNOWN_CATEGORY),
391
387
found_next_number_field(NULL),
443
439
memcpy(&private_normalized_path[0], identifier.getPath().c_str(), identifier.getPath().size());
446
table_category= TABLE_CATEGORY_TEMPORARY;
447
tmp_table= message::Table::INTERNAL;
448
db.str= const_cast<char *>(private_key_for_cache.vector());
449
db.length= strlen(private_key_for_cache.vector());
450
table_name.str= db.str + 1;
451
table_name.length= strlen(table_name.str);
452
path.str= &private_normalized_path[0];
453
normalized_path.str= path.str;
454
path.length= normalized_path.length= private_normalized_path.size();
442
table_category= TABLE_CATEGORY_TEMPORARY;
443
tmp_table= message::Table::INTERNAL;
444
db= str_ref(private_key_for_cache.vector());
445
table_name= str_ref(db.data() + 1);
446
path= private_normalized_path;
447
normalized_path= path;
519
512
Let us use the fact that the key is "db/0/table_name/0" + optional
520
513
part for temporary tables.
522
db.str= const_cast<char *>(private_key_for_cache.vector());
523
db.length= strlen(db.str);
524
table_name.str= db.str + db.length + 1;
525
table_name.length= strlen(table_name.str);
515
db= str_ref(private_key_for_cache.vector());
516
table_name= str_ref(db.data() + db.size() + 1);
527
518
std::string _path;
534
_path= identifier::Table::build_table_filename(db.str, table_name.str, false);
525
_path= identifier::Table::build_table_filename(db.data(), table_name.data(), false);
537
528
char* path_buff= mem_root.strdup(_path);
538
setPath(path_buff, _path.length());
539
setNormalizedPath(path_buff, _path.length());
529
path= str_ref(path_buff, _path.length());
530
normalized_path= str_ref(path_buff, _path.length());
541
532
version= g_refresh_version;
544
void TableShare::init(const char *new_table_name,
545
const char *new_path)
535
void TableShare::init(const char *new_table_name, const char *new_path)
548
table_category= TABLE_CATEGORY_TEMPORARY;
549
tmp_table= message::Table::INTERNAL;
552
table_name.str= (char*) new_table_name;
553
table_name.length= strlen(new_table_name);
554
path.str= (char*) new_path;
555
normalized_path.str= (char*) new_path;
556
path.length= normalized_path.length= strlen(new_path);
537
table_category= TABLE_CATEGORY_TEMPORARY;
538
tmp_table= message::Table::INTERNAL;
540
table_name= str_ref(new_table_name);
541
path= str_ref(new_path);
542
normalized_path= str_ref(new_path);
559
545
TableShare::~TableShare()
571
557
Let us use the fact that the key is "db/0/table_name/0" + optional
572
558
part for temporary tables.
574
db.str= const_cast<char *>(private_key_for_cache.vector());
575
db.length= strlen(db.str);
576
table_name.str= db.str + db.length + 1;
577
table_name.length= strlen(table_name.str);
560
db= str_ref(private_key_for_cache.vector());
561
table_name= str_ref(db.data() + db.size() + 1);
579
563
getTableMessage()->set_name(identifier_arg.getTableName());
580
564
getTableMessage()->set_schema(identifier_arg.getSchemaName());
635
619
for (int indx= 0; indx < table.indexes_size(); indx++)
636
620
key_parts+= table.indexes(indx).index_part_size();
638
key_info= (KeyInfo*) alloc(table.indexes_size() * sizeof(KeyInfo) +key_parts*sizeof(KeyPartInfo));
622
key_info= (KeyInfo*) mem().alloc(table.indexes_size() * sizeof(KeyInfo) +key_parts*sizeof(KeyPartInfo));
640
624
KeyPartInfo *key_part;
643
627
(key_info+table.indexes_size());
646
ulong *rec_per_key= (ulong*) alloc(sizeof(ulong*)*key_parts);
630
ulong *rec_per_key= (ulong*) mem().alloc(sizeof(ulong*)*key_parts);
648
632
KeyInfo* keyinfo= key_info;
649
633
for (int keynr= 0; keynr < table.indexes_size(); keynr++, keyinfo++)
925
909
TYPELIB *t= (&intervals[interval_nr]);
927
t->type_names= (const char**)alloc((field_options.field_value_size() + 1) * sizeof(char*));
929
t->type_lengths= (unsigned int*)alloc((field_options.field_value_size() + 1) * sizeof(unsigned int));
911
t->type_names= (const char**)mem().alloc((field_options.field_value_size() + 1) * sizeof(char*));
912
t->type_lengths= (unsigned int*)mem().alloc((field_options.field_value_size() + 1) * sizeof(unsigned int));
931
914
t->type_names[field_options.field_value_size()]= NULL;
932
915
t->type_lengths[field_options.field_value_size()]= 0;
1329
1312
/* Fix key stuff */
1332
uint32_t local_primary_key= 0;
1333
doesKeyNameExist("PRIMARY", local_primary_key);
1315
uint32_t local_primary_key= doesKeyNameExist("PRIMARY");
1335
1316
keyinfo= key_info;
1336
1317
key_part= keyinfo->key_part;
1787
1768
if (db_errno == ENOENT)
1789
identifier::Table identifier(db.str, table_name.str);
1770
identifier::Table identifier(db.data(), table_name.data());
1790
1771
my_error(ER_TABLE_UNKNOWN, identifier);
1794
snprintf(buff, sizeof(buff), "%s",normalized_path.str);
1795
my_error((db_errno == EMFILE) ? ER_CANT_OPEN_FILE : ER_FILE_NOT_FOUND,
1796
errortype, buff, db_errno);
1775
snprintf(buff, sizeof(buff), "%s",normalized_path.data());
1776
my_error((db_errno == EMFILE) ? ER_CANT_OPEN_FILE : ER_FILE_NOT_FOUND, errortype, buff, db_errno);
1801
drizzled::error_t err_no;
1803
err_no= (db_errno == ENOENT) ? ER_FILE_NOT_FOUND : (db_errno == EAGAIN) ?
1804
ER_FILE_USED : ER_CANT_OPEN_FILE;
1806
my_error(err_no, errortype, normalized_path.str, db_errno);
1781
drizzled::error_t err_no= (db_errno == ENOENT) ? ER_FILE_NOT_FOUND : (db_errno == EAGAIN) ? ER_FILE_USED : ER_CANT_OPEN_FILE;
1782
my_error(err_no, errortype, normalized_path.data(), db_errno);
1815
1791
snprintf(tmp, sizeof(tmp), "#%d", pass_errarg);
1818
my_printf_error(ER_UNKNOWN_COLLATION,
1819
_("Unknown collation '%s' in table '%-.64s' definition"),
1820
MYF(0), csname, table_name.str);
1794
my_printf_error(ER_UNKNOWN_COLLATION, _("Unknown collation '%s' in table '%-.64s' definition"), MYF(0), csname, table_name.data());
1824
snprintf(buff, sizeof(buff), "%s", normalized_path.str);
1825
my_printf_error(ER_NOT_FORM_FILE,
1826
_("Table '%-.64s' was created with a different version "
1827
"of Drizzle and cannot be read"),
1798
snprintf(buff, sizeof(buff), "%s", normalized_path.data());
1799
my_printf_error(ER_NOT_FORM_FILE, _("Table '%-.64s' was created with a different version of Drizzle and cannot be read"), MYF(0), buff);
1832
1803
default: /* Better wrong error than none */
1834
snprintf(buff, sizeof(buff), "%s", normalized_path.str);
1805
snprintf(buff, sizeof(buff), "%s", normalized_path.data());
1835
1806
my_error(ER_NOT_FORM_FILE, errortype, buff, 0);