Commit b1d2c648 authored by unknown's avatar unknown

Merge bk-internal.mysql.com:/home/bk/mysql-5.0

into mysql.com:/home/my/mysql-5.0
parents 87d2717b 1b051075
...@@ -1935,6 +1935,10 @@ static int dump_databases(char **db_names) ...@@ -1935,6 +1935,10 @@ static int dump_databases(char **db_names)
static int init_dumping(char *database) static int init_dumping(char *database)
{ {
if (mysql_get_server_version(sock) >= 50003 &&
!my_strcasecmp(&my_charset_latin1, database, "information_schema"))
return 1;
if (mysql_select_db(sock, database)) if (mysql_select_db(sock, database))
{ {
DBerror(sock, "when selecting the database"); DBerror(sock, "when selecting the database");
......
...@@ -345,6 +345,33 @@ lock_clust_rec_read_check_and_lock( ...@@ -345,6 +345,33 @@ lock_clust_rec_read_check_and_lock(
LOCK_REC_NOT_GAP */ LOCK_REC_NOT_GAP */
que_thr_t* thr); /* in: query thread */ que_thr_t* thr); /* in: query thread */
/************************************************************************* /*************************************************************************
Checks if locks of other transactions prevent an immediate read, or passing
over by a read cursor, of a clustered index record. If they do, first tests
if the query thread should anyway be suspended for some reason; if not, then
puts the transaction and the query thread to the lock wait state and inserts a
waiting request for a record lock to the lock queue. Sets the requested mode
lock on the record. This is an alternative version of
lock_clust_rec_read_check_and_lock() that does not require the parameter
"offsets". */
ulint
lock_clust_rec_read_check_and_lock_alt(
/*===================================*/
/* out: DB_SUCCESS, DB_LOCK_WAIT,
DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */
ulint flags, /* in: if BTR_NO_LOCKING_FLAG bit is set,
does nothing */
rec_t* rec, /* in: user record or page supremum record
which should be read or passed over by a read
cursor */
dict_index_t* index, /* in: clustered index */
ulint mode, /* in: mode of the lock which the read cursor
should set on records: LOCK_S or LOCK_X; the
latter is possible in SELECT FOR UPDATE */
ulint gap_mode,/* in: LOCK_ORDINARY, LOCK_GAP, or
LOCK_REC_NOT_GAP */
que_thr_t* thr); /* in: query thread */
/*************************************************************************
Checks that a record is seen in a consistent read. */ Checks that a record is seen in a consistent read. */
ibool ibool
......
...@@ -5105,3 +5105,45 @@ lock_clust_rec_read_check_and_lock( ...@@ -5105,3 +5105,45 @@ lock_clust_rec_read_check_and_lock(
return(err); return(err);
} }
/*************************************************************************
Checks if locks of other transactions prevent an immediate read, or passing
over by a read cursor, of a clustered index record. If they do, first tests
if the query thread should anyway be suspended for some reason; if not, then
puts the transaction and the query thread to the lock wait state and inserts a
waiting request for a record lock to the lock queue. Sets the requested mode
lock on the record. This is an alternative version of
lock_clust_rec_read_check_and_lock() that does not require the parameter
"offsets". */
ulint
lock_clust_rec_read_check_and_lock_alt(
/*===================================*/
/* out: DB_SUCCESS, DB_LOCK_WAIT,
DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */
ulint flags, /* in: if BTR_NO_LOCKING_FLAG bit is set,
does nothing */
rec_t* rec, /* in: user record or page supremum record
which should be read or passed over by a read
cursor */
dict_index_t* index, /* in: clustered index */
ulint mode, /* in: mode of the lock which the read cursor
should set on records: LOCK_S or LOCK_X; the
latter is possible in SELECT FOR UPDATE */
ulint gap_mode,/* in: LOCK_ORDINARY, LOCK_GAP, or
LOCK_REC_NOT_GAP */
que_thr_t* thr) /* in: query thread */
{
mem_heap_t* tmp_heap = NULL;
ulint offsets_[100] = { 100, };
ulint* offsets = offsets_;
ulint ret;
offsets = rec_get_offsets(rec, index, offsets,
ULINT_UNDEFINED, &tmp_heap);
ret = lock_clust_rec_read_check_and_lock(flags, rec, index,
offsets, mode, gap_mode, thr);
if (tmp_heap) {
mem_heap_free(tmp_heap);
}
return(ret);
}
...@@ -717,8 +717,6 @@ row_ins_foreign_check_on_constraint( ...@@ -717,8 +717,6 @@ row_ins_foreign_check_on_constraint(
ulint i; ulint i;
trx_t* trx; trx_t* trx;
mem_heap_t* tmp_heap = NULL; mem_heap_t* tmp_heap = NULL;
ulint offsets_[100] = { 100, };
ulint* offsets = offsets_;
ut_a(thr && foreign && pcur && mtr); ut_a(thr && foreign && pcur && mtr);
...@@ -886,10 +884,8 @@ row_ins_foreign_check_on_constraint( ...@@ -886,10 +884,8 @@ row_ins_foreign_check_on_constraint(
we already have a normal shared lock on the appropriate we already have a normal shared lock on the appropriate
gap if the search criterion was not unique */ gap if the search criterion was not unique */
offsets = rec_get_offsets(clust_rec, clust_index, offsets, err = lock_clust_rec_read_check_and_lock_alt(0, clust_rec,
ULINT_UNDEFINED, &tmp_heap); clust_index, LOCK_X, LOCK_REC_NOT_GAP, thr);
err = lock_clust_rec_read_check_and_lock(0, clust_rec,
clust_index, offsets, LOCK_X, LOCK_REC_NOT_GAP, thr);
} }
if (err != DB_SUCCESS) { if (err != DB_SUCCESS) {
......
...@@ -52,9 +52,9 @@ KEY NAME (NAME)); ...@@ -52,9 +52,9 @@ KEY NAME (NAME));
ALTER TABLE t1 CHANGE NAME NAME CHAR(80) not null; ALTER TABLE t1 CHANGE NAME NAME CHAR(80) not null;
SHOW FULL COLUMNS FROM t1; SHOW FULL COLUMNS FROM t1;
Field Type Collation Null Key Default Extra Privileges Comment Field Type Collation Null Key Default Extra Privileges Comment
GROUP_ID int(10) unsigned NULL PRI 0 select,insert,update,references GROUP_ID int(10) unsigned NULL NO PRI 0 select,insert,update,references
LANG_ID smallint(5) unsigned NULL PRI 0 select,insert,update,references LANG_ID smallint(5) unsigned NULL NO PRI 0 select,insert,update,references
NAME char(80) latin1_swedish_ci MUL select,insert,update,references NAME char(80) latin1_swedish_ci NO MUL select,insert,update,references
DROP TABLE t1; DROP TABLE t1;
create table t1 (n int); create table t1 (n int);
insert into t1 values(9),(3),(12),(10); insert into t1 values(9),(3),(12),(10);
...@@ -187,7 +187,7 @@ alter table t1 rename t2; ...@@ -187,7 +187,7 @@ alter table t1 rename t2;
alter table t2 rename t1, add c char(10) comment "no comment"; alter table t2 rename t1, add c char(10) comment "no comment";
show columns from t1; show columns from t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
i int(10) unsigned PRI NULL auto_increment i int(10) unsigned NO PRI NULL auto_increment
c char(10) YES NULL c char(10) YES NULL
drop table t1; drop table t1;
create table t1 (a int, b int); create table t1 (a int, b int);
......
...@@ -100,12 +100,12 @@ drop table t2; ...@@ -100,12 +100,12 @@ drop table t2;
create table t2 select now() as a , curtime() as b, curdate() as c , 1+1 as d , 1.0 + 1 as e , 33333333333333333 + 3 as f; create table t2 select now() as a , curtime() as b, curdate() as c , 1+1 as d , 1.0 + 1 as e , 33333333333333333 + 3 as f;
describe t2; describe t2;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a datetime 0000-00-00 00:00:00 a datetime NO 0000-00-00 00:00:00
b time 00:00:00 b time NO 00:00:00
c date 0000-00-00 c date NO 0000-00-00
d bigint(17) 0 d bigint(17) NO 0
e double(18,1) 0.0 e double(18,1) NO 0.0
f bigint(17) 0 f bigint(17) NO 0
drop table t2; drop table t2;
create table t2 select CAST("2001-12-29" AS DATE) as d, CAST("20:45:11" AS TIME) as t, CAST("2001-12-29 20:45:11" AS DATETIME) as dt; create table t2 select CAST("2001-12-29" AS DATE) as d, CAST("20:45:11" AS TIME) as t, CAST("2001-12-29 20:45:11" AS DATETIME) as dt;
describe t2; describe t2;
...@@ -412,13 +412,13 @@ from t1; ...@@ -412,13 +412,13 @@ from t1;
explain t2; explain t2;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
b bigint(11) 0 b bigint(11) NO 0
c bigint(10) 0 c bigint(10) NO 0
d date YES NULL d date YES NULL
e varchar(1) e varchar(1) NO
f datetime YES NULL f datetime YES NULL
g time YES NULL g time YES NULL
h longblob h longblob NO
dd time YES NULL dd time YES NULL
select * from t2; select * from t2;
a b c d e f g h dd a b c d e f g h dd
......
...@@ -488,7 +488,7 @@ t1 CREATE TABLE `t1` ( ...@@ -488,7 +488,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
SHOW FIELDS FROM t1; SHOW FIELDS FROM t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
latin1_f char(32) latin1_f char(32) NO
ALTER TABLE t1 CHANGE latin1_f ALTER TABLE t1 CHANGE latin1_f
latin1_f CHAR(32) CHARACTER SET latin1 COLLATE latin1_bin; latin1_f CHAR(32) CHARACTER SET latin1 COLLATE latin1_bin;
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
......
...@@ -54,7 +54,7 @@ Table Create Table ...@@ -54,7 +54,7 @@ Table Create Table
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT=' ' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT=' '
SHOW FIELDS FROM ; SHOW FIELDS FROM ;
Field Type Null Key Default Extra Field Type Null Key Default Extra
char(32) char(32) NO
SET CHARACTER SET cp1251; SET CHARACTER SET cp1251;
SHOW TABLES; SHOW TABLES;
Tables_in_test Tables_in_test
...@@ -66,7 +66,7 @@ Table Create Table ...@@ -66,7 +66,7 @@ Table Create Table
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT=' ' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT=' '
SHOW FIELDS FROM ; SHOW FIELDS FROM ;
Field Type Null Key Default Extra Field Type Null Key Default Extra
char(32) char(32) NO
SET CHARACTER SET utf8; SET CHARACTER SET utf8;
SHOW TABLES; SHOW TABLES;
Tables_in_test Tables_in_test
...@@ -78,7 +78,7 @@ Table Create Table ...@@ -78,7 +78,7 @@ Table Create Table
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='комментарий таблицы' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='комментарий таблицы'
SHOW FIELDS FROM таблица; SHOW FIELDS FROM таблица;
Field Type Null Key Default Extra Field Type Null Key Default Extra
поле char(32) поле char(32) NO
SET CHARACTER SET koi8r; SET CHARACTER SET koi8r;
DROP TABLE ; DROP TABLE ;
SET CHARACTER SET default; SET CHARACTER SET default;
......
...@@ -123,7 +123,7 @@ t1 CREATE TABLE `t1` ( ...@@ -123,7 +123,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=ujis ) ENGINE=MyISAM DEFAULT CHARSET=ujis
SHOW COLUMNS FROM t1; SHOW COLUMNS FROM t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a char(1) a char(1) NO
b enum('あ','い') YES NULL b enum('あ','い') YES NULL
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 CREATE TABLE t1
......
...@@ -32,6 +32,7 @@ unlock tables; ...@@ -32,6 +32,7 @@ unlock tables;
create database mysqltest; create database mysqltest;
show databases; show databases;
Database Database
information_schema
mysql mysql
mysqltest mysqltest
test test
...@@ -42,6 +43,7 @@ unlock tables; ...@@ -42,6 +43,7 @@ unlock tables;
drop database mysqltest; drop database mysqltest;
show databases; show databases;
Database Database
information_schema
mysql mysql
test test
drop database mysqltest; drop database mysqltest;
......
...@@ -174,12 +174,12 @@ date("1997-12-31 23:59:59.000001") as f8, ...@@ -174,12 +174,12 @@ date("1997-12-31 23:59:59.000001") as f8,
time("1997-12-31 23:59:59.000001") as f9; time("1997-12-31 23:59:59.000001") as f9;
describe t1; describe t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
f1 date 0000-00-00 f1 date NO 0000-00-00
f2 datetime YES NULL f2 datetime YES NULL
f3 time YES NULL f3 time YES NULL
f4 time 00:00:00 f4 time NO 00:00:00
f5 time 00:00:00 f5 time NO 00:00:00
f6 time 00:00:00 f6 time NO 00:00:00
f7 datetime YES NULL f7 datetime YES NULL
f8 date YES NULL f8 date YES NULL
f9 time YES NULL f9 time YES NULL
......
...@@ -611,7 +611,7 @@ create table t1 select last_day('2000-02-05') as a, ...@@ -611,7 +611,7 @@ create table t1 select last_day('2000-02-05') as a,
from_days(to_days("960101")) as b; from_days(to_days("960101")) as b;
describe t1; describe t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a date 0000-00-00 a date NO 0000-00-00
b date YES NULL b date YES NULL
select * from t1; select * from t1;
a b a b
......
...@@ -9,35 +9,35 @@ CREATE TABLE gis_geometrycollection (fid INTEGER NOT NULL PRIMARY KEY, g GEOMET ...@@ -9,35 +9,35 @@ CREATE TABLE gis_geometrycollection (fid INTEGER NOT NULL PRIMARY KEY, g GEOMET
CREATE TABLE gis_geometry (fid INTEGER NOT NULL PRIMARY KEY, g GEOMETRY); CREATE TABLE gis_geometry (fid INTEGER NOT NULL PRIMARY KEY, g GEOMETRY);
SHOW FIELDS FROM gis_point; SHOW FIELDS FROM gis_point;
Field Type Null Key Default Extra Field Type Null Key Default Extra
fid int(11) PRI fid int(11) NO PRI
g point YES NULL g point YES NULL
SHOW FIELDS FROM gis_line; SHOW FIELDS FROM gis_line;
Field Type Null Key Default Extra Field Type Null Key Default Extra
fid int(11) PRI fid int(11) NO PRI
g linestring YES NULL g linestring YES NULL
SHOW FIELDS FROM gis_polygon; SHOW FIELDS FROM gis_polygon;
Field Type Null Key Default Extra Field Type Null Key Default Extra
fid int(11) PRI fid int(11) NO PRI
g polygon YES NULL g polygon YES NULL
SHOW FIELDS FROM gis_multi_point; SHOW FIELDS FROM gis_multi_point;
Field Type Null Key Default Extra Field Type Null Key Default Extra
fid int(11) PRI fid int(11) NO PRI
g multipoint YES NULL g multipoint YES NULL
SHOW FIELDS FROM gis_multi_line; SHOW FIELDS FROM gis_multi_line;
Field Type Null Key Default Extra Field Type Null Key Default Extra
fid int(11) PRI fid int(11) NO PRI
g multilinestring YES NULL g multilinestring YES NULL
SHOW FIELDS FROM gis_multi_polygon; SHOW FIELDS FROM gis_multi_polygon;
Field Type Null Key Default Extra Field Type Null Key Default Extra
fid int(11) PRI fid int(11) NO PRI
g multipolygon YES NULL g multipolygon YES NULL
SHOW FIELDS FROM gis_geometrycollection; SHOW FIELDS FROM gis_geometrycollection;
Field Type Null Key Default Extra Field Type Null Key Default Extra
fid int(11) PRI fid int(11) NO PRI
g geometrycollection YES NULL g geometrycollection YES NULL
SHOW FIELDS FROM gis_geometry; SHOW FIELDS FROM gis_geometry;
Field Type Null Key Default Extra Field Type Null Key Default Extra
fid int(11) PRI fid int(11) NO PRI
g geometry YES NULL g geometry YES NULL
INSERT INTO gis_point VALUES INSERT INTO gis_point VALUES
(101, PointFromText('POINT(10 10)')), (101, PointFromText('POINT(10 10)')),
...@@ -430,7 +430,7 @@ mln multilinestring YES NULL ...@@ -430,7 +430,7 @@ mln multilinestring YES NULL
mpg multipolygon YES NULL mpg multipolygon YES NULL
gc geometrycollection YES NULL gc geometrycollection YES NULL
gm geometry YES NULL gm geometry YES NULL
fid int(11) fid int(11) NO
DROP TABLE t1; DROP TABLE t1;
SELECT AsText(GeometryFromWKB(AsWKB(GeometryFromText('POINT(1 4)')))); SELECT AsText(GeometryFromWKB(AsWKB(GeometryFromText('POINT(1 4)'))));
AsText(GeometryFromWKB(AsWKB(GeometryFromText('POINT(1 4)')))) AsText(GeometryFromWKB(AsWKB(GeometryFromText('POINT(1 4)'))))
......
...@@ -5,10 +5,12 @@ NULL mysql latin1 NULL ...@@ -5,10 +5,12 @@ NULL mysql latin1 NULL
NULL test latin1 NULL NULL test latin1 NULL
select schema_name from information_schema.schemata; select schema_name from information_schema.schemata;
schema_name schema_name
information_schema
mysql mysql
test test
show databases *; show databases *;
CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME SQL_PATH CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME SQL_PATH
NULL information_schema utf8 NULL
NULL mysql latin1 NULL NULL mysql latin1 NULL
NULL test latin1 NULL NULL test latin1 NULL
show databases like 't%'; show databases like 't%';
...@@ -16,6 +18,7 @@ Database (t%) ...@@ -16,6 +18,7 @@ Database (t%)
test test
show databases; show databases;
Database Database
information_schema
mysql mysql
test test
show databases * where schema_name like 't%'; show databases * where schema_name like 't%';
...@@ -31,6 +34,22 @@ create table testtets.t4(a int); ...@@ -31,6 +34,22 @@ create table testtets.t4(a int);
create view v1 (c) as select table_name from information_schema.TABLES; create view v1 (c) as select table_name from information_schema.TABLES;
select * from v1; select * from v1;
c c
SCHEMATA
TABLES
COLUMNS
CHARACTER_SETS
COLLATIONS
COLLATION_CHARACTER_SET_APPLICABILITY
ROUTINES
STATISTICS
VIEWS
USER_PRIVILEGES
SCHEMA_PRIVILEGES
TABLE_PRIVILEGES
COLUMN_PRIVILEGES
TABLE_CONSTRAINTS
KEY_COLUMN_USAGE
TABLE_NAMES
columns_priv columns_priv
db db
func func
...@@ -56,6 +75,10 @@ select c,table_name from v1 ...@@ -56,6 +75,10 @@ select c,table_name from v1
left join information_schema.TABLES v2 on (v1.c=v2.table_name) left join information_schema.TABLES v2 on (v1.c=v2.table_name)
where v1.c like "t%"; where v1.c like "t%";
c table_name c table_name
TABLES TABLES
TABLE_PRIVILEGES TABLE_PRIVILEGES
TABLE_CONSTRAINTS TABLE_CONSTRAINTS
TABLE_NAMES TABLE_NAMES
tables_priv tables_priv tables_priv tables_priv
time_zone time_zone time_zone time_zone
time_zone_leap_second time_zone_leap_second time_zone_leap_second time_zone_leap_second
...@@ -70,6 +93,10 @@ select c, v2.table_name from v1 ...@@ -70,6 +93,10 @@ select c, v2.table_name from v1
right join information_schema.TABLES v2 on (v1.c=v2.table_name) right join information_schema.TABLES v2 on (v1.c=v2.table_name)
where v1.c like "t%"; where v1.c like "t%";
c table_name c table_name
TABLES TABLES
TABLE_PRIVILEGES TABLE_PRIVILEGES
TABLE_CONSTRAINTS TABLE_CONSTRAINTS
TABLE_NAMES TABLE_NAMES
tables_priv tables_priv tables_priv tables_priv
time_zone time_zone time_zone time_zone
time_zone_leap_second time_zone_leap_second time_zone_leap_second time_zone_leap_second
...@@ -88,11 +115,10 @@ t4 ...@@ -88,11 +115,10 @@ t4
select * from information_schema.STATISTICS where TABLE_SCHEMA = "testtets"; select * from information_schema.STATISTICS where TABLE_SCHEMA = "testtets";
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT
NULL testtets t1 1 testtets string_data 1 b A NULL NULL NULL YES BTREE NULL testtets t1 1 testtets string_data 1 b A NULL NULL NULL YES BTREE
show keys * where TABLE_SCHEMA Like "test%"; show keys * from t3 where TABLE_SCHEMA Like "test%";
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT
NULL test t3 1 test a_data 1 a A NULL NULL NULL YES BTREE NULL test t3 1 test a_data 1 a A NULL NULL NULL YES BTREE
NULL testtets t1 1 testtets string_data 1 b A NULL NULL NULL YES BTREE show keys from t3 where INDEX_NAME = "a_data";
show keys where INDEX_NAME = "a_data";
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t3 1 a_data 1 a A NULL NULL NULL YES BTREE t3 1 a_data 1 a A NULL NULL NULL YES BTREE
show tables like 't%'; show tables like 't%';
...@@ -113,15 +139,15 @@ Field Type Collation Null Key Default Extra Privileges Comment ...@@ -113,15 +139,15 @@ Field Type Collation Null Key Default Extra Privileges Comment
a int(11) NULL YES MUL NULL select,insert,update,references a int(11) NULL YES MUL NULL select,insert,update,references
show full columns from mysql.db like "Insert%"; show full columns from mysql.db like "Insert%";
Field Type Collation Null Key Default Extra Privileges Comment Field Type Collation Null Key Default Extra Privileges Comment
Insert_priv enum('N','Y') utf8_bin N select,insert,update,references Insert_priv enum('N','Y') utf8_bin NO N select,insert,update,references
show full columns from v1; show full columns from v1;
Field Type Collation Null Key Default Extra Privileges Comment Field Type Collation Null Key Default Extra Privileges Comment
c varchar(64) utf8_general_ci select,insert,update,references c varchar(64) utf8_general_ci NO 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 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 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 NULL YES int 11 11 11 0 NULL NULL int(11) 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 * from testtets.t1 where table_name = "t1";
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 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 NULL YES int 11 11 11 0 NULL NULL int(11) 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 NULL YES varchar 30 30 NULL NULL latin1 latin1_swedish_ci varchar(30) MUL 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
...@@ -255,6 +281,7 @@ count(*) ...@@ -255,6 +281,7 @@ count(*)
create view v0 (c) as select schema_name from information_schema.schemata; create view v0 (c) as select schema_name from information_schema.schemata;
select * from v0; select * from v0;
c c
information_schema
mysql mysql
test test
explain select * from v0; explain select * from v0;
...@@ -351,18 +378,18 @@ t1 CREATE TABLE `t1` ( ...@@ -351,18 +378,18 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from information_schema.TABLE_CONSTRAINTS where select * from information_schema.TABLE_CONSTRAINTS where
TABLE_SCHEMA= "test"; TABLE_SCHEMA= "test";
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE CONSTRAINT_METHOD CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
NULL test PRIMARY test t1 PRIMARY KEY NULL NULL test PRIMARY test t1 PRIMARY KEY
NULL test constraint_1 test t1 UNIQUE NULL NULL test constraint_1 test t1 UNIQUE
NULL test key_1 test t1 UNIQUE NULL NULL test key_1 test t1 UNIQUE
NULL test key_2 test t1 UNIQUE NULL NULL test key_2 test t1 UNIQUE
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_CATALOG 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 POSITION_IN_UNIQUE_CONSTRAINT REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME
NULL test PRIMARY NULL test t1 a 1 NULL NULL NULL NULL test PRIMARY NULL test t1 a 1 NULL NULL NULL NULL
NULL test constraint_1 NULL test t1 a 1 NULL NULL NULL NULL test constraint_1 NULL test t1 a 1 NULL NULL NULL NULL
NULL test key_1 NULL test t1 a 1 NULL NULL NULL NULL test key_1 NULL test t1 a 1 NULL NULL NULL NULL
NULL test key_2 NULL test t1 a 1 NULL NULL NULL NULL test key_2 NULL test t1 a 1 NULL NULL NULL NULL
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
...@@ -392,7 +419,6 @@ GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRAN ...@@ -392,7 +419,6 @@ GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRAN
'joe'@'localhost' NULL test t1 a SELECT YES 'joe'@'localhost' NULL test t1 a SELECT YES
select * from INFORMATION_SCHEMA.TABLE_PRIVILEGES; select * from INFORMATION_SCHEMA.TABLE_PRIVILEGES;
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE
'joe'@'localhost' NULL test t1 USAGE YES
drop view v1, v2, v3; drop view v1, v2, v3;
drop table t1; drop table t1;
delete from mysql.user where user='joe'; delete from mysql.user where user='joe';
...@@ -404,7 +430,7 @@ create procedure px5 () ...@@ -404,7 +430,7 @@ create procedure px5 ()
begin begin
declare v int; declare v int;
declare c cursor for select version from declare c cursor for select version from
information_schema.tables; information_schema.tables where table_schema <> 'information_schema';
open c; open c;
fetch c into v; fetch c into v;
select v; select v;
...@@ -432,6 +458,7 @@ select s1 from t1 where s1 in (select version from ...@@ -432,6 +458,7 @@ select s1 from t1 where s1 in (select version from
information_schema.tables) union select version from information_schema.tables) union select version from
information_schema.tables; information_schema.tables;
s1 s1
0
9 9
10 10
drop table t1; drop table t1;
...@@ -508,11 +535,6 @@ proc modified timestamp ...@@ -508,11 +535,6 @@ 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 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 char(64) proc comment char(64)
drop table t115; 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 create procedure p108 () begin declare c cursor for select data_type
from information_schema.columns; open c; open c; end;// from information_schema.columns; open c; open c; end;//
call p108()// call p108()//
...@@ -529,8 +551,37 @@ show index from vo; ...@@ -529,8 +551,37 @@ show index from vo;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
select * from information_schema.TABLE_CONSTRAINTS where select * from information_schema.TABLE_CONSTRAINTS where
TABLE_NAME= "vo"; TABLE_NAME= "vo";
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE CONSTRAINT_METHOD CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
select * from information_schema.KEY_COLUMN_USAGE where select * from information_schema.KEY_COLUMN_USAGE where
TABLE_NAME= "vo"; TABLE_NAME= "vo";
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 CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION POSITION_IN_UNIQUE_CONSTRAINT REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME
drop view vo; drop view vo;
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
show tables from information_schema like "t%";
Tables_in_information_schema (t%)
create database information_schema;
ERROR HY000: Can't create database 'information_schema'; database exists
use information_schema;
show full tables like "T%";
Tables_in_information_schema (T%) Table_type
TABLES TEMPORARY
TABLE_PRIVILEGES TEMPORARY
TABLE_CONSTRAINTS TEMPORARY
TABLE_NAMES TEMPORARY
create table t1(a int);
ERROR 42S02: Unknown table 't1' in information_schema
use test;
show tables;
Tables_in_test
use information_schema;
show tables like "T%";
Tables_in_information_schema (T%)
TABLES
TABLE_PRIVILEGES
TABLE_CONSTRAINTS
TABLE_NAMES
...@@ -4,16 +4,16 @@ FOREIGN KEY (t1_id) REFERENCES t1(id) ON DELETE CASCADE, ...@@ -4,16 +4,16 @@ FOREIGN KEY (t1_id) REFERENCES t1(id) ON DELETE CASCADE,
FOREIGN KEY (t1_id) REFERENCES t1(id) ON UPDATE CASCADE) ENGINE=INNODB; FOREIGN KEY (t1_id) REFERENCES t1(id) ON UPDATE CASCADE) ENGINE=INNODB;
select * from information_schema.TABLE_CONSTRAINTS where select * from information_schema.TABLE_CONSTRAINTS where
TABLE_SCHEMA= "test"; TABLE_SCHEMA= "test";
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE CONSTRAINT_METHOD CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
NULL test PRIMARY test t1 PRIMARY KEY NULL NULL test PRIMARY test t1 PRIMARY KEY
NULL test PRIMARY test t2 PRIMARY KEY NULL NULL test PRIMARY test t2 PRIMARY KEY
NULL test t2_ibfk_1 test t2 FOREIGN KEY ON DELETE CASCADE NULL test t2_ibfk_1 test t2 FOREIGN KEY
NULL test t2_ibfk_2 test t2 FOREIGN KEY ON UPDATE CASCADE NULL test t2_ibfk_2 test t2 FOREIGN KEY
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_CATALOG 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 POSITION_IN_UNIQUE_CONSTRAINT REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME
NULL test PRIMARY NULL test t1 id 1 NULL NULL NULL NULL test PRIMARY NULL test t1 id 1 NULL NULL NULL NULL
NULL test PRIMARY NULL test t2 id 1 NULL NULL NULL NULL test PRIMARY NULL test t2 id 1 NULL NULL NULL NULL
NULL test t2_ibfk_1 NULL test t2 t1_id 1 NULL id NULL test t2_ibfk_1 NULL test t2 t1_id 1 1 test t1 id
NULL test t2_ibfk_2 NULL test t2 t1_id 1 NULL id NULL test t2_ibfk_2 NULL test t2 t1_id 1 1 test t1 id
drop table t2, t1; drop table t2, t1;
...@@ -931,7 +931,7 @@ drop table t1; ...@@ -931,7 +931,7 @@ drop table t1;
create table t1 (t int not null default 1, key (t)) engine=innodb; create table t1 (t int not null default 1, key (t)) engine=innodb;
desc t1; desc t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
t int(11) MUL 1 t int(11) NO MUL 1
drop table t1; drop table t1;
CREATE TABLE t1 ( CREATE TABLE t1 (
number bigint(20) NOT NULL default '0', number bigint(20) NOT NULL default '0',
......
...@@ -355,6 +355,7 @@ drop table t2; ...@@ -355,6 +355,7 @@ drop table t2;
drop database test2; drop database test2;
show databases; show databases;
Database Database
information_schema
mysql mysql
test test
use test; use test;
......
...@@ -254,6 +254,7 @@ a int primary key, b char(10) ...@@ -254,6 +254,7 @@ a int primary key, b char(10)
prepare stmt4 from ' show databases '; prepare stmt4 from ' show databases ';
execute stmt4; execute stmt4;
Database Database
information_schema
mysql mysql
test test
prepare stmt4 from ' show tables from test like ''t2%'' '; prepare stmt4 from ' show tables from test like ''t2%'' ';
...@@ -263,7 +264,7 @@ t2 ...@@ -263,7 +264,7 @@ t2
prepare stmt4 from ' show columns from t2 from test like ''a%'' '; prepare stmt4 from ' show columns from t2 from test like ''a%'' ';
execute stmt4; execute stmt4;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) PRI a int(11) NO PRI
create index t2_idx on t2(b); create index t2_idx on t2(b);
prepare stmt4 from ' show index from t2 from test '; prepare stmt4 from ' show index from t2 from test ';
execute stmt4; execute stmt4;
...@@ -410,7 +411,7 @@ drop user drop_user@localhost; ...@@ -410,7 +411,7 @@ drop user drop_user@localhost;
prepare stmt3 from ' describe t2 '; prepare stmt3 from ' describe t2 ';
execute stmt3; execute stmt3;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) PRI a int(11) NO PRI
b char(10) YES MUL NULL b char(10) YES MUL NULL
drop table t2 ; drop table t2 ;
execute stmt3; execute stmt3;
......
...@@ -32,6 +32,7 @@ create database mysqltest2; ...@@ -32,6 +32,7 @@ create database mysqltest2;
create database mysqltest; create database mysqltest;
show databases; show databases;
Database Database
information_schema
mysql mysql
mysqltest mysqltest
mysqltest2 mysqltest2
...@@ -48,6 +49,7 @@ insert into mysqltest.t2 values (11, 'eleven test'), (12, 'twelve test'), ...@@ -48,6 +49,7 @@ insert into mysqltest.t2 values (11, 'eleven test'), (12, 'twelve test'),
set sql_log_bin = 1; set sql_log_bin = 1;
show databases; show databases;
Database Database
information_schema
mysql mysql
test test
create database mysqltest2; create database mysqltest2;
...@@ -66,6 +68,7 @@ insert into mysqltest.t3 values (1, 'original bar.t3'); ...@@ -66,6 +68,7 @@ insert into mysqltest.t3 values (1, 'original bar.t3');
load data from master; load data from master;
show databases; show databases;
Database Database
information_schema
mysql mysql
mysqltest mysqltest
mysqltest2 mysqltest2
......
...@@ -22,6 +22,7 @@ USE mysqltest_sisyfos; ...@@ -22,6 +22,7 @@ USE mysqltest_sisyfos;
ALTER DATABASE mysqltest_bob CHARACTER SET latin1; ALTER DATABASE mysqltest_bob CHARACTER SET latin1;
SHOW DATABASES; SHOW DATABASES;
Database Database
information_schema
mysql mysql
mysqltest_bob mysqltest_bob
mysqltest_prometheus mysqltest_prometheus
...@@ -29,6 +30,7 @@ mysqltest_sisyfos ...@@ -29,6 +30,7 @@ mysqltest_sisyfos
test test
SHOW DATABASES; SHOW DATABASES;
Database Database
information_schema
mysql mysql
mysqltest_prometheus mysqltest_prometheus
mysqltest_sisyfos mysqltest_sisyfos
...@@ -57,6 +59,7 @@ master-bin.000001 # Query 1 # CREATE DATABASE mysqltest_sisyfos ...@@ -57,6 +59,7 @@ master-bin.000001 # Query 1 # CREATE DATABASE mysqltest_sisyfos
master-bin.000001 # Query 1 # use `mysqltest_sisyfos`; CREATE TABLE t2 (a INT) master-bin.000001 # Query 1 # use `mysqltest_sisyfos`; CREATE TABLE t2 (a INT)
SHOW DATABASES; SHOW DATABASES;
Database Database
information_schema
mysql mysql
mysqltest_bob mysqltest_bob
mysqltest_prometheus mysqltest_prometheus
...@@ -64,6 +67,7 @@ mysqltest_sisyfos ...@@ -64,6 +67,7 @@ mysqltest_sisyfos
test test
SHOW DATABASES; SHOW DATABASES;
Database Database
information_schema
mysql mysql
mysqltest_prometheus mysqltest_prometheus
mysqltest_sisyfos mysqltest_sisyfos
......
...@@ -4,6 +4,7 @@ Database Create Database ...@@ -4,6 +4,7 @@ Database Create Database
foo CREATE DATABASE `foo` /*!40100 DEFAULT CHARACTER SET latin1 */ foo CREATE DATABASE `foo` /*!40100 DEFAULT CHARACTER SET latin1 */
show schemas; show schemas;
Database Database
information_schema
foo foo
mysql mysql
test test
......
...@@ -2034,20 +2034,20 @@ show tables from test like "t?"; ...@@ -2034,20 +2034,20 @@ show tables from test like "t?";
Tables_in_test (t?) Tables_in_test (t?)
show full columns from t2; show full columns from t2;
Field Type Collation Null Key Default Extra Privileges Comment Field Type Collation Null Key Default Extra Privileges Comment
auto int(11) NULL PRI NULL auto_increment select,insert,update,references auto int(11) NULL NO PRI NULL auto_increment select,insert,update,references
fld1 int(6) unsigned zerofill NULL UNI 000000 select,insert,update,references fld1 int(6) unsigned zerofill NULL NO UNI 000000 select,insert,update,references
companynr tinyint(2) unsigned zerofill NULL 00 select,insert,update,references companynr tinyint(2) unsigned zerofill NULL NO 00 select,insert,update,references
fld3 char(30) latin1_swedish_ci MUL select,insert,update,references fld3 char(30) latin1_swedish_ci NO MUL select,insert,update,references
fld4 char(35) latin1_swedish_ci select,insert,update,references fld4 char(35) latin1_swedish_ci NO select,insert,update,references
fld5 char(35) latin1_swedish_ci select,insert,update,references fld5 char(35) latin1_swedish_ci NO select,insert,update,references
fld6 char(4) latin1_swedish_ci select,insert,update,references fld6 char(4) latin1_swedish_ci NO select,insert,update,references
show full columns from t2 from test like 'f%'; show full columns from t2 from test like 'f%';
Field Type Collation Null Key Default Extra Privileges Comment Field Type Collation Null Key Default Extra Privileges Comment
fld1 int(6) unsigned zerofill NULL UNI 000000 select,insert,update,references fld1 int(6) unsigned zerofill NULL NO UNI 000000 select,insert,update,references
fld3 char(30) latin1_swedish_ci MUL select,insert,update,references fld3 char(30) latin1_swedish_ci NO MUL select,insert,update,references
fld4 char(35) latin1_swedish_ci select,insert,update,references fld4 char(35) latin1_swedish_ci NO select,insert,update,references
fld5 char(35) latin1_swedish_ci select,insert,update,references fld5 char(35) latin1_swedish_ci NO select,insert,update,references
fld6 char(4) latin1_swedish_ci select,insert,update,references fld6 char(4) latin1_swedish_ci NO select,insert,update,references
show full columns from t2 from test like 's%'; show full columns from t2 from test like 's%';
Field Type Collation Null Key Default Extra Privileges Comment Field Type Collation Null Key Default Extra Privileges Comment
show keys from t2; show keys from t2;
......
...@@ -50,6 +50,7 @@ show table status from test like "this_doesn't_exists%"; ...@@ -50,6 +50,7 @@ show table status from test like "this_doesn't_exists%";
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
show databases; show databases;
Database Database
information_schema
mysql mysql
test test
show databases like "test%"; show databases like "test%";
...@@ -118,9 +119,9 @@ t1 CREATE TABLE t1 ( ...@@ -118,9 +119,9 @@ t1 CREATE TABLE t1 (
set sql_quote_show_create=1; set sql_quote_show_create=1;
show full columns from t1; show full columns from t1;
Field Type Collation Null Key Default Extra Privileges Comment Field Type Collation Null Key Default Extra Privileges Comment
test_set set('val1','val2','val3') latin1_swedish_ci select,insert,update,references test_set set('val1','val2','val3') latin1_swedish_ci NO select,insert,update,references
name char(20) latin1_swedish_ci YES O'Brien select,insert,update,references O'Brien as default name char(20) latin1_swedish_ci YES O'Brien select,insert,update,references O'Brien as default
c int(11) NULL select,insert,update,references int column c int(11) NULL NO select,insert,update,references int column
c-b int(11) NULL YES NULL select,insert,update,references name with a minus c-b int(11) NULL YES NULL select,insert,update,references name with a minus
space 2 int(11) NULL YES NULL select,insert,update,references name with a space space 2 int(11) NULL YES NULL select,insert,update,references name with a space
drop table t1; drop table t1;
......
...@@ -1646,8 +1646,8 @@ test CREATE DATABASE `test` /*!40100 DEFAULT CHARACTER SET latin1 */ ...@@ -1646,8 +1646,8 @@ test CREATE DATABASE `test` /*!40100 DEFAULT CHARACTER SET latin1 */
Database (foo) Database (foo)
Level Code Message Level Code Message
Field Type Null Key Default Extra Field Type Null Key Default Extra
id char(16) id char(16) NO
data int(11) data int(11) NO
Grants for root@localhost Grants for root@localhost
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
...@@ -1696,8 +1696,8 @@ test CREATE DATABASE `test` /*!40100 DEFAULT CHARACTER SET latin1 */ ...@@ -1696,8 +1696,8 @@ test CREATE DATABASE `test` /*!40100 DEFAULT CHARACTER SET latin1 */
Database (foo) Database (foo)
Level Code Message Level Code Message
Field Type Null Key Default Extra Field Type Null Key Default Extra
id char(16) id char(16) NO
data int(11) data int(11) NO
Grants for root@localhost Grants for root@localhost
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
......
...@@ -1654,7 +1654,7 @@ set names latin1; ...@@ -1654,7 +1654,7 @@ set names latin1;
create table t1 (a enum(0xE4, '1', '2') not null default 0xE4); create table t1 (a enum(0xE4, '1', '2') not null default 0xE4);
show columns from t1; show columns from t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a enum('','1','2') a enum('','1','2') NO
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
...@@ -1675,7 +1675,7 @@ t1 CREATE TABLE `t1` ( ...@@ -1675,7 +1675,7 @@ t1 CREATE TABLE `t1` (
show columns from t1; show columns from t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES 1 a int(11) YES 1
b enum('value','_value','') value b enum('value','_value','') NO value
drop table t1; drop table t1;
CREATE TABLE t1 (c enum('a', 'A') BINARY); CREATE TABLE t1 (c enum('a', 'A') BINARY);
INSERT INTO t1 VALUES ('a'),('A'); INSERT INTO t1 VALUES ('a'),('A');
......
...@@ -40,30 +40,30 @@ KEY (options,flags) ...@@ -40,30 +40,30 @@ KEY (options,flags)
); );
show full fields from t1; show full fields from t1;
Field Type Collation Null Key Default Extra Privileges Comment Field Type Collation Null Key Default Extra Privileges Comment
auto int(5) unsigned NULL PRI NULL auto_increment select,insert,update,references auto int(5) unsigned NULL NO PRI NULL auto_increment select,insert,update,references
string char(10) latin1_swedish_ci YES hello select,insert,update,references string char(10) latin1_swedish_ci YES hello select,insert,update,references
tiny tinyint(4) NULL MUL 0 select,insert,update,references tiny tinyint(4) NULL NO MUL 0 select,insert,update,references
short smallint(6) NULL MUL 1 select,insert,update,references short smallint(6) NULL NO MUL 1 select,insert,update,references
medium mediumint(8) NULL MUL 0 select,insert,update,references medium mediumint(8) NULL NO MUL 0 select,insert,update,references
long_int int(11) NULL 0 select,insert,update,references long_int int(11) NULL NO 0 select,insert,update,references
longlong bigint(13) NULL MUL 0 select,insert,update,references longlong bigint(13) NULL NO MUL 0 select,insert,update,references
real_float float(13,1) NULL MUL 0.0 select,insert,update,references real_float float(13,1) NULL NO MUL 0.0 select,insert,update,references
real_double double(16,4) NULL YES NULL select,insert,update,references real_double double(16,4) NULL YES NULL select,insert,update,references
utiny tinyint(3) unsigned NULL MUL 0 select,insert,update,references utiny tinyint(3) unsigned NULL NO MUL 0 select,insert,update,references
ushort smallint(5) unsigned zerofill NULL MUL 00000 select,insert,update,references ushort smallint(5) unsigned zerofill NULL NO MUL 00000 select,insert,update,references
umedium mediumint(8) unsigned NULL MUL 0 select,insert,update,references umedium mediumint(8) unsigned NULL NO MUL 0 select,insert,update,references
ulong int(11) unsigned NULL MUL 0 select,insert,update,references ulong int(11) unsigned NULL NO MUL 0 select,insert,update,references
ulonglong bigint(13) unsigned NULL MUL 0 select,insert,update,references ulonglong bigint(13) unsigned NULL NO MUL 0 select,insert,update,references
time_stamp timestamp NULL YES CURRENT_TIMESTAMP select,insert,update,references time_stamp timestamp NULL YES CURRENT_TIMESTAMP select,insert,update,references
date_field date NULL YES NULL select,insert,update,references date_field date NULL YES NULL select,insert,update,references
time_field time NULL YES NULL select,insert,update,references time_field time NULL YES NULL select,insert,update,references
date_time datetime NULL YES NULL select,insert,update,references date_time datetime NULL YES NULL select,insert,update,references
blob_col blob NULL YES NULL select,insert,update,references blob_col blob NULL YES NULL select,insert,update,references
tinyblob_col tinyblob NULL YES NULL select,insert,update,references tinyblob_col tinyblob NULL YES NULL select,insert,update,references
mediumblob_col mediumblob NULL select,insert,update,references mediumblob_col mediumblob NULL NO select,insert,update,references
longblob_col longblob NULL select,insert,update,references longblob_col longblob NULL NO select,insert,update,references
options enum('one','two','tree') latin1_swedish_ci MUL one select,insert,update,references options enum('one','two','tree') latin1_swedish_ci NO MUL one select,insert,update,references
flags set('one','two','tree') latin1_swedish_ci select,insert,update,references flags set('one','two','tree') latin1_swedish_ci NO select,insert,update,references
show keys from t1; show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 0 PRIMARY 1 auto A 0 NULL NULL BTREE t1 0 PRIMARY 1 auto A 0 NULL NULL BTREE
...@@ -208,56 +208,56 @@ Warning 1265 Data truncated for column 'options' at row 6 ...@@ -208,56 +208,56 @@ Warning 1265 Data truncated for column 'options' at row 6
update t2 set string="changed" where auto=16; update t2 set string="changed" where auto=16;
show full columns from t1; show full columns from t1;
Field Type Collation Null Key Default Extra Privileges Comment Field Type Collation Null Key Default Extra Privileges Comment
auto int(5) unsigned NULL MUL NULL auto_increment select,insert,update,references auto int(5) unsigned NULL NO MUL NULL auto_increment select,insert,update,references
string char(10) latin1_swedish_ci YES new defaul select,insert,update,references string char(10) latin1_swedish_ci YES new defaul select,insert,update,references
tiny tinyint(4) NULL MUL 0 select,insert,update,references tiny tinyint(4) NULL NO MUL 0 select,insert,update,references
short smallint(6) NULL MUL 0 select,insert,update,references short smallint(6) NULL NO MUL 0 select,insert,update,references
medium mediumint(8) NULL MUL 0 select,insert,update,references medium mediumint(8) NULL NO MUL 0 select,insert,update,references
long_int int(11) NULL 0 select,insert,update,references long_int int(11) NULL NO 0 select,insert,update,references
longlong bigint(13) NULL MUL 0 select,insert,update,references longlong bigint(13) NULL NO MUL 0 select,insert,update,references
real_float float(13,1) NULL MUL 0.0 select,insert,update,references real_float float(13,1) NULL NO MUL 0.0 select,insert,update,references
real_double double(16,4) NULL YES NULL select,insert,update,references real_double double(16,4) NULL YES NULL select,insert,update,references
utiny tinyint(3) unsigned NULL 0 select,insert,update,references utiny tinyint(3) unsigned NULL NO 0 select,insert,update,references
ushort smallint(5) unsigned zerofill NULL 00000 select,insert,update,references ushort smallint(5) unsigned zerofill NULL NO 00000 select,insert,update,references
umedium mediumint(8) unsigned NULL MUL 0 select,insert,update,references umedium mediumint(8) unsigned NULL NO MUL 0 select,insert,update,references
ulong int(11) unsigned NULL MUL 0 select,insert,update,references ulong int(11) unsigned NULL NO MUL 0 select,insert,update,references
ulonglong bigint(13) unsigned NULL MUL 0 select,insert,update,references ulonglong bigint(13) unsigned NULL NO MUL 0 select,insert,update,references
time_stamp timestamp NULL YES CURRENT_TIMESTAMP select,insert,update,references time_stamp timestamp NULL YES CURRENT_TIMESTAMP select,insert,update,references
date_field char(10) latin1_swedish_ci YES NULL select,insert,update,references date_field char(10) latin1_swedish_ci YES NULL select,insert,update,references
time_field time NULL YES NULL select,insert,update,references time_field time NULL YES NULL select,insert,update,references
date_time datetime NULL YES NULL select,insert,update,references date_time datetime NULL YES NULL select,insert,update,references
new_blob_col varchar(20) latin1_swedish_ci YES NULL select,insert,update,references new_blob_col varchar(20) latin1_swedish_ci YES NULL select,insert,update,references
tinyblob_col tinyblob NULL YES NULL select,insert,update,references tinyblob_col tinyblob NULL YES NULL select,insert,update,references
mediumblob_col mediumblob NULL select,insert,update,references mediumblob_col mediumblob NULL NO select,insert,update,references
options enum('one','two','tree') latin1_swedish_ci MUL one select,insert,update,references options enum('one','two','tree') latin1_swedish_ci NO MUL one select,insert,update,references
flags set('one','two','tree') latin1_swedish_ci select,insert,update,references flags set('one','two','tree') latin1_swedish_ci NO select,insert,update,references
new_field char(10) latin1_swedish_ci new select,insert,update,references new_field char(10) latin1_swedish_ci NO new select,insert,update,references
show full columns from t2; show full columns from t2;
Field Type Collation Null Key Default Extra Privileges Comment Field Type Collation Null Key Default Extra Privileges Comment
auto int(5) unsigned NULL 0 select,insert,update,references auto int(5) unsigned NULL NO 0 select,insert,update,references
string char(10) latin1_swedish_ci YES new defaul select,insert,update,references string char(10) latin1_swedish_ci YES new defaul select,insert,update,references
tiny tinyint(4) NULL 0 select,insert,update,references tiny tinyint(4) NULL NO 0 select,insert,update,references
short smallint(6) NULL 0 select,insert,update,references short smallint(6) NULL NO 0 select,insert,update,references
medium mediumint(8) NULL 0 select,insert,update,references medium mediumint(8) NULL NO 0 select,insert,update,references
long_int int(11) NULL 0 select,insert,update,references long_int int(11) NULL NO 0 select,insert,update,references
longlong bigint(13) NULL 0 select,insert,update,references longlong bigint(13) NULL NO 0 select,insert,update,references
real_float float(13,1) NULL 0.0 select,insert,update,references real_float float(13,1) NULL NO 0.0 select,insert,update,references
real_double double(16,4) NULL YES NULL select,insert,update,references real_double double(16,4) NULL YES NULL select,insert,update,references
utiny tinyint(3) unsigned NULL 0 select,insert,update,references utiny tinyint(3) unsigned NULL NO 0 select,insert,update,references
ushort smallint(5) unsigned zerofill NULL 00000 select,insert,update,references ushort smallint(5) unsigned zerofill NULL NO 00000 select,insert,update,references
umedium mediumint(8) unsigned NULL 0 select,insert,update,references umedium mediumint(8) unsigned NULL NO 0 select,insert,update,references
ulong int(11) unsigned NULL 0 select,insert,update,references ulong int(11) unsigned NULL NO 0 select,insert,update,references
ulonglong bigint(13) unsigned NULL 0 select,insert,update,references ulonglong bigint(13) unsigned NULL NO 0 select,insert,update,references
time_stamp timestamp NULL YES 0000-00-00 00:00:00 select,insert,update,references time_stamp timestamp NULL YES 0000-00-00 00:00:00 select,insert,update,references
date_field char(10) latin1_swedish_ci YES NULL select,insert,update,references date_field char(10) latin1_swedish_ci YES NULL select,insert,update,references
time_field time NULL YES NULL select,insert,update,references time_field time NULL YES NULL select,insert,update,references
date_time datetime NULL YES NULL select,insert,update,references date_time datetime NULL YES NULL select,insert,update,references
new_blob_col varchar(20) latin1_swedish_ci YES NULL select,insert,update,references new_blob_col varchar(20) latin1_swedish_ci YES NULL select,insert,update,references
tinyblob_col tinyblob NULL YES NULL select,insert,update,references tinyblob_col tinyblob NULL YES NULL select,insert,update,references
mediumblob_col mediumblob NULL select,insert,update,references mediumblob_col mediumblob NULL NO select,insert,update,references
options enum('one','two','tree') latin1_swedish_ci one select,insert,update,references options enum('one','two','tree') latin1_swedish_ci NO one select,insert,update,references
flags set('one','two','tree') latin1_swedish_ci select,insert,update,references flags set('one','two','tree') latin1_swedish_ci NO select,insert,update,references
new_field char(10) latin1_swedish_ci new select,insert,update,references new_field char(10) latin1_swedish_ci NO new select,insert,update,references
select t1.auto,t2.auto from t1,t2 where t1.auto=t2.auto and ((t1.string<>t2.string and (t1.string is not null or t2.string is not null)) or (t1.tiny<>t2.tiny and (t1.tiny is not null or t2.tiny is not null)) or (t1.short<>t2.short and (t1.short is not null or t2.short is not null)) or (t1.medium<>t2.medium and (t1.medium is not null or t2.medium is not null)) or (t1.long_int<>t2.long_int and (t1.long_int is not null or t2.long_int is not null)) or (t1.longlong<>t2.longlong and (t1.longlong is not null or t2.longlong is not null)) or (t1.real_float<>t2.real_float and (t1.real_float is not null or t2.real_float is not null)) or (t1.real_double<>t2.real_double and (t1.real_double is not null or t2.real_double is not null)) or (t1.utiny<>t2.utiny and (t1.utiny is not null or t2.utiny is not null)) or (t1.ushort<>t2.ushort and (t1.ushort is not null or t2.ushort is not null)) or (t1.umedium<>t2.umedium and (t1.umedium is not null or t2.umedium is not null)) or (t1.ulong<>t2.ulong and (t1.ulong is not null or t2.ulong is not null)) or (t1.ulonglong<>t2.ulonglong and (t1.ulonglong is not null or t2.ulonglong is not null)) or (t1.time_stamp<>t2.time_stamp and (t1.time_stamp is not null or t2.time_stamp is not null)) or (t1.date_field<>t2.date_field and (t1.date_field is not null or t2.date_field is not null)) or (t1.time_field<>t2.time_field and (t1.time_field is not null or t2.time_field is not null)) or (t1.date_time<>t2.date_time and (t1.date_time is not null or t2.date_time is not null)) or (t1.new_blob_col<>t2.new_blob_col and (t1.new_blob_col is not null or t2.new_blob_col is not null)) or (t1.tinyblob_col<>t2.tinyblob_col and (t1.tinyblob_col is not null or t2.tinyblob_col is not null)) or (t1.mediumblob_col<>t2.mediumblob_col and (t1.mediumblob_col is not null or t2.mediumblob_col is not null)) or (t1.options<>t2.options and (t1.options is not null or t2.options is not null)) or (t1.flags<>t2.flags and (t1.flags is not null or t2.flags is not null)) or (t1.new_field<>t2.new_field and (t1.new_field is not null or t2.new_field is not null))); select t1.auto,t2.auto from t1,t2 where t1.auto=t2.auto and ((t1.string<>t2.string and (t1.string is not null or t2.string is not null)) or (t1.tiny<>t2.tiny and (t1.tiny is not null or t2.tiny is not null)) or (t1.short<>t2.short and (t1.short is not null or t2.short is not null)) or (t1.medium<>t2.medium and (t1.medium is not null or t2.medium is not null)) or (t1.long_int<>t2.long_int and (t1.long_int is not null or t2.long_int is not null)) or (t1.longlong<>t2.longlong and (t1.longlong is not null or t2.longlong is not null)) or (t1.real_float<>t2.real_float and (t1.real_float is not null or t2.real_float is not null)) or (t1.real_double<>t2.real_double and (t1.real_double is not null or t2.real_double is not null)) or (t1.utiny<>t2.utiny and (t1.utiny is not null or t2.utiny is not null)) or (t1.ushort<>t2.ushort and (t1.ushort is not null or t2.ushort is not null)) or (t1.umedium<>t2.umedium and (t1.umedium is not null or t2.umedium is not null)) or (t1.ulong<>t2.ulong and (t1.ulong is not null or t2.ulong is not null)) or (t1.ulonglong<>t2.ulonglong and (t1.ulonglong is not null or t2.ulonglong is not null)) or (t1.time_stamp<>t2.time_stamp and (t1.time_stamp is not null or t2.time_stamp is not null)) or (t1.date_field<>t2.date_field and (t1.date_field is not null or t2.date_field is not null)) or (t1.time_field<>t2.time_field and (t1.time_field is not null or t2.time_field is not null)) or (t1.date_time<>t2.date_time and (t1.date_time is not null or t2.date_time is not null)) or (t1.new_blob_col<>t2.new_blob_col and (t1.new_blob_col is not null or t2.new_blob_col is not null)) or (t1.tinyblob_col<>t2.tinyblob_col and (t1.tinyblob_col is not null or t2.tinyblob_col is not null)) or (t1.mediumblob_col<>t2.mediumblob_col and (t1.mediumblob_col is not null or t2.mediumblob_col is not null)) or (t1.options<>t2.options and (t1.options is not null or t2.options is not null)) or (t1.flags<>t2.flags and (t1.flags is not null or t2.flags is not null)) or (t1.new_field<>t2.new_field and (t1.new_field is not null or t2.new_field is not null)));
auto auto auto auto
16 16 16 16
...@@ -268,15 +268,15 @@ drop table t2; ...@@ -268,15 +268,15 @@ drop table t2;
create table t2 (primary key (auto)) select auto+1 as auto,1 as t1, 'a' as t2, repeat('a',256) as t3, binary repeat('b',256) as t4, repeat('a',4096) as t5, binary repeat('b',4096) as t6, '' as t7, binary '' as t8 from t1; create table t2 (primary key (auto)) select auto+1 as auto,1 as t1, 'a' as t2, repeat('a',256) as t3, binary repeat('b',256) as t4, repeat('a',4096) as t5, binary repeat('b',4096) as t6, '' as t7, binary '' as t8 from t1;
show full columns from t2; show full columns from t2;
Field Type Collation Null Key Default Extra Privileges Comment Field Type Collation Null Key Default Extra Privileges Comment
auto bigint(17) unsigned NULL PRI 0 select,insert,update,references auto bigint(17) unsigned NULL NO PRI 0 select,insert,update,references
t1 bigint(1) NULL 0 select,insert,update,references t1 bigint(1) NULL NO 0 select,insert,update,references
t2 varchar(1) latin1_swedish_ci select,insert,update,references t2 varchar(1) latin1_swedish_ci NO select,insert,update,references
t3 varchar(256) latin1_swedish_ci select,insert,update,references t3 varchar(256) latin1_swedish_ci NO select,insert,update,references
t4 varbinary(256) NULL select,insert,update,references t4 varbinary(256) NULL NO select,insert,update,references
t5 longtext latin1_swedish_ci select,insert,update,references t5 longtext latin1_swedish_ci NO select,insert,update,references
t6 longblob NULL select,insert,update,references t6 longblob NULL NO select,insert,update,references
t7 char(0) latin1_swedish_ci select,insert,update,references t7 char(0) latin1_swedish_ci NO select,insert,update,references
t8 binary(0) NULL select,insert,update,references t8 binary(0) NULL NO select,insert,update,references
select t1,t2,length(t3),length(t4),length(t5),length(t6),t7,t8 from t2; select t1,t2,length(t3),length(t4),length(t5),length(t6),t7,t8 from t2;
t1 t2 length(t3) length(t4) length(t5) length(t6) t7 t8 t1 t2 length(t3) length(t4) length(t5) length(t6) t7 t8
1 a 256 256 4096 4096 1 a 256 256 4096 4096
...@@ -297,7 +297,7 @@ show full columns from t3; ...@@ -297,7 +297,7 @@ show full columns from t3;
Field Type Collation Null Key Default Extra Privileges Comment Field Type Collation Null Key Default Extra Privileges Comment
c1 int(11) NULL YES NULL select,insert,update,references c1 int(11) NULL YES NULL select,insert,update,references
c2 int(11) NULL YES NULL select,insert,update,references c2 int(11) NULL YES NULL select,insert,update,references
const bigint(1) NULL 0 select,insert,update,references const bigint(1) NULL NO 0 select,insert,update,references
drop table t1,t2,t3; drop table t1,t2,t3;
create table t1 ( myfield INT NOT NULL, UNIQUE INDEX (myfield), unique (myfield), index(myfield)); create table t1 ( myfield INT NOT NULL, UNIQUE INDEX (myfield), unique (myfield), index(myfield));
drop table t1; drop table t1;
......
...@@ -34,8 +34,8 @@ select table_name from information_schema.TABLES ...@@ -34,8 +34,8 @@ select table_name from information_schema.TABLES
where table_schema = "testtets" and table_name like "t%"; where table_schema = "testtets" and table_name like "t%";
select * from information_schema.STATISTICS where TABLE_SCHEMA = "testtets"; select * from information_schema.STATISTICS where TABLE_SCHEMA = "testtets";
show keys * where TABLE_SCHEMA Like "test%"; show keys * from t3 where TABLE_SCHEMA Like "test%";
show keys where INDEX_NAME = "a_data"; show keys from t3 where INDEX_NAME = "a_data";
show tables like 't%'; show tables like 't%';
--replace_column 15 # 16 # --replace_column 15 # 16 #
...@@ -48,7 +48,7 @@ show full columns from mysql.db like "Insert%"; ...@@ -48,7 +48,7 @@ show full columns from mysql.db like "Insert%";
show full columns from v1; show full columns from v1;
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";
show columns * where table_name = "t1"; show columns * from testtets.t1 where table_name = "t1";
drop view v1; drop view v1;
drop tables testtets.t4, testtets.t1, t2, t3; drop tables testtets.t4, testtets.t1, t2, t3;
...@@ -198,7 +198,7 @@ create procedure px5 () ...@@ -198,7 +198,7 @@ create procedure px5 ()
begin begin
declare v int; declare v int;
declare c cursor for select version from declare c cursor for select version from
information_schema.tables; information_schema.tables where table_schema <> 'information_schema';
open c; open c;
fetch c into v; fetch c into v;
select v; select v;
...@@ -250,10 +250,6 @@ from information_schema.columns where table_name = 'proc'; ...@@ -250,10 +250,6 @@ from information_schema.columns where table_name = 'proc';
select * from t115; select * from t115;
drop table t115; drop table t115;
create view vk as select count(*) from information_schema.tables a;
select * from vk;
drop view vk;
delimiter //; delimiter //;
create procedure p108 () begin declare c cursor for select data_type create procedure p108 () begin declare c cursor for select data_type
from information_schema.columns; open c; open c; end;// from information_schema.columns; open c; open c; end;//
...@@ -274,3 +270,19 @@ TABLE_NAME= "vo"; ...@@ -274,3 +270,19 @@ TABLE_NAME= "vo";
select * from information_schema.KEY_COLUMN_USAGE where select * from information_schema.KEY_COLUMN_USAGE where
TABLE_NAME= "vo"; TABLE_NAME= "vo";
drop view vo; drop view vo;
select TABLE_NAME,TABLE_TYPE,ENGINE
from information_schema.tables
where table_schema='information_schema' limit 2;
show tables from information_schema like "t%";
--error 1007
create database information_schema;
use information_schema;
show full tables like "T%";
--error 1109
create table t1(a int);
use test;
show tables;
use information_schema;
show tables like "T%";
...@@ -4670,9 +4670,15 @@ int fill_schema_table_privileges(THD *thd, TABLE_LIST *tables, COND *cond) ...@@ -4670,9 +4670,15 @@ int fill_schema_table_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
if (!(user=grant_table->user)) if (!(user=grant_table->user))
user= ""; user= "";
ulong table_access= grant_table->privs; ulong table_access= grant_table->privs;
if (table_access != 0) if (table_access)
{ {
ulong test_access= table_access & ~GRANT_ACL; ulong test_access= table_access & ~GRANT_ACL;
/*
We should skip 'usage' privilege on table if
we have any privileges on column(s) of this table
*/
if (!test_access && grant_table->cols)
continue;
if (!(table_access & GRANT_ACL)) if (!(table_access & GRANT_ACL))
is_grantable= "NO"; is_grantable= "NO";
......
...@@ -389,6 +389,13 @@ bool mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info, ...@@ -389,6 +389,13 @@ bool mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info,
uint create_options= create_info ? create_info->options : 0; uint create_options= create_info ? create_info->options : 0;
uint path_len; uint path_len;
DBUG_ENTER("mysql_create_db"); DBUG_ENTER("mysql_create_db");
/* do not create 'information_schema' db */
if (!my_strcasecmp(system_charset_info, db, information_schema_name.str))
{
my_error(ER_DB_CREATE_EXISTS, MYF(0), db);
DBUG_RETURN(-1);
}
VOID(pthread_mutex_lock(&LOCK_mysql_create_db)); VOID(pthread_mutex_lock(&LOCK_mysql_create_db));
...@@ -1015,6 +1022,7 @@ bool mysql_change_db(THD *thd, const char *name) ...@@ -1015,6 +1022,7 @@ bool mysql_change_db(THD *thd, const char *name)
char *dbname=my_strdup((char*) name,MYF(MY_WME)); char *dbname=my_strdup((char*) name,MYF(MY_WME));
char path[FN_REFLEN]; char path[FN_REFLEN];
HA_CREATE_INFO create; HA_CREATE_INFO create;
bool schema_db= 0;
#ifndef NO_EMBEDDED_ACCESS_CHECKS #ifndef NO_EMBEDDED_ACCESS_CHECKS
ulong db_access; ulong db_access;
#endif #endif
...@@ -1034,6 +1042,15 @@ bool mysql_change_db(THD *thd, const char *name) ...@@ -1034,6 +1042,15 @@ bool mysql_change_db(THD *thd, const char *name)
DBUG_RETURN(1); DBUG_RETURN(1);
} }
DBUG_PRINT("info",("Use database: %s", dbname)); DBUG_PRINT("info",("Use database: %s", dbname));
if (!my_strcasecmp(system_charset_info, dbname, information_schema_name.str))
{
schema_db= 1;
#ifndef NO_EMBEDDED_ACCESS_CHECKS
db_access= SELECT_ACL;
#endif
goto end;
}
#ifndef NO_EMBEDDED_ACCESS_CHECKS #ifndef NO_EMBEDDED_ACCESS_CHECKS
if (test_all_bits(thd->master_access,DB_ACLS)) if (test_all_bits(thd->master_access,DB_ACLS))
db_access=DB_ACLS; db_access=DB_ACLS;
...@@ -1064,6 +1081,7 @@ bool mysql_change_db(THD *thd, const char *name) ...@@ -1064,6 +1081,7 @@ bool mysql_change_db(THD *thd, const char *name)
my_free(dbname,MYF(0)); my_free(dbname,MYF(0));
DBUG_RETURN(1); DBUG_RETURN(1);
} }
end:
send_ok(thd); send_ok(thd);
x_free(thd->db); x_free(thd->db);
thd->db=dbname; // THD::~THD will free this thd->db=dbname; // THD::~THD will free this
...@@ -1071,11 +1089,19 @@ bool mysql_change_db(THD *thd, const char *name) ...@@ -1071,11 +1089,19 @@ bool mysql_change_db(THD *thd, const char *name)
#ifndef NO_EMBEDDED_ACCESS_CHECKS #ifndef NO_EMBEDDED_ACCESS_CHECKS
thd->db_access=db_access; thd->db_access=db_access;
#endif #endif
strmov(path+unpack_dirname(path,path), MY_DB_OPT_FILE); if (schema_db)
load_db_opt(thd, path, &create); {
thd->db_charset= create.default_table_charset ? thd->db_charset= system_charset_info;
create.default_table_charset : thd->variables.collation_database= system_charset_info;
thd->variables.collation_server; }
thd->variables.collation_database= thd->db_charset; else
{
strmov(path+unpack_dirname(path,path), MY_DB_OPT_FILE);
load_db_opt(thd, path, &create);
thd->db_charset= create.default_table_charset ?
create.default_table_charset :
thd->variables.collation_server;
thd->variables.collation_database= thd->db_charset;
}
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -1941,6 +1941,60 @@ static COND * make_cond_for_info_schema(COND *cond, TABLE_LIST *table) ...@@ -1941,6 +1941,60 @@ static COND * make_cond_for_info_schema(COND *cond, TABLE_LIST *table)
} }
/*
Add 'information_schema' name to db_names list
SYNOPSIS
schema_db_add()
thd thread handler
files list of db names
wild wild string
with_i_schema returns 1 if we added 'IS' name to list
otherwise returns 0
RETURN
1 error
0 success
*/
int schema_db_add(THD *thd, List<char> *files,
const char *wild, bool *with_i_schema)
{
*with_i_schema= 0;
if (!wild || !wild_compare(information_schema_name.str, wild, 0))
{
*with_i_schema= 1;
if (files->push_back(thd->strdup(information_schema_name.str)))
return 1;
}
return 0;
}
int schema_tables_add(THD *thd, List<char> *files, const char *wild)
{
ST_SCHEMA_TABLE *tmp_schema_table= schema_tables;
for ( ; tmp_schema_table->table_name; tmp_schema_table++)
{
if (wild)
{
if (lower_case_table_names)
{
if (wild_case_compare(files_charset_info,
tmp_schema_table->table_name,
wild))
continue;
}
else if (wild_compare(tmp_schema_table->table_name, wild, 0))
continue;
}
if (files->push_back(thd->strdup(tmp_schema_table->table_name)))
return 1;
}
return 0;
}
int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
{ {
LEX *lex= thd->lex; LEX *lex= thd->lex;
...@@ -1970,8 +2024,9 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) ...@@ -1970,8 +2024,9 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
SELECT_LEX sel; SELECT_LEX sel;
INDEX_FIELD_VALUES idx_field_vals; INDEX_FIELD_VALUES idx_field_vals;
char path[FN_REFLEN], *end, *base_name, *file_name; char path[FN_REFLEN], *end= 0, *base_name, *file_name;
uint len; uint len= 0;
bool with_i_schema;
List<char> bases; List<char> bases;
lex->all_selects_list= &sel; lex->all_selects_list= &sel;
enum enum_schema_tables schema_table_idx= enum enum_schema_tables schema_table_idx=
...@@ -1980,6 +2035,11 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) ...@@ -1980,6 +2035,11 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
if (schema_table_idx == SCH_TABLES) if (schema_table_idx == SCH_TABLES)
lock_type= TL_READ; lock_type= TL_READ;
get_index_field_values(lex, &idx_field_vals); get_index_field_values(lex, &idx_field_vals);
/* information schema name always is first in list */
if (schema_db_add(thd, &bases, idx_field_vals.db_value, &with_i_schema))
return 1;
if (mysql_find_files(thd, &bases, NullS, mysql_data_home, if (mysql_find_files(thd, &bases, NullS, mysql_data_home,
idx_field_vals.db_value, 1)) idx_field_vals.db_value, 1))
return 1; return 1;
...@@ -1995,19 +2055,28 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) ...@@ -1995,19 +2055,28 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
(base_name= select_lex->db) && !bases.elements)) (base_name= select_lex->db) && !bases.elements))
{ {
#ifndef NO_EMBEDDED_ACCESS_CHECKS #ifndef NO_EMBEDDED_ACCESS_CHECKS
if (!check_access(thd,SELECT_ACL, base_name, &thd->col_access,0,1) || if (with_i_schema || // don't check the rights if information schema db
!check_access(thd,SELECT_ACL, base_name, &thd->col_access,0,1) ||
thd->master_access & (DB_ACLS | SHOW_DB_ACL) || thd->master_access & (DB_ACLS | SHOW_DB_ACL) ||
acl_get(thd->host, thd->ip, thd->priv_user, base_name,0) || acl_get(thd->host, thd->ip, thd->priv_user, base_name,0) ||
(grant_option && !check_grant_db(thd, base_name))) (grant_option && !check_grant_db(thd, base_name)))
#endif #endif
{ {
List<char> files; List<char> files;
strxmov(path, mysql_data_home, "/", base_name, NullS); if (with_i_schema) // information schema table names
end= path + (len= unpack_dirname(path,path)); {
len= FN_LEN - len; if (schema_tables_add(thd, &files, idx_field_vals.table_value))
if (mysql_find_files(thd, &files, base_name, DBUG_RETURN(1);
path, idx_field_vals.table_value, 0)) }
DBUG_RETURN(1); else
{
strxmov(path, mysql_data_home, "/", base_name, NullS);
end= path + (len= unpack_dirname(path,path));
len= FN_LEN - len;
if (mysql_find_files(thd, &files, base_name,
path, idx_field_vals.table_value, 0))
DBUG_RETURN(1);
}
List_iterator_fast<char> it(files); List_iterator_fast<char> it(files);
while ((file_name=it++)) while ((file_name=it++))
...@@ -2023,20 +2092,27 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) ...@@ -2023,20 +2092,27 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
{ {
if (lex->verbose || lex->orig_sql_command == SQLCOM_END) if (lex->verbose || lex->orig_sql_command == SQLCOM_END)
{ {
my_snprintf(end, len, "/%s%s", file_name, reg_ext); if (with_i_schema)
switch (mysql_frm_type(path))
{ {
case FRMTYPE_ERROR: table->field[3]->store("TEMPORARY", 9, system_charset_info);
table->field[3]->store("ERROR", 5, system_charset_info); }
break; else
case FRMTYPE_TABLE: {
table->field[3]->store("BASE TABLE", 10, system_charset_info); my_snprintf(end, len, "/%s%s", file_name, reg_ext);
break; switch (mysql_frm_type(path))
case FRMTYPE_VIEW: {
table->field[3]->store("VIEW", 4, system_charset_info); case FRMTYPE_ERROR:
break; table->field[3]->store("ERROR", 5, system_charset_info);
default: break;
DBUG_ASSERT(0); case FRMTYPE_TABLE:
table->field[3]->store("BASE TABLE", 10, system_charset_info);
break;
case FRMTYPE_VIEW:
table->field[3]->store("VIEW", 4, system_charset_info);
break;
default:
DBUG_ASSERT(0);
}
} }
} }
table->file->write_row(table->record[0]); table->file->write_row(table->record[0]);
...@@ -2059,6 +2135,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) ...@@ -2059,6 +2135,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
} }
} }
} }
with_i_schema= 0;
} }
} }
lex->all_selects_list= select_lex; lex->all_selects_list= select_lex;
...@@ -2066,6 +2143,16 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) ...@@ -2066,6 +2143,16 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
} }
void store_schema_shemata(TABLE *table, const char *db_name,
const char* cs_name)
{
restore_record(table, default_values);
table->field[1]->store(db_name, strlen(db_name), system_charset_info);
table->field[2]->store(cs_name, strlen(cs_name), system_charset_info);
table->file->write_row(table->record[0]);
}
int fill_schema_shemata(THD *thd, TABLE_LIST *tables, COND *cond) int fill_schema_shemata(THD *thd, TABLE_LIST *tables, COND *cond)
{ {
char path[FN_REFLEN],*end; char path[FN_REFLEN],*end;
...@@ -2074,16 +2161,26 @@ int fill_schema_shemata(THD *thd, TABLE_LIST *tables, COND *cond) ...@@ -2074,16 +2161,26 @@ int fill_schema_shemata(THD *thd, TABLE_LIST *tables, COND *cond)
List<char> files; List<char> files;
char *file_name; char *file_name;
uint length; uint length;
bool with_i_schema;
HA_CREATE_INFO create; HA_CREATE_INFO create;
TABLE *table= tables->table; TABLE *table= tables->table;
get_index_field_values(thd->lex, &idx_field_vals); get_index_field_values(thd->lex, &idx_field_vals);
/* information schema name always is first in list */
if (schema_db_add(thd, &files, idx_field_vals.db_value, &with_i_schema))
return 1;
if (mysql_find_files(thd, &files, NullS, mysql_data_home, if (mysql_find_files(thd, &files, NullS, mysql_data_home,
idx_field_vals.db_value, 1)) idx_field_vals.db_value, 1))
return 1; return 1;
List_iterator_fast<char> it(files); List_iterator_fast<char> it(files);
while ((file_name=it++)) while ((file_name=it++))
{ {
if (with_i_schema) // information schema name is always first in list
{
store_schema_shemata(table, file_name, system_charset_info->csname);
with_i_schema= 0;
continue;
}
#ifndef NO_EMBEDDED_ACCESS_CHECKS #ifndef NO_EMBEDDED_ACCESS_CHECKS
if (thd->master_access & (DB_ACLS | SHOW_DB_ACL) || if (thd->master_access & (DB_ACLS | SHOW_DB_ACL) ||
acl_get(thd->host, thd->ip, thd->priv_user, file_name,0) || acl_get(thd->host, thd->ip, thd->priv_user, file_name,0) ||
...@@ -2103,12 +2200,8 @@ int fill_schema_shemata(THD *thd, TABLE_LIST *tables, COND *cond) ...@@ -2103,12 +2200,8 @@ int fill_schema_shemata(THD *thd, TABLE_LIST *tables, COND *cond)
path[length-1]= FN_LIBCHAR; path[length-1]= FN_LIBCHAR;
strmov(path+length, MY_DB_OPT_FILE); strmov(path+length, MY_DB_OPT_FILE);
load_db_opt(thd, path, &create); load_db_opt(thd, path, &create);
restore_record(table, default_values); store_schema_shemata(table, file_name,
table->field[1]->store(file_name, strlen(file_name), system_charset_info); create.default_table_charset->csname);
table->field[2]->store(create.default_table_charset->csname,
strlen(create.default_table_charset->csname),
system_charset_info);
table->file->write_row(table->record[0]);
} }
} }
return 0; return 0;
...@@ -2147,7 +2240,11 @@ static int get_schema_tables_record(THD *thd, struct st_table_list *tables, ...@@ -2147,7 +2240,11 @@ static int get_schema_tables_record(THD *thd, struct st_table_list *tables,
TABLE *show_table= tables->table; TABLE *show_table= tables->table;
handler *file= show_table->file; handler *file= show_table->file;
file->info(HA_STATUS_VARIABLE | HA_STATUS_TIME | HA_STATUS_NO_LOCK); file->info(HA_STATUS_VARIABLE | HA_STATUS_TIME | HA_STATUS_NO_LOCK);
table->field[3]->store("BASE TABLE", 10, cs); if (table->tmp_table == TMP_TABLE)
table->field[3]->store("TEMPORARY", 9, cs);
else
table->field[3]->store("BASE TABLE", 10, cs);
for (int i= 4; i < 20; i++) for (int i= 4; i < 20; i++)
{ {
if ((i > 12 && i < 17) || i == 18) if ((i > 12 && i < 17) || i == 18)
...@@ -2341,7 +2438,7 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables, ...@@ -2341,7 +2438,7 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables,
} }
pos=(byte*) ((flags & NOT_NULL_FLAG) && pos=(byte*) ((flags & NOT_NULL_FLAG) &&
field->type() != FIELD_TYPE_TIMESTAMP ? field->type() != FIELD_TYPE_TIMESTAMP ?
"" : "YES"); "NO" : "YES");
table->field[6]->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())
...@@ -2741,12 +2838,26 @@ static int get_schema_views_record(THD *thd, struct st_table_list *tables, ...@@ -2741,12 +2838,26 @@ static int get_schema_views_record(THD *thd, struct st_table_list *tables,
} }
void store_constarints(TABLE *table, const char*db, const char *tname,
const char *key_name, uint key_len,
const char *con_type, uint con_len)
{
CHARSET_INFO *cs= system_charset_info;
restore_record(table, default_values);
table->field[1]->store(db, strlen(db), cs);
table->field[2]->store(key_name, key_len, cs);
table->field[3]->store(db, strlen(db), cs);
table->field[4]->store(tname, strlen(tname), cs);
table->field[5]->store(con_type, con_len, cs);
table->file->write_row(table->record[0]);
}
static int get_schema_constarints_record(THD *thd, struct st_table_list *tables, static int get_schema_constarints_record(THD *thd, struct st_table_list *tables,
TABLE *table, bool res, TABLE *table, bool res,
const char *base_name, const char *base_name,
const char *file_name) const char *file_name)
{ {
CHARSET_INFO *cs= system_charset_info;
DBUG_ENTER("get_schema_constarints_record"); DBUG_ENTER("get_schema_constarints_record");
if (!res && !tables->view) if (!res && !tables->view)
{ {
...@@ -2760,17 +2871,14 @@ static int get_schema_constarints_record(THD *thd, struct st_table_list *tables, ...@@ -2760,17 +2871,14 @@ static int get_schema_constarints_record(THD *thd, struct st_table_list *tables,
for (uint i=0 ; i < show_table->keys ; i++, key_info++) for (uint i=0 ; i < show_table->keys ; i++, key_info++)
{ {
if (i != primary_key && !(key_info->flags & HA_NOSAME)) if (i != primary_key && !(key_info->flags & HA_NOSAME))
continue; continue;
restore_record(table, default_values);
table->field[1]->store(base_name, strlen(base_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(file_name, strlen(file_name), cs);
if (i == primary_key && !strcmp(key_info->name, primary_key_name)) if (i == primary_key && !strcmp(key_info->name, primary_key_name))
table->field[5]->store("PRIMARY KEY", 11, cs); store_constarints(table, base_name, file_name, key_info->name,
strlen(key_info->name), "PRIMARY KEY", 11);
else if (key_info->flags & HA_NOSAME) else if (key_info->flags & HA_NOSAME)
table->field[5]->store("UNIQUE", 6, cs); store_constarints(table, base_name, file_name, key_info->name,
table->file->write_row(table->record[0]); strlen(key_info->name), "UNIQUE", 6);
} }
show_table->file->get_foreign_key_list(thd, &f_key_list); show_table->file->get_foreign_key_list(thd, &f_key_list);
...@@ -2778,23 +2886,28 @@ static int get_schema_constarints_record(THD *thd, struct st_table_list *tables, ...@@ -2778,23 +2886,28 @@ static int get_schema_constarints_record(THD *thd, struct st_table_list *tables,
List_iterator_fast<FOREIGN_KEY_INFO> it(f_key_list); List_iterator_fast<FOREIGN_KEY_INFO> it(f_key_list);
while ((f_key_info=it++)) while ((f_key_info=it++))
{ {
restore_record(table, default_values); store_constarints(table, base_name, file_name, f_key_info->forein_id->str,
table->field[1]->store(base_name, strlen(base_name), cs); strlen(f_key_info->forein_id->str), "FOREIGN KEY", 11);
table->field[2]->store(f_key_info->forein_id->str,
f_key_info->forein_id->length, cs);
table->field[3]->store(base_name, strlen(base_name), cs);
table->field[4]->store(file_name, strlen(file_name), cs);
table->field[5]->store("FOREIGN KEY", 11, system_charset_info);
table->field[6]->store(f_key_info->constraint_method->str,
f_key_info->constraint_method->length, cs);
table->field[6]->set_notnull();
table->file->write_row(table->record[0]);
} }
} }
DBUG_RETURN(res); DBUG_RETURN(res);
} }
void store_key_column_usage(TABLE *table, const char*db, const char *tname,
const char *key_name, uint key_len,
const char *con_type, uint con_len, longlong idx)
{
CHARSET_INFO *cs= system_charset_info;
table->field[1]->store(db, strlen(db), cs);
table->field[2]->store(key_name, key_len, cs);
table->field[4]->store(db, strlen(db), cs);
table->field[5]->store(tname, strlen(tname), cs);
table->field[6]->store(con_type, con_len, cs);
table->field[7]->store((longlong) idx);
}
static int get_schema_key_column_usage_record(THD *thd, static int get_schema_key_column_usage_record(THD *thd,
struct st_table_list *tables, struct st_table_list *tables,
TABLE *table, bool res, TABLE *table, bool res,
...@@ -2825,13 +2938,12 @@ static int get_schema_key_column_usage_record(THD *thd, ...@@ -2825,13 +2938,12 @@ static int get_schema_key_column_usage_record(THD *thd,
{ {
f_idx++; f_idx++;
restore_record(table, default_values); restore_record(table, default_values);
table->field[1]->store(base_name, strlen(base_name), cs); store_key_column_usage(table, base_name, file_name,
table->field[2]->store(key_info->name, strlen(key_info->name), cs); key_info->name,
table->field[4]->store(base_name, strlen(base_name), cs); strlen(key_info->name),
table->field[5]->store(file_name, strlen(file_name), cs); key_part->field->field_name,
table->field[6]->store(key_part->field->field_name, strlen(key_part->field->field_name),
strlen(key_part->field->field_name), cs); (longlong) f_idx);
table->field[7]->store((longlong) f_idx);
table->file->write_row(table->record[0]); table->file->write_row(table->record[0]);
} }
} }
...@@ -2851,21 +2963,21 @@ static int get_schema_key_column_usage_record(THD *thd, ...@@ -2851,21 +2963,21 @@ static int get_schema_key_column_usage_record(THD *thd,
r_info= it1++; r_info= it1++;
f_idx++; f_idx++;
restore_record(table, default_values); restore_record(table, default_values);
table->field[1]->store(base_name, strlen(base_name), cs); store_key_column_usage(table, base_name, file_name,
table->field[2]->store(f_key_info->forein_id->str, f_key_info->forein_id->str,
f_key_info->forein_id->length, cs); f_key_info->forein_id->length,
table->field[4]->store(base_name, strlen(base_name), cs); f_info->str, f_info->length,
table->field[5]->store(file_name, strlen(file_name), cs); (longlong) f_idx);
table->field[6]->store(f_info->str, f_info->length, cs); table->field[8]->store((longlong) f_idx);
table->field[7]->store((longlong) f_idx); table->field[8]->set_notnull();
table->field[8]->store(f_key_info->referenced_db->str, table->field[9]->store(f_key_info->referenced_db->str,
f_key_info->referenced_db->length, cs); f_key_info->referenced_db->length, cs);
table->field[9]->set_notnull(); table->field[9]->set_notnull();
table->field[10]->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[9]->set_notnull();
table->field[10]->store(r_info->str, r_info->length, cs);
table->field[10]->set_notnull(); table->field[10]->set_notnull();
table->field[11]->store(r_info->str, r_info->length, cs);
table->field[11]->set_notnull();
table->file->write_row(table->record[0]); table->file->write_row(table->record[0]);
} }
} }
...@@ -3466,7 +3578,6 @@ ST_FIELD_INFO table_constraints_fields_info[]= ...@@ -3466,7 +3578,6 @@ ST_FIELD_INFO table_constraints_fields_info[]=
{"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},
{"CONSTRAINT_TYPE", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, {"CONSTRAINT_TYPE", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
{"CONSTRAINT_METHOD", 20, MYSQL_TYPE_STRING, 0, 1, 0},
{0, 0, MYSQL_TYPE_STRING, 0, 0, 0} {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
}; };
...@@ -3481,6 +3592,7 @@ ST_FIELD_INFO key_column_usage_fields_info[]= ...@@ -3481,6 +3592,7 @@ ST_FIELD_INFO key_column_usage_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, 0}, {"COLUMN_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
{"ORDINAL_POSITION", 10 ,MYSQL_TYPE_LONG, 0, 0, 0}, {"ORDINAL_POSITION", 10 ,MYSQL_TYPE_LONG, 0, 0, 0},
{"POSITION_IN_UNIQUE_CONSTRAINT", 10 ,MYSQL_TYPE_LONG, 0, 1, 0},
{"REFERENCED_TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0}, {"REFERENCED_TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0},
{"REFERENCED_TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0}, {"REFERENCED_TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0},
{"REFERENCED_COLUMN_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0}, {"REFERENCED_COLUMN_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0},
......
...@@ -670,7 +670,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); ...@@ -670,7 +670,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
opt_table_alias opt_table_alias
%type <table> %type <table>
table_ident table_ident_nodb references from_table_ident table_ident table_ident_nodb references
%type <simple_string> %type <simple_string>
remember_name remember_end opt_ident opt_db text_or_password remember_name remember_end opt_ident opt_db text_or_password
...@@ -5902,14 +5902,14 @@ show_param: ...@@ -5902,14 +5902,14 @@ show_param:
| ENGINE_SYM storage_engines | ENGINE_SYM storage_engines
{ Lex->create_info.db_type= $2; } { Lex->create_info.db_type= $2; }
show_engine_param show_engine_param
| opt_full COLUMNS ext_select_item_list from_table_ident opt_db wild_and_where | opt_full COLUMNS ext_select_item_list from_or_in table_ident opt_db wild_and_where
{ {
LEX *lex= Lex; LEX *lex= Lex;
lex->sql_command= SQLCOM_SELECT; lex->sql_command= SQLCOM_SELECT;
lex->orig_sql_command= SQLCOM_SHOW_FIELDS; lex->orig_sql_command= SQLCOM_SHOW_FIELDS;
if ($5) if ($6)
$4->change_db($5); $5->change_db($6);
if (prepare_schema_table(YYTHD, lex, $4, SCH_COLUMNS)) if (prepare_schema_table(YYTHD, lex, $5, SCH_COLUMNS))
YYABORT; YYABORT;
} }
| NEW_SYM MASTER_SYM FOR_SYM SLAVE WITH MASTER_LOG_FILE_SYM EQ | NEW_SYM MASTER_SYM FOR_SYM SLAVE WITH MASTER_LOG_FILE_SYM EQ
...@@ -5935,14 +5935,14 @@ show_param: ...@@ -5935,14 +5935,14 @@ show_param:
LEX *lex= Lex; LEX *lex= Lex;
lex->sql_command= SQLCOM_SHOW_BINLOG_EVENTS; lex->sql_command= SQLCOM_SHOW_BINLOG_EVENTS;
} opt_limit_clause_init } opt_limit_clause_init
| keys_or_index ext_select_item_list from_table_ident opt_db where_clause | keys_or_index ext_select_item_list from_or_in table_ident opt_db where_clause
{ {
LEX *lex= Lex; LEX *lex= Lex;
lex->sql_command= SQLCOM_SELECT; lex->sql_command= SQLCOM_SELECT;
lex->orig_sql_command= SQLCOM_SHOW_KEYS; lex->orig_sql_command= SQLCOM_SHOW_KEYS;
if ($4) if ($5)
$3->change_db($4); $4->change_db($5);
if (prepare_schema_table(YYTHD, lex, $3, SCH_STATISTICS)) if (prepare_schema_table(YYTHD, lex, $4, SCH_STATISTICS))
YYABORT; YYABORT;
} }
| COLUMN_SYM TYPES_SYM | COLUMN_SYM TYPES_SYM
...@@ -6159,11 +6159,6 @@ binlog_from: ...@@ -6159,11 +6159,6 @@ binlog_from:
/* empty */ { Lex->mi.pos = 4; /* skip magic number */ } /* empty */ { Lex->mi.pos = 4; /* skip magic number */ }
| FROM ulonglong_num { Lex->mi.pos = $2; }; | FROM ulonglong_num { Lex->mi.pos = $2; };
from_table_ident:
/* empty */ { $$= 0; }
| from_or_in table_ident { $$= $2; }
;
wild_and_where: wild_and_where:
/* empty */ /* empty */
| LIKE TEXT_STRING_sys | LIKE TEXT_STRING_sys
......
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