changed field names, fields order according to WL description

fixed bug: "create view v7 as select * from information_schema.tables;" failed
parent bb20094e
grant all privileges on test.* to mysqltest_1@localhost; grant all privileges on test.* to mysqltest_1@localhost;
select * from information_schema.SCHEMATA where schema_name > 'm'; select * from information_schema.SCHEMATA where schema_name > 'm';
CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME SQL_PATH
NULL mysql latin1 NULL mysql latin1 NULL
NULL test latin1 NULL test latin1 NULL
select schema_name from information_schema.schemata; select schema_name from information_schema.schemata;
schema_name schema_name
mysql mysql
test test
show databases *; show databases *;
CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME SQL_PATH
NULL mysql latin1 NULL mysql latin1 NULL
NULL test latin1 NULL test latin1 NULL
show databases like 't%'; show databases like 't%';
Database (t%) Database (t%)
test test
...@@ -19,10 +19,10 @@ Database ...@@ -19,10 +19,10 @@ Database
mysql mysql
test test
show databases * where schema_name like 't%'; show databases * where schema_name like 't%';
CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME SQL_PATH
NULL test latin1 NULL test latin1 NULL
show databases * where schema_name = 't%'; show databases * where schema_name = 't%';
CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME SQL_PATH
create database testtets; create database testtets;
create table testtets.t1(a int, b VARCHAR(30), KEY string_data (b)); create table testtets.t1(a int, b VARCHAR(30), KEY string_data (b));
create table test.t2(a int); create table test.t2(a int);
...@@ -119,24 +119,24 @@ Field Type Collation Null Key Default Extra Privileges Comment ...@@ -119,24 +119,24 @@ Field Type Collation Null Key Default Extra Privileges Comment
c char(64) utf8_general_ci select,insert,update,references c char(64) utf8_general_ci select,insert,update,references
select * from information_schema.COLUMNS where table_name="t1" select * from information_schema.COLUMNS where table_name="t1"
and column_name= "a"; and column_name= "a";
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME TYPE COLLATION_NAME IS_NULLABLE KEY COLUMN_DEFAULT EXTRA PRIVILEGES COMMENT TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
NULL testtets t1 a 1 int 0 11 4 0 NULL int(11) NULL YES NULL select,insert,update,references NULL testtets t1 a 1 NULL YES int 11 11 11 0 NULL NULL int(11) select,insert,update,references
show columns * where table_name = "t1"; show columns * where table_name = "t1";
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME TYPE COLLATION_NAME IS_NULLABLE KEY COLUMN_DEFAULT EXTRA PRIVILEGES COMMENT TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
NULL testtets t1 a 1 int 0 11 4 0 NULL int(11) NULL YES NULL select,insert,update,references NULL testtets t1 a 1 NULL YES int 11 11 11 0 NULL NULL int(11) select,insert,update,references
NULL testtets t1 b 2 varchar 30 30 30 31 latin1 varchar(30) latin1_swedish_ci YES MUL NULL select,insert,update,references NULL testtets t1 b 2 NULL YES varchar 30 30 NULL NULL latin1 latin1_swedish_ci varchar(30) MUL select,insert,update,references
drop view v1; drop view v1;
drop tables testtets.t4, testtets.t1, t2, t3; drop tables testtets.t4, testtets.t1, t2, t3;
drop database testtets; drop database testtets;
select * from information_schema.CHARACTER_SETS select * from information_schema.CHARACTER_SETS
where CHARACTER_SET_NAME like 'latin1%'; where CHARACTER_SET_NAME like 'latin1%';
CHARACTER_SET_NAME Description DEFAULT_COLLATE_NAME Maxlen CHARACTER_SET_NAME DESCRIPTION DEFAULT_COLLATE_NAME MAXLEN
latin1 ISO 8859-1 West European latin1_swedish_ci 1 latin1 ISO 8859-1 West European latin1_swedish_ci 1
SHOW CHARACTER SET LIKE 'latin1%'; SHOW CHARACTER SET LIKE 'latin1%';
Charset Description Default collation Maxlen Charset Description Default collation Maxlen
latin1 ISO 8859-1 West European latin1_swedish_ci 1 latin1 ISO 8859-1 West European latin1_swedish_ci 1
SHOW CHARACTER SET * LIKE 'latin1%'; SHOW CHARACTER SET * LIKE 'latin1%';
CHARACTER_SET_NAME Description DEFAULT_COLLATE_NAME Maxlen CHARACTER_SET_NAME DESCRIPTION DEFAULT_COLLATE_NAME MAXLEN
latin1 ISO 8859-1 West European latin1_swedish_ci 1 latin1 ISO 8859-1 West European latin1_swedish_ci 1
SHOW CHARACTER SET WHERE CHARACTER_SET_NAME like 'latin1%'; SHOW CHARACTER SET WHERE CHARACTER_SET_NAME like 'latin1%';
Charset Description Default collation Maxlen Charset Description Default collation Maxlen
...@@ -145,11 +145,11 @@ SHOW CHARACTER SET CHARACTER_SET_NAME WHERE CHARACTER_SET_NAME like 'latin1%'; ...@@ -145,11 +145,11 @@ SHOW CHARACTER SET CHARACTER_SET_NAME WHERE CHARACTER_SET_NAME like 'latin1%';
CHARACTER_SET_NAME CHARACTER_SET_NAME
latin1 latin1
SHOW CHARACTER SET * WHERE CHARACTER_SET_NAME like 'latin1%'; SHOW CHARACTER SET * WHERE CHARACTER_SET_NAME like 'latin1%';
CHARACTER_SET_NAME Description DEFAULT_COLLATE_NAME Maxlen CHARACTER_SET_NAME DESCRIPTION DEFAULT_COLLATE_NAME MAXLEN
latin1 ISO 8859-1 West European latin1_swedish_ci 1 latin1 ISO 8859-1 West European latin1_swedish_ci 1
select * from information_schema.COLLATIONS select * from information_schema.COLLATIONS
where COLLATION_NAME like 'latin1%'; where COLLATION_NAME like 'latin1%';
COLLATION_NAME Charset Id Default Compiled Sortlen COLLATION_NAME CHARSET ID DEFAULT COMPILED SORTLEN
latin1_german1_ci latin1 5 0 latin1_german1_ci latin1 5 0
latin1_swedish_ci latin1 8 Yes Yes 1 latin1_swedish_ci latin1 8 Yes Yes 1
latin1_danish_ci latin1 15 0 latin1_danish_ci latin1 15 0
...@@ -169,7 +169,7 @@ latin1_general_ci latin1 48 0 ...@@ -169,7 +169,7 @@ latin1_general_ci latin1 48 0
latin1_general_cs latin1 49 0 latin1_general_cs latin1 49 0
latin1_spanish_ci latin1 94 0 latin1_spanish_ci latin1 94 0
SHOW COLLATION * LIKE 'latin1%'; SHOW COLLATION * LIKE 'latin1%';
COLLATION_NAME Charset Id Default Compiled Sortlen COLLATION_NAME CHARSET ID DEFAULT COMPILED SORTLEN
latin1_german1_ci latin1 5 0 latin1_german1_ci latin1 5 0
latin1_swedish_ci latin1 8 Yes Yes 1 latin1_swedish_ci latin1 8 Yes Yes 1
latin1_danish_ci latin1 15 0 latin1_danish_ci latin1 15 0
...@@ -199,7 +199,7 @@ latin1_general_ci ...@@ -199,7 +199,7 @@ latin1_general_ci
latin1_general_cs latin1_general_cs
latin1_spanish_ci latin1_spanish_ci
SHOW COLLATION * WHERE COLLATION_NAME like 'latin1%'; SHOW COLLATION * WHERE COLLATION_NAME like 'latin1%';
COLLATION_NAME Charset Id Default Compiled Sortlen COLLATION_NAME CHARSET ID DEFAULT COMPILED SORTLEN
latin1_german1_ci latin1 5 0 latin1_german1_ci latin1 5 0
latin1_swedish_ci latin1 8 Yes Yes 1 latin1_swedish_ci latin1 8 Yes Yes 1
latin1_danish_ci latin1 15 0 latin1_danish_ci latin1 15 0
...@@ -358,11 +358,11 @@ NULL test key_1 test t1 UNIQUE NULL ...@@ -358,11 +358,11 @@ NULL test key_1 test t1 UNIQUE NULL
NULL test key_2 test t1 UNIQUE NULL NULL test key_2 test t1 UNIQUE NULL
select * from information_schema.KEY_COLUMN_USAGE where select * from information_schema.KEY_COLUMN_USAGE where
TABLE_SCHEMA= "test"; TABLE_SCHEMA= "test";
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME
NULL test PRIMARY test t1 a 1 NULL NULL NULL NULL test PRIMARY NULL test t1 a 1 NULL NULL NULL
NULL test constraint_1 test t1 a 1 NULL NULL NULL NULL test constraint_1 NULL test t1 a 1 NULL NULL NULL
NULL test key_1 test t1 a 1 NULL NULL NULL NULL test key_1 NULL test t1 a 1 NULL NULL NULL
NULL test key_2 test t1 a 1 NULL NULL NULL NULL test key_2 NULL test t1 a 1 NULL NULL NULL
drop table t1; drop table t1;
CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB; CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id), CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id),
...@@ -377,11 +377,11 @@ NULL test t2_ibfk_1 test t2 FOREIGN KEY ON DELETE CASCADE ...@@ -377,11 +377,11 @@ NULL test t2_ibfk_1 test t2 FOREIGN KEY ON DELETE CASCADE
NULL test t2_ibfk_2 test t2 FOREIGN KEY ON UPDATE CASCADE NULL test t2_ibfk_2 test t2 FOREIGN KEY ON UPDATE CASCADE
select * from information_schema.KEY_COLUMN_USAGE where select * from information_schema.KEY_COLUMN_USAGE where
TABLE_SCHEMA= "test"; TABLE_SCHEMA= "test";
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME
NULL test PRIMARY test t1 id 1 NULL NULL NULL NULL test PRIMARY NULL test t1 id 1 NULL NULL NULL
NULL test PRIMARY test t2 id 1 NULL NULL NULL NULL test PRIMARY NULL test t2 id 1 NULL NULL NULL
NULL test t2_ibfk_1 test t2 t1_id 1 test t1 id NULL test t2_ibfk_1 NULL test t2 t1_id 1 NULL id
NULL test t2_ibfk_2 test t2 t1_id 1 test t1 id NULL test t2_ibfk_2 NULL test t2 t1_id 1 NULL id
select table_name from information_schema.TABLES where table_schema like "test%"; select table_name from information_schema.TABLES where table_schema like "test%";
table_name table_name
t1 t1
...@@ -439,6 +439,9 @@ v ...@@ -439,6 +439,9 @@ v
call px5()// call px5()//
v v
9 9
select sql_mode from information_schema.ROUTINES;
sql_mode
create table t1 (a int not null auto_increment,b int, primary key (a)); create table t1 (a int not null auto_increment,b int, primary key (a));
insert into t1 values (1,1),(NULL,3),(NULL,4); insert into t1 values (1,1),(NULL,3),(NULL,4);
select AUTO_INCREMENT from information_schema.tables where table_name = 't1'; select AUTO_INCREMENT from information_schema.tables where table_name = 't1';
...@@ -457,32 +460,51 @@ SHOW CREATE TABLE INFORMATION_SCHEMA.CHARACTER_SETS; ...@@ -457,32 +460,51 @@ SHOW CREATE TABLE INFORMATION_SCHEMA.CHARACTER_SETS;
Table Create Table Table Create Table
CHARACTER_SETS CREATE TEMPORARY TABLE `CHARACTER_SETS` ( CHARACTER_SETS CREATE TEMPORARY TABLE `CHARACTER_SETS` (
`CHARACTER_SET_NAME` char(30) NOT NULL default '', `CHARACTER_SET_NAME` char(30) NOT NULL default '',
`Description` char(60) NOT NULL default '', `DESCRIPTION` char(60) NOT NULL default '',
`DEFAULT_COLLATE_NAME` char(60) NOT NULL default '', `DEFAULT_COLLATE_NAME` char(60) NOT NULL default '',
`Maxlen` bigint(3) NOT NULL default '0' `MAXLEN` bigint(3) NOT NULL default '0'
) ENGINE=HEAP DEFAULT CHARSET=utf8 MAX_ROWS=2282 ) ENGINE=HEAP DEFAULT CHARSET=utf8 MAX_ROWS=2282
set names latin2; set names latin2;
SHOW CREATE TABLE INFORMATION_SCHEMA.CHARACTER_SETS; SHOW CREATE TABLE INFORMATION_SCHEMA.CHARACTER_SETS;
Table Create Table Table Create Table
CHARACTER_SETS CREATE TEMPORARY TABLE `CHARACTER_SETS` ( CHARACTER_SETS CREATE TEMPORARY TABLE `CHARACTER_SETS` (
`CHARACTER_SET_NAME` char(30) NOT NULL default '', `CHARACTER_SET_NAME` char(30) NOT NULL default '',
`Description` char(60) NOT NULL default '', `DESCRIPTION` char(60) NOT NULL default '',
`DEFAULT_COLLATE_NAME` char(60) NOT NULL default '', `DEFAULT_COLLATE_NAME` char(60) NOT NULL default '',
`Maxlen` bigint(3) NOT NULL default '0' `MAXLEN` bigint(3) NOT NULL default '0'
) ENGINE=HEAP DEFAULT CHARSET=utf8 MAX_ROWS=2282 ) ENGINE=HEAP DEFAULT CHARSET=utf8 MAX_ROWS=2282
set names latin1; set names latin1;
create table t1 select * from information_schema.CHARACTER_SETS create table t1 select * from information_schema.CHARACTER_SETS
where CHARACTER_SET_NAME like "latin1"; where CHARACTER_SET_NAME like "latin1";
select * from t1; select * from t1;
CHARACTER_SET_NAME Description DEFAULT_COLLATE_NAME Maxlen CHARACTER_SET_NAME DESCRIPTION DEFAULT_COLLATE_NAME MAXLEN
latin1 ISO 8859-1 West European latin1_swedish_ci 1 latin1 ISO 8859-1 West European latin1_swedish_ci 1
alter table t1 default character set utf8; alter table t1 default character set utf8;
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`CHARACTER_SET_NAME` char(30) NOT NULL default '', `CHARACTER_SET_NAME` char(30) NOT NULL default '',
`Description` char(60) NOT NULL default '', `DESCRIPTION` char(60) NOT NULL default '',
`DEFAULT_COLLATE_NAME` char(60) NOT NULL default '', `DEFAULT_COLLATE_NAME` char(60) NOT NULL default '',
`Maxlen` bigint(3) NOT NULL default '0' `MAXLEN` bigint(3) NOT NULL default '0'
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ) ENGINE=MyISAM DEFAULT CHARSET=utf8
drop table t1; drop table t1;
create view v1 as select * from information_schema.TABLES;
drop view v1;
create table t1(a NUMERIC(5,3), b NUMERIC(5,1), c float(5,2),
d NUMERIC(6,4), e float, f DECIMAL(6,3), g int(11), h DOUBLE(10,3),
i DOUBLE);
select COLUMN_NAME,COLUMN_TYPE, CHARACTER_MAXIMUM_LENGTH,
CHARACTER_OCTET_LENGTH, NUMERIC_PRECISION, NUMERIC_SCALE
from information_schema.columns where table_name= 't1';
COLUMN_NAME COLUMN_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE
a decimal(5,3) 7 7 5 3
b decimal(5,1) 7 7 5 1
c float(5,2) 5 5 5 2
d decimal(6,4) 8 8 6 4
e float 12 12 12 NULL
f decimal(6,3) 8 8 6 3
g int(11) 11 11 11 0
h double(10,3) 10 10 10 3
i double 22 22 22 NULL
drop table t1;
...@@ -217,6 +217,7 @@ end;// ...@@ -217,6 +217,7 @@ end;//
call px5()// call px5()//
call px5()// call px5()//
delimiter ;// delimiter ;//
select sql_mode from information_schema.ROUTINES;
create table t1 (a int not null auto_increment,b int, primary key (a)); create table t1 (a int not null auto_increment,b int, primary key (a));
insert into t1 values (1,1),(NULL,3),(NULL,4); insert into t1 values (1,1),(NULL,3),(NULL,4);
...@@ -240,5 +241,14 @@ where CHARACTER_SET_NAME like "latin1"; ...@@ -240,5 +241,14 @@ where CHARACTER_SET_NAME like "latin1";
select * from t1; select * from t1;
alter table t1 default character set utf8; alter table t1 default character set utf8;
show create table t1; show create table t1;
drop table t1; drop table t1;
create view v1 as select * from information_schema.TABLES;
drop view v1;
create table t1(a NUMERIC(5,3), b NUMERIC(5,1), c float(5,2),
d NUMERIC(6,4), e float, f DECIMAL(6,3), g int(11), h DOUBLE(10,3),
i DOUBLE);
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;
...@@ -2297,17 +2297,16 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables, ...@@ -2297,17 +2297,16 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables,
cs); cs);
table->field[4]->store((longlong) count); table->field[4]->store((longlong) count);
field->sql_type(type); field->sql_type(type);
table->field[11]->store(type.ptr(), type.length(), cs); table->field[14]->store(type.ptr(), type.length(), cs);
tmp_buff= strchr(type.ptr(),'('); tmp_buff= strchr(type.ptr(),'(');
table->field[5]->store(type.ptr(), table->field[7]->store(type.ptr(),
(tmp_buff ? tmp_buff - type.ptr() : (tmp_buff ? tmp_buff - type.ptr() :
type.length()), cs); type.length()), cs);
if (show_table->timestamp_field == field && if (show_table->timestamp_field == field &&
field->unireg_check != Field::TIMESTAMP_UN_FIELD) field->unireg_check != Field::TIMESTAMP_UN_FIELD)
{ {
table->field[15]->store("CURRENT_TIMESTAMP", 17, cs); table->field[5]->store("CURRENT_TIMESTAMP", 17, cs);
table->field[15]->set_notnull(); table->field[5]->set_notnull();
} }
else if (field->unireg_check != Field::NEXT_NUMBER && else if (field->unireg_check != Field::NEXT_NUMBER &&
!field->is_null() && !field->is_null() &&
...@@ -2318,46 +2317,77 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables, ...@@ -2318,46 +2317,77 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables,
field->val_str(&type); field->val_str(&type);
uint dummy_errors; uint dummy_errors;
def.copy(type.ptr(), type.length(), type.charset(), cs, &dummy_errors); def.copy(type.ptr(), type.length(), type.charset(), cs, &dummy_errors);
table->field[15]->store(def.ptr(), def.length(), def.charset()); table->field[5]->store(def.ptr(), def.length(), def.charset());
table->field[15]->set_notnull(); table->field[5]->set_notnull();
} }
else if (field->unireg_check == Field::NEXT_NUMBER || else if (field->unireg_check == Field::NEXT_NUMBER ||
field->maybe_null()) field->maybe_null())
table->field[15]->set_null(); // Null as default table->field[5]->set_null(); // Null as default
else else
{ {
table->field[15]->store("",0, cs); table->field[5]->store("",0, cs);
table->field[15]->set_notnull(); table->field[5]->set_notnull();
} }
pos=(byte*) ((flags & NOT_NULL_FLAG) && pos=(byte*) ((flags & NOT_NULL_FLAG) &&
field->type() != FIELD_TYPE_TIMESTAMP ? field->type() != FIELD_TYPE_TIMESTAMP ?
"" : "YES"); "" : "YES");
table->field[13]->store((const char*) pos, table->field[6]->store((const char*) pos,
strlen((const char*) pos), cs); strlen((const char*) pos), cs);
if (field->has_charset()) if (field->has_charset())
{ table->field[8]->store((longlong) field->field_length/
table->field[6]->store((longlong) field->field_length/
field->charset()->mbmaxlen); field->charset()->mbmaxlen);
else
table->field[8]->store((longlong) field->field_length);
table->field[9]->store((longlong) field->field_length);
{
uint dec =field->decimals();
switch (field->type()) {
case FIELD_TYPE_DECIMAL:
{
uint int_part=field->field_length - (dec ? dec + 1 : 0);
table->field[10]->store((longlong) (int_part + dec - 1));
table->field[10]->set_notnull();
table->field[11]->store((longlong) field->decimals());
table->field[11]->set_notnull();
}
break;
case FIELD_TYPE_TINY:
case FIELD_TYPE_SHORT:
case FIELD_TYPE_LONG:
case FIELD_TYPE_LONGLONG:
case FIELD_TYPE_INT24:
case FIELD_TYPE_FLOAT:
case FIELD_TYPE_DOUBLE:
{
table->field[10]->store((longlong) field->field_length);
table->field[10]->set_notnull();
if (dec != NOT_FIXED_DEC)
{
table->field[11]->store((longlong) dec);
table->field[11]->set_notnull();
}
}
break;
default:
break;
}
} }
table->field[7]->store((longlong) field->field_length);
table->field[8]->store((longlong) field->pack_length());
table->field[9]->store((longlong) field->decimals());
if (field->has_charset()) if (field->has_charset())
{ {
pos=(byte*) field->charset()->csname; pos=(byte*) field->charset()->csname;
table->field[10]->store((const char*) pos,
strlen((const char*) pos), cs);
table->field[10]->set_notnull();
pos=(byte*) field->charset()->name;
table->field[12]->store((const char*) pos, table->field[12]->store((const char*) pos,
strlen((const char*) pos), cs); strlen((const char*) pos), cs);
table->field[12]->set_notnull(); table->field[12]->set_notnull();
pos=(byte*) field->charset()->name;
table->field[13]->store((const char*) pos,
strlen((const char*) pos), cs);
table->field[13]->set_notnull();
} }
pos=(byte*) ((field->flags & PRI_KEY_FLAG) ? "PRI" : pos=(byte*) ((field->flags & PRI_KEY_FLAG) ? "PRI" :
(field->flags & UNIQUE_KEY_FLAG) ? "UNI" : (field->flags & UNIQUE_KEY_FLAG) ? "UNI" :
(field->flags & MULTIPLE_KEY_FLAG) ? "MUL":""); (field->flags & MULTIPLE_KEY_FLAG) ? "MUL":"");
table->field[14]->store((const char*) pos, table->field[15]->store((const char*) pos,
strlen((const char*) pos), cs); strlen((const char*) pos), cs);
char *end=tmp; char *end=tmp;
if (field->unireg_check == Field::NEXT_NUMBER) if (field->unireg_check == Field::NEXT_NUMBER)
...@@ -2511,45 +2541,46 @@ void store_schema_proc(THD *thd, TABLE *table, ...@@ -2511,45 +2541,46 @@ void store_schema_proc(THD *thd, TABLE *table,
{ {
table->field[3]->store(tmp_string.ptr(), tmp_string.length(), cs); table->field[3]->store(tmp_string.ptr(), tmp_string.length(), cs);
tmp_string.length(0); tmp_string.length(0);
get_field(thd->mem_root, proc_table->field[3], &tmp_string);
table->field[0]->store(tmp_string.ptr(), tmp_string.length(), cs);
tmp_string.length(0);
get_field(thd->mem_root, proc_table->field[0], &tmp_string); get_field(thd->mem_root, proc_table->field[0], &tmp_string);
table->field[2]->store(tmp_string.ptr(), tmp_string.length(), cs); table->field[2]->store(tmp_string.ptr(), tmp_string.length(), cs);
tmp_string.length(0); tmp_string.length(0);
get_field(thd->mem_root, proc_table->field[2], &tmp_string); get_field(thd->mem_root, proc_table->field[2], &tmp_string);
table->field[4]->store(tmp_string.ptr(), tmp_string.length(), cs); table->field[4]->store(tmp_string.ptr(), tmp_string.length(), cs);
tmp_string.length(0); tmp_string.length(0);
get_field(thd->mem_root, proc_table->field[3], &tmp_string); get_field(thd->mem_root, proc_table->field[9], &tmp_string);
table->field[0]->store(tmp_string.ptr(), tmp_string.length(), cs); table->field[5]->store(tmp_string.ptr(), tmp_string.length(), cs);
table->field[6]->store("SQL", 3, cs);
tmp_string.length(0); tmp_string.length(0);
get_field(thd->mem_root, proc_table->field[5], &tmp_string); get_field(thd->mem_root, proc_table->field[10], &tmp_string);
table->field[11]->store(tmp_string.ptr(), tmp_string.length(), cs); table->field[7]->store(tmp_string.ptr(), tmp_string.length(), cs);
table->field[8]->store("SQL", 3, cs);
tmp_string.length(0); tmp_string.length(0);
get_field(thd->mem_root, proc_table->field[6], &tmp_string); get_field(thd->mem_root, proc_table->field[6], &tmp_string);
table->field[10]->store(tmp_string.ptr(), tmp_string.length(), cs); table->field[11]->store(tmp_string.ptr(), tmp_string.length(), cs);
tmp_string.length(0);
get_field(thd->mem_root, proc_table->field[7], &tmp_string);
table->field[15]->store(tmp_string.ptr(), tmp_string.length(), cs);
tmp_string.length(0);
get_field(thd->mem_root, proc_table->field[9], &tmp_string);
table->field[6]->store(tmp_string.ptr(), tmp_string.length(), cs);
tmp_string.length(0); tmp_string.length(0);
get_field(thd->mem_root, proc_table->field[10], &tmp_string); get_field(thd->mem_root, proc_table->field[5], &tmp_string);
table->field[8]->store(tmp_string.ptr(), tmp_string.length(), cs); table->field[12]->store(tmp_string.ptr(), tmp_string.length(), cs);
tmp_string.length(0); tmp_string.length(0);
get_field(thd->mem_root, proc_table->field[11], &tmp_string); get_field(thd->mem_root, proc_table->field[7], &tmp_string);
table->field[5]->store(tmp_string.ptr(), tmp_string.length(), cs); table->field[14]->store(tmp_string.ptr(), tmp_string.length(), cs);
bzero((char *)&time, sizeof(time)); bzero((char *)&time, sizeof(time));
((Field_timestamp *) proc_table->field[12])->get_time(&time); ((Field_timestamp *) proc_table->field[12])->get_time(&time);
table->field[14]->store_time(&time, MYSQL_TIMESTAMP_DATETIME); table->field[15]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
bzero((char *)&time, sizeof(time)); bzero((char *)&time, sizeof(time));
((Field_timestamp *) proc_table->field[13])->get_time(&time); ((Field_timestamp *) proc_table->field[13])->get_time(&time);
table->field[13]->store_time(&time, MYSQL_TIMESTAMP_DATETIME); table->field[16]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
tmp_string.length(0);
get_field(thd->mem_root, proc_table->field[14], &tmp_string); get_field(thd->mem_root, proc_table->field[14], &tmp_string);
table->field[16]->store(tmp_string.ptr(), tmp_string.length(), cs); table->field[17]->store(tmp_string.ptr(), tmp_string.length(), cs);
tmp_string.length(0); tmp_string.length(0);
get_field(thd->mem_root, proc_table->field[15], &tmp_string); get_field(thd->mem_root, proc_table->field[15], &tmp_string);
table->field[17]->store(tmp_string.ptr(), tmp_string.length(), cs); table->field[18]->store(tmp_string.ptr(), tmp_string.length(), cs);
table->field[7]->store("SQL", 3, cs); tmp_string.length(0);
table->field[9]->store("SQL", 3, cs); get_field(thd->mem_root, proc_table->field[11], &tmp_string);
table->field[19]->store(tmp_string.ptr(), tmp_string.length(), cs);
table->file->write_row(table->record[0]); table->file->write_row(table->record[0]);
} }
} }
...@@ -2785,11 +2816,11 @@ static int get_schema_key_column_usage_record(THD *thd, ...@@ -2785,11 +2816,11 @@ static int get_schema_key_column_usage_record(THD *thd,
restore_record(table, default_values); restore_record(table, default_values);
table->field[1]->store(base_name, strlen(base_name), cs); table->field[1]->store(base_name, strlen(base_name), cs);
table->field[2]->store(key_info->name, strlen(key_info->name), cs); table->field[2]->store(key_info->name, strlen(key_info->name), cs);
table->field[3]->store(base_name, strlen(base_name), cs); table->field[4]->store(base_name, strlen(base_name), cs);
table->field[4]->store(file_name, strlen(file_name), cs); table->field[5]->store(file_name, strlen(file_name), cs);
table->field[5]->store(key_part->field->field_name, table->field[6]->store(key_part->field->field_name,
strlen(key_part->field->field_name), cs); strlen(key_part->field->field_name), cs);
table->field[6]->store((longlong) f_idx); table->field[7]->store((longlong) f_idx);
table->file->write_row(table->record[0]); table->file->write_row(table->record[0]);
} }
} }
...@@ -2812,18 +2843,18 @@ static int get_schema_key_column_usage_record(THD *thd, ...@@ -2812,18 +2843,18 @@ static int get_schema_key_column_usage_record(THD *thd,
table->field[1]->store(base_name, strlen(base_name), cs); table->field[1]->store(base_name, strlen(base_name), cs);
table->field[2]->store(f_key_info->forein_id->str, table->field[2]->store(f_key_info->forein_id->str,
f_key_info->forein_id->length, cs); f_key_info->forein_id->length, cs);
table->field[3]->store(base_name, strlen(base_name), cs); table->field[4]->store(base_name, strlen(base_name), cs);
table->field[4]->store(file_name, strlen(file_name), cs); table->field[5]->store(file_name, strlen(file_name), cs);
table->field[5]->store(f_info->str, f_info->length, cs); table->field[6]->store(f_info->str, f_info->length, cs);
table->field[6]->store((longlong) f_idx); table->field[7]->store((longlong) f_idx);
table->field[7]->store(f_key_info->referenced_db->str, table->field[8]->store(f_key_info->referenced_db->str,
f_key_info->referenced_db->length, cs); f_key_info->referenced_db->length, cs);
table->field[7]->set_notnull(); table->field[9]->set_notnull();
table->field[8]->store(f_key_info->referenced_table->str, table->field[10]->store(f_key_info->referenced_table->str,
f_key_info->referenced_table->length, cs); f_key_info->referenced_table->length, cs);
table->field[8]->set_notnull();
table->field[9]->store(r_info->str, r_info->length, cs);
table->field[9]->set_notnull(); table->field[9]->set_notnull();
table->field[10]->store(r_info->str, r_info->length, cs);
table->field[10]->set_notnull();
table->file->write_row(table->record[0]); table->file->write_row(table->record[0]);
} }
} }
...@@ -3035,24 +3066,46 @@ int make_table_names_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table) ...@@ -3035,24 +3066,46 @@ int make_table_names_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
int make_columns_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table) int make_columns_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
{ {
ST_FIELD_INFO *field_info= &schema_table->fields_info[3]; int fields_arr[]= {3, 14, 13, 6, 15, 5, 16, 17, 18, -1};
int count= 2; int *field_num= fields_arr;
for ( ; field_info->field_name; field_info++) ST_FIELD_INFO *field_info;
for (; *field_num >= 0; field_num++)
{ {
count++; field_info= &schema_table->fields_info[*field_num];
if (field_info->old_name) if (!thd->lex->verbose && (*field_num == 13 ||
*field_num == 17 ||
*field_num == 18))
continue;
Item_field *field= new Item_field(NullS, NullS, field_info->field_name);
if (field)
{ {
if (!thd->lex->verbose && (count == 12 ||count == 17 || count == 18)) field->set_name(field_info->old_name,
continue; strlen(field_info->old_name),
Item_field *field= new Item_field(NullS, NullS, field_info->field_name); system_charset_info);
if (field) if (add_item_to_list(thd, field))
{ return 1;
field->set_name(field_info->old_name, }
strlen(field_info->old_name), }
system_charset_info); return 0;
if (add_item_to_list(thd, field)) }
return 1;
}
int make_proc_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
{
int fields_arr[]= {2, 3, 4, 19, 16, 15, 14, 18, -1};
int *field_num= fields_arr;
ST_FIELD_INFO *field_info;
for (; *field_num >= 0; field_num++)
{
field_info= &schema_table->fields_info[*field_num];
Item_field *field= new Item_field(NullS, NullS, field_info->field_name);
if (field)
{
field->set_name(field_info->old_name,
strlen(field_info->old_name),
system_charset_info);
if (add_item_to_list(thd, field))
return 1;
} }
} }
return 0; return 0;
...@@ -3197,6 +3250,7 @@ ST_FIELD_INFO schema_fields_info[]= ...@@ -3197,6 +3250,7 @@ ST_FIELD_INFO schema_fields_info[]=
{"CATALOG_NAME", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0}, {"CATALOG_NAME", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0},
{"SCHEMA_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Database"}, {"SCHEMA_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Database"},
{"DEFAULT_CHARACTER_SET_NAME", 60, MYSQL_TYPE_STRING, 0, 0, 0}, {"DEFAULT_CHARACTER_SET_NAME", 60, MYSQL_TYPE_STRING, 0, 0, 0},
{"SQL_PATH", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0},
{0, 0, MYSQL_TYPE_STRING, 0, 0, 0} {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
}; };
...@@ -3210,7 +3264,7 @@ ST_FIELD_INFO tables_fields_info[]= ...@@ -3210,7 +3264,7 @@ ST_FIELD_INFO tables_fields_info[]=
{"ENGINE", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, "Engine"}, {"ENGINE", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, "Engine"},
{"VERSION", 21 , MYSQL_TYPE_LONG, 0, 1, "Version"}, {"VERSION", 21 , MYSQL_TYPE_LONG, 0, 1, "Version"},
{"ROW_FORMAT", 10, MYSQL_TYPE_STRING, 0, 1, "Row_format"}, {"ROW_FORMAT", 10, MYSQL_TYPE_STRING, 0, 1, "Row_format"},
{"ROWS", 21 , MYSQL_TYPE_LONG, 0, 1, "Rows"}, {"TABLE_ROWS", 21 , MYSQL_TYPE_LONG, 0, 1, "Rows"},
{"AVG_ROW_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 1, "Avg_row_length"}, {"AVG_ROW_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 1, "Avg_row_length"},
{"DATA_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 1, "Data_length"}, {"DATA_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 1, "Data_length"},
{"MAX_DATA_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 1, "Max_data_length"}, {"MAX_DATA_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 1, "Max_data_length"},
...@@ -3223,7 +3277,7 @@ ST_FIELD_INFO tables_fields_info[]= ...@@ -3223,7 +3277,7 @@ ST_FIELD_INFO tables_fields_info[]=
{"COLLATION", 60, MYSQL_TYPE_STRING, 0, 1, "Collation"}, {"COLLATION", 60, MYSQL_TYPE_STRING, 0, 1, "Collation"},
{"CHECKSUM", 21 , MYSQL_TYPE_LONG, 0, 1, "Checksum"}, {"CHECKSUM", 21 , MYSQL_TYPE_LONG, 0, 1, "Checksum"},
{"CREATE_OPTIONS", 255, MYSQL_TYPE_STRING, 0, 1, "Create_options"}, {"CREATE_OPTIONS", 255, MYSQL_TYPE_STRING, 0, 1, "Create_options"},
{"COMMENT", 80, MYSQL_TYPE_STRING, 0, 0, "Comment"}, {"TABLE_COMMENT", 80, MYSQL_TYPE_STRING, 0, 0, "Comment"},
{0, 0, MYSQL_TYPE_STRING, 0, 0, 0} {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
}; };
...@@ -3235,20 +3289,20 @@ ST_FIELD_INFO columns_fields_info[]= ...@@ -3235,20 +3289,20 @@ ST_FIELD_INFO columns_fields_info[]=
{"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
{"COLUMN_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Field"}, {"COLUMN_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Field"},
{"ORDINAL_POSITION", 21 , MYSQL_TYPE_LONG, 0, 0, 0}, {"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", 40, MYSQL_TYPE_STRING, 0, 0, 0},
{"CHARACTER_MAXIMUM_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 0, 0}, {"CHARACTER_MAXIMUM_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 0, 0},
{"CHARACTER_OCTET_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, 0, 0}, {"NUMERIC_PRECISION", 21 , MYSQL_TYPE_LONG, 0, 1, 0},
{"NUMERIC_SCALE", 21 , MYSQL_TYPE_LONG, 0, 0, 0}, {"NUMERIC_SCALE", 21 , MYSQL_TYPE_LONG, 0, 1, 0},
{"CHARACTER_SET_NAME", 40, MYSQL_TYPE_STRING, 0, 1, 0}, {"CHARACTER_SET_NAME", 40, MYSQL_TYPE_STRING, 0, 1, 0},
{"TYPE", 40, MYSQL_TYPE_STRING, 0, 0, "Type"},
{"COLLATION_NAME", 40, MYSQL_TYPE_STRING, 0, 1, "Collation"}, {"COLLATION_NAME", 40, MYSQL_TYPE_STRING, 0, 1, "Collation"},
{"IS_NULLABLE", 3, MYSQL_TYPE_STRING, 0, 0, "Null"}, {"COLUMN_TYPE", 40, MYSQL_TYPE_STRING, 0, 0, "Type"},
{"KEY", 3, MYSQL_TYPE_STRING, 0, 0, "Key"}, {"COLUMN_KEY", 3, MYSQL_TYPE_STRING, 0, 0, "Key"},
{"COLUMN_DEFAULT", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, "Default"},
{"EXTRA", 20, MYSQL_TYPE_STRING, 0, 0, "Extra"}, {"EXTRA", 20, MYSQL_TYPE_STRING, 0, 0, "Extra"},
{"PRIVILEGES", 80, MYSQL_TYPE_STRING, 0, 0, "Privileges"}, {"PRIVILEGES", 80, MYSQL_TYPE_STRING, 0, 0, "Privileges"},
{"COMMENT", 255, MYSQL_TYPE_STRING, 0, 0, "Comment"}, {"COLUMN_COMMENT", 255, MYSQL_TYPE_STRING, 0, 0, "Comment"},
{0, 0, MYSQL_TYPE_STRING, 0, 0, 0} {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
}; };
...@@ -3256,9 +3310,9 @@ ST_FIELD_INFO columns_fields_info[]= ...@@ -3256,9 +3310,9 @@ ST_FIELD_INFO columns_fields_info[]=
ST_FIELD_INFO charsets_fields_info[]= ST_FIELD_INFO charsets_fields_info[]=
{ {
{"CHARACTER_SET_NAME", 30, MYSQL_TYPE_STRING, 0, 0, "Charset"}, {"CHARACTER_SET_NAME", 30, MYSQL_TYPE_STRING, 0, 0, "Charset"},
{"Description", 60, MYSQL_TYPE_STRING, 0, 0, "Description"}, {"DESCRIPTION", 60, MYSQL_TYPE_STRING, 0, 0, "Description"},
{"DEFAULT_COLLATE_NAME", 60, MYSQL_TYPE_STRING, 0, 0, "Default collation"}, {"DEFAULT_COLLATE_NAME", 60, MYSQL_TYPE_STRING, 0, 0, "Default collation"},
{"Maxlen", 3 ,MYSQL_TYPE_LONG, 0, 0, "Maxlen"}, {"MAXLEN", 3 ,MYSQL_TYPE_LONG, 0, 0, "Maxlen"},
{0, 0, MYSQL_TYPE_STRING, 0, 0, 0} {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
}; };
...@@ -3266,11 +3320,11 @@ ST_FIELD_INFO charsets_fields_info[]= ...@@ -3266,11 +3320,11 @@ ST_FIELD_INFO charsets_fields_info[]=
ST_FIELD_INFO collation_fields_info[]= ST_FIELD_INFO collation_fields_info[]=
{ {
{"COLLATION_NAME", 30, MYSQL_TYPE_STRING, 0, 0, "Collation"}, {"COLLATION_NAME", 30, MYSQL_TYPE_STRING, 0, 0, "Collation"},
{"Charset", 30, MYSQL_TYPE_STRING, 0, 0, "Charset"}, {"CHARSET", 30, MYSQL_TYPE_STRING, 0, 0, "Charset"},
{"Id", 11, MYSQL_TYPE_LONG, 0, 0, "Id"}, {"ID", 11, MYSQL_TYPE_LONG, 0, 0, "Id"},
{"Default", 30 ,MYSQL_TYPE_STRING, 0, 0, "Default"}, {"DEFAULT", 30 ,MYSQL_TYPE_STRING, 0, 0, "Default"},
{"Compiled", 30 ,MYSQL_TYPE_STRING, 0, 0, "Compiled"}, {"COMPILED", 30 ,MYSQL_TYPE_STRING, 0, 0, "Compiled"},
{"Sortlen", 3 ,MYSQL_TYPE_LONG, 0, 0, "Sortlen"}, {"SORTLEN", 3 ,MYSQL_TYPE_LONG, 0, 0, "Sortlen"},
{0, 0, MYSQL_TYPE_STRING, 0, 0, 0} {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
}; };
...@@ -3290,19 +3344,21 @@ ST_FIELD_INFO proc_fields_info[]= ...@@ -3290,19 +3344,21 @@ ST_FIELD_INFO proc_fields_info[]=
{"ROUTINE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Db"}, {"ROUTINE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Db"},
{"ROUTINE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Name"}, {"ROUTINE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Name"},
{"ROUTINE_TYPE", 9, MYSQL_TYPE_STRING, 0, 0, "Type"}, {"ROUTINE_TYPE", 9, MYSQL_TYPE_STRING, 0, 0, "Type"},
{"DEFINER", 77, MYSQL_TYPE_STRING, 0, 0, "Definer"},
{"DTD_IDENTIFIER", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, {"DTD_IDENTIFIER", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
{"ROUTINE_BODY", 3, MYSQL_TYPE_STRING, 0, 0, 0}, {"ROUTINE_BODY", 3, MYSQL_TYPE_STRING, 0, 0, 0},
{"ROUTINE_DEFINITION", 65535, MYSQL_TYPE_STRING, 0, 0, 0}, {"ROUTINE_DEFINITION", 65535, MYSQL_TYPE_STRING, 0, 0, 0},
{"EXTERNAL_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0},
{"EXTERNAL_LANGUAGE", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0},
{"PARAMETER_STYLE", 3, MYSQL_TYPE_STRING, 0, 0, 0}, {"PARAMETER_STYLE", 3, MYSQL_TYPE_STRING, 0, 0, 0},
{"IS_DETERMINISTIC", 3, MYSQL_TYPE_STRING, 0, 0, 0}, {"IS_DETERMINISTIC", 3, MYSQL_TYPE_STRING, 0, 0, 0},
{"SQL_DATA_ACCESS", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, {"SQL_DATA_ACCESS", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
{"SQL_PATH", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0}, {"SQL_PATH", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0},
{"LAST_ALTERED", 0, MYSQL_TYPE_TIMESTAMP, 0, 0, "Modified"},
{"CREATED", 0, MYSQL_TYPE_TIMESTAMP, 0, 0, "Created"},
{"SECURITY_TYPE", 7, MYSQL_TYPE_STRING, 0, 0, "Security_type"}, {"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", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
{"ROUTINE_COMMENT", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Comment"}, {"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} {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
}; };
...@@ -3404,6 +3460,7 @@ ST_FIELD_INFO key_column_usage_fields_info[]= ...@@ -3404,6 +3460,7 @@ ST_FIELD_INFO key_column_usage_fields_info[]=
{"CONSTRAINT_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0}, {"CONSTRAINT_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0},
{"CONSTRAINT_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, {"CONSTRAINT_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
{"CONSTRAINT_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, {"CONSTRAINT_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
{"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0},
{"TABLE_SCHEMA", 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}, {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
{"COLUMN_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, {"COLUMN_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
...@@ -3444,7 +3501,7 @@ ST_SCHEMA_TABLE schema_tables[]= ...@@ -3444,7 +3501,7 @@ ST_SCHEMA_TABLE schema_tables[]=
{"COLLATION_CHARACTER_SET_APPLICABILITY", coll_charset_app_fields_info, {"COLLATION_CHARACTER_SET_APPLICABILITY", coll_charset_app_fields_info,
create_schema_table, fill_schema_coll_charset_app, 0, 0, -1, -1}, create_schema_table, fill_schema_coll_charset_app, 0, 0, -1, -1},
{"ROUTINES", proc_fields_info, create_schema_table, {"ROUTINES", proc_fields_info, create_schema_table,
fill_schema_proc, make_old_format, 0, -1, -1}, fill_schema_proc, make_proc_old_format, 0, -1, -1},
{"STATISTICS", stat_fields_info, create_schema_table, {"STATISTICS", stat_fields_info, create_schema_table,
get_all_tables, make_old_format, get_schema_stat_record, 1, 2}, get_all_tables, make_old_format, get_schema_stat_record, 1, 2},
{"VIEWS", view_fields_info, create_schema_table, {"VIEWS", view_fields_info, create_schema_table,
...@@ -3460,7 +3517,7 @@ ST_SCHEMA_TABLE schema_tables[]= ...@@ -3460,7 +3517,7 @@ ST_SCHEMA_TABLE schema_tables[]=
{"TABLE_CONSTRAINTS", table_constraints_fields_info, create_schema_table, {"TABLE_CONSTRAINTS", table_constraints_fields_info, create_schema_table,
get_all_tables, 0, get_schema_constarints_record, 3, 4}, get_all_tables, 0, get_schema_constarints_record, 3, 4},
{"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table, {"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table,
get_all_tables, 0, get_schema_key_column_usage_record, 3, 4}, get_all_tables, 0, get_schema_key_column_usage_record, 4, 5},
{"TABLE_NAMES", table_names_fields_info, create_schema_table, {"TABLE_NAMES", table_names_fields_info, create_schema_table,
get_all_tables, make_table_names_old_format, 0, 1, 2}, get_all_tables, make_table_names_old_format, 0, 1, 2},
{0, 0, 0, 0, 0, 0, 0, 0} {0, 0, 0, 0, 0, 0, 0, 0}
......
...@@ -283,7 +283,7 @@ bool mysql_create_view(THD *thd, ...@@ -283,7 +283,7 @@ bool mysql_create_view(THD *thd,
/* /*
Do we have more privileges on view field then underlying table field? Do we have more privileges on view field then underlying table field?
*/ */
if ((~fld->have_privileges & priv)) if (!fld->field->table->tmp_table && (~fld->have_privileges & priv))
{ {
/* VIEW column has more privileges */ /* VIEW column has more privileges */
my_error(ER_COLUMNACCESS_DENIED_ERROR, MYF(0), my_error(ER_COLUMNACCESS_DENIED_ERROR, MYF(0),
......
...@@ -7263,13 +7263,13 @@ static void test_explain_bug() ...@@ -7263,13 +7263,13 @@ static void test_explain_bug()
verify_prepare_field(result, 0, "Field", "COLUMN_NAME", verify_prepare_field(result, 0, "Field", "COLUMN_NAME",
MYSQL_TYPE_STRING, 0, 0, "", 192, 0); MYSQL_TYPE_STRING, 0, 0, "", 192, 0);
verify_prepare_field(result, 1, "Type", "TYPE", verify_prepare_field(result, 1, "Type", "COLUMN_TYPE",
MYSQL_TYPE_STRING, 0, 0, "", 120, 0); MYSQL_TYPE_STRING, 0, 0, "", 120, 0);
verify_prepare_field(result, 2, "Null", "IS_NULLABLE", verify_prepare_field(result, 2, "Null", "IS_NULLABLE",
MYSQL_TYPE_STRING, 0, 0, "", 9, 0); MYSQL_TYPE_STRING, 0, 0, "", 9, 0);
verify_prepare_field(result, 3, "Key", "KEY", verify_prepare_field(result, 3, "Key", "COLUMN_KEY",
MYSQL_TYPE_STRING, 0, 0, "", 9, 0); MYSQL_TYPE_STRING, 0, 0, "", 9, 0);
verify_prepare_field(result, 4, "Default", "COLUMN_DEFAULT", verify_prepare_field(result, 4, "Default", "COLUMN_DEFAULT",
......
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