Commit 2999284a authored by unknown's avatar unknown

More test cases are added

Fixed bug 'using of alias with information schema tables in views'
removed compiler warnings


mysql-test/r/information_schema.result:
  More test cases are added
mysql-test/t/information_schema.test:
  More test cases are added
sql/sql_select.cc:
  Fixed bug 'using of alias with information schema tables in views'
sql/sql_show.cc:
  Fixed bug 'using of alias with information schema tables in views'
  Changed length of some columns
sql/table.h:
  Fixed bug 'using of alias with information schema tables in views'
tests/client_test.c:
  Changed length of some columns
parent d7ed9470
......@@ -442,6 +442,7 @@ v
select sql_mode from information_schema.ROUTINES;
sql_mode
drop procedure px5;
create table t1 (a int not null auto_increment,b int, primary key (a));
insert into t1 values (1,1),(NULL,3),(NULL,4);
select AUTO_INCREMENT from information_schema.tables where table_name = 't1';
......@@ -508,3 +509,34 @@ g int(11) 11 11 11 0
h double(10,3) 10 10 10 3
i double 22 22 22 NULL
drop table t1;
create table t115 as select table_name, column_name, column_type
from information_schema.columns where table_name = 'proc';
select * from t115;
table_name column_name column_type
proc db varchar(64)
proc name varchar(64)
proc type enum('FUNCTION','PROCEDURE')
proc specific_name varchar(64)
proc language enum('SQL')
proc sql_data_access enum('CONTAINS_SQL','NO_SQL','READS_SQL_DATA','MODIFIES_SQL_DATA')
proc is_deterministic enum('YES','NO')
proc security_type enum('INVOKER','DEFINER')
proc param_list blob
proc returns varchar(64)
proc body blob
proc definer varchar(77)
proc created timestamp
proc modified timestamp
proc sql_mode set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO')
proc comment varchar(64)
drop table t115;
create view vk as select count(*) from information_schema.tables a;
select * from vk;
count(*)
17
drop view vk;
create procedure p108 () begin declare c cursor for select data_type
from information_schema.columns; open c; open c; end;//
call p108()//
ERROR 24000: Cursor is already open
drop procedure p108;
......@@ -218,6 +218,7 @@ call px5()//
call px5()//
delimiter ;//
select sql_mode from information_schema.ROUTINES;
drop procedure px5;
create table t1 (a int not null auto_increment,b int, primary key (a));
insert into t1 values (1,1),(NULL,3),(NULL,4);
......@@ -252,3 +253,20 @@ select COLUMN_NAME,COLUMN_TYPE, CHARACTER_MAXIMUM_LENGTH,
CHARACTER_OCTET_LENGTH, NUMERIC_PRECISION, NUMERIC_SCALE
from information_schema.columns where table_name= 't1';
drop table t1;
create table t115 as select table_name, column_name, column_type
from information_schema.columns where table_name = 'proc';
select * from t115;
drop table t115;
create view vk as select count(*) from information_schema.tables a;
select * from vk;
drop view vk;
delimiter //;
create procedure p108 () begin declare c cursor for select data_type
from information_schema.columns; open c; open c; end;//
--error 1325
call p108()//
delimiter ;//
drop procedure p108;
......@@ -12885,8 +12885,9 @@ void st_table_list::print(THD *thd, String *str)
str->append('.');
if (schema_table)
{
append_identifier(thd, str, alias, strlen(alias));
cmp_name= alias;
append_identifier(thd, str, schema_table_name,
strlen(schema_table_name));
cmp_name= schema_table_name;
}
else
{
......
......@@ -597,7 +597,7 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
else
{
if (table_list->schema_table)
protocol->store(table_list->alias, system_charset_info);
protocol->store(table_list->schema_table_name, system_charset_info);
else
protocol->store(table->table_name, system_charset_info);
if (store_create_info(thd, table_list, &buffer))
......@@ -938,7 +938,7 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet)
else
packet->append("CREATE TABLE ", 13);
if (table_list->schema_table)
alias= table_list->alias;
alias= table_list->schema_table_name;
else
alias= (lower_case_table_names == 2 ? table->table_name :
table->real_name);
......@@ -2193,7 +2193,7 @@ static int get_schema_tables_record(THD *thd, struct st_table_list *tables,
tmp_buff= (show_table->table_charset ? show_table->
table_charset->name : "default");
table->field[17]->store(tmp_buff, strlen(tmp_buff), cs);
if (file->table_flags() & HA_HAS_CHECKSUM)
if (file->table_flags() & (ulong) HA_HAS_CHECKSUM)
{
table->field[18]->store((longlong) file->checksum());
table->field[18]->set_notnull();
......@@ -2282,7 +2282,7 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables,
!wild_case_compare(system_charset_info, field->field_name,wild))
{
uint tmp_length;
char *tmp_buff;
const char *tmp_buff;
byte *pos;
uint flags=field->flags;
char tmp[MAX_FIELD_WIDTH];
......@@ -2298,7 +2298,7 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables,
table->field[4]->store((longlong) count);
field->sql_type(type);
table->field[14]->store(type.ptr(), type.length(), cs);
tmp_buff= strchr(type.ptr(),'(');
tmp_buff= strchr(type.ptr(), '(');
table->field[7]->store(type.ptr(),
(tmp_buff ? tmp_buff - type.ptr() :
type.length()), cs);
......@@ -3137,6 +3137,7 @@ int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list)
}
table->tmp_table= TMP_TABLE;
table->grant.privilege= SELECT_ACL;
table_list->schema_table_name= table_list->real_name;
table_list->real_name= table->real_name;
table_list->table= table;
table->next= thd->derived_tables;
......@@ -3291,14 +3292,14 @@ ST_FIELD_INFO columns_fields_info[]=
{"ORDINAL_POSITION", 21 , MYSQL_TYPE_LONG, 0, 0, 0},
{"COLUMN_DEFAULT", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, "Default"},
{"IS_NULLABLE", 3, MYSQL_TYPE_STRING, 0, 0, "Null"},
{"DATA_TYPE", 40, MYSQL_TYPE_STRING, 0, 0, 0},
{"DATA_TYPE", 65535, MYSQL_TYPE_STRING, 0, 0, 0},
{"CHARACTER_MAXIMUM_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 0, 0},
{"CHARACTER_OCTET_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 0, 0},
{"NUMERIC_PRECISION", 21 , MYSQL_TYPE_LONG, 0, 1, 0},
{"NUMERIC_SCALE", 21 , MYSQL_TYPE_LONG, 0, 1, 0},
{"CHARACTER_SET_NAME", 40, MYSQL_TYPE_STRING, 0, 1, 0},
{"COLLATION_NAME", 40, MYSQL_TYPE_STRING, 0, 1, "Collation"},
{"COLUMN_TYPE", 40, MYSQL_TYPE_STRING, 0, 0, "Type"},
{"COLUMN_TYPE", 65535, MYSQL_TYPE_STRING, 0, 0, "Type"},
{"COLUMN_KEY", 3, MYSQL_TYPE_STRING, 0, 0, "Key"},
{"EXTRA", 20, MYSQL_TYPE_STRING, 0, 0, "Extra"},
{"PRIVILEGES", 80, MYSQL_TYPE_STRING, 0, 0, "Privileges"},
......@@ -3356,7 +3357,7 @@ ST_FIELD_INFO proc_fields_info[]=
{"SECURITY_TYPE", 7, MYSQL_TYPE_STRING, 0, 0, "Security_type"},
{"CREATED", 0, MYSQL_TYPE_TIMESTAMP, 0, 0, "Created"},
{"LAST_ALTERED", 0, MYSQL_TYPE_TIMESTAMP, 0, 0, "Modified"},
{"SQL_MODE", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
{"SQL_MODE", 65535, MYSQL_TYPE_STRING, 0, 0, 0},
{"ROUTINE_COMMENT", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Comment"},
{"DEFINER", 77, MYSQL_TYPE_STRING, 0, 0, "Definer"},
{0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
......
......@@ -281,7 +281,7 @@ typedef struct st_table_list
struct st_table_list *next_local;
/* link in a global list of all queries tables */
struct st_table_list *next_global, **prev_global;
char *db, *alias, *real_name;
char *db, *alias, *real_name, *schema_table_name;
char *option; /* Used by cache index */
Item *on_expr; /* Used with outer join */
COND_EQUAL *cond_equal; /* Used with outer join */
......
......@@ -7280,7 +7280,7 @@ static void test_explain_bug()
MYSQL_TYPE_STRING, 0, 0, "", 192, 0);
verify_prepare_field(result, 1, "Type", "COLUMN_TYPE",
MYSQL_TYPE_STRING, 0, 0, "", 120, 0);
MYSQL_TYPE_BLOB, 0, 0, "", 193203, 0);
verify_prepare_field(result, 2, "Null", "IS_NULLABLE",
MYSQL_TYPE_STRING, 0, 0, "", 9, 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