Commit daca4887 authored by marko's avatar marko

branches/zip: Allow CREATE INDEX to be interrupted. (Issue #354)

rb://183 approved by Heikki Tuuri
parent cba4f2af
2009-11-12 The InnoDB Team
* handler/ha_innodb.cc, include/db0err.h,
row/row0merge.c, row/row0mysql.c:
Allow CREATE INDEX to be interrupted.
Also, when CHECK TABLE is interrupted, report ER_QUERY_INTERRUPTED.
2009-11-11 The InnoDB Team 2009-11-11 The InnoDB Team
* handler/ha_innodb.cc, mysql-test/innodb_bug47167.result, * handler/ha_innodb.cc, mysql-test/innodb_bug47167.result,
......
...@@ -785,6 +785,9 @@ convert_error_code_to_mysql( ...@@ -785,6 +785,9 @@ convert_error_code_to_mysql(
case DB_SUCCESS: case DB_SUCCESS:
return(0); return(0);
case DB_INTERRUPTED:
my_error(ER_QUERY_INTERRUPTED, MYF(0));
/* fall through */
case DB_ERROR: case DB_ERROR:
default: default:
return(-1); /* unspecified error */ return(-1); /* unspecified error */
...@@ -7361,11 +7364,15 @@ ha_innobase::check( ...@@ -7361,11 +7364,15 @@ ha_innobase::check(
ret = row_check_table_for_mysql(prebuilt); ret = row_check_table_for_mysql(prebuilt);
if (ret == DB_SUCCESS) { switch (ret) {
case DB_SUCCESS:
return(HA_ADMIN_OK); return(HA_ADMIN_OK);
} case DB_INTERRUPTED:
my_error(ER_QUERY_INTERRUPTED, MYF(0));
return(-1);
default:
return(HA_ADMIN_CORRUPT); return(HA_ADMIN_CORRUPT);
}
} }
/*************************************************************//** /*************************************************************//**
......
...@@ -32,6 +32,7 @@ enum db_err { ...@@ -32,6 +32,7 @@ enum db_err {
/* The following are error codes */ /* The following are error codes */
DB_ERROR, DB_ERROR,
DB_INTERRUPTED,
DB_OUT_OF_MEMORY, DB_OUT_OF_MEMORY,
DB_OUT_OF_FILE_SPACE, DB_OUT_OF_FILE_SPACE,
DB_LOCK_WAIT, DB_LOCK_WAIT,
......
...@@ -1200,6 +1200,12 @@ row_merge_read_clustered_index( ...@@ -1200,6 +1200,12 @@ row_merge_read_clustered_index(
in order to release the latch on the old page. */ in order to release the latch on the old page. */
if (btr_pcur_is_after_last_on_page(&pcur)) { if (btr_pcur_is_after_last_on_page(&pcur)) {
if (UNIV_UNLIKELY(trx_is_interrupted(trx))) {
i = 0;
err = DB_INTERRUPTED;
goto err_exit;
}
btr_pcur_store_position(&pcur, &mtr); btr_pcur_store_position(&pcur, &mtr);
mtr_commit(&mtr); mtr_commit(&mtr);
mtr_start(&mtr); mtr_start(&mtr);
...@@ -1557,6 +1563,7 @@ static __attribute__((nonnull)) ...@@ -1557,6 +1563,7 @@ static __attribute__((nonnull))
ulint ulint
row_merge( row_merge(
/*======*/ /*======*/
trx_t* trx, /*!< in: transaction */
const dict_index_t* index, /*!< in: index being created */ const dict_index_t* index, /*!< in: index being created */
merge_file_t* file, /*!< in/out: file containing merge_file_t* file, /*!< in/out: file containing
index entries */ index entries */
...@@ -1590,6 +1597,10 @@ row_merge( ...@@ -1590,6 +1597,10 @@ row_merge(
for (; foffs0 < ihalf && foffs1 < file->offset; foffs0++, foffs1++) { for (; foffs0 < ihalf && foffs1 < file->offset; foffs0++, foffs1++) {
ulint ahalf; /*!< arithmetic half the input file */ ulint ahalf; /*!< arithmetic half the input file */
if (UNIV_UNLIKELY(trx_is_interrupted(trx))) {
return(DB_INTERRUPTED);
}
error = row_merge_blocks(index, file, block, error = row_merge_blocks(index, file, block,
&foffs0, &foffs1, &of, table); &foffs0, &foffs1, &of, table);
...@@ -1617,6 +1628,10 @@ row_merge( ...@@ -1617,6 +1628,10 @@ row_merge(
/* Copy the last blocks, if there are any. */ /* Copy the last blocks, if there are any. */
while (foffs0 < ihalf) { while (foffs0 < ihalf) {
if (UNIV_UNLIKELY(trx_is_interrupted(trx))) {
return(DB_INTERRUPTED);
}
if (!row_merge_blocks_copy(index, file, block, &foffs0, &of)) { if (!row_merge_blocks_copy(index, file, block, &foffs0, &of)) {
return(DB_CORRUPTION); return(DB_CORRUPTION);
} }
...@@ -1625,6 +1640,10 @@ row_merge( ...@@ -1625,6 +1640,10 @@ row_merge(
ut_ad(foffs0 == ihalf); ut_ad(foffs0 == ihalf);
while (foffs1 < file->offset) { while (foffs1 < file->offset) {
if (UNIV_UNLIKELY(trx_is_interrupted(trx))) {
return(DB_INTERRUPTED);
}
if (!row_merge_blocks_copy(index, file, block, &foffs1, &of)) { if (!row_merge_blocks_copy(index, file, block, &foffs1, &of)) {
return(DB_CORRUPTION); return(DB_CORRUPTION);
} }
...@@ -1653,6 +1672,7 @@ static ...@@ -1653,6 +1672,7 @@ static
ulint ulint
row_merge_sort( row_merge_sort(
/*===========*/ /*===========*/
trx_t* trx, /*!< in: transaction */
const dict_index_t* index, /*!< in: index being created */ const dict_index_t* index, /*!< in: index being created */
merge_file_t* file, /*!< in/out: file containing merge_file_t* file, /*!< in/out: file containing
index entries */ index entries */
...@@ -1671,7 +1691,8 @@ row_merge_sort( ...@@ -1671,7 +1691,8 @@ row_merge_sort(
do { do {
ulint error; ulint error;
error = row_merge(index, file, &half, block, tmpfd, table); error = row_merge(trx, index, file, &half,
block, tmpfd, table);
if (error != DB_SUCCESS) { if (error != DB_SUCCESS) {
return(error); return(error);
...@@ -2490,7 +2511,7 @@ row_merge_build_indexes( ...@@ -2490,7 +2511,7 @@ row_merge_build_indexes(
sorting and inserting. */ sorting and inserting. */
for (i = 0; i < n_indexes; i++) { for (i = 0; i < n_indexes; i++) {
error = row_merge_sort(indexes[i], &merge_files[i], error = row_merge_sort(trx, indexes[i], &merge_files[i],
block, &tmpfd, table); block, &tmpfd, table);
if (error == DB_SUCCESS) { if (error == DB_SUCCESS) {
......
...@@ -4157,6 +4157,7 @@ row_check_table_for_mysql( ...@@ -4157,6 +4157,7 @@ row_check_table_for_mysql(
} }
if (trx_is_interrupted(prebuilt->trx)) { if (trx_is_interrupted(prebuilt->trx)) {
ret = DB_INTERRUPTED;
break; break;
} }
......
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