Commit 4ffeba76 authored by tsmith@siva.hindu.god's avatar tsmith@siva.hindu.god

Applied innodb-5.1-ss1381 snapshot

Bug #27381: InnoDB exits when attempting to rename table to non-existant database
  Fix Bug#27381 by calling os_file_handle_error_no_exit() instead of
  os_file_handle_error().
parent 16640ef3
......@@ -1810,7 +1810,6 @@ select a,hex(s1) from t1;
select hex(s1) from t2;
drop table t2,t1;
# Ensure that <tablename>_ibfk_0 is not mistreated as a
# generated foreign key identifier. (Bug #16387)
......
......@@ -89,6 +89,8 @@ EXTRA_DIST = include/btr0btr.h include/btr0btr.ic include/btr0cur.h include/btr
include/ut0sort.h include/ut0ut.h include/ut0ut.ic include/ut0vec.h include/ut0vec.ic include/ha_prototypes.h \
include/ut0list.h include/ut0list.ic \
include/ut0wqueue.h \
pars/make_bison.sh pars/make_flex.sh \
pars/pars0grm.y pars/pars0lex.l
CMakeLists.txt plug.in
noinst_LIBRARIES = libinnobase.a
......
......@@ -689,7 +689,8 @@ dict_table_get_on_id(
if we are doing a rollback to handle an error in TABLE
CREATE, for example, we already have the mutex! */
ut_ad(mutex_own(&(dict_sys->mutex)));
ut_ad(mutex_own(&(dict_sys->mutex))
|| trx->dict_operation_lock_mode == RW_X_LATCH);
return(dict_table_get_on_id_low(table_id));
}
......
......@@ -92,9 +92,6 @@ extern "C" {
#include "../storage/innobase/include/ha_prototypes.h"
}
#define HA_INNOBASE_ROWS_IN_TABLE 10000 /* to get optimization right */
#define HA_INNOBASE_RANGE_COUNT 100
ulong innobase_large_page_size = 0;
/* The default values for the following, type long or longlong, start-up
......@@ -142,7 +139,7 @@ srv_active_wake_master_thread after each fetch or search, we only do
it every INNOBASE_WAKE_INTERVAL'th step. */
#define INNOBASE_WAKE_INTERVAL 32
ulong innobase_active_counter = 0;
static ulong innobase_active_counter = 0;
static HASH innobase_open_tables;
......@@ -311,13 +308,13 @@ bool innobase_show_status(handlerton *hton, THD* thd,
/*********************************************************************
Commits a transaction in an InnoDB database. */
static
void
innobase_commit_low(
/*================*/
trx_t* trx); /* in: transaction handle */
SHOW_VAR innodb_status_variables[]= {
static SHOW_VAR innodb_status_variables[]= {
{"buffer_pool_pages_data",
(char*) &export_vars.innodb_buffer_pool_pages_data, SHOW_LONG},
{"buffer_pool_pages_dirty",
......@@ -1140,7 +1137,7 @@ holding any InnoDB semaphores. The calling thread is holding the
query cache mutex, and this function will reserver the InnoDB kernel mutex.
Thus, the 'rank' in sync0sync.h of the MySQL query cache mutex is above
the InnoDB kernel mutex. */
static
my_bool
innobase_query_caching_of_table_permitted(
/*======================================*/
......@@ -1765,7 +1762,7 @@ innobase_flush_logs(handlerton *hton)
/*********************************************************************
Commits a transaction in an InnoDB database. */
static
void
innobase_commit_low(
/*================*/
......@@ -1849,12 +1846,11 @@ innobase_commit(
/* Update the info whether we should skip XA steps that eat CPU time */
trx->support_xa = (ibool)(thd->variables.innodb_support_xa);
/* Release a possible FIFO ticket and search latch. Since we will
reserve the kernel mutex, we have to release the search system latch
first to obey the latching order. */
/* Since we will reserve the kernel mutex, we have to release
the search system latch first to obey the latching order. */
if (trx->has_search_latch) {
trx_search_latch_release_if_reserved(trx);
trx_search_latch_release_if_reserved(trx);
}
/* The flag trx->active_trans is set to 1 in
......@@ -1941,18 +1937,20 @@ retry:
trx_mark_sql_stat_end(trx);
}
/* Tell the InnoDB server that there might be work for utility
threads: */
if (trx->declared_to_be_inside_innodb) {
/* Release our possible ticket in the FIFO */
/* Release our possible ticket in the FIFO */
srv_conc_force_exit_innodb(trx);
srv_conc_force_exit_innodb(trx);
}
/* Tell the InnoDB server that there might be work for utility
threads: */
srv_active_wake_master_thread();
DBUG_RETURN(0);
}
#if 0
/* TODO: put the
MySQL-4.1 functionality back to 5.0. This is needed to get InnoDB Hot Backup
to work. */
......@@ -1965,7 +1963,7 @@ transaction inside InnoDB but does NOT flush InnoDB log files to disk.
To flush you have to call innobase_commit_complete(). We have separated
flushing to eliminate the bottleneck of LOCK_log in log.cc which disabled
InnoDB's group commit capability. */
static
int
innobase_report_binlog_offset_and_commit(
/*=====================================*/
......@@ -1995,7 +1993,6 @@ innobase_report_binlog_offset_and_commit(
return(0);
}
#if 0
/***********************************************************************
This function stores the binlog offset and flushes logs. */
static
......@@ -2026,12 +2023,11 @@ innobase_store_binlog_offset_and_flush_log(
/* Synchronous flush of the log buffer to disk */
log_buffer_flush_to_disk();
}
#endif
/*********************************************************************
This is called after MySQL has written the binlog entry for the current
transaction. Flushes the InnoDB log files to disk if required. */
static
int
innobase_commit_complete(
/*=====================*/
......@@ -2057,6 +2053,7 @@ innobase_commit_complete(
return(0);
}
#endif
/*********************************************************************
Rolls back a transaction or the latest SQL statement. */
......@@ -2110,7 +2107,7 @@ innobase_rollback(
/*********************************************************************
Rolls back a transaction */
static
int
innobase_rollback_trx(
/*==================*/
......@@ -2405,8 +2402,6 @@ ha_innobase::open(
user_thd = NULL;
last_query_id = (ulong)-1;
if (!(share=get_share(name))) {
DBUG_RETURN(1);
......@@ -3374,8 +3369,7 @@ ha_innobase::write_row(
ut_error;
}
statistic_increment(thd->status_var.ha_write_count,
&LOCK_status);
ha_statistic_increment(&SSV::ha_write_count);
if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT)
table->timestamp_field->set_time();
......@@ -3450,13 +3444,6 @@ no_commit:
num_write_row++;
if (last_query_id != user_thd->query_id) {
prebuilt->sql_stat_start = TRUE;
last_query_id = user_thd->query_id;
innobase_release_stat_resources(prebuilt->trx);
}
if (table->next_number_field && record == table->record[0]) {
/* This is the case where the table has an
auto-increment column */
......@@ -3611,13 +3598,6 @@ calc_row_difference(
for (i = 0; i < n_fields; i++) {
field = table->field[i];
/* if (thd->query_id != field->query_id) { */
/* TODO: check that these fields cannot have
changed! */
/* goto skip_field;
}*/
o_ptr = (byte*) old_row + get_field_offset(table, field);
n_ptr = (byte*) new_row + get_field_offset(table, field);
......@@ -3749,13 +3729,6 @@ ha_innobase::update_row(
if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
table->timestamp_field->set_time();
if (last_query_id != user_thd->query_id) {
prebuilt->sql_stat_start = TRUE;
last_query_id = user_thd->query_id;
innobase_release_stat_resources(trx);
}
if (prebuilt->upd_node) {
uvect = prebuilt->upd_node->update;
} else {
......@@ -3806,13 +3779,6 @@ ha_innobase::delete_row(
ut_a(prebuilt->trx == trx);
if (last_query_id != user_thd->query_id) {
prebuilt->sql_stat_start = TRUE;
last_query_id = user_thd->query_id;
innobase_release_stat_resources(trx);
}
if (!prebuilt->upd_node) {
row_get_prebuilt_update_vector(prebuilt);
}
......@@ -3848,15 +3814,6 @@ ha_innobase::unlock_row(void)
{
DBUG_ENTER("ha_innobase::unlock_row");
if (UNIV_UNLIKELY(last_query_id != user_thd->query_id)) {
ut_print_timestamp(stderr);
sql_print_error("last_query_id is %lu != user_thd_query_id is "
"%lu", (ulong) last_query_id,
(ulong) user_thd->query_id);
mem_analyze_corruption(prebuilt->trx);
ut_error;
}
/* Consistent read does not take any locks, thus there is
nothing to unlock. */
......@@ -4062,15 +4019,7 @@ ha_innobase::index_read(
ut_a(prebuilt->trx == thd_to_trx(current_thd, ht));
statistic_increment(current_thd->status_var.ha_read_key_count,
&LOCK_status);
if (last_query_id != user_thd->query_id) {
prebuilt->sql_stat_start = TRUE;
last_query_id = user_thd->query_id;
innobase_release_stat_resources(prebuilt->trx);
}
ha_statistic_increment(&SSV::ha_read_key_count);
index = prebuilt->index;
......@@ -4168,12 +4117,11 @@ ha_innobase::change_active_index(
InnoDB */
{
KEY* key=0;
THD* thd = current_thd;
statistic_increment(thd->status_var.ha_read_key_count, &LOCK_status);
ha_statistic_increment(&SSV::ha_read_key_count);
DBUG_ENTER("change_active_index");
ut_ad(user_thd == thd);
ut_a(prebuilt->trx == thd_to_trx(thd, ht));
ut_ad(user_thd == current_thd);
ut_a(prebuilt->trx == thd_to_trx(user_thd, ht));
active_index = keynr;
......@@ -4300,8 +4248,7 @@ ha_innobase::index_next(
mysql_byte* buf) /* in/out: buffer for next row in MySQL
format */
{
statistic_increment(current_thd->status_var.ha_read_next_count,
&LOCK_status);
ha_statistic_increment(&SSV::ha_read_next_count);
return(general_fetch(buf, ROW_SEL_NEXT, 0));
}
......@@ -4318,8 +4265,7 @@ ha_innobase::index_next_same(
const mysql_byte* key, /* in: key value */
uint keylen) /* in: key value length */
{
statistic_increment(current_thd->status_var.ha_read_next_count,
&LOCK_status);
ha_statistic_increment(&SSV::ha_read_next_count);
return(general_fetch(buf, ROW_SEL_NEXT, last_match_mode));
}
......@@ -4336,8 +4282,7 @@ ha_innobase::index_prev(
mysql_byte* buf) /* in/out: buffer for previous row in MySQL
format */
{
statistic_increment(current_thd->status_var.ha_read_prev_count,
&LOCK_status);
ha_statistic_increment(&SSV::ha_read_prev_count);
return(general_fetch(buf, ROW_SEL_PREV, 0));
}
......@@ -4356,8 +4301,7 @@ ha_innobase::index_first(
int error;
DBUG_ENTER("index_first");
statistic_increment(current_thd->status_var.ha_read_first_count,
&LOCK_status);
ha_statistic_increment(&SSV::ha_read_first_count);
error = index_read(buf, NULL, 0, HA_READ_AFTER_KEY);
......@@ -4383,8 +4327,7 @@ ha_innobase::index_last(
int error;
DBUG_ENTER("index_last");
statistic_increment(current_thd->status_var.ha_read_last_count,
&LOCK_status);
ha_statistic_increment(&SSV::ha_read_last_count);
error = index_read(buf, NULL, 0, HA_READ_BEFORE_KEY);
......@@ -4454,8 +4397,7 @@ ha_innobase::rnd_next(
int error;
DBUG_ENTER("rnd_next");
statistic_increment(current_thd->status_var.ha_read_rnd_next_count,
&LOCK_status);
ha_statistic_increment(&SSV::ha_read_rnd_next_count);
if (start_of_scan) {
error = index_first(buf);
......@@ -4490,8 +4432,7 @@ ha_innobase::rnd_pos(
DBUG_ENTER("rnd_pos");
DBUG_DUMP("key", (char*) pos, ref_length);
statistic_increment(current_thd->status_var.ha_read_rnd_count,
&LOCK_status);
ha_statistic_increment(&SSV::ha_read_rnd_count);
ut_a(prebuilt->trx == thd_to_trx(current_thd, ht));
......@@ -6534,7 +6475,7 @@ ha_innobase::transactional_table_lock(
/****************************************************************************
Here we export InnoDB status variables to MySQL. */
static
int
innodb_export_status()
/*==================*/
......@@ -6640,7 +6581,7 @@ innodb_show_status(
/****************************************************************************
Implements the SHOW MUTEX STATUS command. . */
static
bool
innodb_mutex_show_status(
/*=====================*/
......@@ -7325,6 +7266,33 @@ ha_innobase::cmp_ref(
return(0);
}
/***********************************************************************
Ask InnoDB if a query to a table can be cached. */
my_bool
ha_innobase::register_query_cache_table(
/*====================================*/
/* out: TRUE if query caching
of the table is permitted */
THD* thd, /* in: user thread handle */
char* table_key, /* in: concatenation of database name,
the null character '\0',
and the table name */
uint key_length, /* in: length of the full name, i.e.
len(dbname) + len(tablename) + 1 */
qc_engine_callback*
call_back, /* out: pointer to function for
checking if query caching
is permitted */
ulonglong *engine_data) /* in/out: data to call_back */
{
*call_back = innobase_query_caching_of_table_permitted;
*engine_data = 0;
return(innobase_query_caching_of_table_permitted(thd, table_key,
key_length,
engine_data));
}
char*
ha_innobase::get_mysql_bin_log_name()
{
......@@ -7702,12 +7670,12 @@ static int show_innodb_vars(THD *thd, SHOW_VAR *var, char *buff)
return 0;
}
SHOW_VAR innodb_status_variables_export[]= {
static SHOW_VAR innodb_status_variables_export[]= {
{"Innodb", (char*) &show_innodb_vars, SHOW_FUNC},
{NullS, NullS, SHOW_LONG}
};
struct st_mysql_storage_engine innobase_storage_engine=
static struct st_mysql_storage_engine innobase_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
mysql_declare_plugin(innobase)
......
......@@ -35,10 +35,6 @@ typedef struct st_innobase_share {
struct row_prebuilt_struct;
typedef struct row_prebuilt_struct row_prebuilt_t;
my_bool innobase_query_caching_of_table_permitted(THD* thd, char* full_name,
uint full_name_len,
ulonglong *unused);
/* The class defining a handle to an Innodb table */
class ha_innobase: public handler
{
......@@ -48,8 +44,6 @@ class ha_innobase: public handler
THD* user_thd; /* the thread handle of the user
currently using the handle; this is
set in external_lock function */
query_id_t last_query_id; /* the latest query id where the
handle was used */
THR_LOCK_DATA lock;
INNOBASE_SHARE *share;
......@@ -186,14 +180,7 @@ class ha_innobase: public handler
my_bool register_query_cache_table(THD *thd, char *table_key,
uint key_length,
qc_engine_callback *call_back,
ulonglong *engine_data)
{
*call_back= innobase_query_caching_of_table_permitted;
*engine_data= 0;
return innobase_query_caching_of_table_permitted(thd, table_key,
key_length,
engine_data);
}
ulonglong *engine_data);
static char *get_mysql_bin_log_name();
static ulonglong get_mysql_bin_log_pos();
bool primary_key_is_clustered() { return true; }
......@@ -202,7 +189,6 @@ class ha_innobase: public handler
uint table_changes);
};
extern SHOW_VAR innodb_status_variables[];
extern ulong innobase_fast_shutdown;
extern ulong innobase_large_page_size;
extern long innobase_mirrored_log_groups, innobase_log_files_in_group;
......
......@@ -375,8 +375,6 @@ trx_is_interrupted(
/* Signal to a transaction */
struct trx_sig_struct{
ulint type; /* signal type */
ulint state; /* TRX_SIG_WAITING or
TRX_SIG_BEING_HANDLED */
ulint sender; /* TRX_SIG_SELF or
TRX_SIG_OTHER_SESS */
que_thr_t* receiver; /* non-NULL if the sender of the signal
......@@ -404,7 +402,7 @@ struct trx_struct{
const char* op_info; /* English text describing the
current operation, or an empty
string */
ulint type; /* TRX_USER, TRX_PURGE */
unsigned is_purge:1; /* 0=user transaction, 1=purge */
ulint conc_state; /* state of the trx from the point
of view of concurrency control:
TRX_ACTIVE, TRX_COMMITTED_IN_MEMORY,
......@@ -675,12 +673,6 @@ struct trx_struct{
single operation of a
transaction, e.g., a parallel
query */
/* Transaction types */
#define TRX_USER 1 /* normal user transaction */
#define TRX_PURGE 2 /* purge transaction: this is not
inserted to the trx list of trx_sys
and no rollback segment is assigned to
this */
/* Transaction concurrency states */
#define TRX_NOT_STARTED 1
#define TRX_ACTIVE 2
......@@ -742,9 +734,6 @@ struct trx_struct{
session */
#define TRX_SIG_OTHER_SESS 2 /* sent by another session (which
must hold rights to this) */
/* Signal states */
#define TRX_SIG_WAITING 1
#define TRX_SIG_BEING_HANDLED 2
/* Commit command node in a query graph */
struct commit_node_struct{
......
......@@ -930,7 +930,7 @@ try_again:
file = CreateFile((LPCTSTR) name,
access,
FILE_SHARE_READ | FILE_SHARE_WRITE,
/* file can be read ansd written also
/* file can be read and written also
by other processes */
NULL, /* default security attributes */
create_flag,
......@@ -1509,7 +1509,7 @@ os_file_rename(
return(TRUE);
}
os_file_handle_error(oldpath, "rename");
os_file_handle_error_no_exit(oldpath, "rename");
return(FALSE);
#else
......@@ -1518,7 +1518,7 @@ os_file_rename(
ret = rename((const char*)oldpath, (const char*)newpath);
if (ret != 0) {
os_file_handle_error(oldpath, "rename");
os_file_handle_error_no_exit(oldpath, "rename");
return(FALSE);
}
......
......@@ -213,7 +213,7 @@ row_undo(
ulint err;
trx_t* trx;
dulint roll_ptr;
ibool froze_data_dict = FALSE;
ibool locked_data_dict;
ut_ad(node && thr);
......@@ -266,13 +266,13 @@ row_undo(
/* Prevent DROP TABLE etc. while we are rolling back this row.
If we are doing a TABLE CREATE or some other dictionary operation,
then we already have dict_operation_lock locked in x-mode. Do not
try to lock again in s-mode, because that would cause a hang. */
try to lock again, because that would cause a hang. */
if (trx->dict_operation_lock_mode == 0) {
locked_data_dict = (trx->dict_operation_lock_mode == 0);
row_mysql_freeze_data_dictionary(trx);
if (locked_data_dict) {
froze_data_dict = TRUE;
row_mysql_lock_data_dictionary(trx);
}
if (node->state == UNDO_NODE_INSERT) {
......@@ -285,9 +285,9 @@ row_undo(
err = row_undo_mod(node, thr);
}
if (froze_data_dict) {
if (locked_data_dict) {
row_mysql_unfreeze_data_dictionary(trx);
row_mysql_unlock_data_dictionary(trx);
}
/* Do some cleanup */
......
......@@ -221,7 +221,7 @@ trx_purge_sys_create(void)
purge_sys->trx = purge_sys->sess->trx;
purge_sys->trx->type = TRX_PURGE;
purge_sys->trx->is_purge = 1;
ut_a(trx_start_low(purge_sys->trx, ULINT_UNDEFINED));
......
......@@ -109,7 +109,7 @@ trx_create(
trx->op_info = "";
trx->type = TRX_USER;
trx->is_purge = 0;
trx->conc_state = TRX_NOT_STARTED;
trx->start_time = time(NULL);
......@@ -667,7 +667,7 @@ trx_start_low(
ut_ad(mutex_own(&kernel_mutex));
ut_ad(trx->rseg == NULL);
if (trx->type == TRX_PURGE) {
if (trx->is_purge) {
trx->id = ut_dulint_zero;
trx->conc_state = TRX_ACTIVE;
trx->start_time = time(NULL);
......@@ -1262,7 +1262,6 @@ trx_sig_send(
UT_LIST_ADD_LAST(signals, trx->signals, sig);
sig->type = type;
sig->state = TRX_SIG_WAITING;
sig->sender = sender;
sig->receiver = receiver_thr;
......@@ -1709,7 +1708,7 @@ trx_print(
fputs(trx->op_info, f);
}
if (trx->type != TRX_USER) {
if (trx->is_purge) {
fputs(" purge trx", f);
}
......
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