Index: mysql-test/innodb.result
===================================================================
--- mysql-test/innodb.result	(revision 88)
+++ mysql-test/innodb.result	(working copy)
@@ -2833,3 +2833,14 @@
 ERROR HY000: Error on rename of './test/t3' to './test/t1' (errno: 150)
 set foreign_key_checks=1;
 drop table t2,t3;
+create table t1(a int primary key) row_format=redundant engine=innodb;
+create table t2(a int primary key,constraint foreign key(a)references t1(a)) row_format=compact engine=innodb;
+create table t3(a int primary key) row_format=compact engine=innodb;
+create table t4(a int primary key,constraint foreign key(a)references t3(a)) row_format=redundant engine=innodb;
+insert into t1 values(1);
+insert into t3 values(1);
+insert into t2 values(2);
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test/t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
+insert into t4 values(2);
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test/t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`))
+drop table t4,t3,t2,t1;
Index: mysql-test/innodb.test
===================================================================
--- mysql-test/innodb.test	(revision 88)
+++ mysql-test/innodb.test	(working copy)
@@ -1815,3 +1815,19 @@
 rename table t3 to t1;
 set foreign_key_checks=1;
 drop table t2,t3;
+
+# test that foreign key errors are reported correctly (Bug #15550)
+
+create table t1(a int primary key) row_format=redundant engine=innodb;
+create table t2(a int primary key,constraint foreign key(a)references t1(a)) row_format=compact engine=innodb;
+create table t3(a int primary key) row_format=compact engine=innodb;
+create table t4(a int primary key,constraint foreign key(a)references t3(a)) row_format=redundant engine=innodb;
+
+insert into t1 values(1);
+insert into t3 values(1);
+-- error 1452
+insert into t2 values(2);
+-- error 1452
+insert into t4 values(2);
+
+drop table t4,t3,t2,t1;
Index: row/row0ins.c
===================================================================
--- row/row0ins.c	(revision 90)
+++ row/row0ins.c	(working copy)
@@ -674,6 +674,7 @@
 	rec_t*		rec,		/* in: a record in the parent table:
 					it does not match entry because we
 					have an error! */
+	dict_index_t*	index,		/* in: the index that rec belongs to */
 	dtuple_t*	entry)		/* in: index entry to insert in the
 					child table */
 {
@@ -710,7 +711,7 @@
 	}
 
 	if (rec) {
-		rec_print(ef, rec, foreign->foreign_index);
+		rec_print(ef, rec, index);
 	}
 	putc('\n', ef);
 
@@ -1402,7 +1403,7 @@
 			if (check_ref) {			
 				err = DB_NO_REFERENCED_ROW;
 				row_ins_foreign_report_add_err(
-					trx, foreign, rec, entry);
+					trx, foreign, rec, check_index, entry);
 			} else {
 				err = DB_SUCCESS;
 			}
@@ -1418,7 +1419,7 @@
 			if (check_ref) {			
 				rec = btr_pcur_get_rec(&pcur);
 				row_ins_foreign_report_add_err(
-					trx, foreign, rec, entry);
+					trx, foreign, rec, check_index, entry);
 				err = DB_NO_REFERENCED_ROW;
 			} else {
 				err = DB_SUCCESS;
