List:Commits« Previous MessageNext Message »
From:marko.makela Date:May 28 2012 8:59am
Subject:bzr push into mysql-trunk-wl6255 branch (marko.makela:3873 to 3876) WL#6255
View as plain text  
 3876 Marko Mäkelä	2012-05-28
      WL#6255: Implement in-place DROP PRIMARY KEY (DROP_PK_INDEX)
      when ADD PRIMARY KEY is specified at the same time.
      
      innobase_fts_check_doc_id_index_in_def(): Add an optional output parameter
      for the FTS_DOC_ID column number.
      
      ha_innobase::check_if_supported_inplace_alter(): Allow DROP_PK_INDEX
      only if ADD_PK_INDEX is specified at the same time.
      
      ha_innobase::prepare_inplace_alter_table(): For DROP_PK_INDEX, do not
      collect the clustered index in drop_index[].

    modified:
      mysql-test/r/group_min_max_innodb.result
      mysql-test/suite/innodb/r/innodb_mysql.result
      storage/innobase/handler/handler0alter.cc
 3875 Marko Mäkelä	2012-05-28
      row_merge_read_clustered_index(): Narrow the scope of a loop variable.

    modified:
      storage/innobase/row/row0merge.cc
 3874 Marko Mäkelä	2012-05-28
      Replace ibool with bool.

    modified:
      storage/innobase/handler/handler0alter.cc
 3873 Marko Mäkelä	2012-05-27
      Non-functional changes.
      
      Rename row_log_struct to row_log_t. Remove an unnecessary cast.

    modified:
      storage/innobase/include/row0types.h
      storage/innobase/row/row0ftsort.cc
      storage/innobase/row/row0log.cc
=== modified file 'mysql-test/r/group_min_max_innodb.result'
--- a/mysql-test/r/group_min_max_innodb.result	revid:marko.makela@stripped20120527201004-wm4xl4zhgmczvbac
+++ b/mysql-test/r/group_min_max_innodb.result	revid:marko.makela@stripped528085724-d8zn6ng382v01sd2
@@ -70,7 +70,7 @@ id	select_type	table	type	possible_keys
 1	SIMPLE	t1	index	NULL	PRIMARY	5	NULL	4	Using index; Using temporary
 explain select distinct f1, f2 from t1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	NULL	PRIMARY	5	NULL	3	Using index for group-by; Using temporary
+1	SIMPLE	t1	index	NULL	PRIMARY	5	NULL	4	Using index
 drop table t1;
 create table t1(pk int primary key) engine=innodb;
 create view v1 as select pk from t1 where pk < 20;

=== modified file 'mysql-test/suite/innodb/r/innodb_mysql.result'
--- a/mysql-test/suite/innodb/r/innodb_mysql.result	revid:marko.makela@strippedwm4xl4zhgmczvbac
+++ b/mysql-test/suite/innodb/r/innodb_mysql.result	revid:marko.makela@strippedd8zn6ng382v01sd2
@@ -344,7 +344,7 @@ id	select_type	table	type	possible_keys
 1	SIMPLE	t1	index	NULL	PRIMARY	5	NULL	4	Using index; Using temporary
 explain select distinct f1, f2 from t1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	NULL	PRIMARY	5	NULL	3	Using index for group-by; Using temporary
+1	SIMPLE	t1	index	NULL	PRIMARY	5	NULL	4	Using index
 drop table t1;
 CREATE TABLE t1 (id int(11) NOT NULL PRIMARY KEY, name varchar(20),
 INDEX (name));

=== modified file 'storage/innobase/handler/handler0alter.cc'
--- a/storage/innobase/handler/handler0alter.cc	revid:marko.makela@oracle.com-20120527201004-wm4xl4zhgmczvbac
+++ b/storage/innobase/handler/handler0alter.cc	revid:marko.makela@strippedom-20120528085724-d8zn6ng382v01sd2
@@ -51,6 +51,7 @@ static const Alter_inplace_info::HA_ALTE
 /** Operations for rebuilding a table in place */
 static const Alter_inplace_info::HA_ALTER_FLAGS INNOBASE_INPLACE_REBUILD
 	= Alter_inplace_info::ADD_PK_INDEX
