diff --git a/handler/ha_innodb.cc b/handler/ha_innodb.cc
index 76fff790db2bafdb2afd86e856ef79be377c438c..efdc4369458b37c3503e68a2b18e4fe9d5724af8 100644
--- a/handler/ha_innodb.cc
+++ b/handler/ha_innodb.cc
@@ -2984,6 +2984,8 @@ retry:
 	prebuilt = row_create_prebuilt(ib_table);
 
 	prebuilt->mysql_row_len = table->s->reclength;
+	prebuilt->default_rec = table->s->default_values;
+	ut_ad(prebuilt->default_rec);
 
 	/* Looks like MySQL-3.23 sometimes has primary key number != 0 */
 
diff --git a/ibuf/ibuf0ibuf.c b/ibuf/ibuf0ibuf.c
index a0081dcf4249b7b0819584f80ec85c48baf4f836..22f29af84deecec15d81c545c3008943dc74f8da 100644
--- a/ibuf/ibuf0ibuf.c
+++ b/ibuf/ibuf0ibuf.c
@@ -2984,7 +2984,7 @@ ibuf_delete_rec(
 			/* The tablespace has been dropped.  It is possible
 			that another thread has deleted the insert buffer
 			entry.  Do not complain. */
-			goto func_exit;
+			goto commit_and_exit;
 		}
 
 		fprintf(stderr,
@@ -3027,6 +3027,7 @@ ibuf_delete_rec(
 #endif
 	ibuf_size_update(root, mtr);
 
+commit_and_exit:
 	btr_pcur_commit_specify_mtr(pcur, mtr);
 
 func_exit:
diff --git a/include/hash0hash.ic b/include/hash0hash.ic
index 37eb5ec2813e78cefcb6f103e274678039ccfc1d..c9e0536a2709e6b61a823461fdd447466663ee7e 100644
--- a/include/hash0hash.ic
+++ b/include/hash0hash.ic
@@ -71,7 +71,8 @@ hash_get_mutex_no(
 	ulint		fold)	/* in: fold */
 {
 	ut_ad(ut_is_2pow(table->n_mutexes));
-	return(ut_2pow_remainder(fold, table->n_mutexes));
+	return(ut_2pow_remainder(hash_calc_hash(fold, table),
+				 table->n_mutexes));
 }
 
 /****************************************************************
diff --git a/include/row0mysql.h b/include/row0mysql.h
index 596ef169a42f3d985c4b40afb53ff6b55b2fcb58..b5db338fcc468e3f09de4d6182725aa8a5b83959 100644
--- a/include/row0mysql.h
+++ b/include/row0mysql.h
@@ -617,6 +617,8 @@ struct row_prebuilt_struct {
 	byte*		ins_upd_rec_buff;/* buffer for storing data converted
 					to the Innobase format from the MySQL
 					format */
+	const byte*	default_rec;	/* the default values of all columns
+					(a "default row") in MySQL format */
 	ulint		hint_need_to_fetch_extra_cols;
 					/* normally this is set to 0; if this
 					is set to ROW_RETRIEVE_PRIMARY_KEY,
diff --git a/row/row0sel.c b/row/row0sel.c
index 207a89726ba075ea1f3ef93955c6a0a6ac3bbeb7..8d40c6c44ed33e9cacdd0b1d270d4203c7351f99 100644
--- a/row/row0sel.c
+++ b/row/row0sel.c
@@ -2670,6 +2670,7 @@ row_sel_store_mysql_rec(
 	ulint			i;
 
 	ut_ad(prebuilt->mysql_template);
+	ut_ad(prebuilt->default_rec);
 	ut_ad(rec_offs_validate(rec, NULL, offsets));
 
 	if (UNIV_LIKELY_NULL(prebuilt->blob_heap)) {
@@ -2757,58 +2758,14 @@ row_sel_store_mysql_rec(
 					&= ~(byte) templ->mysql_null_bit_mask;
 			}
 		} else {
-			/* MySQL seems to assume the field for an SQL NULL
-			value is set to zero or space. Not taking this into
-			account caused seg faults with NULL BLOB fields, and
-			bug number 154 in the MySQL bug database: GROUP BY
-			and DISTINCT could treat NULL values inequal. */
-			int	pad_char;
+			/* MySQL assumes that the field for an SQL
+			NULL value is set to the default value. */
 
 			mysql_rec[templ->mysql_null_byte_offset]
 				|= (byte) templ->mysql_null_bit_mask;
-			switch (templ->type) {
-			case DATA_VARCHAR:
-			case DATA_BINARY:
-			case DATA_VARMYSQL:
-				if (templ->mysql_type
-				    == DATA_MYSQL_TRUE_VARCHAR) {
-					/* This is a >= 5.0.3 type
-					true VARCHAR.  Zero the field. */
-					pad_char = 0x00;
-					break;
-				}
-				/* Fall through */
-			case DATA_CHAR:
-			case DATA_FIXBINARY:
-			case DATA_MYSQL:
-				/* MySQL pads all string types (except
-				BLOB, TEXT and true VARCHAR) with space. */
-				if (UNIV_UNLIKELY(templ->mbminlen == 2)) {
-					/* Treat UCS2 as a special case. */
-					byte* d	= mysql_rec
-						+ templ->mysql_col_offset;
-					len = templ->mysql_col_len;
-					/* There are two UCS2 bytes per char,
-					so the length has to be even. */
-					ut_a(!(len & 1));
-					/* Pad with 0x0020. */
-					while (len) {
-						*d++ = 0x00;
-						*d++ = 0x20;
-						len -= 2;
-					}
-					continue;
-				}
-				pad_char = 0x20;
-				break;
-			default:
-				pad_char = 0x00;
-				break;
-			}
-
-			ut_ad(!pad_char || templ->mbminlen == 1);
-			memset(mysql_rec + templ->mysql_col_offset,
-			       pad_char, templ->mysql_col_len);
+			memcpy(mysql_rec + templ->mysql_col_offset,
+			       prebuilt->default_rec + templ->mysql_col_offset,
+			       templ->mysql_col_len);
 		}
 	}