summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/count_distinct2.result4
-rw-r--r--mysql-test/r/information_schema.result20
-rw-r--r--mysql-test/r/temp_table.result2
-rw-r--r--mysql-test/t/information_schema.test10
-rw-r--r--sql/sql_class.h4
-rw-r--r--sql/sql_select.cc41
-rw-r--r--sql/sql_show.cc1
7 files changed, 72 insertions, 10 deletions
diff --git a/mysql-test/r/count_distinct2.result b/mysql-test/r/count_distinct2.result
index f6b888dec3b..131e3b325ec 100644
--- a/mysql-test/r/count_distinct2.result
+++ b/mysql-test/r/count_distinct2.result
@@ -116,7 +116,7 @@ count(distinct n)
5000
show status like 'Created_tmp_disk_tables';
Variable_name Value
-Created_tmp_disk_tables 2
+Created_tmp_disk_tables 1
drop table t1;
create table t1 (s text);
flush status;
@@ -125,5 +125,5 @@ count(distinct s)
5000
show status like 'Created_tmp_disk_tables';
Variable_name Value
-Created_tmp_disk_tables 2
+Created_tmp_disk_tables 1
drop table t1;
diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result
index a201aa3ed63..121de940560 100644
--- a/mysql-test/r/information_schema.result
+++ b/mysql-test/r/information_schema.result
@@ -494,8 +494,8 @@ select TABLE_NAME,TABLE_TYPE,ENGINE
from information_schema.tables
where table_schema='information_schema' limit 2;
TABLE_NAME TABLE_TYPE ENGINE
-SCHEMATA TEMPORARY MyISAM
-TABLES TEMPORARY MyISAM
+SCHEMATA TEMPORARY MEMORY
+TABLES TEMPORARY MEMORY
show tables from information_schema like "T%";
Tables_in_information_schema (T%)
TABLES
@@ -615,3 +615,19 @@ CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
drop view a2, a1;
drop table t_crashme;
+select table_schema,table_name, column_name from
+information_schema.columns
+where data_type = 'longtext';
+table_schema table_name column_name
+information_schema COLUMNS COLUMN_TYPE
+information_schema ROUTINES ROUTINE_DEFINITION
+information_schema ROUTINES SQL_MODE
+information_schema VIEWS VIEW_DEFINITION
+select table_name, column_name, data_type from information_schema.columns
+where data_type = 'datetime';
+table_name column_name data_type
+TABLES CREATE_TIME datetime
+TABLES UPDATE_TIME datetime
+TABLES CHECK_TIME datetime
+ROUTINES CREATED datetime
+ROUTINES LAST_ALTERED datetime
diff --git a/mysql-test/r/temp_table.result b/mysql-test/r/temp_table.result
index 6e36f24d8b0..2dd58f54327 100644
--- a/mysql-test/r/temp_table.result
+++ b/mysql-test/r/temp_table.result
@@ -94,6 +94,6 @@ d
2002-10-24 14:50:40
show status like "created_tmp%tables";
Variable_name Value
-Created_tmp_disk_tables 1
+Created_tmp_disk_tables 0
Created_tmp_tables 2
drop table t1;
diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test
index 99fbc181136..86d7bad76bc 100644
--- a/mysql-test/t/information_schema.test
+++ b/mysql-test/t/information_schema.test
@@ -390,3 +390,13 @@ while ($tab_count)
--enable_query_log
drop view a2, a1;
drop table t_crashme;
+
+#
+# Bug #7215 information_schema: columns are longtext instead of varchar
+# Bug #7217 information_schema: columns are varbinary() instead of timestamp
+#
+select table_schema,table_name, column_name from
+information_schema.columns
+where data_type = 'longtext';
+select table_name, column_name, data_type from information_schema.columns
+where data_type = 'datetime';
diff --git a/sql/sql_class.h b/sql/sql_class.h
index d57eb3d3cc6..93aacd14753 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -1613,10 +1613,12 @@ public:
/* If >0 convert all blob fields to varchar(convert_blob_length) */
uint convert_blob_length;
CHARSET_INFO *table_charset;
+ bool schema_table;
TMP_TABLE_PARAM()
:copy_field(0), group_parts(0),
- group_length(0), group_null_parts(0), convert_blob_length(0)
+ group_length(0), group_null_parts(0), convert_blob_length(0),
+ schema_table(0)
{}
~TMP_TABLE_PARAM()
{
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 91ced987f6a..f7ff9254f64 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -7676,6 +7676,36 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table,
return new_field;
}
+
+/*
+ Create field for information schema table
+
+ SYNOPSIS
+ create_tmp_field_for_schema()
+ thd Thread handler
+ table Temporary table
+ item Item to create a field for
+
+ RETURN
+ 0 on error
+ new_created field
+*/
+
+Field *create_tmp_field_for_schema(THD *thd, Item *item, TABLE *table)
+{
+ if (item->field_type() == MYSQL_TYPE_VARCHAR)
+ {
+ if (item->max_length > MAX_FIELD_VARCHARLENGTH /
+ item->collation.collation->mbmaxlen)
+ return new Field_blob(item->max_length, item->maybe_null,
+ item->name, table, item->collation.collation);
+ return new Field_varstring(item->max_length, item->maybe_null, item->name,
+ table, item->collation.collation);
+ }
+ return item->tmp_table_field_from_field_type(table);
+}
+
+
/*
Create field for temporary table
@@ -7978,10 +8008,13 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
We here distinguish between UNION and multi-table-updates by the fact
that in the later case group is set to the row pointer.
*/
- Field *new_field= create_tmp_field(thd, table, item, type, &copy_func,
- tmp_from_field, group != 0,
- not_all_columns || group !=0,
- param->convert_blob_length);
+ Field *new_field= (param->schema_table) ?
+ create_tmp_field_for_schema(thd, item, table) :
+ create_tmp_field(thd, table, item, type, &copy_func,
+ tmp_from_field, group != 0,
+ not_all_columns || group !=0,
+ param->convert_blob_length);
+
if (!new_field)
{
if (thd->is_fatal_error)
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index e95b20c29c9..8bf6f36ccdc 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -3017,6 +3017,7 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list)
tmp_table_param->init();
tmp_table_param->table_charset= cs;
tmp_table_param->field_count= field_count;
+ tmp_table_param->schema_table= 1;
SELECT_LEX *select_lex= thd->lex->current_select;
if (!(table= create_tmp_table(thd, tmp_table_param,
field_list, (ORDER*) 0, 0, 0,