mirror of
https://github.com/MariaDB/server.git
synced 2025-12-03 05:41:09 +03:00
1.0.2 version imported
This commit is contained in:
100
row/row0mysql.c
100
row/row0mysql.c
@@ -625,6 +625,15 @@ row_create_prebuilt(
|
||||
|
||||
prebuilt->clust_ref = ref;
|
||||
|
||||
prebuilt->autoinc_error = 0;
|
||||
prebuilt->autoinc_offset = 0;
|
||||
|
||||
/* Default to 1, we will set the actual value later in
|
||||
ha_innobase::get_auto_increment(). */
|
||||
prebuilt->autoinc_increment = 1;
|
||||
|
||||
prebuilt->autoinc_last_value = 0;
|
||||
|
||||
return(prebuilt);
|
||||
}
|
||||
|
||||
@@ -843,19 +852,18 @@ row_update_statistics_if_needed(
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Unlocks an AUTO_INC type lock possibly reserved by trx. */
|
||||
Unlocks AUTO_INC type locks that were possibly reserved by a trx. */
|
||||
UNIV_INTERN
|
||||
void
|
||||
row_unlock_table_autoinc_for_mysql(
|
||||
/*===============================*/
|
||||
trx_t* trx) /* in: transaction */
|
||||
trx_t* trx) /* in/out: transaction */
|
||||
{
|
||||
if (!trx->auto_inc_lock) {
|
||||
mutex_enter(&kernel_mutex);
|
||||
|
||||
return;
|
||||
}
|
||||
lock_release_autoinc_locks(trx);
|
||||
|
||||
lock_table_unlock_auto_inc(trx);
|
||||
mutex_exit(&kernel_mutex);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
@@ -872,16 +880,20 @@ row_lock_table_autoinc_for_mysql(
|
||||
row_prebuilt_t* prebuilt) /* in: prebuilt struct in the MySQL
|
||||
table handle */
|
||||
{
|
||||
trx_t* trx = prebuilt->trx;
|
||||
ins_node_t* node = prebuilt->ins_node;
|
||||
que_thr_t* thr;
|
||||
ulint err;
|
||||
ibool was_lock_wait;
|
||||
trx_t* trx = prebuilt->trx;
|
||||
ins_node_t* node = prebuilt->ins_node;
|
||||
const dict_table_t* table = prebuilt->table;
|
||||
que_thr_t* thr;
|
||||
ulint err;
|
||||
ibool was_lock_wait;
|
||||
|
||||
ut_ad(trx);
|
||||
ut_ad(trx->mysql_thread_id == os_thread_get_curr_id());
|
||||
|
||||
if (trx->auto_inc_lock) {
|
||||
/* If we already hold an AUTOINC lock on the table then do nothing.
|
||||
Note: We peek at the value of the current owner without acquiring
|
||||
the kernel mutex. **/
|
||||
if (trx == table->autoinc_trx) {
|
||||
|
||||
return(DB_SUCCESS);
|
||||
}
|
||||
@@ -1701,7 +1713,8 @@ int
|
||||
row_create_table_for_mysql(
|
||||
/*=======================*/
|
||||
/* out: error code or DB_SUCCESS */
|
||||
dict_table_t* table, /* in: table definition */
|
||||
dict_table_t* table, /* in, own: table definition
|
||||
(will be freed) */
|
||||
trx_t* trx) /* in: transaction handle */
|
||||
{
|
||||
tab_node_t* node;
|
||||
@@ -1842,6 +1855,7 @@ err_exit:
|
||||
if (dict_table_get_low(table->name)) {
|
||||
|
||||
row_drop_table_for_mysql(table->name, trx, FALSE);
|
||||
trx_commit_for_mysql(trx);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1894,7 +1908,8 @@ int
|
||||
row_create_index_for_mysql(
|
||||
/*=======================*/
|
||||
/* out: error number or DB_SUCCESS */
|
||||
dict_index_t* index, /* in: index definition */
|
||||
dict_index_t* index, /* in, own: index definition
|
||||
(will be freed) */
|
||||
trx_t* trx, /* in: transaction handle */
|
||||
const ulint* field_lengths) /* in: if not NULL, must contain
|
||||
dict_index_get_n_fields(index)
|
||||
@@ -1999,6 +2014,8 @@ error_handling:
|
||||
|
||||
row_drop_table_for_mysql(table_name, trx, FALSE);
|
||||
|
||||
trx_commit_for_mysql(trx);
|
||||
|
||||
trx->error_state = DB_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -2066,6 +2083,8 @@ row_table_add_foreign_constraints(
|
||||
|
||||
row_drop_table_for_mysql(name, trx, FALSE);
|
||||
|
||||
trx_commit_for_mysql(trx);
|
||||
|
||||
trx->error_state = DB_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -2397,8 +2416,8 @@ row_discard_tablespace_for_mysql(
|
||||
|
||||
new_id = dict_hdr_get_new_id(DICT_HDR_TABLE_ID);
|
||||
|
||||
/* Remove any locks there are on the table or its records */
|
||||
lock_reset_all_on_table(table);
|
||||
/* Remove all locks except the table-level S and X locks. */
|
||||
lock_remove_all_on_table(table, FALSE);
|
||||
|
||||
info = pars_info_create();
|
||||
|
||||
@@ -2742,9 +2761,8 @@ row_truncate_table_for_mysql(
|
||||
goto funct_exit;
|
||||
}
|
||||
|
||||
/* Remove any locks there are on the table or its records */
|
||||
|
||||
lock_reset_all_on_table(table);
|
||||
/* Remove all locks except the table-level S and X locks. */
|
||||
lock_remove_all_on_table(table, FALSE);
|
||||
|
||||
trx->table_id = table->id;
|
||||
|
||||
@@ -2908,7 +2926,7 @@ next_rec:
|
||||
/* MySQL calls ha_innobase::reset_auto_increment() which does
|
||||
the same thing. */
|
||||
dict_table_autoinc_lock(table);
|
||||
dict_table_autoinc_initialize(table, 0);
|
||||
dict_table_autoinc_initialize(table, 1);
|
||||
dict_table_autoinc_unlock(table);
|
||||
dict_update_statistics(table);
|
||||
|
||||
@@ -2926,10 +2944,12 @@ funct_exit:
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Drops a table for MySQL. If the name of the dropped table ends in
|
||||
Drops a table for MySQL. If the name of the dropped table ends in
|
||||
one of "innodb_monitor", "innodb_lock_monitor", "innodb_tablespace_monitor",
|
||||
"innodb_table_monitor", then this will also stop the printing of monitor
|
||||
output by the master thread. */
|
||||
output by the master thread. If the data dictionary was not already locked
|
||||
by the transaction, the transaction will be committed. Otherwise, the
|
||||
data dictionary will remain locked. */
|
||||
UNIV_INTERN
|
||||
int
|
||||
row_drop_table_for_mysql(
|
||||
@@ -2938,29 +2958,6 @@ row_drop_table_for_mysql(
|
||||
const char* name, /* in: table name */
|
||||
trx_t* trx, /* in: transaction handle */
|
||||
ibool drop_db)/* in: TRUE=dropping whole database */
|
||||
{
|
||||
ulint err;
|
||||
|
||||
err = row_drop_table_for_mysql_no_commit(name, trx, drop_db);
|
||||
trx_commit_for_mysql(trx);
|
||||
|
||||
return(err);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Drops a table for MySQL but does not commit the transaction. If the
|
||||
name of the dropped table ends in one of "innodb_monitor",
|
||||
"innodb_lock_monitor", "innodb_tablespace_monitor",
|
||||
"innodb_table_monitor", then this will also stop the printing of
|
||||
monitor output by the master thread. */
|
||||
UNIV_INTERN
|
||||
int
|
||||
row_drop_table_for_mysql_no_commit(
|
||||
/*===============================*/
|
||||
/* out: error code or DB_SUCCESS */
|
||||
const char* name, /* in: table name */
|
||||
trx_t* trx, /* in: transaction handle */
|
||||
ibool drop_db)/* in: TRUE=dropping whole database */
|
||||
{
|
||||
dict_foreign_t* foreign;
|
||||
dict_table_t* table;
|
||||
@@ -3165,9 +3162,8 @@ check_next_foreign:
|
||||
goto funct_exit;
|
||||
}
|
||||
|
||||
/* Remove any locks there are on the table or its records */
|
||||
|
||||
lock_reset_all_on_table(table);
|
||||
/* Remove all locks there are on the table or its records */
|
||||
lock_remove_all_on_table(table, TRUE);
|
||||
|
||||
trx_set_dict_operation(trx, TRX_DICT_OP_TABLE);
|
||||
trx->table_id = table->id;
|
||||
@@ -3330,6 +3326,8 @@ check_next_foreign:
|
||||
funct_exit:
|
||||
|
||||
if (locked_dictionary) {
|
||||
trx_commit_for_mysql(trx);
|
||||
|
||||
row_mysql_unlock_data_dictionary(trx);
|
||||
}
|
||||
|
||||
@@ -3458,8 +3456,7 @@ loop:
|
||||
}
|
||||
|
||||
err = row_drop_table_for_mysql(table_name, trx, TRUE);
|
||||
|
||||
mem_free(table_name);
|
||||
trx_commit_for_mysql(trx);
|
||||
|
||||
if (err != DB_SUCCESS) {
|
||||
fputs("InnoDB: DROP DATABASE ", stderr);
|
||||
@@ -3468,8 +3465,11 @@ loop:
|
||||
(ulint) err);
|
||||
ut_print_name(stderr, trx, TRUE, table_name);
|
||||
putc('\n', stderr);
|
||||
mem_free(table_name);
|
||||
break;
|
||||
}
|
||||
|
||||
mem_free(table_name);
|
||||
}
|
||||
|
||||
if (err == DB_SUCCESS) {
|
||||
|
||||
Reference in New Issue
Block a user