List:Commits« Previous MessageNext Message »
From:marko.makela Date:February 15 2011 10:42am
Subject:bzr commit into mysql-trunk-innodb branch (marko.makela:3502) Bug#60049
View as plain text  
#At file:///home/marko/innobase/dev/mysql2a/5.6-innodb/ based on revid:marko.makela@strippedg1nuoubwculb

 3502 Marko Mäkelä	2011-02-15
      Bug#60049 Clarify the comments in row_ins_must_modify()
      
      row_ins_must_modify_rec(): Renamed from row_ins_must_modify().
      Change the return type to ibool. Make the parameter const.
      Clarify why we only allow updating the previous record in place.
      
      ROW_INS_PREV, ROW_INS_NEXT: Remove. These were the nonzero return
      values of row_ins_must_modify(). ROW_INS_NEXT was never returned.
      
      row_ins_index_entry_low(): Change the type of "modify" to ibool.
      Remove the handling for ROW_INS_NEXT, which was never returned.
      
      btr_cur_get_block(), btr_cur_get_rec(): Define as constness-preserving
      macros.

    modified:
      storage/innobase/include/btr0cur.h
      storage/innobase/include/btr0cur.ic
      storage/innobase/row/row0ins.c
=== modified file 'storage/innobase/include/btr0cur.h'
--- a/storage/innobase/include/btr0cur.h	revid:marko.makela@oracle.com-20110215102045-2nqfg1nuoubwculb
+++ b/storage/innobase/include/btr0cur.h	revid:marko.makela@stripped110215104253-rk0nqzdo0m6f7bb1
@@ -54,9 +54,6 @@ page_cur_t*
 btr_cur_get_page_cur(
 /*=================*/
 	const btr_cur_t*	cursor);/*!< in: tree cursor */
-#else /* UNIV_DEBUG */
-# define btr_cur_get_page_cur(cursor) (&(cursor)->page_cur)
-#endif /* UNIV_DEBUG */
 /*********************************************************//**
 Returns the buffer block on which the tree cursor is positioned.
 @return	pointer to buffer block */
@@ -64,7 +61,7 @@ UNIV_INLINE
 buf_block_t*
 btr_cur_get_block(
 /*==============*/
-	btr_cur_t*	cursor);/*!< in: tree cursor */
+	const btr_cur_t*	cursor);/*!< in: tree cursor */
 /*********************************************************//**
 Returns the record pointer of a tree cursor.
 @return	pointer to record */
@@ -72,7 +69,12 @@ UNIV_INLINE
 rec_t*
 btr_cur_get_rec(
 /*============*/
-	btr_cur_t*	cursor);/*!< in: tree cursor */
+	const btr_cur_t*	cursor);/*!< in: tree cursor */
+#else /* UNIV_DEBUG */
+# define btr_cur_get_page_cur(cursor)	(&(cursor)->page_cur)
+# define btr_cur_get_block(cursor)	((cursor)->page_cur.block)
+# define btr_cur_get_rec(cursor)	((cursor)->page_cur.rec)
+#endif /* UNIV_DEBUG */
 /*********************************************************//**
 Returns the compressed page on which the tree cursor is positioned.
 @return	pointer to compressed page, or NULL if the page is not compressed */

=== modified file 'storage/innobase/include/btr0cur.ic'
--- a/storage/innobase/include/btr0cur.ic	revid:marko.makela@stripped
+++ b/storage/innobase/include/btr0cur.ic	revid:marko.makela@oracle.com-20110215104253-rk0nqzdo0m6f7bb1
@@ -38,7 +38,7 @@ btr_cur_get_page_cur(
 {
 	return(&((btr_cur_t*) cursor)->page_cur);
 }
-#endif /* UNIV_DEBUG */
+
 /*********************************************************//**
 Returns the buffer block on which the tree cursor is positioned.
 @return	pointer to buffer block */
@@ -46,7 +46,7 @@ UNIV_INLINE
 buf_block_t*
 btr_cur_get_block(
 /*==============*/
-	btr_cur_t*	cursor)	/*!< in: tree cursor */
+	const btr_cur_t*	cursor)	/*!< in: tree cursor */
 {
 	return(page_cur_get_block(btr_cur_get_page_cur(cursor)));
 }
@@ -58,10 +58,11 @@ UNIV_INLINE
 rec_t*
 btr_cur_get_rec(
 /*============*/
-	btr_cur_t*	cursor)	/*!< in: tree cursor */
+	const btr_cur_t*	cursor)	/*!< in: tree cursor */
 {
-	return(page_cur_get_rec(&(cursor->page_cur)));
+	return(page_cur_get_rec(btr_cur_get_page_cur(cursor)));
 }
