Commit f3009f3f authored by unknown's avatar unknown
Browse files

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().


mysql-test/t/innodb.test:
  Applied innodb-5.1-ss1381 snapshot
  
  Revision r1373:
  Port r1372 from branches/5.0: Merge a change from MySQL AB, and remove
  the innodb_gis test case.
  
  ChangeSet
    2007/02/19 13:57:06+03:00 kaa@polly.local
    Bug#18743: Several test cases fails if "classic" configuration in 5.0
    The problem happened because those tests were using "cp932" and "ucs2"
    without checking whether these character sets are available.
    This fix moves test parts to make character set specific parts be
    tested only if they are:
    - some parts were moved to "ctype_ucs.test" and "ctype_cp932.test"
    - some parts were moved to the newly added tests "innodb-ucs2.test",
    "mysqlbinglog-cp932.test" and "sp-ucs2.test"
  
  mysql-test/t/innodb.test
    2007/02/19 13:57:02+03:00 kaa@polly.local +0 -222
    Moved ucs2-specific test cases to innodb-ucs2.test
storage/innobase/Makefile.am:
  Applied innodb-5.1-ss1381 snapshot
  
  Revision r1353:
  Makefile.am: EXTRA_DIST: Add the grammar source files to the
  source distribution of MySQL.
storage/innobase/dict/dict0dict.c:
  Applied innodb-5.1-ss1381 snapshot
  
  Revision r1350:
  Lock the data dictionary during rollback.  This removes the rare
  debug assertion failure ut_ad(mutex_own(&(dict_sys->mutex))) in
  dict_table_get_on_id() after the rollback following crash recovery.
storage/innobase/handler/ha_innodb.cc:
  Applied innodb-5.1-ss1381 snapshot
  
  Revision r1377:
  Add static qualifiers to some symbols in ha_innodb.cc that are not
  referenced from other modules.
  
  
  Revision r1380:
  Remove ha_innobase::last_query_id and references to thd->query_id.
  
  MySQL calls external_lock at the beginning and end of a statement
  when it is not calling start_stmt or commit or rollback.  Thus,
  statement boundaries can be (and are already) detected without
  monitoring thd->query_id.
  
  The function innobase_commit() seemingly lacks the call to
  innobase_release_stat_resources(), which should be called at
  the end of every SQL statement.  The call was replaced by
  equivalent statements by Vadim Tkachenko when he implemented
  innodb_commit_concurrency in MySQL 5.0:
  
  http://mysql.bkbits.net:8080/mysql-5.0/?PAGE=patch&REV=1.1886.70.1
  
  
  Revision r1355:
  class ha_innobase: Replace statistic_increment() with ha_statistic_increment().
  
  ha_innobase::change_active_index(): Do not call current_thd unless
  UNIV_DEBUG is defined.
  
  
  Revision r1369:
  Merge a change from MySQL AB:
  
  ChangeSet@1.2409.1.83  2007-03-06 10:36:15-07:00  tsmith@hindu.god
  Bug #26598: Create variable to allow turning off of statistic gathering
  on metadata commands
  
  Add innodb_stats_on_metadata option, which enables gathering
  index statistics when processing metadata commands such as
  SHOW TABLE STATUS.  Default behavior of the server does not
  change (this option is enabled by default).
  
  
  Revision r1342:
  Minor cleanup in ha_innodb.cc.
  
  Remove the unused constants HA_INNOBASE_ROWS_IN_TABLE and
  HA_INNOBASE_RANGE_COUNT.  Declare innobase_active_counter static.
  
  
  Revision r1381:
  innobase_commit(): Correct the comments and formatting that were broken when
  innodb_commit_concurrency was implemented.
  
  
  Revision r1360:
  Minor cleanup.
  
  innobase_query_caching_of_table_permitted(): Make static.
  
  ha_innobase::register_query_cache_table(): Move the function
  definition from ha_innodb.h to ha_innodb.cc.  Add comments.
