152
152
elsewhere, and then assign a table map id inside open_table()
153
153
under the protection of the LOCK_open mutex.
155
share->table_map_id= UINT32_MAX;
155
share->table_map_id= ~0UL;
156
156
share->cached_row_logging_check= -1;
158
158
memcpy(&share->mem_root, &mem_root, sizeof(mem_root));
1386
1386
ha_open(outparam, share->normalized_path.str,
1387
1387
(db_stat & HA_READ_ONLY ? O_RDONLY : O_RDWR),
1388
1388
(db_stat & HA_OPEN_TEMPORARY ? HA_OPEN_TMP_TABLE :
1389
(db_stat & HA_WAIT_IF_LOCKED) ? HA_OPEN_WAIT_IF_LOCKED :
1389
((db_stat & HA_WAIT_IF_LOCKED) ||
1390
(specialflag & SPECIAL_WAIT_IF_LOCKED)) ?
1391
HA_OPEN_WAIT_IF_LOCKED :
1390
1392
(db_stat & (HA_ABORT_IF_LOCKED | HA_GET_INFO)) ?
1391
1393
HA_OPEN_ABORT_IF_LOCKED :
1392
1394
HA_OPEN_IGNORE_IF_LOCKED) | ha_open_flags))))
3104
size_t Table::max_row_length(const uchar *data)
3106
size_t max_row_length(Table *table, const uchar *data)
3106
size_t length= getRecordLength() + 2 * sizeFields();
3107
uint *const beg= getBlobField();
3108
uint *const end= beg + sizeBlobFields();
3108
size_t length= table->getRecordLength() + 2 * table->sizeFields();
3109
uint *const beg= table->getBlobField();
3110
uint *const end= beg + table->sizeBlobFields();
3110
3112
for (uint *ptr= beg ; ptr != end ; ++ptr)
3112
Field_blob* const blob= (Field_blob*) field[*ptr];
3114
Field_blob* const blob= (Field_blob*) table->field[*ptr];
3113
3115
length+= blob->get_length((const uchar*)
3114
(data + blob->offset(record[0]))) +
3116
(data + blob->offset(table->record[0]))) +
3115
3117
HA_KEY_BLOB_LENGTH;
3122
void Field_iterator_table::set(TableList *table)
3124
ptr= table->table->field;
3121
3129
Check type of .frm if we are not going to parse it
4567
4575
new_table.s->db_type())))
4568
4576
return(1); // End of memory
4570
save_proc_info=thd->get_proc_info();
4578
save_proc_info=thd->proc_info;
4571
4579
thd_proc_info(thd, "converting HEAP to MyISAM");
4573
4581
if (new_table.create_myisam_tmp_table(table->key_info, start_recinfo,
4655
my_bitmap_map *Table::use_all_columns(MY_BITMAP *bitmap)
4657
my_bitmap_map *old= bitmap->bitmap;
4658
bitmap->bitmap= s->all_set.bitmap;
4662
void Table::restore_column_map(my_bitmap_map *old)
4664
read_set->bitmap= old;
4667
uint Table::find_shortest_key(const key_map *usable_keys)
4669
uint32_t min_length= UINT32_MAX;
4670
uint32_t best= MAX_KEY;
4671
if (!usable_keys->is_clear_all())
4673
for (uint nr=0; nr < s->keys ; nr++)
4675
if (usable_keys->is_set(nr))
4677
if (key_info[nr].key_length < min_length)
4679
min_length= key_info[nr].key_length;
4688
/*****************************************************************************
4689
Remove duplicates from tmp table
4690
This should be recoded to add a unique index to the table and remove
4692
Table is a locked single thread table
4693
fields is the number of fields to check (from the end)
4694
*****************************************************************************/
4696
bool Table::compare_record(Field **ptr)
4698
for (; *ptr ; ptr++)
4700
if ((*ptr)->cmp_offset(s->rec_buff_length))
4706
/* Return false if row hasn't changed */
4708
bool Table::compare_record()
4710
if (s->blob_fields + s->varchar_fields == 0)
4711
return cmp_record(this, record[1]);
4712
/* Compare null bits */
4713
if (memcmp(null_flags,
4714
null_flags + s->rec_buff_length,
4716
return true; // Diff in NULL value
4717
/* Compare updated fields */
4718
for (Field **ptr= field ; *ptr ; ptr++)
4720
if (bitmap_is_set(write_set, (*ptr)->field_index) &&
4721
(*ptr)->cmp_binary_offset(s->rec_buff_length))
4731
/*****************************************************************************
4732
The different ways to read a record
4733
Returns -1 if row was not found, 0 if row was found and 1 on errors
4734
*****************************************************************************/
4736
/** Help function when we get some an error from the table handler. */
4738
int Table::report_error(int error)
4740
if (error == HA_ERR_END_OF_FILE || error == HA_ERR_KEY_NOT_FOUND)
4742
status= STATUS_GARBAGE;
4743
return -1; // key not found; ok
4746
Locking reads can legally return also these errors, do not
4747
print them to the .err log
4749
if (error != HA_ERR_LOCK_DEADLOCK && error != HA_ERR_LOCK_WAIT_TIMEOUT)
4750
sql_print_error(_("Got error %d when reading table '%s'"),
4751
error, s->path.str);
4752
file->print_error(error,MYF(0));
4758
4664
/*****************************************************************************
4759
4665
** Instansiate templates