Commit 3b14ba64 authored by monty@mysql.com's avatar monty@mysql.com

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

into mysql.com:/home/my/mysql-5.0
parents 36d11d95 7d1b9541
...@@ -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');
......
This diff is collapsed.
...@@ -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";
......
...@@ -390,6 +390,13 @@ bool mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info, ...@@ -390,6 +390,13 @@ bool mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info,
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));
// do not create database if another thread is holding read lock // do not create database if another thread is holding read lock
...@@ -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
if (schema_db)
{
thd->db_charset= system_charset_info;
thd->variables.collation_database= system_charset_info;
}
else
{
strmov(path+unpack_dirname(path,path), MY_DB_OPT_FILE); strmov(path+unpack_dirname(path,path), MY_DB_OPT_FILE);
load_db_opt(thd, path, &create); load_db_opt(thd, path, &create);
thd->db_charset= create.default_table_charset ? thd->db_charset= create.default_table_charset ?
create.default_table_charset : create.default_table_charset :
thd->variables.collation_server; thd->variables.collation_server;
thd->variables.collation_database= thd->db_charset; thd->variables.collation_database= thd->db_charset;
}
DBUG_RETURN(0); DBUG_RETURN(0);
} }
This diff is collapsed.
...@@ -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