Commit 6434e352 authored by unknown's avatar unknown

BUG#20073 information_schema.FILES for UNDO LOG give incorrect EXTENT_SIZE, FREE_EXTENTS,

Change things around so that we add a row for each log file group that lists
the free space for that log file group.


client/mysqldump.c:
  dump logfile groups correctly (ignore row for the log file group itself)
mysql-test/r/ndb_dd_dump.result:
  update results with new row for log file groups
sql/ha_ndbcluster.cc:
  for fill_files_table:
  - set null bits properly
  - add rows for log file groups with free undo space.
sql/sql_show.cc:
  make most I_S.FILES columns nullable to better fit with reality.
parent c7f93b41
......@@ -2747,6 +2747,7 @@ static int dump_all_tablespaces()
" ENGINE"
" FROM INFORMATION_SCHEMA.FILES"
" WHERE FILE_TYPE = \"UNDO LOG\""
" AND FILE_NAME IS NOT NULL"
" ORDER BY LOGFILE_GROUP_NAME"))
return 1;
......
......@@ -172,6 +172,7 @@ INITIAL_SIZE,
ENGINE
FROM INFORMATION_SCHEMA.FILES WHERE FILE_TYPE="UNDO LOG" ORDER BY FILE_NAME;
LOGFILE_GROUP_NAME FILE_NAME TOTAL_EXTENTS INITIAL_SIZE ENGINE
lg1 NULL NULL NULL ndbcluster
lg1 undofile_lg1_01.dat 524288 2097152 ndbcluster
lg1 undofile_lg1_02.dat 1048576 4194304 ndbcluster
SELECT DISTINCT
......
......@@ -10439,9 +10439,12 @@ static int ndbcluster_fill_files_table(THD *thd, TABLE_LIST *tables,
}
table->field[c++]->set_null(); // FILE_ID
table->field[c]->set_notnull();
table->field[c++]->store(elt.name, strlen(elt.name),
system_charset_info);
table->field[c]->set_notnull();
table->field[c++]->store("DATAFILE",8,system_charset_info);
table->field[c]->set_notnull();
table->field[c++]->store(df.getTablespace(), strlen(df.getTablespace()),
system_charset_info);
table->field[c++]->set_null(); // TABLE_CATALOG
......@@ -10449,10 +10452,12 @@ static int ndbcluster_fill_files_table(THD *thd, TABLE_LIST *tables,
table->field[c++]->set_null(); // TABLE_NAME
// LOGFILE_GROUP_NAME
table->field[c]->set_notnull();
table->field[c++]->store(ts.getDefaultLogfileGroup(),
strlen(ts.getDefaultLogfileGroup()),
system_charset_info);
table->field[c++]->set_null(); // LOGFILE_GROUP_NUMBER
table->field[c]->set_notnull();
table->field[c++]->store(ndbcluster_hton_name,
ndbcluster_hton_name_length,
system_charset_info); // ENGINE
......@@ -10460,11 +10465,16 @@ static int ndbcluster_fill_files_table(THD *thd, TABLE_LIST *tables,
table->field[c++]->set_null(); // FULLTEXT_KEYS
table->field[c++]->set_null(); // DELETED_ROWS
table->field[c++]->set_null(); // UPDATE_COUNT
table->field[c]->set_notnull();
table->field[c++]->store(df.getFree() / ts.getExtentSize()); // FREE_EXTENTS
table->field[c]->set_notnull();
table->field[c++]->store(df.getSize() / ts.getExtentSize()); // TOTAL_EXTENTS
table->field[c]->set_notnull();
table->field[c++]->store(ts.getExtentSize()); // EXTENT_SIZE
table->field[c]->set_notnull();
table->field[c++]->store(df.getSize()); // INITIAL_SIZE
table->field[c]->set_notnull();
table->field[c++]->store(df.getSize()); // MAXIMUM_SIZE
table->field[c++]->set_null(); // AUTOEXTEND_SIZE
......@@ -10474,8 +10484,10 @@ static int ndbcluster_fill_files_table(THD *thd, TABLE_LIST *tables,
table->field[c++]->set_null(); // RECOVER_TIME
table->field[c++]->set_null(); // TRANSACTION_COUNTER
table->field[c]->set_notnull();
table->field[c++]->store(df.getObjectVersion()); // VERSION
table->field[c]->set_notnull();
table->field[c++]->store("FIXED", 5, system_charset_info); // ROW_FORMAT
table->field[c++]->set_null(); // TABLE_ROWS
......@@ -10489,11 +10501,13 @@ static int ndbcluster_fill_files_table(THD *thd, TABLE_LIST *tables,
table->field[c++]->set_null(); // CHECK_TIME
table->field[c++]->set_null(); // CHECKSUM
table->field[c]->set_notnull();
table->field[c++]->store("NORMAL", 6, system_charset_info);
char extra[30];
int len= my_snprintf(extra, sizeof(extra), "CLUSTER_NODE=%u", id);
table->field[c]->store(extra, len, system_charset_info);
table->field[c]->set_notnull();
schema_table_store_record(thd, table);
}
}
......@@ -10534,8 +10548,10 @@ static int ndbcluster_fill_files_table(THD *thd, TABLE_LIST *tables,
int c= 0;
table->field[c++]->set_null(); // FILE_ID
table->field[c]->set_notnull();
table->field[c++]->store(elt.name, strlen(elt.name),
system_charset_info);
table->field[c]->set_notnull();
table->field[c++]->store("UNDO LOG", 8, system_charset_info);
table->field[c++]->set_null(); // TABLESPACE NAME
table->field[c++]->set_null(); // TABLE_CATALOG
......@@ -10545,10 +10561,13 @@ static int ndbcluster_fill_files_table(THD *thd, TABLE_LIST *tables,
// LOGFILE_GROUP_NAME
NdbDictionary::ObjectId objid;
uf.getLogfileGroupId(&objid);
table->field[c]->set_notnull();
table->field[c++]->store(uf.getLogfileGroup(),
strlen(uf.getLogfileGroup()),
system_charset_info);
table->field[c]->set_notnull();
table->field[c++]->store(objid.getObjectId()); // LOGFILE_GROUP_NUMBER
table->field[c]->set_notnull();
table->field[c++]->store(ndbcluster_hton_name,
ndbcluster_hton_name_length,
system_charset_info); // ENGINE
......@@ -10556,11 +10575,15 @@ static int ndbcluster_fill_files_table(THD *thd, TABLE_LIST *tables,
table->field[c++]->set_null(); // FULLTEXT_KEYS
table->field[c++]->set_null(); // DELETED_ROWS
table->field[c++]->set_null(); // UPDATE_COUNT
table->field[c++]->store(lfg.getUndoFreeWords()); // FREE_EXTENTS
table->field[c++]->set_null(); // FREE_EXTENTS
table->field[c]->set_notnull();
table->field[c++]->store(uf.getSize()/4); // TOTAL_EXTENTS
table->field[c]->set_notnull();
table->field[c++]->store(4); // EXTENT_SIZE
table->field[c]->set_notnull();
table->field[c++]->store(uf.getSize()); // INITIAL_SIZE
table->field[c]->set_notnull();
table->field[c++]->store(uf.getSize()); // MAXIMUM_SIZE
table->field[c++]->set_null(); // AUTOEXTEND_SIZE
......@@ -10570,6 +10593,7 @@ static int ndbcluster_fill_files_table(THD *thd, TABLE_LIST *tables,
table->field[c++]->set_null(); // RECOVER_TIME
table->field[c++]->set_null(); // TRANSACTION_COUNTER
table->field[c]->set_notnull();
table->field[c++]->store(uf.getObjectVersion()); // VERSION
table->field[c++]->set_null(); // ROW FORMAT
......@@ -10585,14 +10609,103 @@ static int ndbcluster_fill_files_table(THD *thd, TABLE_LIST *tables,
table->field[c++]->set_null(); // CHECK_TIME
table->field[c++]->set_null(); // CHECKSUM
table->field[c]->set_notnull();
table->field[c++]->store("NORMAL", 6, system_charset_info);
char extra[100];
int len= my_snprintf(extra,sizeof(extra),"CLUSTER_NODE=%u;UNDO_BUFFER_SIZE=%lu",id,lfg.getUndoBufferSize());
table->field[c]->set_notnull();
table->field[c]->store(extra, len, system_charset_info);
schema_table_store_record(thd, table);
}
}
// now for LFGs
NdbDictionary::Dictionary::List lfglist;
dict->listObjects(lfglist, NdbDictionary::Object::LogfileGroup);
ndberr= dict->getNdbError();
if (ndberr.classification != NdbError::NoError)
ERR_RETURN(ndberr);
for (i= 0; i < lfglist.count; i++)
{
NdbDictionary::Dictionary::List::Element& elt= lfglist.elements[i];
unsigned id;
NdbDictionary::LogfileGroup lfg= dict->getLogfileGroup(elt.name);
ndberr= dict->getNdbError();
if (ndberr.classification != NdbError::NoError)
{
if (ndberr.classification == NdbError::SchemaError)
continue;
ERR_RETURN(ndberr);
}
int c= 0;
table->field[c++]->set_null(); // FILE_ID
table->field[c++]->set_null(); // name
table->field[c]->set_notnull();
table->field[c++]->store("UNDO LOG", 8, system_charset_info);
table->field[c++]->set_null(); // TABLESPACE NAME
table->field[c++]->set_null(); // TABLE_CATALOG
table->field[c++]->set_null(); // TABLE_SCHEMA
table->field[c++]->set_null(); // TABLE_NAME
// LOGFILE_GROUP_NAME
table->field[c]->set_notnull();
table->field[c++]->store(elt.name, strlen(elt.name),
system_charset_info);
table->field[c]->set_notnull();
table->field[c++]->store(lfg.getObjectId()); // LOGFILE_GROUP_NUMBER
table->field[c]->set_notnull();
table->field[c++]->store(ndbcluster_hton_name,
ndbcluster_hton_name_length,
system_charset_info); // ENGINE
table->field[c++]->set_null(); // FULLTEXT_KEYS
table->field[c++]->set_null(); // DELETED_ROWS
table->field[c++]->set_null(); // UPDATE_COUNT
table->field[c]->set_notnull();
table->field[c++]->store(lfg.getUndoFreeWords()); // FREE_EXTENTS
table->field[c++]->set_null(); //store(uf.getSize()/4); // TOTAL_EXTENTS
table->field[c]->set_notnull();
table->field[c++]->store(4); // EXTENT_SIZE
table->field[c++]->set_null();//store(uf.getSize()); // INITIAL_SIZE
table->field[c++]->set_null(); //store(uf.getSize()); // MAXIMUM_SIZE
table->field[c++]->set_null(); // AUTOEXTEND_SIZE
table->field[c++]->set_null(); // CREATION_TIME
table->field[c++]->set_null(); // LAST_UPDATE_TIME
table->field[c++]->set_null(); // LAST_ACCESS_TIME
table->field[c++]->set_null(); // RECOVER_TIME
table->field[c++]->set_null(); // TRANSACTION_COUNTER
table->field[c]->set_notnull();
table->field[c++]->store(lfg.getObjectVersion()); // VERSION
table->field[c++]->set_null(); // ROW FORMAT
table->field[c++]->set_null(); // TABLE_ROWS
table->field[c++]->set_null(); // AVG_ROW_LENGTH
table->field[c++]->set_null(); // DATA_LENGTH
table->field[c++]->set_null(); // MAX_DATA_LENGTH
table->field[c++]->set_null(); // INDEX_LENGTH
table->field[c++]->set_null(); // DATA_FREE
table->field[c++]->set_null(); // CREATE_TIME
table->field[c++]->set_null(); // UPDATE_TIME
table->field[c++]->set_null(); // CHECK_TIME
table->field[c++]->set_null(); // CHECKSUM
table->field[c]->set_notnull();
table->field[c++]->store("NORMAL", 6, system_charset_info);
char extra[100];
int len= my_snprintf(extra,sizeof(extra),"UNDO_BUFFER_SIZE=%lu",id,lfg.getUndoBufferSize());
table->field[c]->set_notnull();
table->field[c]->store(extra, len, system_charset_info);
schema_table_store_record(thd, table);
}
DBUG_RETURN(0);
}
......
......@@ -5553,29 +5553,29 @@ ST_FIELD_INFO plugin_fields_info[]=
ST_FIELD_INFO files_fields_info[]=
{
{"FILE_ID", 4, MYSQL_TYPE_LONG, 0, 0, 0},
{"FILE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
{"FILE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0},
{"FILE_TYPE", 20, MYSQL_TYPE_STRING, 0, 0, 0},
{"TABLESPACE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
{"TABLE_CATALOG", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
{"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
{"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
{"LOGFILE_GROUP_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
{"LOGFILE_GROUP_NUMBER", 4, MYSQL_TYPE_LONG, 0, 0, 0},
{"TABLESPACE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0},
{"TABLE_CATALOG", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0},
{"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0},
{"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0},
{"LOGFILE_GROUP_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0},
{"LOGFILE_GROUP_NUMBER", 4, MYSQL_TYPE_LONG, 0, 1, 0},
{"ENGINE", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
{"FULLTEXT_KEYS", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
{"DELETED_ROWS", 4, MYSQL_TYPE_LONG, 0, 0, 0},
{"UPDATE_COUNT", 4, MYSQL_TYPE_LONG, 0, 0, 0},
{"FREE_EXTENTS", 4, MYSQL_TYPE_LONG, 0, 0, 0},
{"TOTAL_EXTENTS", 4, MYSQL_TYPE_LONG, 0, 0, 0},
{"FULLTEXT_KEYS", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0},
{"DELETED_ROWS", 4, MYSQL_TYPE_LONG, 0, 1, 0},
{"UPDATE_COUNT", 4, MYSQL_TYPE_LONG, 0, 1, 0},
{"FREE_EXTENTS", 4, MYSQL_TYPE_LONG, 0, 1, 0},
{"TOTAL_EXTENTS", 4, MYSQL_TYPE_LONG, 0, 1, 0},
{"EXTENT_SIZE", 4, MYSQL_TYPE_LONG, 0, 0, 0},
{"INITIAL_SIZE", 21, MYSQL_TYPE_LONG, 0, 0, 0},
{"MAXIMUM_SIZE", 21, MYSQL_TYPE_LONG, 0, 0, 0},
{"AUTOEXTEND_SIZE", 21, MYSQL_TYPE_LONG, 0, 0, 0},
{"CREATION_TIME", 0, MYSQL_TYPE_TIMESTAMP, 0, 0, 0},
{"LAST_UPDATE_TIME", 0, MYSQL_TYPE_TIMESTAMP, 0, 0, 0},
{"LAST_ACCESS_TIME", 0, MYSQL_TYPE_TIMESTAMP, 0, 0, 0},
{"RECOVER_TIME", 4, MYSQL_TYPE_LONG, 0, 0, 0},
{"TRANSACTION_COUNTER", 4, MYSQL_TYPE_LONG, 0, 0, 0},
{"INITIAL_SIZE", 21, MYSQL_TYPE_LONG, 0, 1, 0},
{"MAXIMUM_SIZE", 21, MYSQL_TYPE_LONG, 0, 1, 0},
{"AUTOEXTEND_SIZE", 21, MYSQL_TYPE_LONG, 0, 1, 0},
{"CREATION_TIME", 0, MYSQL_TYPE_TIMESTAMP, 0, 1, 0},
{"LAST_UPDATE_TIME", 0, MYSQL_TYPE_TIMESTAMP, 0, 1, 0},
{"LAST_ACCESS_TIME", 0, MYSQL_TYPE_TIMESTAMP, 0, 1, 0},
{"RECOVER_TIME", 4, MYSQL_TYPE_LONG, 0, 1, 0},
{"TRANSACTION_COUNTER", 4, MYSQL_TYPE_LONG, 0, 1, 0},
{"VERSION", 21 , MYSQL_TYPE_LONG, 0, 1, "Version"},
{"ROW_FORMAT", 10, MYSQL_TYPE_STRING, 0, 1, "Row_format"},
{"TABLE_ROWS", 21 , MYSQL_TYPE_LONG, 0, 1, "Rows"},
......@@ -5589,7 +5589,7 @@ ST_FIELD_INFO files_fields_info[]=
{"CHECK_TIME", 0, MYSQL_TYPE_TIMESTAMP, 0, 1, "Check_time"},
{"CHECKSUM", 21 , MYSQL_TYPE_LONG, 0, 1, "Checksum"},
{"STATUS", 20, MYSQL_TYPE_STRING, 0, 0, 0},
{"EXTRA", 255, MYSQL_TYPE_STRING, 0, 0, 0},
{"EXTRA", 255, MYSQL_TYPE_STRING, 0, 1, 0},
{0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
};
......
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