Commit ce82592e authored by sunny's avatar sunny

branches/5.1: Undo the change from r6424. We need to return DB_SUCCESS even

if we were unable to initialize the tabe autoinc value. This is required for
the open to succeed. The only condition we currently treat as a hard error
is if the autoinc field instance passed in by MySQL is NULL.

Previously if the table autoinc value was 0 and the next value was requested
we had an assertion that would fail. Change that assertion and treat a value
of 0 to mean that the autoinc system is unavailable. Generation of next
value will now return failure.

rb://237
parent 3e04d74c
...@@ -2652,9 +2652,9 @@ ha_innobase::innobase_initialize_autoinc() ...@@ -2652,9 +2652,9 @@ ha_innobase::innobase_initialize_autoinc()
auto_inc = innobase_get_int_col_max_value(field); auto_inc = innobase_get_int_col_max_value(field);
} else { } else {
/* We have no idea what's been passed in to us as the /* We have no idea what's been passed in to us as the
autoinc column. We set it to the MAX_INT of our table autoinc column. We set it to the 0, effectively disabling
autoinc type. */ updates to the table. */
auto_inc = 0xFFFFFFFFFFFFFFFFULL; auto_inc = 0;
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, " InnoDB: Unable to determine the AUTOINC " fprintf(stderr, " InnoDB: Unable to determine the AUTOINC "
...@@ -2663,7 +2663,7 @@ ha_innobase::innobase_initialize_autoinc() ...@@ -2663,7 +2663,7 @@ ha_innobase::innobase_initialize_autoinc()
if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) { if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) {
/* If the recovery level is set so high that writes /* If the recovery level is set so high that writes
are disabled we force the AUTOINC counter to the MAX are disabled we force the AUTOINC counter to 0
value effectively disabling writes to the table. value effectively disabling writes to the table.
Secondly, we avoid reading the table in case the read Secondly, we avoid reading the table in case the read
results in failure due to a corrupted table/index. results in failure due to a corrupted table/index.
...@@ -2672,7 +2672,10 @@ ha_innobase::innobase_initialize_autoinc() ...@@ -2672,7 +2672,10 @@ ha_innobase::innobase_initialize_autoinc()
tables can be dumped with minimal hassle. If an error tables can be dumped with minimal hassle. If an error
were returned in this case, the first attempt to read were returned in this case, the first attempt to read
the table would fail and subsequent SELECTs would succeed. */ the table would fail and subsequent SELECTs would succeed. */
auto_inc = 0;
} else if (field == NULL) { } else if (field == NULL) {
/* This is a far more serious error, best to avoid
opening the table and return failure. */
my_error(ER_AUTOINC_READ_FAILED, MYF(0)); my_error(ER_AUTOINC_READ_FAILED, MYF(0));
} else { } else {
dict_index_t* index; dict_index_t* index;
...@@ -2701,7 +2704,7 @@ ha_innobase::innobase_initialize_autoinc() ...@@ -2701,7 +2704,7 @@ ha_innobase::innobase_initialize_autoinc()
"InnoDB: Unable to find the AUTOINC column " "InnoDB: Unable to find the AUTOINC column "
"%s in the InnoDB table %s.\n" "%s in the InnoDB table %s.\n"
"InnoDB: We set the next AUTOINC column " "InnoDB: We set the next AUTOINC column "
"value to the maximum possible value,\n" "value to 0,\n"
"InnoDB: in effect disabling the AUTOINC " "InnoDB: in effect disabling the AUTOINC "
"next value generation.\n" "next value generation.\n"
"InnoDB: You can either set the next " "InnoDB: You can either set the next "
...@@ -2710,7 +2713,13 @@ ha_innobase::innobase_initialize_autoinc() ...@@ -2710,7 +2713,13 @@ ha_innobase::innobase_initialize_autoinc()
"recreating the table.\n", "recreating the table.\n",
col_name, index->table->name); col_name, index->table->name);
my_error(ER_AUTOINC_READ_FAILED, MYF(0)); /* This will disable the AUTOINC generation. */
auto_inc = 0;
/* We want the open to succeed, so that the user can
take corrective action. ie. reads should succeed but
updates should fail. */
err = DB_SUCCESS;
break; break;
default: default:
/* row_search_max_autoinc() should only return /* row_search_max_autoinc() should only return
...@@ -3968,11 +3977,17 @@ ha_innobase::write_row( ...@@ -3968,11 +3977,17 @@ ha_innobase::write_row(
prebuilt->autoinc_error = DB_SUCCESS; prebuilt->autoinc_error = DB_SUCCESS;
if ((error = update_auto_increment())) { if ((error = update_auto_increment())) {
/* We don't want to mask autoinc overflow errors. */ /* We don't want to mask autoinc overflow errors. */
if (prebuilt->autoinc_error != DB_SUCCESS) {
error = (int) prebuilt->autoinc_error;
/* Handle the case where the AUTOINC sub-system
failed during initialization. */
if (prebuilt->autoinc_error == DB_UNSUPPORTED) {
error_result = ER_AUTOINC_READ_FAILED;
/* Set the error message to report too. */
my_error(ER_AUTOINC_READ_FAILED, MYF(0));
goto func_exit;
} else if (prebuilt->autoinc_error != DB_SUCCESS) {
error = (int) prebuilt->autoinc_error;
goto report_error; goto report_error;
} }
...@@ -7883,7 +7898,10 @@ ha_innobase::innobase_get_autoinc( ...@@ -7883,7 +7898,10 @@ ha_innobase::innobase_get_autoinc(
*value = dict_table_autoinc_read(prebuilt->table); *value = dict_table_autoinc_read(prebuilt->table);
/* It should have been initialized during open. */ /* It should have been initialized during open. */
ut_a(*value != 0); if (*value == 0) {
prebuilt->autoinc_error = DB_UNSUPPORTED;
dict_table_autoinc_unlock(prebuilt->table);
}
} }
return(ulong(prebuilt->autoinc_error)); return(ulong(prebuilt->autoinc_error));
......
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