summaryrefslogtreecommitdiff
path: root/innobase/row
diff options
context:
space:
mode:
authorheikki@hundin.mysql.fi <>2002-12-05 22:03:24 +0200
committerheikki@hundin.mysql.fi <>2002-12-05 22:03:24 +0200
commit5c3c4d3721fbc2630e9d70c4a9e35246855eef8a (patch)
treef45e33c419fff3114e499f1a661e8e737301a675 /innobase/row
parent7b58a93a997c247ccdac24d491dee965ad13477d (diff)
downloadmariadb-git-5c3c4d3721fbc2630e9d70c4a9e35246855eef8a.tar.gz
row0mysql.c, dict0dict.c, db0err.h, ha_innobase.cc:
Heikki will merge to 4.0: Prevent listing the same column twice in an InnoDB index: that will cause index corruption when that col is UPDATEd
Diffstat (limited to 'innobase/row')
-rw-r--r--innobase/row/row0mysql.c40
1 files changed, 33 insertions, 7 deletions
diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c
index 705ded785fc..325e931b455 100644
--- a/innobase/row/row0mysql.c
+++ b/innobase/row/row0mysql.c
@@ -1393,7 +1393,7 @@ int
row_create_index_for_mysql(
/*=======================*/
/* out: error number or DB_SUCCESS */
- dict_index_t* index, /* in: index defintion */
+ dict_index_t* index, /* in: index definition */
trx_t* trx) /* in: transaction handle */
{
ind_node_t* node;
@@ -1402,11 +1402,14 @@ row_create_index_for_mysql(
ulint namelen;
ulint keywordlen;
ulint err;
+ ulint i;
+ ulint j;
+ ut_ad(rw_lock_own(&dict_operation_lock, RW_LOCK_EX));
ut_ad(mutex_own(&(dict_sys->mutex)));
ut_ad(trx->mysql_thread_id == os_thread_get_curr_id());
- trx->op_info = "creating index";
+ trx->op_info = (char *) "creating index";
trx_start_if_not_started(trx);
@@ -1422,6 +1425,29 @@ row_create_index_for_mysql(
return(DB_SUCCESS);
}
+ /* Check that the same column does not appear twice in the index.
+ InnoDB assumes this in its algorithms, e.g., update of an index
+ entry */
+
+ for (i = 0; i < dict_index_get_n_fields(index); i++) {
+ for (j = 0; j < i; j++) {
+ if (0 == ut_strcmp(
+ dict_index_get_nth_field(index, j)->name,
+ dict_index_get_nth_field(index, i)->name)) {
+
+ fprintf(stderr,
+"InnoDB: Error: column %s appears twice in index %s\n"
+"InnoDB: This is not allowed in InnoDB.\n",
+ dict_index_get_nth_field(index, i)->name,
+ index->name);
+
+ err = DB_COL_APPEARS_TWICE_IN_INDEX;
+
+ goto error_handling;
+ }
+ }
+ }
+
heap = mem_heap_create(512);
trx->dict_operation = TRUE;
@@ -1434,11 +1460,13 @@ row_create_index_for_mysql(
SESS_COMM_EXECUTE, 0));
que_run_threads(thr);
- err = trx->error_state;
+ err = trx->error_state;
+
+ que_graph_free((que_t*) que_node_get_parent(thr));
+error_handling:
if (err != DB_SUCCESS) {
/* We have special error handling here */
- ut_a(err == DB_OUT_OF_FILE_SPACE);
trx->error_state = DB_SUCCESS;
@@ -1448,10 +1476,8 @@ row_create_index_for_mysql(
trx->error_state = DB_SUCCESS;
}
-
- que_graph_free((que_t*) que_node_get_parent(thr));
- trx->op_info = "";
+ trx->op_info = (char *) "";
return((int) err);
}