Commit 546c6eb3 authored by heikki@donna.mysql.fi's avatar heikki@donna.mysql.fi
Browse files

dict0dict.h InnoDB now tries to provide autoinc column value from a counter table in data dict

dict0mem.h	InnoDB now tries to provide autoinc column value from a counter table in data dict
sync0sync.h	InnoDB now tries to provide autoinc column value from a counter table in data dict
univ.i  	InnoDB now tries to provide autoinc column value from a counter table in data dict
dict0dict.c	InnoDB now tries to provide autoinc column value from a counter table in data dict
dict0mem.c	InnoDB now tries to provide autoinc column value from a counter table in data dict
sync0sync.c	InnoDB now tries to provide autoinc column value from a counter table in data dict
ha_innobase.cc	InnoDB now tries to provide autoinc column value from a counter table in data dict
parent 1970e436
Loading
Loading
Loading
Loading
+67 −0
Original line number Diff line number Diff line
@@ -235,6 +235,71 @@ dict_table_get_index_noninline(
	return(dict_table_get_index(table, name));
}
	
/************************************************************************
Initializes the autoinc counter. It is not an error to initialize already
initialized counter. */

void
dict_table_autoinc_initialize(
/*==========================*/
	dict_table_t*	table,	/* in: table */
	ib_longlong	value)	/* in: value which was assigned to a row */
{
	mutex_enter(&(table->autoinc_mutex));

	table->autoinc_inited = TRUE;
	table->autoinc = value;

	mutex_exit(&(table->autoinc_mutex));
}

/************************************************************************
Gets the next autoinc value, 0 if not yet initialized. */

ib_longlong
dict_table_autoinc_get(
/*===================*/
				/* out: value for a new row, or 0 */
	dict_table_t*	table)	/* in: table */
{
	ib_longlong	value;

	mutex_enter(&(table->autoinc_mutex));

	if (!table->autoinc_inited) {

		value = 0;
	} else {
		table->autoinc = table->autoinc + 1;
		value = table->autoinc;
	}
	
	mutex_exit(&(table->autoinc_mutex));

	return(value);
}

/************************************************************************
Updates the autoinc counter if the value supplied is bigger than the
current value. If not inited, does nothing. */

void
dict_table_autoinc_update(
/*======================*/
	dict_table_t*	table,	/* in: table */
	ib_longlong	value)	/* in: value which was assigned to a row */
{
	mutex_enter(&(table->autoinc_mutex));

	if (table->autoinc_inited) {
		if (value > table->autoinc) {
			table->autoinc = value;
		}
	}	

	mutex_exit(&(table->autoinc_mutex));
}

/************************************************************************
Looks for column n in an index. */

@@ -568,6 +633,8 @@ dict_table_remove_from_cache(
	/* Remove table from LRU list of tables */
	UT_LIST_REMOVE(table_LRU, dict_sys->table_LRU, table);

	mutex_free(&(table->autoinc_mutex));

	size = mem_heap_get_size(table->heap);

	ut_ad(dict_sys->size >= size);
+5 −0
Original line number Diff line number Diff line
@@ -71,6 +71,11 @@ dict_mem_table_create(

	table->stat_modif_counter = 0;
	
	mutex_create(&(table->autoinc_mutex));
	mutex_set_level(&(table->autoinc_mutex), SYNC_DICT_AUTOINC_MUTEX);

	table->autoinc_inited = FALSE;

	table->magic_n = DICT_TABLE_MAGIC_N;
	
	return(table);
+26 −0
Original line number Diff line number Diff line
@@ -88,6 +88,32 @@ ulint
dict_col_get_clust_pos(
/*===================*/
	dict_col_t*	col);
/************************************************************************
Initializes the autoinc counter. It is not an error to initialize already
initialized counter. */

void
dict_table_autoinc_initialize(
/*==========================*/
	dict_table_t*	table,	/* in: table */
	ib_longlong	value);	/* in: value which was assigned to a row */
/************************************************************************
Gets the next autoinc value, 0 if not yet initialized. */

ib_longlong
dict_table_autoinc_get(
/*===================*/
				/* out: value for a new row, or 0 */
	dict_table_t*	table);	/* in: table */
/************************************************************************
Updates the autoinc counter if the value supplied is bigger than the
current value. If not inited, does nothing. */

void
dict_table_autoinc_update(
/*======================*/
	dict_table_t*	table,	/* in: table */
	ib_longlong	value);	/* in: value which was assigned to a row */
/**************************************************************************
Adds a table object to the dictionary cache. */

+10 −0
Original line number Diff line number Diff line
@@ -302,6 +302,16 @@ struct dict_table_struct{
				for MySQL SHOW TABLE STATUS; this counter
				is not protected by any latch, because this
				is only used for heuristics */
	/*----------------------*/
	mutex_t		autoinc_mutex;
				/* mutex protecting the autoincrement
				counter */
	ibool		autoinc_inited;
				/* TRUE if the autoinc counter has been
				inited; MySQL gets the init value by executing
				SELECT MAX(auto inc column) */
	ib_longlong	autoinc;/* autoinc counter value already given to
				a row */	
	ulint		magic_n;/* magic number */
};
#define	DICT_TABLE_MAGIC_N	76333786
+1 −0
Original line number Diff line number Diff line
@@ -372,6 +372,7 @@ Memory pool mutex */
					latching order checking */
#define	SYNC_LEVEL_NONE		2000	/* default: level not defined */
#define SYNC_DICT		1000
#define SYNC_DICT_AUTOINC_MUTEX	999
#define	SYNC_PURGE_IS_RUNNING	997
#define SYNC_DICT_HEADER	995
#define SYNC_IBUF_HEADER	914
Loading