storage/innobase/handler/ha_innodb.h:
  Applied innodb-5.1-ss1381 snapshot
  
  Revision r1377:
  Add static qualifiers to some symbols in ha_innodb.cc that are not
  referenced from other modules.
  
  
  Revision r1380:
  Remove ha_innobase::last_query_id and references to thd->query_id.
  
  MySQL calls external_lock at the beginning and end of a statement
  when it is not calling start_stmt or commit or rollback.  Thus,
  statement boundaries can be (and are already) detected without
  monitoring thd->query_id.
  
  The function innobase_commit() seemingly lacks the call to
  innobase_release_stat_resources(), which should be called at
  the end of every SQL statement.  The call was replaced by
  equivalent statements by Vadim Tkachenko when he implemented
  innodb_commit_concurrency in MySQL 5.0:
  
  http://mysql.bkbits.net:8080/mysql-5.0/?PAGE=patch&REV=1.1886.70.1
  
  
  Revision r1369:
  Merge a change from MySQL AB:
  
  ChangeSet@1.2409.1.83  2007-03-06 10:36:15-07:00  tsmith@hindu.god
  Bug #26598: Create variable to allow turning off of statistic gathering
  on metadata commands
  
  Add innodb_stats_on_metadata option, which enables gathering
  index statistics when processing metadata commands such as
  SHOW TABLE STATUS.  Default behavior of the server does not
  change (this option is enabled by default).
  
  
  Revision r1360:
  Minor cleanup.
  
  innobase_query_caching_of_table_permitted(): Make static.
  
  ha_innobase::register_query_cache_table(): Move the function
  definition from ha_innodb.h to ha_innodb.cc.  Add comments.
storage/innobase/include/trx0trx.h:
  Applied innodb-5.1-ss1381 snapshot
  
  Revision r1344:
  Rename the Boolean field trx->type to trx->is_purge
  and remove the constants TRX_USER and TRX_PURGE.
  
  
  Revision r1343:
  trx_sig_struct: Remove state.  It is always assigned to TRX_SIG_WAITING
  and never tested.
storage/innobase/os/os0file.c:
  Applied innodb-5.1-ss1381 snapshot
  
  Revision r1352:
  Fix typo in comment in os/os0file.c
  
  Approved by:	heikki
  
  
  
  Revision r1366:
  Fix Bug#27381 by calling os_file_handle_error_no_exit() instead of
  os_file_handle_error().
  
  Approved by:	Heikki
storage/innobase/row/row0undo.c:
  Applied innodb-5.1-ss1381 snapshot
  
  Revision r1350:
  Lock the data dictionary during rollback.  This removes the rare
  debug assertion failure ut_ad(mutex_own(&(dict_sys->mutex))) in
  dict_table_get_on_id() after the rollback following crash recovery.
storage/innobase/trx/trx0purge.c:
  Applied innodb-5.1-ss1381 snapshot
  
  Revision r1344:
  Rename the Boolean field trx->type to trx->is_purge
  and remove the constants TRX_USER and TRX_PURGE.
storage/innobase/trx/trx0trx.c:
  Applied innodb-5.1-ss1381 snapshot
  
  Revision r1344:
  Rename the Boolean field trx->type to trx->is_purge
  and remove the constants TRX_USER and TRX_PURGE.
  
  
  Revision r1343:
  trx_sig_struct: Remove state.  It is always assigned to TRX_SIG_WAITING
  and never tested.
parent c8fde97f
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -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)

+2 −0
Original line number Diff line number Diff line
@@ -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
+2 −1
Original line number Diff line number Diff line
@@ -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));
	}
+61 −93
Original line number Diff line number Diff line
@@ -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,9 +1846,8 @@ 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);
@@ -1941,18 +1937,20 @@ innobase_commit(
		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 */

		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 @@ ha_innobase::write_row(

	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)
+1 −15
Original line number Diff line number Diff line
@@ -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;
Loading