Commit 2b466294 authored by unknown's avatar unknown
Browse files

Automerge


sql/sql_parse.cc:
  Auto merged
sql/handler.cc:
  SCCS merged
sql/mysql_priv.h:
  SCCS merged
parents 5c1b91f1 1f919052
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -390,8 +390,9 @@ struct trx_struct{
	dulint		table_id;	/* table id if the preceding field is
					TRUE */
	/*------------------------------*/
	int		active_trans;	/* whether a transaction in MySQL
					is active */
	int		active_trans;	/* 1 - if a transaction in MySQL
					is active. 2 - if prepare_commit_mutex
                                        was taken */
	void*           mysql_thd;      /* MySQL thread handle corresponding
					to this trx, or NULL */
	char**		mysql_query_str;/* pointer to the field in mysqld_thd
+29 −11
Original line number Diff line number Diff line
@@ -45,7 +45,8 @@ have disables the InnoDB inlining in this file. */

#include "ha_innodb.h"

pthread_mutex_t innobase_mutex;
pthread_mutex_t innobase_share_mutex, // to protect innobase_open_files
                prepare_commit_mutex; // to force correct commit order in binlog
bool innodb_inited= 0;

/* Store MySQL definition of 'byte': in Linux it is char while InnoDB
@@ -1268,7 +1269,8 @@ innobase_init(void)

	(void) hash_init(&innobase_open_tables,system_charset_info, 32, 0, 0,
			 		(hash_get_key) innobase_get_key, 0, 0);
	pthread_mutex_init(&innobase_mutex, MY_MUTEX_INIT_FAST);
        pthread_mutex_init(&innobase_share_mutex, MY_MUTEX_INIT_FAST);
        pthread_mutex_init(&prepare_commit_mutex, MY_MUTEX_INIT_FAST);
	innodb_inited= 1;

	/* If this is a replication slave and we needed to do a crash recovery,
@@ -1322,7 +1324,8 @@ innobase_end(void)
	  	hash_free(&innobase_open_tables);
	  	my_free(internal_innobase_data_file_path,
						MYF(MY_ALLOW_ZERO_PTR));
	  	pthread_mutex_destroy(&innobase_mutex);
                pthread_mutex_destroy(&innobase_share_mutex);
                pthread_mutex_destroy(&prepare_commit_mutex);
	}

  	DBUG_RETURN(err);
@@ -1480,9 +1483,20 @@ innobase_commit(
 		/* We were instructed to commit the whole transaction, or
		this is an SQL statement end and autocommit is on */

                /* We need current binlog position for HotBackup to work.
                Note, the position is current because of prepare_commit_mutex */
                trx->mysql_log_file_name = mysql_bin_log.get_log_fname();
                trx->mysql_log_offset =
                        (ib_longlong)mysql_bin_log.get_log_file()->pos_in_file;

		innobase_commit_low(trx);

                if (trx->active_trans == 2) {

                        pthread_mutex_unlock(&prepare_commit_mutex);
                }
                trx->active_trans = 0;

	} else {
	        /* We just mark the SQL statement ended and do not do a
		transaction commit */
@@ -5953,7 +5967,7 @@ static mysql_byte* innobase_get_key(INNOBASE_SHARE *share,uint *length,
static INNOBASE_SHARE *get_share(const char *table_name)
{
  INNOBASE_SHARE *share;
  pthread_mutex_lock(&innobase_mutex);
  pthread_mutex_lock(&innobase_share_mutex);
  uint length=(uint) strlen(table_name);
  if (!(share=(INNOBASE_SHARE*) hash_search(&innobase_open_tables,
					(mysql_byte*) table_name,
@@ -5967,7 +5981,7 @@ static INNOBASE_SHARE *get_share(const char *table_name)
      strmov(share->table_name,table_name);
      if (my_hash_insert(&innobase_open_tables, (mysql_byte*) share))
      {
	pthread_mutex_unlock(&innobase_mutex);
        pthread_mutex_unlock(&innobase_share_mutex);
	my_free((gptr) share,0);
	return 0;
      }
@@ -5976,13 +5990,13 @@ static INNOBASE_SHARE *get_share(const char *table_name)
    }
  }
  share->use_count++;
  pthread_mutex_unlock(&innobase_mutex);
  pthread_mutex_unlock(&innobase_share_mutex);
  return share;
}

static void free_share(INNOBASE_SHARE *share)
{
  pthread_mutex_lock(&innobase_mutex);
  pthread_mutex_lock(&innobase_share_mutex);
  if (!--share->use_count)
  {
    hash_delete(&innobase_open_tables, (mysql_byte*) share);
@@ -5990,7 +6004,7 @@ static void free_share(INNOBASE_SHARE *share)
    pthread_mutex_destroy(&share->mutex);
    my_free((gptr) share, MYF(0));
  }
  pthread_mutex_unlock(&innobase_mutex);
  pthread_mutex_unlock(&innobase_share_mutex);
}

/*********************************************************************
@@ -6454,15 +6468,19 @@ innobase_xa_prepare(
			FALSE - the current SQL statement ended */
{
	int error = 0;
        trx_t* trx;
        trx_t* trx = check_trx_exists(thd);

        if (thd->lex->sql_command != SQLCOM_XA_PREPARE) {

                pthread_mutex_lock(&prepare_commit_mutex);
                trx->active_trans = 2;
        }

	if (!thd->variables.innodb_support_xa) {

		return(0);
	}

        trx = check_trx_exists(thd);

        trx->xid=thd->transaction.xid;

	/* Release a possible FIFO ticket and search latch. Since we will
+0 −3
Original line number Diff line number Diff line
@@ -526,7 +526,6 @@ void trans_register_ha(THD *thd, bool all, handlerton *ht_arg)

/*
  RETURN
     -1  - cannot prepare
      0  - ok
      1  - error, transaction was rolled back
*/
@@ -539,8 +538,6 @@ int ha_prepare(THD *thd)
#ifdef USING_TRANSACTIONS
  if (trans->nht)
  {
    if (trans->no_2pc)
      DBUG_RETURN(-1);
    for (; *ht; ht++)
    {
      int err;