Commit 03ddc19a authored by Jan Lindström's avatar Jan Lindström

MDEV-6424: MariaDB server crashes with assertion failure in file ha_innodb.c line 11652

This is not a fix, this is instrumentation to find out is MySQL frm dictionary
and InnoDB data dictionary really out-of-sync when this assertion is fired,
or is there some other reason (bug).
parent 42a398b5
......@@ -1998,11 +1998,16 @@ innobase_get_stmt(
THD* thd, /*!< in: MySQL thread handle */
size_t* length) /*!< out: length of the SQL statement */
{
LEX_STRING* stmt;
const char* query = NULL;
LEX_STRING *stmt = NULL;
if (thd) {
stmt = thd_query_string(thd);
if (stmt) {
*length = stmt->length;
return(stmt->str);
query = stmt->str;
}
}
return (query);
}
/**********************************************************************//**
......@@ -6616,7 +6621,66 @@ build_template_field(
UNIV_MEM_INVALID(templ, sizeof *templ);
templ->col_no = i;
templ->clust_rec_field_no = dict_col_get_clust_pos(col, clust_index);
/* If clustered index record field is not found, lets print out
field names and all the rest to understand why field is not found. */
if (templ->clust_rec_field_no == ULINT_UNDEFINED) {
const char* tb_col_name = dict_table_get_col_name(clust_index->table, i);
dict_field_t* field=NULL;
size_t size = 0;
for(ulint j=0; j < clust_index->n_user_defined_cols; j++) {
dict_field_t* ifield = &(clust_index->fields[j]);
if (ifield && !memcmp(tb_col_name, ifield->name,
strlen(tb_col_name))) {
field = ifield;
break;
}
}
ib_logf(IB_LOG_LEVEL_INFO,
"Looking for field %lu name %s from table %s",
i,
(tb_col_name ? tb_col_name : "NULL"),
clust_index->table->name);
for(ulint j=0; j < clust_index->n_user_defined_cols; j++) {
dict_field_t* ifield = &(clust_index->fields[j]);
ib_logf(IB_LOG_LEVEL_INFO,
"InnoDB Table %s field %lu name %s",
clust_index->table->name,
j,
(ifield ? ifield->name : "NULL"));
}
for(ulint j=0; j < table->s->stored_fields; j++) {
ib_logf(IB_LOG_LEVEL_INFO,
"MySQL table %s field %lu name %s",
table->s->table_name.str,
j,
table->field[j]->field_name);
}
ib_logf(IB_LOG_LEVEL_ERROR,
"Clustered record field for column %lu"
" not found table n_user_defined %d"
" index n_user_defined %d"
" InnoDB table %s field name %s"
" MySQL table %s field name %s n_fields %d"
" query %s",
i,
clust_index->n_user_defined_cols,
clust_index->table->n_cols - DATA_N_SYS_COLS,
clust_index->table->name,
(field ? field->name : "NULL"),
table->s->table_name.str,
(tb_col_name ? tb_col_name : "NULL"),
table->s->stored_fields,
innobase_get_stmt(current_thd, &size));
ut_a(templ->clust_rec_field_no != ULINT_UNDEFINED);
}
if (dict_index_is_clust(index)) {
templ->rec_field_no = templ->clust_rec_field_no;
......
......@@ -2355,11 +2355,16 @@ innobase_get_stmt(
THD* thd, /*!< in: MySQL thread handle */
size_t* length) /*!< out: length of the SQL statement */
{
LEX_STRING* stmt;
const char* query = NULL;
LEX_STRING *stmt = NULL;
if (thd) {
stmt = thd_query_string(thd);
if (stmt) {
*length = stmt->length;
return(stmt->str);
query = stmt->str;
}
}
return (query);
}
/**********************************************************************//**
......@@ -7517,7 +7522,66 @@ build_template_field(
UNIV_MEM_INVALID(templ, sizeof *templ);
templ->col_no = i;
templ->clust_rec_field_no = dict_col_get_clust_pos(col, clust_index);
/* If clustered index record field is not found, lets print out
field names and all the rest to understand why field is not found. */
if (templ->clust_rec_field_no == ULINT_UNDEFINED) {
const char* tb_col_name = dict_table_get_col_name(clust_index->table, i);
dict_field_t* field=NULL;
size_t size = 0;
for(ulint j=0; j < clust_index->n_user_defined_cols; j++) {
dict_field_t* ifield = &(clust_index->fields[j]);
if (ifield && !memcmp(tb_col_name, ifield->name,
strlen(tb_col_name))) {
field = ifield;
break;
}
}
ib_logf(IB_LOG_LEVEL_INFO,
"Looking for field %lu name %s from table %s",
i,
(tb_col_name ? tb_col_name : "NULL"),
clust_index->table->name);
for(ulint j=0; j < clust_index->n_user_defined_cols; j++) {
dict_field_t* ifield = &(clust_index->fields[j]);
ib_logf(IB_LOG_LEVEL_INFO,
"InnoDB Table %s field %lu name %s",
clust_index->table->name,
j,
(ifield ? ifield->name : "NULL"));
}
for(ulint j=0; j < table->s->stored_fields; j++) {
ib_logf(IB_LOG_LEVEL_INFO,
"MySQL table %s field %lu name %s",
table->s->table_name.str,
j,
table->field[j]->field_name);
}
ib_logf(IB_LOG_LEVEL_ERROR,
"Clustered record field for column %lu"
" not found table n_user_defined %d"
" index n_user_defined %d"
" InnoDB table %s field name %s"
" MySQL table %s field name %s n_fields %d"
" query %s",
i,
clust_index->n_user_defined_cols,
clust_index->table->n_cols - DATA_N_SYS_COLS,
clust_index->table->name,
(field ? field->name : "NULL"),
table->s->table_name.str,
(tb_col_name ? tb_col_name : "NULL"),
table->s->stored_fields,
innobase_get_stmt(current_thd, &size));
ut_a(templ->clust_rec_field_no != ULINT_UNDEFINED);
}
if (dict_index_is_clust(index)) {
templ->rec_field_no = templ->clust_rec_field_no;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment