Bug #70649 Add increased logging for mtype check in dict_table_schema_check()
Submitted: 17 Oct 2013 15:35 Modified: 17 Oct 2013 16:16
Reporter: Chris Calender Email Updates:
Status: Open Impact on me:
None 
Category:MySQL Server Severity:S4 (Feature request)
Version:5.6.14 OS:Any
Assigned to: CPU Architecture:Any
Tags: dict_table_schema_check, innodb_table_stats

[17 Oct 2013 15:35] Chris Calender
Description:
I'm running into the following error in a 5.6.14 instance on Windows 64-bit:

InnoDB: Error: Column database_name in table "mysql"."innodb_table_stats" is VARCHAR(192) NOT NULL but should be VARCHAR(192) NOT NULL (type mismatch).

It says there is a "type mismatch", but both types are reported as VARCHAR(192).  Note in this case, the 192 is the number of bytes, not the actual length, because the length is 64 (i.e., if you look at the SHOW CREATE TABLE output, you see it is a VARCHAR(64)).

This is a MySQL system table, `mysql`.`innodb_table_stats`, not something I've created.

In trying to debug this, I got to function dict_table_schema_check() in the dict0dict.cc file.

In there, the only section that triggers this error is:

	/* check mtype for exact match */
	if (req_schema->columns[i].mtype != table->cols[j].mtype) {

		ut_snprintf(errstr, errstr_sz,
			"Column %s in table %s is %s "
			"but should be %s (type mismatch).",
			req_schema->columns[i].name,
			ut_format_name(req_schema->table_name,
				TRUE, buf, sizeof(buf)),
			actual_type, req_type);

		return(DB_ERROR);
	}

However, the error does not output neither "mtype" value, so we cannot really see what the mismatch is.

I propose to add both mtypes (req_schema->columns[i].mtype & table->cols[j].mtype) to the error.

That way, we do not see error messages that report the same type saying there is a "type mismatch".

How to repeat:
See above.

Suggested fix:
Add both mtypes (req_schema->columns[i].mtype & table->cols[j].mtype) to the error that is written.