Commit 0ba8d3ef authored by heikki@donna.mysql.fi's avatar heikki@donna.mysql.fi

trx0trx.h Innobase now returns the key number in a duplicate key error,...

trx0trx.h	Innobase now returns the key number in a duplicate key error, removed innobase/include from make dirs
row0ins.c	Innobase now returns the key number in a duplicate key error, removed innobase/include from make dirs
row0mysql.c	Innobase now returns the key number in a duplicate key error, removed innobase/include from make dirs
row0mysql.h	Innobase now returns the key number in a duplicate key error, removed innobase/include from make dirs
ha_innobase.cc	Innobase now returns the key number in a duplicate key error, removed innobase/include from make dirs
parent 853a2f01
...@@ -170,6 +170,14 @@ row_table_got_default_clust_index( ...@@ -170,6 +170,14 @@ row_table_got_default_clust_index(
/*==============================*/ /*==============================*/
dict_table_t* table); dict_table_t* table);
/************************************************************************* /*************************************************************************
Calculates the key number used inside MySQL for an Innobase index. We have
to take into account if we generated a default clustered index for the table */
ulint
row_get_mysql_key_number_for_index(
/*===============================*/
dict_index_t* index);
/*************************************************************************
Does an update or delete of a row for MySQL. */ Does an update or delete of a row for MySQL. */
int int
......
...@@ -307,6 +307,9 @@ struct trx_struct{ ...@@ -307,6 +307,9 @@ struct trx_struct{
/*------------------------------*/ /*------------------------------*/
ulint error_state; /* 0 if no error, otherwise error ulint error_state; /* 0 if no error, otherwise error
number */ number */
void* error_info; /* if the error number indicates a
duplicate key error, a pointer to
the problematic index is stored here */
sess_t* sess; /* session of the trx, NULL if none */ sess_t* sess; /* session of the trx, NULL if none */
ulint que_state; /* TRX_QUE_RUNNING, TRX_QUE_LOCK_WAIT, ulint que_state; /* TRX_QUE_RUNNING, TRX_QUE_LOCK_WAIT,
... */ ... */
......
...@@ -407,6 +407,7 @@ row_ins_scan_sec_index_for_duplicate( ...@@ -407,6 +407,7 @@ row_ins_scan_sec_index_for_duplicate(
ut_a(dupl_count >= 1); ut_a(dupl_count >= 1);
if (dupl_count > 1) { if (dupl_count > 1) {
trx->error_info = index;
return(DB_DUPLICATE_KEY); return(DB_DUPLICATE_KEY);
} }
...@@ -468,6 +469,7 @@ row_ins_duplicate_error( ...@@ -468,6 +469,7 @@ row_ins_duplicate_error(
if (row_ins_dupl_error_with_rec(rec, entry, if (row_ins_dupl_error_with_rec(rec, entry,
cursor->index, trx)) { cursor->index, trx)) {
*dupl_rec = rec; *dupl_rec = rec;
trx->error_info = cursor->index;
return(DB_DUPLICATE_KEY); return(DB_DUPLICATE_KEY);
} }
...@@ -484,6 +486,7 @@ row_ins_duplicate_error( ...@@ -484,6 +486,7 @@ row_ins_duplicate_error(
if (row_ins_dupl_error_with_rec(rec, entry, if (row_ins_dupl_error_with_rec(rec, entry,
cursor->index, trx)) { cursor->index, trx)) {
*dupl_rec = rec; *dupl_rec = rec;
trx->error_info = cursor->index;
return(DB_DUPLICATE_KEY); return(DB_DUPLICATE_KEY);
} }
......
...@@ -761,6 +761,36 @@ row_table_got_default_clust_index( ...@@ -761,6 +761,36 @@ row_table_got_default_clust_index(
return(FALSE); return(FALSE);
} }
/*************************************************************************
Calculates the key number used inside MySQL for an Innobase index. We have
to take into account if we generated a default clustered index for the table */
ulint
row_get_mysql_key_number_for_index(
/*===============================*/
dict_index_t* index)
{
dict_index_t* ind;
ulint i;
ut_a(index);
i = 0;
ind = dict_table_get_first_index(index->table);
while (index != ind) {
ind = dict_table_get_next_index(ind);
i++;
}
if (row_table_got_default_clust_index(index->table)) {
ut_a(i > 0);
i--;
}
return(i);
}
/************************************************************************* /*************************************************************************
Does a table creation operation for MySQL. */ Does a table creation operation for MySQL. */
......
...@@ -18,12 +18,6 @@ ...@@ -18,12 +18,6 @@
Innobase */ Innobase */
/* TODO list for the Innobase handler: /* TODO list for the Innobase handler:
- How to check for deadlocks if Innobase tables are used alongside
other MySQL table types? Solution: we will use a timeout.
- Innobase currently includes the path to a table name: the path should
actually be dropped off, because we may move a whole database to a new
directory.
- Add a deadlock error message to MySQL.
- Ask Monty if strings of different languages can exist in the same - Ask Monty if strings of different languages can exist in the same
database. Answer: in near future yes, but not yet. database. Answer: in near future yes, but not yet.
*/ */
...@@ -415,10 +409,10 @@ innobase_init(void) ...@@ -415,10 +409,10 @@ innobase_init(void)
/*===============*/ /*===============*/
/* out: TRUE if error */ /* out: TRUE if error */
{ {
static char current_dir[3];
int err; int err;
bool ret; bool ret;
ibool test_bool;
static char current_dir[3];
DBUG_ENTER("innobase_init"); DBUG_ENTER("innobase_init");
/* Use current_dir if no paths are set */ /* Use current_dir if no paths are set */
...@@ -1659,7 +1653,7 @@ ha_innobase::change_active_index( ...@@ -1659,7 +1653,7 @@ ha_innobase::change_active_index(
statistic_increment(ha_read_key_count, &LOCK_status); statistic_increment(ha_read_key_count, &LOCK_status);
DBUG_ENTER("ha_innobase::change_active_index"); DBUG_ENTER("index_read_idx");
active_index = keynr; active_index = keynr;
...@@ -1685,7 +1679,7 @@ ha_innobase::change_active_index( ...@@ -1685,7 +1679,7 @@ ha_innobase::change_active_index(
build_template(prebuilt, user_thd, table, ROW_MYSQL_WHOLE_ROW); build_template(prebuilt, user_thd, table, ROW_MYSQL_WHOLE_ROW);
DBUG_RETURN(0); return(0);
} }
/************************************************************************** /**************************************************************************
...@@ -2219,7 +2213,6 @@ ha_innobase::create( ...@@ -2219,7 +2213,6 @@ ha_innobase::create(
{ {
int error; int error;
dict_table_t* innobase_table; dict_table_t* innobase_table;
uint name_len;
trx_t* trx; trx_t* trx;
int primary_key_no = -1; int primary_key_no = -1;
KEY* key; KEY* key;
...@@ -2237,7 +2230,7 @@ ha_innobase::create( ...@@ -2237,7 +2230,7 @@ ha_innobase::create(
/* Create the table definition in Innobase */ /* Create the table definition in Innobase */
if ((error = create_table_def(trx, form, norm_name))) { if (error = create_table_def(trx, form, norm_name)) {
trx_commit_for_mysql(trx); trx_commit_for_mysql(trx);
...@@ -2256,6 +2249,11 @@ ha_innobase::create( ...@@ -2256,6 +2249,11 @@ ha_innobase::create(
} }
} }
/* Our function row_get_mysql_key_number_for_index assumes
the primary key is always number 0, if it exists */
assert(primary_key_no == -1 || primary_key_no == 0);
/* Create the keys */ /* Create the keys */
if (form->keys == 0 || primary_key_no == -1) { if (form->keys == 0 || primary_key_no == -1) {
...@@ -2569,9 +2567,9 @@ ha_innobase::info( ...@@ -2569,9 +2567,9 @@ ha_innobase::info(
} }
if (flag & HA_STATUS_ERRKEY) { if (flag & HA_STATUS_ERRKEY) {
errkey = (unsigned int) row_get_mysql_key_number_for_index(
errkey = (unsigned int)-1; /* TODO: get the key number from (dict_index_t*)
Innobase */ prebuilt->trx->error_info);
} }
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
......
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