Commit a5868736 authored by unknown's avatar unknown
Browse files

Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots.

Fixes:
- Bug #24712: SHOW TABLE STATUS for file-per-table showing incorrect time fields
- Bug #24386: Performance degradation caused by instrumentation in mutex_struct
- Bug #24190: many exportable definitions of field_in_record_is_null
- Bug #21468: InnoDB crash during recovery with corrupted data pages: XA bug?


storage/innobase/buf/buf0buf.c:
  Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots.
  
  Revision r1045:
  buf_page_init_for_read(): Correct the indentation.
storage/innobase/buf/buf0flu.c:
  Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots.
  
  Revision r1038:
  Port r983 from branches/zip: Enclose some more debug code in
  #ifdef UNIV_SYNC_DEBUG to allow the code to be built
  with UNIV_DEBUG but without UNIV_SYNC_DEBUG.
storage/innobase/dict/dict0dict.c:
  Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots.
  
  Revision r1124:
  Unify dict_table_get_and_increment_handle_count() with dict_table_get() by
  adding a second parameter, adjust callers.
storage/innobase/ha/ha0ha.c:
  Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots.
  
  Revision r1039:
  Port r1034 from branches/zip: Remove some instrumentation and reduce
  the output of SHOW MUTEX STATUS in non-debug builds.  (Bug #24386)
storage/innobase/ha/hash0hash.c:
  Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots.
  
  Revision r1039:
  Port r1034 from branches/zip: Remove some instrumentation and reduce
  the output of SHOW MUTEX STATUS in non-debug builds.  (Bug #24386)
storage/innobase/handler/ha_innodb.cc:
  Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots.
  
  Revision r1028:
  Merge a change from MySQL AB.
  
  ChangeSet
    2006/11/10 17:22:43+02:00 aelkin@dsl-hkibras-fe30f900-107.dhcp.inet.fi 
    Bug #24190  many exportable definitions of field_in_record_is_null
    
    mysql had several(2) exportable definitions of field_in_record_is_null function.
    
    Fixed with adding static.
  
  storage/innobase/handler/ha_innodb.cc
    2006/11/10 17:22:36+02:00 aelkin@dsl-hkibras-fe30f900-107.dhcp.inet.fi +1 -1
    made static
  
  
  Revision r1008:
  Minor cleanup.
  
  ha_innobase::rnd_pos(): Use correct format in DBUG_PRINT statements.
  
  buf_page_release(): Remove the local variable buf_fix_count.
  
  
  Revision r1039:
  Port r1034 from branches/zip: Remove some instrumentation and reduce
  the output of SHOW MUTEX STATUS in non-debug builds.  (Bug #24386)
  
  
  Revision r1124:
  Unify dict_table_get_and_increment_handle_count() with dict_table_get() by
  adding a second parameter, adjust callers.
  
  Revision r1134:
  Fix a potential bug in ha_innodb.cc:innobase_query_is_update() where the
  function can be called with "current_thd == NULL". Minor non-functional fix
  in log0recv.c
  
  
  Revision r1098:
  Fix bug #24712: SHOW TABLE STATUS for file-per-table showing incorrect
  time fields
  
  
  Revision r1109:
  ha_innodb.cc: Remove unused define MAX_ULONG_BIT.
storage/innobase/include/btr0sea.h:
  Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots.
  
  Revision r1088:
  Replace the Latin abbreviation "cf." in comments.
storage/innobase/include/buf0buf.ic:
  Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots.
  
  Revision r1008:
  Minor cleanup.
  
  ha_innobase::rnd_pos(): Use correct format in DBUG_PRINT statements.
  
  buf_page_release(): Remove the local variable buf_fix_count.
storage/innobase/include/data0type.ic:
  Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots.
  
  Revision r1088:
  Replace the Latin abbreviation "cf." in comments.
storage/innobase/include/dict0dict.h:
  Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots.
  
  Revision r1124:
  Unify dict_table_get_and_increment_handle_count() with dict_table_get() by
  adding a second parameter, adjust callers.
storage/innobase/include/ha0ha.h:
  Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots.
  
  Revision r1039:
  Port r1034 from branches/zip: Remove some instrumentation and reduce
  the output of SHOW MUTEX STATUS in non-debug builds.  (Bug #24386)
storage/innobase/include/hash0hash.h:
  Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots.
  
  Revision r1039:
  Port r1034 from branches/zip: Remove some instrumentation and reduce
  the output of SHOW MUTEX STATUS in non-debug builds.  (Bug #24386)
storage/innobase/include/sync0rw.h:
  Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots.
  
  Revision r1039:
  Port r1034 from branches/zip: Remove some instrumentation and reduce
  the output of SHOW MUTEX STATUS in non-debug builds.  (Bug #24386)
storage/innobase/include/sync0sync.h:
  Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots.
  
  Revision r1038:
  Port r983 from branches/zip: Enclose some more debug code in
  #ifdef UNIV_SYNC_DEBUG to allow the code to be built
  with UNIV_DEBUG but without UNIV_SYNC_DEBUG.
  
  
  Revision r1037:
  Port r972 from branches/zip: Enclose some debug code in #ifdef UNIV_SYNC_DEBUG.
  The code was previously unused in non-debug builds.
  
  
  Revision r1039:
  Port r1034 from branches/zip: Remove some instrumentation and reduce
  the output of SHOW MUTEX STATUS in non-debug builds.  (Bug #24386)
  
  
  Revision r1084:
  Remove the unused constants SYNC_INFINITE_TIME and SYNC_TIME_EXCEEDED.
storage/innobase/include/sync0sync.ic:
  Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots.
  
  Revision r1039:
  Port r1034 from branches/zip: Remove some instrumentation and reduce
  the output of SHOW MUTEX STATUS in non-debug builds.  (Bug #24386)
storage/innobase/include/univ.i:
  Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots.
  
  Revision r1006:
  Introduce #define UNIV_LIST_DEBUG for enabling the debug code in
  UT_LIST_REMOVE_CLEAR().
  
  
  Revision r1088:
  Replace the Latin abbreviation "cf." in comments.
  
  
  Revision r1083:
  univ.i: Document the debug flags (UNIV_DEBUG et al).
storage/innobase/include/ut0lst.h:
  Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots.
  
  Revision r1006:
  Introduce #define UNIV_LIST_DEBUG for enabling the debug code in
  UT_LIST_REMOVE_CLEAR().
storage/innobase/lock/lock0lock.c:
  Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots.
  
  Revision r1009:
  Remove duplicate printing of row lock counts in SHOW INNODB STATUS, and in
  the remaining print, add a comma so it doesn't get combined with the heap
  size. Both problems were introduced in r383.
storage/innobase/log/log0recv.c:
  Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots.
  
  Revision r1134:
  Fix a potential bug in ha_innodb.cc:innobase_query_is_update() where the
  function can be called with "current_thd == NULL". Minor non-functional fix
  in log0recv.c
  
  
  Revision r1078:
  Merge r1067:1077 from branches/5.0:
  
  innobase_start_or_create_for_mysql(): Remove unnecessary delay now that
  we moved the setting sync_order_checks_on=TRUE to log0recv.c,
  to the start of the rollback phase in crash recovery.
  
  Fix assertion failure sync0sync.c line 1239
  (the latter ut_error in sync_thread_reset_level())
  in crash recovery when UNIV_SYNC_DEBUG is enabled.
  
  
  Revision r1080:
  Merge r1079 from branches/5.0:
  
  recv_recovery_from_checkpoint_finish(): Add 1 sec delay
  before switching on the sync order checks in crash recovery, so that
  file I/O threads have time to suspend themselves.
storage/innobase/row/row0ins.c:
  Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots.
  
  Revision r1124:
  Unify dict_table_get_and_increment_handle_count() with dict_table_get() by
  adding a second parameter, adjust callers.
storage/innobase/row/row0sel.c:
  Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots.
  
  Revision r1038:
  Port r983 from branches/zip: Enclose some more debug code in
  #ifdef UNIV_SYNC_DEBUG to allow the code to be built
  with UNIV_DEBUG but without UNIV_SYNC_DEBUG.
  
  
  Revision r1124:
  Unify dict_table_get_and_increment_handle_count() with dict_table_get() by
  adding a second parameter, adjust callers.
storage/innobase/row/row0upd.c:
  Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots.
  
  Revision r1124:
  Unify dict_table_get_and_increment_handle_count() with dict_table_get() by
  adding a second parameter, adjust callers.
storage/innobase/srv/srv0start.c:
  Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots.
  
  Revision r1038:
  Port r983 from branches/zip: Enclose some more debug code in
  #ifdef UNIV_SYNC_DEBUG to allow the code to be built
  with UNIV_DEBUG but without UNIV_SYNC_DEBUG.
  
  
  Revision r1078:
  Merge r1067:1077 from branches/5.0:
  
  innobase_start_or_create_for_mysql(): Remove unnecessary delay now that
  we moved the setting sync_order_checks_on=TRUE to log0recv.c,
  to the start of the rollback phase in crash recovery.
  
  Fix assertion failure sync0sync.c line 1239
  (the latter ut_error in sync_thread_reset_level())
  in crash recovery when UNIV_SYNC_DEBUG is enabled.
  
  
  Revision r1070:
  Remove another accidentally committed change to srv0start.c.
  The change was accidentally committed with the merge in r1068.
  This revision corresponds to r1051 with a properly merged
  r1067 of branches/5.0.
  
  
  Revision r1068:
  Merge r1067 from branches/5.0:
  
  trx_rollback_for_mysql(), trx_commit_for_mysql():
  Protect the creation of trx_dummy_sess with kernel_mutex.
  This error was introduced in r1046 and r1050.
  
  
  Revision r1069:
  Remove an accidentally committed change to srv0start.c.
  The change was accidentally committed with the merge in r1068.
storage/innobase/sync/sync0rw.c:
  Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots.
  
  Revision r1039:
  Port r1034 from branches/zip: Remove some instrumentation and reduce
  the output of SHOW MUTEX STATUS in non-debug builds.  (Bug #24386)
storage/innobase/sync/sync0sync.c:
  Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots.
  
  Revision r1038:
  Port r983 from branches/zip: Enclose some more debug code in
  #ifdef UNIV_SYNC_DEBUG to allow the code to be built
  with UNIV_DEBUG but without UNIV_SYNC_DEBUG.
  
  
  Revision r1037:
  Port r972 from branches/zip: Enclose some debug code in #ifdef UNIV_SYNC_DEBUG.
  The code was previously unused in non-debug builds.
  
  
  Revision r1039:
  Port r1034 from branches/zip: Remove some instrumentation and reduce
  the output of SHOW MUTEX STATUS in non-debug builds.  (Bug #24386)
storage/innobase/trx/trx0roll.c:
  Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots.
  
  Revision r1049:
  Merge r1048 from branches/5.0:
  
  trx_rollback_for_mysql(): Do not set trx->sess back to NULL.
  This bug was introduced in r1046.
  
  
  Revision r1047:
  Merge r1046 from branches/5.0:
  
  branches/5.0: trx_rollback_for_mysql(): Ensure that trx->sess is non-NULL
  when calling trx_general_rollback_for_mysql().  This removes a segmentation
  fault when rolling back a prepared transaction in XA recovery.  (Bug #21468)
  
  
  Revision r1068:
  Merge r1067 from branches/5.0:
  
  trx_rollback_for_mysql(), trx_commit_for_mysql():
  Protect the creation of trx_dummy_sess with kernel_mutex.
  This error was introduced in r1046 and r1050.
  
  
  Revision r1051:
  Merge r1050 from branches/5.0:
  
  trx_rollback_for_mysql(): Fix the comment introduced in r1046.
  
  trx_commit_for_mysql(): Use the dummy trx->sess also for committing a prepared
  transaction in XA recovery, just in case our code would need the session
  object also in that case (does not seem to need it right now).
storage/innobase/trx/trx0trx.c:
  Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots.
  
  Revision r1009:
  Remove duplicate printing of row lock counts in SHOW INNODB STATUS, and in
  the remaining print, add a comma so it doesn't get combined with the heap
  size. Both problems were introduced in r383.
  
  Revision r1068:
  Merge r1067 from branches/5.0:
  
  trx_rollback_for_mysql(), trx_commit_for_mysql():
  Protect the creation of trx_dummy_sess with kernel_mutex.
  This error was introduced in r1046 and r1050.
  
  
  Revision r1051:
  Merge r1050 from branches/5.0:
  
  trx_rollback_for_mysql(): Fix the comment introduced in r1046.
  
  trx_commit_for_mysql(): Use the dummy trx->sess also for committing a prepared
  transaction in XA recovery, just in case our code would need the session
  object also in that case (does not seem to need it right now).
parent 4dabfa5d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -854,8 +854,10 @@ buf_flush_batch(

	ut_ad((flush_type == BUF_FLUSH_LRU)
	      || (flush_type == BUF_FLUSH_LIST));
#ifdef UNIV_SYNC_DEBUG
	ut_ad((flush_type != BUF_FLUSH_LIST)
	      || sync_thread_levels_empty_gen(TRUE));
#endif /* UNIV_SYNC_DEBUG */
	mutex_enter(&(buf_pool->mutex));

	if ((buf_pool->n_flush[flush_type] > 0)
+13 −34
Original line number Diff line number Diff line
@@ -801,43 +801,20 @@ dict_init(void)
}

/**************************************************************************
Returns a table object. NOTE! This is a high-level function to be used
mainly from outside the 'dict' directory. Inside this directory
dict_table_get_low is usually the appropriate function. */
Returns a table object and optionally increment its MySQL open handle count.
NOTE! This is a high-level function to be used mainly from outside the
'dict' directory. Inside this directory dict_table_get_low is usually the
appropriate function. */

dict_table_t*
dict_table_get(
/*===========*/
					/* out: table, NULL if
					does not exist */
	const char*	table_name)	/* in: table name */
{
	dict_table_t*	table;

	mutex_enter(&(dict_sys->mutex));

	table = dict_table_get_low(table_name);

	mutex_exit(&(dict_sys->mutex));

	if (table != NULL) {
		if (!table->stat_initialized) {
			dict_update_statistics(table);
		}
	}

	return(table);
}

/**************************************************************************
Returns a table object and increments MySQL open handle count on the table. */

dict_table_t*
dict_table_get_and_increment_handle_count(
/*======================================*/
					/* out: table, NULL if
					does not exist */
	const char*	table_name)	/* in: table name */
	const char*	table_name,	/* in: table name */
	ibool		inc_mysql_count)
     					/* in: whether to increment the open
					handle count on the table */
{
	dict_table_t*	table;

@@ -845,15 +822,17 @@ dict_table_get_and_increment_handle_count(

	table = dict_table_get_low(table_name);

	if (table != NULL) {

	if (inc_mysql_count && table) {
		table->n_mysql_handles_opened++;
	}

	mutex_exit(&(dict_sys->mutex));

	if (table != NULL) {
		if (!table->stat_initialized && !table->ibd_file_missing) {
		if (!table->stat_initialized) {
			/* If table->ibd_file_missing == TRUE, this will
			print an error message and return without doing
			anything. */
			dict_update_statistics(table);
		}
	}
+7 −5
Original line number Diff line number Diff line
@@ -18,16 +18,18 @@ Creates a hash table with >= n array cells. The actual number of cells is
chosen to be a prime number slightly bigger than n. */

hash_table_t*
ha_create(
/*======*/
ha_create_func(
/*===========*/
				/* out, own: created table */
	ibool	in_btr_search,	/* in: TRUE if the hash table is used in
				the btr_search module */
	ulint	n,		/* in: number of array cells */
	ulint	n_mutexes,	/* in: number of mutexes to protect the
				hash table: must be a power of 2, or 0 */
	ulint	mutex_level)	/* in: level of the mutexes in the latching
#ifdef UNIV_SYNC_DEBUG
	ulint	mutex_level,	/* in: level of the mutexes in the latching
				order: this is used in the debug version */
#endif /* UNIV_SYNC_DEBUG */
	ulint	n_mutexes)	/* in: number of mutexes to protect the
				hash table: must be a power of 2, or 0 */
{
	hash_table_t*	table;
	ulint		i;
+7 −5
Original line number Diff line number Diff line
@@ -129,13 +129,15 @@ hash_table_free(
Creates a mutex array to protect a hash table. */

void
hash_create_mutexes(
/*================*/
hash_create_mutexes_func(
/*=====================*/
	hash_table_t*	table,		/* in: hash table */
	ulint		n_mutexes,	/* in: number of mutexes, must be a
					power of 2 */
	ulint		sync_level)	/* in: latching order level of the
#ifdef UNIV_SYNC_DEBUG
	ulint		sync_level,	/* in: latching order level of the
					mutexes: used in the debug version */
#endif /* UNIV_SYNC_DEBUG */
	ulint		n_mutexes)	/* in: number of mutexes, must be a
					power of 2 */
{
	ulint	i;

+48 −56
Original line number Diff line number Diff line
@@ -39,9 +39,6 @@ have disables the InnoDB inlining in this file. */
#include <myisampack.h>
#include <mysys_err.h>
#include <my_sys.h>

#define MAX_ULONG_BIT ((ulong) 1 << (sizeof(ulong)*8-1))

#include "ha_innodb.h"

pthread_mutex_t innobase_share_mutex,	/* to protect innobase_open_files */
@@ -1261,18 +1258,6 @@ trx_is_interrupted(
	return(trx && trx->mysql_thd && ((THD*) trx->mysql_thd)->killed);
}

/**************************************************************************
Obtain a pointer to the MySQL THD object, as in current_thd().	This
definition must match the one in sql/ha_innodb.cc! */
extern "C"
void*
innobase_current_thd(void)
/*======================*/
			/* out: MySQL THD object */
{
	return(current_thd);
}

/*********************************************************************
Call this when you have opened a new table handle in HANDLER, before you
call index_read_idx() etc. Actually, we can let the cursor stay open even
@@ -2354,7 +2339,7 @@ ha_innobase::open(

	/* Get pointer to a table object in InnoDB dictionary cache */

	ib_table = dict_table_get_and_increment_handle_count(norm_name);
	ib_table = dict_table_get(norm_name, TRUE);

	if (NULL == ib_table) {
		ut_print_timestamp(stderr);
@@ -4932,7 +4917,7 @@ ha_innobase::create(

	log_buffer_flush_to_disk();

	innobase_table = dict_table_get(norm_name);
	innobase_table = dict_table_get(norm_name, FALSE);

	DBUG_ASSERT(innobase_table != 0);

@@ -5543,16 +5528,10 @@ ha_innobase::info(
		prebuilt->trx->op_info = (char*)
					  "returning various info to MySQL";

		if (ib_table->space != 0) {
			my_snprintf(path, sizeof(path), "%s/%s%s",
				mysql_data_home, ib_table->name, ".ibd");
			unpack_filename(path,path);
		} else {
		my_snprintf(path, sizeof(path), "%s/%s%s",
				mysql_data_home, ib_table->name, reg_ext);

		unpack_filename(path,path);
		}

		/* Note that we do not know the access time of the table,
		nor the CHECK TABLE time, nor the UPDATE or INSERT time. */
@@ -6605,22 +6584,23 @@ innodb_mutex_show_status(
{
	char buf1[IO_SIZE], buf2[IO_SIZE];
	mutex_t*  mutex;
#ifdef UNIV_DEBUG
	ulint	  rw_lock_count= 0;
	ulint	  rw_lock_count_spin_loop= 0;
	ulint	  rw_lock_count_spin_rounds= 0;
	ulint	  rw_lock_count_os_wait= 0;
	ulint	  rw_lock_count_os_yield= 0;
	ulonglong rw_lock_wait_time= 0;
#endif /* UNIV_DEBUG */
	uint	  hton_name_len= strlen(innobase_hton_name), buf1len, buf2len;
	DBUG_ENTER("innodb_mutex_show_status");

#ifdef MUTEX_PROTECT_TO_BE_ADDED_LATER
	mutex_enter(&mutex_list_mutex);
#endif
	mutex_enter_noninline(&mutex_list_mutex);

	mutex = UT_LIST_GET_FIRST(mutex_list);

	while (mutex != NULL) {
#ifdef UNIV_DEBUG
		if (mutex->mutex_type != 1) {
			if (mutex->count_using > 0) {
				buf1len= my_snprintf(buf1, sizeof(buf1),
@@ -6641,9 +6621,8 @@ innodb_mutex_show_status(
				if (stat_print(thd, innobase_hton_name,
						hton_name_len, buf1, buf1len,
						buf2, buf2len)) {
#ifdef MUTEX_PROTECT_TO_BE_ADDED_LATER
					mutex_exit(&mutex_list_mutex);
#endif
					mutex_exit_noninline(
						&mutex_list_mutex);
					DBUG_RETURN(1);
				}
			}
@@ -6656,10 +6635,26 @@ innodb_mutex_show_status(
			rw_lock_count_os_yield += mutex->count_os_yield;
			rw_lock_wait_time += mutex->lspent_time;
		}
#else /* UNIV_DEBUG */
		buf1len= my_snprintf(buf1, sizeof(buf1), "%s:%lu",
				     mutex->cfile_name, (ulong) mutex->cline);
		buf2len= my_snprintf(buf2, sizeof(buf2), "os_waits=%lu",
				     mutex->count_os_wait);

		if (stat_print(thd, innobase_hton_name,
			       hton_name_len, buf1, buf1len,
			       buf2, buf2len)) {
			mutex_exit_noninline(&mutex_list_mutex);
			DBUG_RETURN(1);
		}
#endif /* UNIV_DEBUG */

		mutex = UT_LIST_GET_NEXT(list, mutex);
	}

	mutex_exit_noninline(&mutex_list_mutex);

#ifdef UNIV_DEBUG
	buf2len= my_snprintf(buf2, sizeof(buf2),
		"count=%lu, spin_waits=%lu, spin_rounds=%lu, "
		"os_waits=%lu, os_yields=%lu, os_wait_times=%lu",
@@ -6672,10 +6667,7 @@ innodb_mutex_show_status(
			STRING_WITH_LEN("rw_lock_mutexes"), buf2, buf2len)) {
		DBUG_RETURN(1);
	}

#ifdef MUTEX_PROTECT_TO_BE_ADDED_LATER
	mutex_exit(&mutex_list_mutex);
#endif
#endif /* UNIV_DEBUG */

	DBUG_RETURN(FALSE);
}
@@ -7348,7 +7340,6 @@ innobase_get_at_most_n_mbchars(
}
}

extern "C" {
/**********************************************************************
This function returns true if

@@ -7358,32 +7349,33 @@ is either REPLACE or LOAD DATA INFILE REPLACE.
2) SQL-query in the current thread
is INSERT ON DUPLICATE KEY UPDATE.

NOTE that /mysql/innobase/row/row0ins.c must contain the
NOTE that storage/innobase/row/row0ins.c must contain the
prototype for this function ! */

extern "C"
ibool
innobase_query_is_update(void)
/*==========================*/
{
	THD*	thd;

	thd = (THD *)innobase_current_thd();

	if (thd->lex->sql_command == SQLCOM_REPLACE ||
		thd->lex->sql_command == SQLCOM_REPLACE_SELECT ||
		(thd->lex->sql_command == SQLCOM_LOAD &&
			thd->lex->duplicates == DUP_REPLACE)) {

		return(1);
	}
	THD*	thd = current_thd;

	if (thd->lex->sql_command == SQLCOM_INSERT &&
		thd->lex->duplicates  == DUP_UPDATE) {
	if (!thd) {
		/* InnoDB's internal threads may run InnoDB stored procedures
		that call this function. Then current_thd is not defined
		(it is probably NULL). */

		return(1);
		return(FALSE);
	}

	return(0);
	switch (thd->lex->sql_command) {
	case SQLCOM_REPLACE:
	case SQLCOM_REPLACE_SELECT:
		return(TRUE);
	case SQLCOM_LOAD:
		return(thd->lex->duplicates == DUP_REPLACE);
	case SQLCOM_INSERT:
		return(thd->lex->duplicates == DUP_UPDATE);
	default:
		return(FALSE);
	}
}

Loading