Commit 082b859d authored by Jan Lindström's avatar Jan Lindström

MDEV-9233: Copying MySQL 5.5 data directory to 10.0 with partition tables crashes on insert

Analysis: There were two problems. (1) if partition table was
created using lower_case_tables = 1 on windows we did find the
correct table but we did not set share->ib_table correctly.
(2) we did open table on dictionary but did not increase
mysql_open_tables.

Fix: In xtradb allow access to tables with incorrect
lower case names (warning is printed to error log). If
table is opened increase mysql_open_tables count to avoid
crash on flush tables.
parent d87bc55b
...@@ -4053,7 +4053,7 @@ ha_innobase::open( ...@@ -4053,7 +4053,7 @@ ha_innobase::open(
} }
ib_table = dict_table_get( ib_table = dict_table_get(
par_case_name, FALSE, ignore_err); par_case_name, TRUE, ignore_err);
} }
if (ib_table) { if (ib_table) {
#ifndef __WIN__ #ifndef __WIN__
......
...@@ -4692,7 +4692,8 @@ ha_innobase::open( ...@@ -4692,7 +4692,8 @@ ha_innobase::open(
DBUG_RETURN(1); DBUG_RETURN(1);
} }
if (UNIV_UNLIKELY(share->ib_table && share->ib_table->is_corrupt && if (UNIV_UNLIKELY(share->ib_table &&
share->ib_table->is_corrupt &&
srv_pass_corrupt_table <= 1)) { srv_pass_corrupt_table <= 1)) {
free_share(share); free_share(share);
...@@ -4721,7 +4722,8 @@ ha_innobase::open( ...@@ -4721,7 +4722,8 @@ ha_innobase::open(
/* Get pointer to a table object in InnoDB dictionary cache */ /* Get pointer to a table object in InnoDB dictionary cache */
ib_table = dict_table_get(norm_name, TRUE, ignore_err); ib_table = dict_table_get(norm_name, TRUE, ignore_err);
if (UNIV_UNLIKELY(ib_table && ib_table->is_corrupt && if (UNIV_UNLIKELY(ib_table &&
ib_table->is_corrupt &&
srv_pass_corrupt_table <= 1)) { srv_pass_corrupt_table <= 1)) {
free_share(share); free_share(share);
my_free(upd_buf); my_free(upd_buf);
...@@ -4775,8 +4777,9 @@ ha_innobase::open( ...@@ -4775,8 +4777,9 @@ ha_innobase::open(
} }
ib_table = dict_table_get( ib_table = dict_table_get(
par_case_name, FALSE, ignore_err); par_case_name, TRUE, ignore_err);
} }
if (ib_table) { if (ib_table) {
#ifndef __WIN__ #ifndef __WIN__
sql_print_warning("Partition table %s opened " sql_print_warning("Partition table %s opened "
...@@ -4798,6 +4801,10 @@ ha_innobase::open( ...@@ -4798,6 +4801,10 @@ ha_innobase::open(
"current file system\n", "current file system\n",
norm_name); norm_name);
#endif #endif
/* We allow use of table if it is found.
this is consistent to current behavior
to innodb_plugin */
share->ib_table = ib_table;
goto table_opened; goto table_opened;
} }
} }
...@@ -6190,7 +6197,7 @@ ha_innobase::write_row( ...@@ -6190,7 +6197,7 @@ ha_innobase::write_row(
ha_statistic_increment(&SSV::ha_write_count); ha_statistic_increment(&SSV::ha_write_count);
if (share->ib_table->is_corrupt) { if (!share->ib_table || share->ib_table->is_corrupt) {
DBUG_RETURN(HA_ERR_CRASHED); DBUG_RETURN(HA_ERR_CRASHED);
} }
...@@ -6416,7 +6423,7 @@ report_error: ...@@ -6416,7 +6423,7 @@ report_error:
func_exit: func_exit:
innobase_active_small(); innobase_active_small();
if (share->ib_table->is_corrupt) { if (!share->ib_table || share->ib_table->is_corrupt) {
DBUG_RETURN(HA_ERR_CRASHED); DBUG_RETURN(HA_ERR_CRASHED);
} }
...@@ -6618,7 +6625,7 @@ ha_innobase::update_row( ...@@ -6618,7 +6625,7 @@ ha_innobase::update_row(
ha_statistic_increment(&SSV::ha_update_count); ha_statistic_increment(&SSV::ha_update_count);
if (share->ib_table->is_corrupt) { if (!share->ib_table || share->ib_table->is_corrupt) {
DBUG_RETURN(HA_ERR_CRASHED); DBUG_RETURN(HA_ERR_CRASHED);
} }
...@@ -6711,7 +6718,7 @@ ha_innobase::update_row( ...@@ -6711,7 +6718,7 @@ ha_innobase::update_row(
innobase_active_small(); innobase_active_small();
if (share->ib_table->is_corrupt) { if (!share->ib_table || share->ib_table->is_corrupt) {
DBUG_RETURN(HA_ERR_CRASHED); DBUG_RETURN(HA_ERR_CRASHED);
} }
...@@ -6736,7 +6743,7 @@ ha_innobase::delete_row( ...@@ -6736,7 +6743,7 @@ ha_innobase::delete_row(
ha_statistic_increment(&SSV::ha_delete_count); ha_statistic_increment(&SSV::ha_delete_count);
if (share->ib_table->is_corrupt) { if (!share->ib_table || share->ib_table->is_corrupt) {
DBUG_RETURN(HA_ERR_CRASHED); DBUG_RETURN(HA_ERR_CRASHED);
} }
...@@ -6768,7 +6775,7 @@ ha_innobase::delete_row( ...@@ -6768,7 +6775,7 @@ ha_innobase::delete_row(
innobase_active_small(); innobase_active_small();
if (share->ib_table->is_corrupt) { if (!share->ib_table || share->ib_table->is_corrupt) {
DBUG_RETURN(HA_ERR_CRASHED); DBUG_RETURN(HA_ERR_CRASHED);
} }
...@@ -7017,8 +7024,10 @@ ha_innobase::index_read( ...@@ -7017,8 +7024,10 @@ ha_innobase::index_read(
ha_statistic_increment(&SSV::ha_read_key_count); ha_statistic_increment(&SSV::ha_read_key_count);
if (UNIV_UNLIKELY(share->ib_table->is_corrupt && if (UNIV_UNLIKELY(!share->ib_table ||
srv_pass_corrupt_table <= 1)) { (share->ib_table &&
share->ib_table->is_corrupt &&
srv_pass_corrupt_table <= 1))) {
DBUG_RETURN(HA_ERR_CRASHED); DBUG_RETURN(HA_ERR_CRASHED);
} }
...@@ -7089,8 +7098,10 @@ ha_innobase::index_read( ...@@ -7089,8 +7098,10 @@ ha_innobase::index_read(
ret = DB_UNSUPPORTED; ret = DB_UNSUPPORTED;
} }
if (UNIV_UNLIKELY(share->ib_table->is_corrupt && if (UNIV_UNLIKELY(!share->ib_table ||
srv_pass_corrupt_table <= 1)) { (share->ib_table &&
share->ib_table->is_corrupt &&
srv_pass_corrupt_table <= 1))) {
DBUG_RETURN(HA_ERR_CRASHED); DBUG_RETURN(HA_ERR_CRASHED);
} }
...@@ -7208,8 +7219,10 @@ ha_innobase::change_active_index( ...@@ -7208,8 +7219,10 @@ ha_innobase::change_active_index(
{ {
DBUG_ENTER("change_active_index"); DBUG_ENTER("change_active_index");
if (UNIV_UNLIKELY(share->ib_table->is_corrupt && if (UNIV_UNLIKELY(!share->ib_table ||
srv_pass_corrupt_table <= 1)) { (share->ib_table &&
share->ib_table->is_corrupt &&
srv_pass_corrupt_table <= 1))) {
DBUG_RETURN(HA_ERR_CRASHED); DBUG_RETURN(HA_ERR_CRASHED);
} }
...@@ -7332,8 +7345,10 @@ ha_innobase::general_fetch( ...@@ -7332,8 +7345,10 @@ ha_innobase::general_fetch(
DBUG_RETURN(HA_ERR_END_OF_FILE); DBUG_RETURN(HA_ERR_END_OF_FILE);
} }
if (UNIV_UNLIKELY(share->ib_table->is_corrupt && if (UNIV_UNLIKELY(!share->ib_table ||
srv_pass_corrupt_table <= 1)) { (share->ib_table &&
share->ib_table->is_corrupt &&
srv_pass_corrupt_table <= 1))) {
DBUG_RETURN(HA_ERR_CRASHED); DBUG_RETURN(HA_ERR_CRASHED);
} }
...@@ -7346,8 +7361,10 @@ ha_innobase::general_fetch( ...@@ -7346,8 +7361,10 @@ ha_innobase::general_fetch(
innodb_srv_conc_exit_innodb(prebuilt->trx); innodb_srv_conc_exit_innodb(prebuilt->trx);
if (UNIV_UNLIKELY(share->ib_table->is_corrupt && if (UNIV_UNLIKELY(!share->ib_table ||
srv_pass_corrupt_table <= 1)) { (share->ib_table &&
share->ib_table->is_corrupt &&
srv_pass_corrupt_table <= 1))) {
DBUG_RETURN(HA_ERR_CRASHED); DBUG_RETURN(HA_ERR_CRASHED);
} }
...@@ -8628,7 +8645,7 @@ ha_innobase::truncate(void) ...@@ -8628,7 +8645,7 @@ ha_innobase::truncate(void)
update_thd(ha_thd()); update_thd(ha_thd());
if (share->ib_table->is_corrupt) { if (!share->ib_table || share->ib_table->is_corrupt) {
DBUG_RETURN(HA_ERR_CRASHED); DBUG_RETURN(HA_ERR_CRASHED);
} }
...@@ -8640,7 +8657,7 @@ ha_innobase::truncate(void) ...@@ -8640,7 +8657,7 @@ ha_innobase::truncate(void)
error = row_truncate_table_for_mysql(prebuilt->table, prebuilt->trx); error = row_truncate_table_for_mysql(prebuilt->table, prebuilt->trx);
if (share->ib_table->is_corrupt) { if (!share->ib_table || share->ib_table->is_corrupt) {
DBUG_RETURN(HA_ERR_CRASHED); DBUG_RETURN(HA_ERR_CRASHED);
} }
...@@ -9365,7 +9382,8 @@ ha_innobase::info_low( ...@@ -9365,7 +9382,8 @@ ha_innobase::info_low(
ib_table = prebuilt->table; ib_table = prebuilt->table;
if (flag & HA_STATUS_TIME) { if (flag & HA_STATUS_TIME) {
if ((called_from_analyze || innobase_stats_on_metadata) && !share->ib_table->is_corrupt) { if ((called_from_analyze || innobase_stats_on_metadata) &&
share->ib_table && !share->ib_table->is_corrupt) {
/* In sql_show we call with this flag: update /* In sql_show we call with this flag: update
then statistics so that they are up-to-date */ then statistics so that they are up-to-date */
...@@ -9719,7 +9737,7 @@ ha_innobase::analyze( ...@@ -9719,7 +9737,7 @@ ha_innobase::analyze(
THD* thd, /*!< in: connection thread handle */ THD* thd, /*!< in: connection thread handle */
HA_CHECK_OPT* check_opt) /*!< in: currently ignored */ HA_CHECK_OPT* check_opt) /*!< in: currently ignored */
{ {
if (share->ib_table->is_corrupt) { if (!share->ib_table || share->ib_table->is_corrupt) {
return(HA_ADMIN_CORRUPT); return(HA_ADMIN_CORRUPT);
} }
...@@ -9727,7 +9745,7 @@ ha_innobase::analyze( ...@@ -9727,7 +9745,7 @@ ha_innobase::analyze(
info_low(HA_STATUS_TIME | HA_STATUS_CONST | HA_STATUS_VARIABLE, info_low(HA_STATUS_TIME | HA_STATUS_CONST | HA_STATUS_VARIABLE,
true /* called from analyze */); true /* called from analyze */);
if (share->ib_table->is_corrupt) { if (!share->ib_table || share->ib_table->is_corrupt) {
return(HA_ADMIN_CORRUPT); return(HA_ADMIN_CORRUPT);
} }
...@@ -9980,7 +9998,7 @@ ha_innobase::check( ...@@ -9980,7 +9998,7 @@ ha_innobase::check(
my_error(ER_QUERY_INTERRUPTED, MYF(0)); my_error(ER_QUERY_INTERRUPTED, MYF(0));
} }
if (share->ib_table->is_corrupt) { if (!share->ib_table || share->ib_table->is_corrupt) {
return(HA_ADMIN_CORRUPT); return(HA_ADMIN_CORRUPT);
} }
...@@ -10783,7 +10801,7 @@ ha_innobase::transactional_table_lock( ...@@ -10783,7 +10801,7 @@ ha_innobase::transactional_table_lock(
update_thd(thd); update_thd(thd);
if (share->ib_table->is_corrupt) { if (!share->ib_table || share->ib_table->is_corrupt) {
DBUG_RETURN(HA_ERR_CRASHED); DBUG_RETURN(HA_ERR_CRASHED);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment