Commit 67457597 authored by unknown's avatar unknown
Browse files

ha_innodb.cc:

  Correct indentation + some small style corrections


sql/ha_innodb.cc:
  Correct indentation + some small style corrections
parent af529fd1
Loading
Loading
Loading
Loading
+118 −97
Original line number Diff line number Diff line
/* Copyright (C) 2000 MySQL AB & Innobase Oy
/* Copyright (C) 2000-2005 MySQL AB & Innobase Oy

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -336,15 +336,19 @@ innobase_release_temporary_latches(
/*===============================*/
        THD *thd)
{
	trx_t*	trx;

	if (!innodb_inited) {
		
		return;
	}

  trx_t *trx= (trx_t*) thd->ha_data[innobase_hton.slot];
  if (trx)
	trx = (trx_t*) thd->ha_data[innobase_hton.slot];

	if (trx) {
        	innobase_release_stat_resources(trx);
	}
}

/************************************************************************
Increments innobase_active_counter and every INNOBASE_WAKE_INTERVALth
@@ -743,14 +747,15 @@ transaction internally. */
static
void
register_trans(
/*============*/
/*===========*/
	THD*	thd)	/* in: thd to use the handle */
{
        /* register the start of the statement */
        /* Register the start of the statement */
        trans_register_ha(thd, FALSE, &innobase_hton);

        if (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) {

              /* no autocommit mode, register for a transaction */
              /* No autocommit mode, register for a transaction */
              trans_register_ha(thd, TRUE, &innobase_hton);
        }
}
@@ -1346,6 +1351,8 @@ innobase_commit_low(
                return;
        }

/* The following will be enabled later when we put the 4.1 functionality back
to 5.0. */
#ifdef DISABLE_HAVE_REPLICATION
        if (current_thd->slave_thread) {
                /* Update the replication position info inside InnoDB */
@@ -1456,7 +1463,8 @@ innobase_commit(
"InnoDB: but trx->conc_state != TRX_NOT_STARTED\n");
	}

        if (all || (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))) {
        if (all
	    || (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))) {
	        
 		/* We were instructed to commit the whole transaction, or
		this is an SQL statement end and autocommit is on */
@@ -1489,10 +1497,9 @@ innobase_commit(
	DBUG_RETURN(0);
}

/*
  don't delete it - it may be re-enabled later
  as an optimization for the most common case InnoDB+binlog
*/
/* The following defined-out code will be enabled later when we put the
MySQL-4.1 functionality back to 5.0. This is needed to get InnoDB Hot Backup
to work. */
#if 0
/*********************************************************************
This is called when MySQL writes the binlog entry for the current
@@ -1627,7 +1634,8 @@ innobase_rollback(
		row_unlock_table_autoinc_for_mysql(trx);
	}

        if (all || (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))) {
        if (all
	    || (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))) {

		error = trx_rollback_for_mysql(trx);
                trx->active_trans = 0;
@@ -1686,6 +1694,7 @@ innobase_rollback_to_savepoint(
	ib_longlong mysql_binlog_cache_pos;
	int	    error = 0;
	trx_t*	    trx;
        char 	    name[64];

	DBUG_ENTER("innobase_rollback_to_savepoint");

@@ -1698,7 +1707,7 @@ innobase_rollback_to_savepoint(
	innobase_release_stat_resources(trx);

        /* TODO: use provided savepoint data area to store savepoint data */
        char name[64];

        longlong2str((ulonglong)savepoint, name, 36);

        error = trx_rollback_to_savepoint_for_mysql(trx, name,
@@ -1708,10 +1717,10 @@ innobase_rollback_to_savepoint(

/*********************************************************************
Release transaction savepoint name. */

static int
static
int
innobase_release_savepoint(
/*===========================*/
/*=======================*/
				/* out: 0 if success, HA_ERR_NO_SAVEPOINT if
				no savepoint with the given name */
	THD*	thd,		/* in: handle to the MySQL thread of the user
@@ -1720,13 +1729,14 @@ innobase_release_savepoint(
{
	int	    error = 0;
	trx_t*	    trx;
        char 	    name[64];

	DBUG_ENTER("innobase_release_savepoint");

	trx = check_trx_exists(thd);

        /* TODO: use provided savepoint data area to store savepoint data */
        char name[64];

        longlong2str((ulonglong)savepoint, name, 36);

	error = trx_release_savepoint_for_mysql(trx, name);
@@ -1736,8 +1746,8 @@ innobase_release_savepoint(

/*********************************************************************
Sets a transaction savepoint. */

static int
static
int
innobase_savepoint(
/*===============*/
				/* out: always 0, that is, always succeeds */
@@ -1911,7 +1921,8 @@ ha_innobase::open(
	fields when packed actually became 1 byte longer, when we also
	stored the string length as the first byte. */

	upd_and_key_val_buff_len = table->s->reclength + table->s->max_key_length
	upd_and_key_val_buff_len =
				table->s->reclength + table->s->max_key_length
							+ MAX_REF_PARTS * 3;
	if (!(mysql_byte*) my_multi_malloc(MYF(MY_WME),
				     &upd_buff, upd_and_key_val_buff_len,
@@ -1963,7 +1974,8 @@ ha_innobase::open(

	innobase_prebuilt = row_create_prebuilt(ib_table);

	((row_prebuilt_t*)innobase_prebuilt)->mysql_row_len = table->s->reclength;
	((row_prebuilt_t*)innobase_prebuilt)->mysql_row_len =
							table->s->reclength;

	/* Looks like MySQL-3.23 sometimes has primary key number != 0 */

@@ -1985,13 +1997,11 @@ ha_innobase::open(

		((row_prebuilt_t*)innobase_prebuilt)
				->clust_index_was_generated = FALSE;
 		/*
		  MySQL allocates the buffer for ref. key_info->key_length
 		/* MySQL allocates the buffer for ref. key_info->key_length
		includes space for all key columns + one byte for each column
		that may be NULL. ref_length must be as exact as possible to
		save space, because all row reference buffers are allocated
		  based on ref_length.
		*/
		based on ref_length. */
 
  		ref_length = table->key_info[primary_key].key_length;
	} else {
@@ -2013,15 +2023,13 @@ ha_innobase::open(

  		ref_length = DATA_ROW_ID_LEN;

		/*
		  If we automatically created the clustered index, then
		/* If we automatically created the clustered index, then
		MySQL does not know about it, and MySQL must NOT be aware
		of the index used on scan, to make it avoid checking if we
		update the column of the index. That is why we assert below
		that key_used_on_scan is the undefined value MAX_KEY.
		The column is the row id in the automatical generation case,
		  and it will never be updated anyway.
		*/
		and it will never be updated anyway. */
	       
		if (key_used_on_scan != MAX_KEY) {
	                fprintf(stderr,
@@ -2611,7 +2619,8 @@ ha_innobase::write_row(
			"InnoDB: Dump of 200 bytes around transaction.all: ",
			stderr);
		ut_print_buf(stderr,
                        ((byte*)(&(current_thd->ha_data[innobase_hton.slot]))) - 100, 200);
           	 ((byte*)(&(current_thd->ha_data[innobase_hton.slot]))) - 100,
								200);
		putc('\n', stderr);
		ut_error;
	}
@@ -2669,6 +2678,7 @@ ha_innobase::write_row(
		} else {
			/* Ensure that there are no other table locks than
			LOCK_IX and LOCK_AUTO_INC on the destination table. */

			if (!lock_is_table_exclusive(prebuilt->table,
							prebuilt->trx)) {
				goto no_commit;
@@ -2765,8 +2775,8 @@ ha_innobase::write_row(
            		error = row_lock_table_autoinc_for_mysql(prebuilt);

            		if (error != DB_SUCCESS) {

              error = convert_error_code_to_mysql(error, user_thd);
              			error = convert_error_code_to_mysql(error,
								user_thd);
              			goto func_exit;
            		}
            		dict_table_autoinc_update(prebuilt->table, auto_inc);
@@ -2785,7 +2795,6 @@ ha_innobase::write_row(
  	DBUG_RETURN(error);
}


/******************************************************************
Converts field data for storage in an InnoDB update vector. */
inline
@@ -4674,19 +4683,25 @@ ha_innobase::read_time(
	ha_rows total_rows;
	double  time_for_scan;
  
	if (index != table->s->primary_key)
	  return handler::read_time(index, ranges, rows); // Not clustered
	if (index != table->s->primary_key) {
		/* Not clustered */		
	  	return(handler::read_time(index, ranges, rows));
	}

	if (rows <= 2) {

	if (rows <= 2)
	  return (double) rows;
		return((double) rows);
	}

	/* Assume that the read time is proportional to the scan time for all
	rows + at most one seek per range. */

	time_for_scan = scan_time();

	if ((total_rows = estimate_rows_upper_bound()) < rows)
	  return time_for_scan;
	if ((total_rows = estimate_rows_upper_bound()) < rows) {

	  	return(time_for_scan);
	}

	return(ranges + (double) rows / (double) total_rows * time_for_scan);
}
@@ -5624,7 +5639,6 @@ innodb_export_status(void)
  srv_export_innodb_status();
}


/****************************************************************************
Implements the SHOW INNODB STATUS command. Sends the output of the InnoDB
Monitor to the client. */
@@ -5636,6 +5650,8 @@ innodb_show_status(
{
        Protocol        *protocol= thd->protocol;
	trx_t*		trx;
	long		flen;
	char*		str;

        DBUG_ENTER("innodb_show_status");

@@ -5652,14 +5668,13 @@ innodb_show_status(

	/* We let the InnoDB Monitor to output at most 64000 bytes of text. */

	long	flen;
	char*	str;

	mutex_enter_noninline(&srv_monitor_file_mutex);
	rewind(srv_monitor_file);

	srv_printf_innodb_monitor(srv_monitor_file);
	flen = ftell(srv_monitor_file);
	os_file_set_eof(srv_monitor_file);

	if (flen < 0) {
		flen = 0;
	} else if (flen > 64000 - 1) {
@@ -5669,9 +5684,9 @@ innodb_show_status(
	/* allocate buffer for the string, and
	read the contents of the temporary file */

	if (!(str = my_malloc(flen + 1, MYF(0))))
        {
	if (!(str = my_malloc(flen + 1, MYF(0)))) {
        	mutex_exit_noninline(&srv_monitor_file_mutex);

        	DBUG_RETURN(TRUE);
        }

@@ -5686,7 +5701,6 @@ innodb_show_status(

	if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS |
                                               Protocol::SEND_EOF)) {

		my_free(str, MYF(0));

		DBUG_RETURN(TRUE);
@@ -5696,10 +5710,12 @@ innodb_show_status(
        protocol->store(str, flen, system_charset_info);
        my_free(str, MYF(0));

        if (protocol->write())
          DBUG_RETURN(TRUE);
        if (protocol->write()) {

        	DBUG_RETURN(TRUE);
	}
	send_eof(thd);

  	DBUG_RETURN(FALSE);
}

@@ -6115,7 +6131,8 @@ ha_innobase::cmp_ref(

	/* Do type-aware comparison of Primary Key members. PK members
	are always NOT NULL, so no checks for NULL are performed */
	KEY_PART_INFO *key_part= table->key_info[table->s->primary_key].key_part;
	KEY_PART_INFO *key_part=
			table->key_info[table->s->primary_key].key_part;
	KEY_PART_INFO *key_part_end= 
	  key_part + table->key_info[table->s->primary_key].key_parts;
	for (; key_part != key_part_end; ++key_part) {
@@ -6264,15 +6281,17 @@ innobase_query_is_update(void)
	    thd->lex->sql_command == SQLCOM_REPLACE_SELECT ||
	    (thd->lex->sql_command == SQLCOM_LOAD &&
	     thd->lex->duplicates == DUP_REPLACE)) {
		return true;

		return(1);
	}

	if (thd->lex->sql_command == SQLCOM_INSERT &&
	    thd->lex->duplicates  == DUP_UPDATE) {
		return true;

		return(1);
	}

	return false;
	return(0);
}
}

@@ -6308,7 +6327,8 @@ innobase_xa_prepare(
"InnoDB: but trx->conc_state != TRX_NOT_STARTED\n");
	}

	if (all || (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))) {
	if (all
	    || (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))) {

                /* We were instructed to prepare the whole transaction, or
                this is an SQL statement end and autocommit is on */
@@ -6359,7 +6379,8 @@ innobase_xa_recover(
	uint	len)		/* in: number of slots in xid_list */
{
	if (len == 0 || xid_list == NULL) {
		return 0;

		return(0);
	}

	return(trx_recover_for_mysql(xid_list, len));
@@ -6373,7 +6394,7 @@ int
innobase_commit_by_xid(
/*===================*/
			/* out: 0 or error number */
	XID*	xid)	/*  in: X/Open XA Transaction Identification */
	XID*	xid)	/* in: X/Open XA transaction identification */
{
	trx_t*	trx;

@@ -6396,7 +6417,7 @@ int
innobase_rollback_by_xid(
/*=====================*/
			/* out: 0 or error number */
	XID	*xid)	/* in : X/Open XA Transaction Idenfification */
	XID	*xid)	/* in: X/Open XA transaction idenfification */
{
	trx_t*	trx;