+#endif /* UNIV_DEBUG */
 
 /*********************************************************//**
 Returns the compressed page on which the tree cursor is positioned.

=== modified file 'storage/innobase/row/row0ins.c'
--- a/storage/innobase/row/row0ins.c	revid:marko.makela@stripped045-2nqfg1nuoubwculb
+++ b/storage/innobase/row/row0ins.c	revid:marko.makela@strippedf7bb1
@@ -48,9 +48,6 @@ Created 4/20/1996 Heikki Tuuri
 #include "usr0sess.h"
 #include "buf0lru.h"
 
-#define	ROW_INS_PREV	1
-#define	ROW_INS_NEXT	2
-
 /*************************************************************************
 IMPORTANT NOTE: Any operation that generates redo MUST check that there
 is enough space in the redo log before for that operation. This is
@@ -1930,23 +1927,22 @@ func_exit:
 }
 
 /***************************************************************//**
-Checks if an index entry has long enough common prefix with an existing
-record so that the intended insert of the entry must be changed to a modify of
-the existing record. In the case of a clustered index, the prefix must be
-n_unique fields long, and in the case of a secondary index, all fields must be
-equal.
-@return 0 if no update, ROW_INS_PREV if previous should be updated;
-currently we do the search so that only the low_match record can match
-enough to the search tuple, not the next record */
+Checks if an index entry has long enough common prefix with an
+existing record so that the intended insert of the entry must be
+changed to a modify of the existing record. In the case of a clustered
+index, the prefix must be n_unique fields long. In the case of a
+secondary index, all fields must be equal.  InnoDB never updates
+secondary index records in place, other than clearing or setting the
+delete-mark flag. We could be able to update the non-unique fields
+of a unique secondary index record by checking the cursor->up_match,
+but we do not do so, because it could have some locking implications.
+@return TRUE if the existing record should be updated; FALSE if not */
 UNIV_INLINE
-ulint
-row_ins_must_modify(
-/*================*/
-	btr_cur_t*	cursor)	/*!< in: B-tree cursor */
+ibool
+row_ins_must_modify_rec(
+/*====================*/
+	const btr_cur_t*	cursor)	/*!< in: B-tree cursor */
 {
-	ulint	enough_match;
-	rec_t*	rec;
-
 	/* NOTE: (compare to the note in row_ins_duplicate_error) Because node
 	pointers on upper levels of the B-tree may match more to entry than
 	to actual user records on the leaf level, we have to check if the
@@ -1954,19 +1950,9 @@ row_ins_must_modify(
 	node pointers contain index->n_unique first fields, and in the case
 	of a secondary index, all fields of the index. */
 
-	enough_match = dict_index_get_n_unique_in_tree(cursor->index);
-
-	if (cursor->low_match >= enough_match) {
-
-		rec = btr_cur_get_rec(cursor);
-
-		if (!page_rec_is_infimum(rec)) {
-
-			return(ROW_INS_PREV);
-		}
-	}
-
-	return(0);
+	return(cursor->low_match
+	       >= dict_index_get_n_unique_in_tree(cursor->index)
+	       && !page_rec_is_infimum(btr_cur_get_rec(cursor)));
 }
 
 /***************************************************************//**
@@ -1994,9 +1980,8 @@ row_ins_index_entry_low(
 {
 	btr_cur_t	cursor;
 	ulint		search_mode;
-	ulint		modify = 0; /* remove warning */
+	ibool		modify			= FALSE;
 	rec_t*		insert_rec;
-	rec_t*		rec;
 	ulint		err;
 	ulint		n_unique;
 	big_rec_t*	big_rec			= NULL;
@@ -2087,20 +2072,13 @@ row_ins_index_entry_low(
 		}
 	}
 
-	modify = row_ins_must_modify(&cursor);
+	modify = row_ins_must_modify_rec(&cursor);
 
-	if (modify != 0) {
+	if (modify) {
 		/* There is already an index entry with a long enough common
 		prefix, we must convert the insert into a modify of an
 		existing record */
 
-		if (modify == ROW_INS_NEXT) {
-			rec = page_rec_get_next(btr_cur_get_rec(&cursor));
-
-			btr_cur_position(index, rec,
-					 btr_cur_get_block(&cursor),&cursor);
-		}
-
 		if (dict_index_is_clust(index)) {
 			err = row_ins_clust_index_entry_by_modify(
 				mode, &cursor, &heap, &big_rec, entry,

Attachment: [text/bzr-bundle] bzr/marko.makela@oracle.com-20110215104253-rk0nqzdo0m6f7bb1.bundle
Thread
bzr commit into mysql-trunk-innodb branch (marko.makela:3502) Bug#60049marko.makela15 Feb