106
136
void TableShare::release(TableShare *share)
108
138
bool to_be_deleted= false;
109
safe_mutex_assert_owner(table::Cache::singleton().mutex().native_handle);
112
if (!--share->ref_count)
120
definition::Cache::singleton().erase(share->getCacheKey());
124
void TableShare::release(TableShare::shared_ptr &share)
126
bool to_be_deleted= false;
127
safe_mutex_assert_owner(table::Cache::singleton().mutex().native_handle);
130
if (!--share->ref_count)
138
definition::Cache::singleton().erase(share->getCacheKey());
142
void TableShare::release(const TableIdentifier &identifier)
144
TableShare::shared_ptr share= definition::Cache::singleton().find(identifier.getKey());
139
safe_mutex_assert_owner(&LOCK_open);
141
pthread_mutex_lock(&share->mutex);
142
if (!--share->ref_count)
149
const string key_string(share->getCacheKey(),
150
share->getCacheKeySize());
151
plugin::EventObserver::deregisterTableEvents(*share);
153
TableDefinitionCache::iterator iter= table_def_cache.find(key_string);
154
if (iter != table_def_cache.end())
156
table_def_cache.erase(iter);
161
pthread_mutex_unlock(&share->mutex);
164
void TableShare::release(const char *key, uint32_t key_length)
166
const string key_string(key, key_length);
168
TableDefinitionCache::iterator iter= table_def_cache.find(key_string);
169
if (iter != table_def_cache.end())
171
TableShare *share= (*iter).second;
147
172
share->version= 0; // Mark for delete
148
173
if (share->ref_count == 0)
150
definition::Cache::singleton().erase(identifier.getKey());
175
pthread_mutex_lock(&share->mutex);
176
plugin::EventObserver::deregisterTableEvents(*share);
177
table_def_cache.erase(key_string);
156
static TableShare::shared_ptr foundTableShare(TableShare::shared_ptr share)
184
static TableShare *foundTableShare(TableShare *share)
159
187
We found an existing table definition. Return it if we didn't get
197
228
# Share for table
200
TableShare::shared_ptr TableShare::getShareCreate(Session *session,
201
const TableIdentifier &identifier,
231
TableShare *TableShare::getShare(Session *session,
233
uint32_t key_length, int *error)
204
TableShare::shared_ptr share;
235
const string key_string(key, key_length);
236
TableShare *share= NULL;
208
240
/* Read table definition from cache */
209
if ((share= definition::Cache::singleton().find(identifier.getKey())))
241
TableDefinitionCache::iterator iter= table_def_cache.find(key_string);
242
if (iter != table_def_cache.end())
244
share= (*iter).second;
210
245
return foundTableShare(share);
212
share.reset(new TableShare(message::Table::STANDARD, identifier));
248
if (not (share= new TableShare(key, key_length)))
254
Lock mutex to be able to read table definition from file without
257
(void) pthread_mutex_lock(&share->mutex);
260
* @TODO: we need to eject something if we exceed table_def_size
262
pair<TableDefinitionCache::iterator, bool> ret=
263
table_def_cache.insert(make_pair(key_string, share));
264
if (ret.second == false)
271
TableIdentifier identifier(share->getSchemaName(), share->getTableName());
214
272
if (share->open_table_def(*session, identifier))
216
in_error= share->error;
274
*error= share->error;
275
table_def_cache.erase(key_string);
218
return TableShare::shared_ptr();
220
280
share->ref_count++; // Mark in use
222
282
plugin::EventObserver::registerTableEvents(*share);
224
bool ret= definition::Cache::singleton().insert(identifier.getKey(), share);
227
return TableShare::shared_ptr();
284
(void) pthread_mutex_unlock(&share->mutex);
291
Check if table definition exits in cache
294
get_cached_table_share()
296
table_name Table name
300
# TableShare for table
302
TableShare *TableShare::getShare(TableIdentifier &identifier)
304
char key[MAX_DBKEY_LENGTH];
306
safe_mutex_assert_owner(&LOCK_open);
308
key_length= TableShare::createKey(key, identifier);
310
const string key_string(key, key_length);
312
TableDefinitionCache::iterator iter= table_def_cache.find(key_string);
313
if (iter != table_def_cache.end())
315
return (*iter).second;
323
/* Get column name from column hash */
325
static unsigned char *get_field_name(Field **buff, size_t *length, bool)
327
*length= (uint32_t) strlen((*buff)->field_name);
328
return (unsigned char*) (*buff)->field_name;
232
331
static enum_field_types proto_field_type_to_drizzle_type(uint32_t proto_field_type)
234
333
enum_field_types field_type;
372
TableShare::TableShare(const TableIdentifier::Type type_arg) :
373
table_category(TABLE_UNKNOWN_CATEGORY),
374
found_next_number_field(NULL),
375
timestamp_field(NULL),
377
mem_root(TABLE_ALLOC_BLOCK_SIZE),
383
stored_rec_length(0),
386
storage_engine(NULL),
390
last_null_bit_pos(0),
396
max_unique_length(0),
401
has_variable_width(false),
402
db_create_options(0),
403
db_options_in_use(0),
405
rowid_field_offset(0),
406
primary_key(MAX_KEY),
407
next_number_index(0),
408
next_number_key_offset(0),
409
next_number_keypart(0),
414
db_low_byte_first(false),
417
event_observers(NULL)
421
memset(&db, 0, sizeof(LEX_STRING));
422
memset(&table_name, 0, sizeof(LEX_STRING));
423
memset(&path, 0, sizeof(LEX_STRING));
424
memset(&normalized_path, 0, sizeof(LEX_STRING));
426
if (type_arg == message::Table::INTERNAL)
428
TableIdentifier::build_tmptable_filename(private_key_for_cache.vectorPtr());
429
init(private_key_for_cache.vector(), private_key_for_cache.vector());
437
TableShare::TableShare(const TableIdentifier &identifier, const TableIdentifier::Key &key) :// Used by placeholder
438
table_category(TABLE_UNKNOWN_CATEGORY),
439
found_next_number_field(NULL),
440
timestamp_field(NULL),
442
mem_root(TABLE_ALLOC_BLOCK_SIZE),
448
stored_rec_length(0),
451
storage_engine(NULL),
452
tmp_table(message::Table::INTERNAL),
455
last_null_bit_pos(0),
461
max_unique_length(0),
466
has_variable_width(false),
467
db_create_options(0),
468
db_options_in_use(0),
470
rowid_field_offset(0),
471
primary_key(MAX_KEY),
472
next_number_index(0),
473
next_number_key_offset(0),
474
next_number_keypart(0),
479
db_low_byte_first(false),
482
event_observers(NULL)
484
assert(identifier.getKey() == key);
487
memset(&path, 0, sizeof(LEX_STRING));
488
memset(&normalized_path, 0, sizeof(LEX_STRING));
490
private_key_for_cache= key;
492
table_category= TABLE_CATEGORY_TEMPORARY;
493
tmp_table= message::Table::INTERNAL;
495
db.str= const_cast<char *>(private_key_for_cache.vector());
496
db.length= strlen(private_key_for_cache.vector());
498
table_name.str= const_cast<char *>(private_key_for_cache.vector()) + strlen(private_key_for_cache.vector()) + 1;
499
table_name.length= strlen(table_name.str);
500
path.str= (char *)"";
501
normalized_path.str= path.str;
502
path.length= normalized_path.length= 0;
504
std::string tb_name(identifier.getTableName());
505
std::transform(tb_name.begin(), tb_name.end(), tb_name.begin(), ::tolower);
506
assert(strcmp(tb_name.c_str(), table_name.str) == 0);
508
assert(strcmp(identifier.getSchemaName().c_str(), db.str) == 0);
512
TableShare::TableShare(const TableIdentifier &identifier) : // Just used during createTable()
513
table_category(TABLE_UNKNOWN_CATEGORY),
514
found_next_number_field(NULL),
515
timestamp_field(NULL),
517
mem_root(TABLE_ALLOC_BLOCK_SIZE),
523
stored_rec_length(0),
526
storage_engine(NULL),
527
tmp_table(identifier.getType()),
530
last_null_bit_pos(0),
536
max_unique_length(0),
541
has_variable_width(false),
542
db_create_options(0),
543
db_options_in_use(0),
545
rowid_field_offset(0),
546
primary_key(MAX_KEY),
547
next_number_index(0),
548
next_number_key_offset(0),
549
next_number_keypart(0),
554
db_low_byte_first(false),
557
event_observers(NULL)
560
memset(&db, 0, sizeof(LEX_STRING));
561
memset(&table_name, 0, sizeof(LEX_STRING));
562
memset(&path, 0, sizeof(LEX_STRING));
563
memset(&normalized_path, 0, sizeof(LEX_STRING));
565
private_key_for_cache= identifier.getKey();
566
assert(identifier.getPath().size()); // Since we are doing a create table, this should be a positive value
567
private_normalized_path.resize(identifier.getPath().size() + 1);
568
memcpy(&private_normalized_path[0], identifier.getPath().c_str(), identifier.getPath().size());
571
table_category= TABLE_CATEGORY_TEMPORARY;
572
tmp_table= message::Table::INTERNAL;
573
db.str= const_cast<char *>(private_key_for_cache.vector());
574
db.length= strlen(private_key_for_cache.vector());
575
table_name.str= db.str + 1;
576
table_name.length= strlen(table_name.str);
577
path.str= &private_normalized_path[0];
578
normalized_path.str= path.str;
579
path.length= normalized_path.length= private_normalized_path.size();
585
Used for shares that will go into the cache.
587
TableShare::TableShare(const TableIdentifier::Type type_arg,
588
const TableIdentifier &identifier,
590
uint32_t path_length_arg) :
591
table_category(TABLE_UNKNOWN_CATEGORY),
592
found_next_number_field(NULL),
593
timestamp_field(NULL),
595
mem_root(TABLE_ALLOC_BLOCK_SIZE),
601
stored_rec_length(0),
604
storage_engine(NULL),
608
last_null_bit_pos(0),
614
max_unique_length(0),
619
has_variable_width(false),
620
db_create_options(0),
621
db_options_in_use(0),
623
rowid_field_offset(0),
624
primary_key(MAX_KEY),
625
next_number_index(0),
626
next_number_key_offset(0),
627
next_number_keypart(0),
632
db_low_byte_first(false),
635
event_observers(NULL)
638
memset(&db, 0, sizeof(LEX_STRING));
639
memset(&table_name, 0, sizeof(LEX_STRING));
640
memset(&path, 0, sizeof(LEX_STRING));
641
memset(&normalized_path, 0, sizeof(LEX_STRING));
468
TableDefinitionCache &TableShare::getCache()
470
return table_def_cache;
473
TableShare::TableShare(char *key, uint32_t key_length, char *path_arg, uint32_t path_length_arg) :
474
table_category(TABLE_UNKNOWN_CATEGORY),
477
found_next_number_field(NULL),
478
timestamp_field(NULL),
482
default_values(NULL),
487
stored_rec_length(0),
488
row_type(ROW_TYPE_DEFAULT),
491
storage_engine(NULL),
492
tmp_table(message::Table::STANDARD),
495
last_null_bit_pos(0),
501
max_unique_length(0),
506
timestamp_field_offset(0),
508
db_create_options(0),
509
db_options_in_use(0),
511
rowid_field_offset(0),
513
next_number_index(0),
514
next_number_key_offset(0),
515
next_number_keypart(0),
519
column_bitmap_size(0),
521
db_low_byte_first(false),
523
replace_with_name_lock(false),
524
waiting_on_cond(false),
529
memset(&name_hash, 0, sizeof(HASH));
532
memset(&all_set, 0, sizeof (MyBitmap));
533
memset(&table_cache_key, 0, sizeof(LEX_STRING));
534
memset(&db, 0, sizeof(LEX_STRING));
535
memset(&table_name, 0, sizeof(LEX_STRING));
536
memset(&path, 0, sizeof(LEX_STRING));
537
memset(&normalized_path, 0, sizeof(LEX_STRING));
539
mem_root.init_alloc_root(TABLE_ALLOC_BLOCK_SIZE);
540
char *key_buff, *path_buff;
644
541
std::string _path;
646
private_key_for_cache= identifier.getKey();
648
Let us use the fact that the key is "db/0/table_name/0" + optional
649
part for temporary tables.
651
db.str= const_cast<char *>(private_key_for_cache.vector());
652
db.length= strlen(db.str);
653
table_name.str= db.str + db.length + 1;
544
db.length= strlen(db.str);
545
table_name.str= db.str + db.length + 1;
654
546
table_name.length= strlen(table_name.str);
662
TableIdentifier::build_table_filename(_path, db.str, table_name.str, false);
554
build_table_filename(_path, db.str, table_name.str, false);
665
if ((path_buff= (char *)mem_root.alloc_root(_path.length() + 1)))
557
if (mem_root.multi_alloc_root(0, &key_buff, key_length,
558
&path_buff, _path.length() + 1,
561
memcpy(key_buff, key, key_length);
562
set_table_cache_key(key_buff, key_length, db.length, table_name.length);
667
564
setPath(path_buff, _path.length());
668
565
strcpy(path_buff, _path.c_str());
669
566
setNormalizedPath(path_buff, _path.length());
671
568
version= refresh_version;
570
pthread_mutex_init(&mutex, MY_MUTEX_INIT_FAST);
571
pthread_cond_init(&cond, NULL);
675
575
assert(0); // We should throw here.
680
void TableShare::init(const char *new_table_name,
681
const char *new_path)
684
table_category= TABLE_CATEGORY_TEMPORARY;
685
tmp_table= message::Table::INTERNAL;
688
table_name.str= (char*) new_table_name;
689
table_name.length= strlen(new_table_name);
690
path.str= (char*) new_path;
691
normalized_path.str= (char*) new_path;
692
path.length= normalized_path.length= strlen(new_path);
695
TableShare::~TableShare()
697
assert(ref_count == 0);
699
storage_engine= NULL;
704
plugin::EventObserver::deregisterTableEvents(*this);
706
mem_root.free_root(MYF(0)); // Free's share
709
void TableShare::setIdentifier(const TableIdentifier &identifier_arg)
711
private_key_for_cache= identifier_arg.getKey();
714
Let us use the fact that the key is "db/0/table_name/0" + optional
715
part for temporary tables.
717
db.str= const_cast<char *>(private_key_for_cache.vector());
718
db.length= strlen(db.str);
719
table_name.str= db.str + db.length + 1;
720
table_name.length= strlen(table_name.str);
722
table_proto->set_name(identifier_arg.getTableName());
723
table_proto->set_schema(identifier_arg.getSchemaName());
726
581
int TableShare::inner_parse_table_proto(Session& session, message::Table &table)
583
TableShare *share= this;
728
584
int local_error= 0;
730
586
if (! table.IsInitialized())
751
607
/* local_db_create_options was stored as 2 bytes in FRM
752
608
Any HA_OPTION_ that doesn't fit into 2 bytes was silently truncated away.
754
db_create_options= (local_db_create_options & 0x0000FFFF);
755
db_options_in_use= db_create_options;
757
block_size= table_options.has_block_size() ?
610
share->db_create_options= (local_db_create_options & 0x0000FFFF);
611
share->db_options_in_use= share->db_create_options;
613
share->row_type= table_options.has_row_type() ?
614
(enum row_type) table_options.row_type() : ROW_TYPE_DEFAULT;
616
share->block_size= table_options.has_block_size() ?
758
617
table_options.block_size() : 0;
760
table_charset= get_charset(table_options.collation_id());
619
share->table_charset= get_charset(table_options.has_collation_id()?
620
table_options.collation_id() : 0);
622
if (!share->table_charset)
765
snprintf(errmsg, sizeof(errmsg),
766
_("Table %s has invalid/unknown collation: %d,%s"),
768
table_options.collation_id(),
769
table_options.collation().c_str());
772
my_error(ER_CORRUPT_TABLE_DEFINITION, MYF(0), errmsg);
773
return ER_CORRUPT_TABLE_DEFINITION;
624
/* unknown charset in head[38] or pre-3.23 frm */
625
if (use_mb(default_charset_info))
627
/* Warn that we may be changing the size of character columns */
628
errmsg_printf(ERRMSG_LVL_WARN,
629
_("'%s' had no or invalid character set, "
630
"and default character set is multi-byte, "
631
"so character column sizes may have changed"),
634
share->table_charset= default_charset_info;
778
blob_ptr_size= portable_sizeof_char_ptr; // more bonghits.
780
keys= table.indexes_size();
637
share->db_record_offset= 1;
639
share->blob_ptr_size= portable_sizeof_char_ptr; // more bonghits.
641
share->keys= table.indexes_size();
783
644
for (int indx= 0; indx < table.indexes_size(); indx++)
784
key_parts+= table.indexes(indx).index_part_size();
645
share->key_parts+= table.indexes(indx).index_part_size();
786
key_info= (KeyInfo*) alloc_root( table.indexes_size() * sizeof(KeyInfo) +key_parts*sizeof(KeyPartInfo));
647
share->key_info= (KeyInfo*) share->alloc_root( table.indexes_size() * sizeof(KeyInfo) +share->key_parts*sizeof(KeyPartInfo));
788
649
KeyPartInfo *key_part;
790
651
key_part= reinterpret_cast<KeyPartInfo*>
791
(key_info+table.indexes_size());
794
ulong *rec_per_key= (ulong*) alloc_root(sizeof(ulong*)*key_parts);
796
KeyInfo* keyinfo= key_info;
652
(share->key_info+table.indexes_size());
655
ulong *rec_per_key= (ulong*) share->alloc_root(sizeof(ulong*)*share->key_parts);
657
KeyInfo* keyinfo= share->key_info;
797
658
for (int keynr= 0; keynr < table.indexes_size(); keynr++, keyinfo++)
799
660
message::Table::Index indx= table.indexes(keynr);
916
759
keyinfo->flags|= HA_USES_COMMENT;
917
760
keyinfo->comment.length= indx.comment().length();
918
keyinfo->comment.str= strmake_root(indx.comment().c_str(), keyinfo->comment.length);
761
keyinfo->comment.str= share->strmake_root(indx.comment().c_str(), keyinfo->comment.length);
921
keyinfo->name= strmake_root(indx.name().c_str(), indx.name().length());
764
keyinfo->name= share->strmake_root(indx.name().c_str(), indx.name().length());
923
766
addKeyName(string(keyinfo->name, indx.name().length()));
926
keys_for_keyread.reset();
927
set_prefix(keys_in_use, keys);
929
fields= table.field_size();
931
setFields(fields + 1);
769
share->keys_for_keyread.reset();
770
set_prefix(share->keys_in_use, share->keys);
772
share->fields= table.field_size();
774
share->field= (Field**) share->alloc_root(((share->fields+1) * sizeof(Field*)));
775
share->field[share->fields]= NULL;
934
777
uint32_t local_null_fields= 0;
937
std::vector<uint32_t> field_offsets;
938
std::vector<uint32_t> field_pack_length;
940
field_offsets.resize(fields);
941
field_pack_length.resize(fields);
780
vector<uint32_t> field_offsets;
781
vector<uint32_t> field_pack_length;
783
field_offsets.resize(share->fields);
784
field_pack_length.resize(share->fields);
943
786
uint32_t interval_count= 0;
944
787
uint32_t interval_parts= 0;
946
789
uint32_t stored_columns_reclength= 0;
948
for (unsigned int fieldnr= 0; fieldnr < fields; fieldnr++)
791
for (unsigned int fieldnr= 0; fieldnr < share->fields; fieldnr++)
950
793
message::Table::Field pfield= table.field(fieldnr);
951
794
if (pfield.constraints().is_nullable())
1315
1170
case DRIZZLE_TYPE_LONGLONG:
1316
1171
field_length= MAX_BIGINT_WIDTH;
1318
case DRIZZLE_TYPE_UUID:
1319
field_length= field::Uuid::max_string_length();
1321
1173
case DRIZZLE_TYPE_NULL:
1322
1174
abort(); // Programming error
1325
assert(enum_field_types_size == 12);
1327
Field* f= make_field(record + field_offsets[fieldnr] + data_offset,
1329
pfield.constraints().is_nullable(),
1335
MTYP_TYPENR(unireg_type),
1336
((field_type == DRIZZLE_TYPE_ENUM) ? &intervals[interval_nr++] : (TYPELIB*) 0),
1337
getTableProto()->field(fieldnr).name().c_str());
1341
// Insert post make_field code here.
1344
case DRIZZLE_TYPE_BLOB:
1345
case DRIZZLE_TYPE_VARCHAR:
1346
case DRIZZLE_TYPE_DOUBLE:
1347
case DRIZZLE_TYPE_DECIMAL:
1348
case DRIZZLE_TYPE_TIMESTAMP:
1349
case DRIZZLE_TYPE_DATETIME:
1350
case DRIZZLE_TYPE_DATE:
1351
case DRIZZLE_TYPE_ENUM:
1352
case DRIZZLE_TYPE_LONG:
1353
case DRIZZLE_TYPE_LONGLONG:
1354
case DRIZZLE_TYPE_NULL:
1355
case DRIZZLE_TYPE_UUID:
1359
// This needs to go, we should be setting the "use" on the field so that
1360
// it does not reference the share/table.
1361
table::Shell temp_table(*this); /* Use this so that BLOB DEFAULT '' works */
1362
temp_table.in_use= &session;
1177
Field* f= share->make_field(record + field_offsets[fieldnr] + data_offset,
1179
pfield.constraints().is_nullable(),
1185
(Field::utype) MTYP_TYPENR(unireg_type),
1186
((field_type == DRIZZLE_TYPE_ENUM) ?
1187
share->intervals + (interval_nr++)
1189
getTableProto()->field(fieldnr).name().c_str());
1191
share->field[fieldnr]= f;
1364
1193
f->init(&temp_table); /* blob default values need table obj */
1555
1388
keyinfo->usable_key_parts= usable_parts; // Filesort
1557
set_if_bigger(max_key_length,keyinfo->key_length+
1390
set_if_bigger(share->max_key_length,keyinfo->key_length+
1558
1391
keyinfo->key_parts);
1559
total_key_length+= keyinfo->key_length;
1392
share->total_key_length+= keyinfo->key_length;
1561
1394
if (keyinfo->flags & HA_NOSAME)
1563
set_if_bigger(max_unique_length,keyinfo->key_length);
1396
set_if_bigger(share->max_unique_length,keyinfo->key_length);
1566
1399
if (local_primary_key < MAX_KEY &&
1567
(keys_in_use.test(local_primary_key)))
1400
(share->keys_in_use.test(local_primary_key)))
1569
primary_key= local_primary_key;
1402
share->primary_key= local_primary_key;
1571
1404
If we are using an integer as the primary key then allow the user to
1572
1405
refer to it as '_rowid'
1574
if (key_info[local_primary_key].key_parts == 1)
1407
if (share->key_info[local_primary_key].key_parts == 1)
1576
Field *local_field= key_info[local_primary_key].key_part[0].field;
1409
Field *local_field= share->key_info[local_primary_key].key_part[0].field;
1577
1410
if (local_field && local_field->result_type() == INT_RESULT)
1579
1412
/* note that fieldnr here (and rowid_field_offset) starts from 1 */
1580
rowid_field_offset= (key_info[local_primary_key].key_part[0].
1413
share->rowid_field_offset= (share->key_info[local_primary_key].key_part[0].
1420
share->primary_key = MAX_KEY; // we do not have a primary key
1425
share->primary_key= MAX_KEY;
1587
if (found_next_number_field)
1428
if (share->found_next_number_field)
1589
Field *reg_field= *found_next_number_field;
1590
if ((int) (next_number_index= (uint32_t)
1591
find_ref_key(key_info, keys,
1592
getDefaultValues(), reg_field,
1593
&next_number_key_offset,
1594
&next_number_keypart)) < 0)
1430
Field *reg_field= *share->found_next_number_field;
1431
if ((int) (share->next_number_index= (uint32_t)
1432
find_ref_key(share->key_info, share->keys,
1433
share->default_values, reg_field,
1434
&share->next_number_key_offset,
1435
&share->next_number_keypart)) < 0)
1596
1437
/* Wrong field definition */
1597
1438
local_error= 4;
1801
1635
if (records > 1)
1802
1636
outparam.record[1]= record+ rec_buff_length;
1804
outparam.record[1]= outparam.getInsertRecord(); // Safety
1638
outparam.record[1]= outparam.record[0]; // Safety
1807
#ifdef HAVE_VALGRIND
1809
1643
We need this because when we read var-length rows, we are not updating
1810
1644
bytes after end of varchar
1812
1646
if (records > 1)
1814
memcpy(outparam.getInsertRecord(), getDefaultValues(), rec_buff_length);
1815
memcpy(outparam.getUpdateRecord(), getDefaultValues(), null_bytes);
1648
memcpy(outparam.record[0], default_values, rec_buff_length);
1649
memcpy(outparam.record[1], default_values, null_bytes);
1816
1650
if (records > 2)
1817
memcpy(outparam.getUpdateRecord(), getDefaultValues(), rec_buff_length);
1651
memcpy(outparam.record[1], default_values, rec_buff_length);
1820
1654
if (records > 1)
1822
memcpy(outparam.getUpdateRecord(), getDefaultValues(), null_bytes);
1656
memcpy(outparam.record[1], default_values, null_bytes);
1825
1659
if (!(field_ptr = (Field **) outparam.alloc_root( (uint32_t) ((fields+1)* sizeof(Field*)))))
1830
outparam.setFields(field_ptr);
1664
outparam.field= field_ptr;
1832
record= (unsigned char*) outparam.getInsertRecord()-1; /* Fieldstart = 1 */
1666
record= (unsigned char*) outparam.record[0]-1; /* Fieldstart = 1 */
1834
1668
outparam.null_flags= (unsigned char*) record+1;
1895
1730
/* Allocate bitmaps */
1897
outparam.def_read_set.resize(fields);
1898
outparam.def_write_set.resize(fields);
1899
outparam.tmp_set.resize(fields);
1732
bitmap_size= column_bitmap_size;
1733
if (!(bitmaps= (unsigned char*) outparam.alloc_root(bitmap_size*3)))
1737
outparam.def_read_set.init((my_bitmap_map*) bitmaps, fields);
1738
outparam.def_write_set.init((my_bitmap_map*) (bitmaps+bitmap_size), fields);
1739
outparam.tmp_set.init((my_bitmap_map*) (bitmaps+bitmap_size*2), fields);
1900
1740
outparam.default_column_bitmaps();
1905
int TableShare::open_table_cursor_inner(const TableIdentifier &identifier,
1906
uint32_t db_stat, uint32_t ha_open_flags,
1908
bool &error_reported)
1910
1742
/* The table struct is now initialized; Open the table */
1914
assert(!(db_stat & HA_WAIT_IF_LOCKED));
1917
if ((ha_err= (outparam.cursor->ha_open(identifier,
1918
(db_stat & HA_READ_ONLY ? O_RDONLY : O_RDWR),
1919
(db_stat & HA_OPEN_TEMPORARY ? HA_OPEN_TMP_TABLE : HA_OPEN_IGNORE_IF_LOCKED) | ha_open_flags))))
1747
if ((ha_err= (outparam.cursor->
1748
ha_open(&outparam, getNormalizedPath(),
1749
(db_stat & HA_READ_ONLY ? O_RDONLY : O_RDWR),
1750
(db_stat & HA_OPEN_TEMPORARY ? HA_OPEN_TMP_TABLE :
1751
(db_stat & HA_WAIT_IF_LOCKED) ? HA_OPEN_WAIT_IF_LOCKED :
1752
(db_stat & (HA_ABORT_IF_LOCKED | HA_GET_INFO)) ?
1753
HA_OPEN_ABORT_IF_LOCKED :
1754
HA_OPEN_IGNORE_IF_LOCKED) | ha_open_flags))))
1921
1756
switch (ha_err)