+	| Alter_inplace_info::DROP_PK_INDEX
 	| Alter_inplace_info::CHANGE_CREATE_OPTION
 	/*
 	| Alter_inplace_info::ALTER_COLUMN_NULLABLE
@@ -222,6 +223,15 @@ ha_innobase::check_if_supported_inplace_
 		DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
 	}
 
+	/* DROP PRIMARY KEY is only allowed in combination with ADD
+	PRIMARY KEY. */
+	if ((ha_alter_info->handler_flags
+	     & (Alter_inplace_info::ADD_PK_INDEX
+		| Alter_inplace_info::DROP_PK_INDEX))
+	    == Alter_inplace_info::DROP_PK_INDEX) {
+		DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
+	}
+
 	update_thd();
 	trx_search_latch_release_if_reserved(prebuilt->trx);
 
@@ -1396,7 +1406,7 @@ prepare_inplace_alter_table_dict(
 	bool			add_fts_doc_id_idx)
 {
 	trx_t*			trx;
-	ibool			dict_locked	= FALSE;
+	bool			dict_locked	= false;
 	dict_index_t**		add_index;	/* indexes to be created */
 	ulint*			add_key_nums;	/* MySQL key numbers */
 	ulint			n_add_index;
@@ -1488,7 +1498,7 @@ prepare_inplace_alter_table_dict(
 	or lock waits can happen in it during an index create operation. */
 
 	row_mysql_lock_data_dictionary(trx);
-	dict_locked = TRUE;
+	dict_locked = true;
 
 	online_retry_drop_indexes_low(indexed_table, trx);
 
@@ -1781,7 +1791,7 @@ op_ok:
 	trx_commit_for_mysql(trx);
 
 	row_mysql_unlock_data_dictionary(trx);
-	dict_locked = FALSE;
+	dict_locked = false;
 
 	ut_a(trx->lock.n_active_thrs == 0);
 
@@ -2128,7 +2138,8 @@ found_fk:
 	if (ha_alter_info->index_drop_count) {
 		DBUG_ASSERT(ha_alter_info->handler_flags
 			    & (Alter_inplace_info::DROP_INDEX
-			       | Alter_inplace_info::DROP_UNIQUE_INDEX));
+			       | Alter_inplace_info::DROP_UNIQUE_INDEX
+			       | Alter_inplace_info::DROP_PK_INDEX));
 		/* Check which indexes to drop. */
 		if (!heap) {
 			heap = mem_heap_create(1024);
@@ -2152,12 +2163,11 @@ found_fk:
 					HA_ERR_WRONG_INDEX,
 					"InnoDB could not find key "
 					"with name %s", key->name);
-			} else if (dict_index_is_clust(index)) {
-				my_error(ER_REQUIRES_PRIMARY_KEY, MYF(0));
-				goto err_exit;
 			} else {
 				ut_ad(!index->to_be_dropped);
-				drop_index[n_drop_index++] = index;
+				if (!dict_index_is_clust(index)) {
+					drop_index[n_drop_index++] = index;
+				}
 			}
 		}
 
@@ -2271,10 +2281,14 @@ index_needed:
 			}
 		}
 
