368
374
HA_KEYSEG *t1_keysegs= t1_keyinfo[i].seg;
369
375
HA_KEYSEG *t2_keysegs= t2_keyinfo[i].seg;
376
if (t1_keyinfo[i].flag & HA_FULLTEXT && t2_keyinfo[i].flag & HA_FULLTEXT)
378
else if (t1_keyinfo[i].flag & HA_FULLTEXT ||
379
t2_keyinfo[i].flag & HA_FULLTEXT)
381
DBUG_PRINT("error", ("Key %d has different definition", i));
382
DBUG_PRINT("error", ("t1_fulltext= %d, t2_fulltext=%d",
383
test(t1_keyinfo[i].flag & HA_FULLTEXT),
384
test(t2_keyinfo[i].flag & HA_FULLTEXT)));
387
if (t1_keyinfo[i].flag & HA_SPATIAL && t2_keyinfo[i].flag & HA_SPATIAL)
389
else if (t1_keyinfo[i].flag & HA_SPATIAL ||
390
t2_keyinfo[i].flag & HA_SPATIAL)
392
DBUG_PRINT("error", ("Key %d has different definition", i));
393
DBUG_PRINT("error", ("t1_spatial= %d, t2_spatial=%d",
394
test(t1_keyinfo[i].flag & HA_SPATIAL),
395
test(t2_keyinfo[i].flag & HA_SPATIAL)));
370
398
if (t1_keyinfo[i].keysegs != t2_keyinfo[i].keysegs ||
371
399
t1_keyinfo[i].key_alg != t2_keyinfo[i].key_alg)
404
432
MI_COLUMNDEF *t1_rec= &t1_recinfo[i];
405
433
MI_COLUMNDEF *t2_rec= &t2_recinfo[i];
406
if (t1_rec->type != t2_rec->type ||
435
FIELD_SKIP_ZERO can be changed to FIELD_NORMAL in mi_create,
436
see NOTE1 in mi_create.c
438
if ((t1_rec->type != t2_rec->type &&
439
!(t1_rec->type == (int) FIELD_SKIP_ZERO &&
440
t1_rec->length == 1 &&
441
t2_rec->type == (int) FIELD_NORMAL)) ||
407
442
t1_rec->length != t2_rec->length ||
408
443
t1_rec->null_bit != t2_rec->null_bit)
933
int ha_myisam::repair(THD *thd, MI_CHECK ¶m, bool optimize)
968
int ha_myisam::repair(THD *thd, MI_CHECK ¶m, bool do_optimize)
936
971
uint local_testflag=param.testflag;
937
bool optimize_done= !optimize, statistics_done=0;
972
bool optimize_done= !do_optimize, statistics_done=0;
938
973
const char *old_proc_info=thd->proc_info;
939
974
char fixed_name[FN_REFLEN];
940
975
MYISAM_SHARE* share = file->s;
979
1014
/* TODO: respect myisam_repair_threads variable */
980
1015
my_snprintf(buf, 40, "Repair with %d threads", my_count_bits(key_map));
981
thd_proc_info(thd, buf);
982
1017
error = mi_repair_parallel(¶m, file, fixed_name,
983
1018
param.testflag & T_QUICK);
984
thd_proc_info(thd, "Repair done"); // to reset proc_info, as
1019
thd->proc_info="Repair done"; // to reset proc_info, as
985
1020
// it was pointing to local buffer
989
thd_proc_info(thd, "Repair by sorting");
1024
thd->proc_info="Repair by sorting";
990
1025
error = mi_repair_by_sort(¶m, file, fixed_name,
991
1026
param.testflag & T_QUICK);
996
thd_proc_info(thd, "Repair with keycache");
1031
thd->proc_info="Repair with keycache";
997
1032
param.testflag &= ~T_REP_BY_SORT;
998
1033
error= mi_repair(¶m, file, fixed_name,
999
1034
param.testflag & T_QUICK);
1015
1050
if (share->state.changed & STATE_NOT_ANALYZED)
1017
1052
optimize_done=1;
1018
thd_proc_info(thd, "Analyzing");
1053
thd->proc_info="Analyzing";
1019
1054
error = chk_key(¶m, file);
1022
1057
local_testflag&= ~T_STATISTICS; // Don't update statistics
1025
thd_proc_info(thd, "Saving state");
1060
thd->proc_info="Saving state";
1028
1063
if ((share->state.changed & STATE_CHANGED) || mi_is_crashed(file))
1594
1629
void ha_myisam::position(const byte* record)
1596
my_off_t position=mi_position(file);
1597
my_store_ptr(ref, ref_length, position);
1631
my_off_t row_position= mi_position(file);
1632
my_store_ptr(ref, ref_length, row_position);
1600
1635
int ha_myisam::info(uint flag)
1637
MI_ISAMINFO misam_info;
1603
1638
char name_buff[FN_REFLEN];
1605
(void) mi_status(file,&info,flag);
1640
(void) mi_status(file,&misam_info,flag);
1606
1641
if (flag & HA_STATUS_VARIABLE)
1608
records = info.records;
1609
deleted = info.deleted;
1610
data_file_length=info.data_file_length;
1611
index_file_length=info.index_file_length;
1612
delete_length = info.delete_length;
1613
check_time = info.check_time;
1614
mean_rec_length=info.mean_reclength;
1643
records= misam_info.records;
1644
deleted= misam_info.deleted;
1645
data_file_length= misam_info.data_file_length;
1646
index_file_length= misam_info.index_file_length;
1647
delete_length= misam_info.delete_length;
1648
check_time= misam_info.check_time;
1649
mean_rec_length= misam_info.mean_reclength;
1616
1651
if (flag & HA_STATUS_CONST)
1618
1653
TABLE_SHARE *share= table->s;
1619
max_data_file_length= info.max_data_file_length;
1620
max_index_file_length= info.max_index_file_length;
1621
create_time= info.create_time;
1622
sortkey= info.sortkey;
1623
ref_length= info.reflength;
1624
share->db_options_in_use= info.options;
1654
max_data_file_length= misam_info.max_data_file_length;
1655
max_index_file_length= misam_info.max_index_file_length;
1656
create_time= misam_info.create_time;
1657
sortkey= misam_info.sortkey;
1658
ref_length= misam_info.reflength;
1659
share->db_options_in_use= misam_info.options;
1625
1660
block_size= myisam_block_size;
1626
1661
share->keys_in_use.set_prefix(share->keys);
1627
share->keys_in_use.intersect_extended(info.key_map);
1662
share->keys_in_use.intersect_extended(misam_info.key_map);
1628
1663
share->keys_for_keyread.intersect(share->keys_in_use);
1629
share->db_record_offset= info.record_offset;
1664
share->db_record_offset= misam_info.record_offset;
1630
1665
if (share->key_parts)
1631
1666
memcpy((char*) table->key_info[0].rec_per_key,
1632
(char*) info.rec_per_key,
1667
(char*) misam_info.rec_per_key,
1633
1668
sizeof(table->key_info[0].rec_per_key)*share->key_parts);
1634
raid_type= info.raid_type;
1635
raid_chunks= info.raid_chunks;
1636
raid_chunksize= info.raid_chunksize;
1669
raid_type= misam_info.raid_type;
1670
raid_chunks= misam_info.raid_chunks;
1671
raid_chunksize= misam_info.raid_chunksize;
1639
1674
Set data_file_name and index_file_name to point at the symlink value
1642
1677
data_file_name=index_file_name=0;
1643
1678
fn_format(name_buff, file->filename, "", MI_NAME_DEXT, 2);
1644
if (strcmp(name_buff, info.data_file_name))
1645
data_file_name=info.data_file_name;
1679
if (strcmp(name_buff, misam_info.data_file_name))
1680
data_file_name= misam_info.data_file_name;
1646
1681
strmov(fn_ext(name_buff),MI_NAME_IEXT);
1647
if (strcmp(name_buff, info.index_file_name))
1648
index_file_name=info.index_file_name;
1682
if (strcmp(name_buff, misam_info.index_file_name))
1683
index_file_name= misam_info.index_file_name;
1650
1685
if (flag & HA_STATUS_ERRKEY)
1652
errkey = info.errkey;
1653
my_store_ptr(dupp_ref, ref_length, info.dupp_key_pos);
1687
errkey = misam_info.errkey;
1688
my_store_ptr(dupp_ref, ref_length, misam_info.dupp_key_pos);
1655
1690
if (flag & HA_STATUS_TIME)
1656
update_time = info.update_time;
1691
update_time = misam_info.update_time;
1657
1692
if (flag & HA_STATUS_AUTO)
1658
auto_increment_value= info.auto_increment;
1693
auto_increment_value= misam_info.auto_increment;
1742
1777
create_info.max_rows= share->max_rows;
1743
1778
create_info.reloc_rows= share->min_rows;
1744
1779
create_info.with_auto_increment= share->next_number_key_offset == 0;
1745
create_info.auto_increment= (info->auto_increment_value ?
1746
info->auto_increment_value -1 :
1780
create_info.auto_increment= (ha_create_info->auto_increment_value ?
1781
ha_create_info->auto_increment_value -1 :
1747
1782
(ulonglong) 0);
1748
1783
create_info.data_file_length= ((ulonglong) share->max_rows *
1749
1784
share->avg_row_length);
1750
create_info.raid_type= info->raid_type;
1751
create_info.raid_chunks= (info->raid_chunks ? info->raid_chunks :
1785
create_info.raid_type= ha_create_info->raid_type;
1786
create_info.raid_chunks= (ha_create_info->raid_chunks ?
1787
ha_create_info->raid_chunks :
1752
1788
RAID_DEFAULT_CHUNKS);
1753
create_info.raid_chunksize= (info->raid_chunksize ? info->raid_chunksize :
1789
create_info.raid_chunksize= (ha_create_info->raid_chunksize ?
1790
ha_create_info->raid_chunksize :
1754
1791
RAID_DEFAULT_CHUNKSIZE);
1755
create_info.data_file_name= info->data_file_name;
1756
create_info.index_file_name= info->index_file_name;
1792
create_info.data_file_name= ha_create_info->data_file_name;
1793
create_info.index_file_name= ha_create_info->index_file_name;
1758
if (info->options & HA_LEX_CREATE_TMP_TABLE)
1795
if (ha_create_info->options & HA_LEX_CREATE_TMP_TABLE)
1759
1796
create_flags|= HA_CREATE_TMP_TABLE;
1760
1797
if (options & HA_OPTION_PACK_RECORD)
1761
1798
create_flags|= HA_PACK_RECORD;