-		/* Flag all indexes that are to be dropped. */
-		for (ulint i = 0; i < n_drop_index; i++) {
-			ut_ad(!drop_index[i]->to_be_dropped);
-			drop_index[i]->to_be_dropped = 1;
+		if (!n_drop_index) {
+			drop_index = NULL;
+		} else {
+			/* Flag all indexes that are to be dropped. */
+			for (ulint i = 0; i < n_drop_index; i++) {
+				ut_ad(!drop_index[i]->to_be_dropped);
+				drop_index[i]->to_be_dropped = 1;
+			}
 		}
 
 		row_mysql_unlock_data_dictionary(prebuilt->trx);

=== modified file 'storage/innobase/row/row0merge.cc'
--- a/storage/innobase/row/row0merge.cc	revid:marko.makela@stripped-wm4xl4zhgmczvbac
+++ b/storage/innobase/row/row0merge.cc	revid:marko.makela@stripped01sd2
@@ -1232,7 +1232,6 @@ row_merge_read_clustered_index(
 						index */
 	mtr_t			mtr;		/* Mini transaction */
 	dberr_t			err = DB_SUCCESS;/* Return code */
-	ulint			i;
 	ulint			n_nonnull = 0;	/* number of columns
 						changed to NOT NULL */
 	ulint*			nonnull = NULL;	/* NOT NULL columns */
@@ -1258,7 +1257,7 @@ row_merge_read_clustered_index(
 		mem_alloc(n_index * sizeof *merge_buf));
 
 
-	for (i = 0; i < n_index; i++) {
+	for (ulint i = 0; i < n_index; i++) {
 		if (index[i]->type & DICT_FTS) {
 
 			/* We are building a FT index, make sure
@@ -1316,7 +1315,7 @@ row_merge_read_clustered_index(
 		nonnull = static_cast<ulint*>(
 			mem_alloc(n_cols * sizeof *nonnull));
 
-		for (i = 0; i < n_cols; i++) {
+		for (ulint i = 0; i < n_cols; i++) {
 			if (dict_table_get_nth_col(old_table, i)->prtype
 			    & DATA_NOT_NULL) {
 
@@ -1483,7 +1482,7 @@ row_merge_read_clustered_index(
 				rec, offsets, new_table, &ext, row_heap);
 		ut_ad(row);
 
-		for (i = 0; i < n_nonnull; i++) {
+		for (ulint i = 0; i < n_nonnull; i++) {
 			dfield_t*	field
 				= &row->fields[nonnull[i]];
 			dtype_t*	field_type
@@ -1511,7 +1510,7 @@ write_buffers:
 		/* Build all entries for all the indexes to be created
 		in a single scan of the clustered index. */
 
-		for (i = 0; i < n_index; i++) {
+		for (ulint i = 0; i < n_index; i++) {
 			row_merge_buf_t*	buf	= merge_buf[i];
 			merge_file_t*		file	= &files[i];
 			ulint			rows_added = 0;
@@ -1644,14 +1643,14 @@ all_done:
 	DEBUG_FTS_SORT_PRINT("FTS_SORT: Complete Scan Table\n");
 #endif
 	if (fts_pll_sort) {
-		for (i = 0; i < fts_sort_pll_degree; i++) {
+		for (ulint i = 0; i < fts_sort_pll_degree; i++) {
 			psort_info[i].state = FTS_PARENT_COMPLETE;
 		}
 wait_again:
 		os_event_wait_time_low(fts_parallel_sort_event,
 				       1000000, sig_count);
 
-		for (i = 0; i < fts_sort_pll_degree; i++) {
+		for (ulint i = 0; i < fts_sort_pll_degree; i++) {
 			if (psort_info[i].child_status != FTS_CHILD_COMPLETE) {
 				sig_count = os_event_reset(
 					fts_parallel_sort_event);
@@ -1663,7 +1662,7 @@ wait_again:
 #ifdef FTS_INTERNAL_DIAG_PRINT
 	DEBUG_FTS_SORT_PRINT("FTS_SORT: Complete Tokenization\n");
 #endif
-	for (i = 0; i < n_index; i++) {
+	for (ulint i = 0; i < n_index; i++) {
 		row_merge_buf_free(merge_buf[i]);
 	}
 

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk-wl6255 branch (marko.makela:3873 to 3876) WL#6255marko.makela28 May