Commit 2d108230 authored by monty@donna.mysql.com's avatar monty@donna.mysql.com

SHOW [FULL] COLUMNS

Added timeouts to replication tests to handle concurrent inserts
parent 0f28f7a4
......@@ -20129,7 +20129,7 @@ commands to examine and kill threads.
@example
SHOW DATABASES [LIKE wild]
or SHOW [OPEN] TABLES [FROM db_name] [LIKE wild]
or SHOW COLUMNS FROM tbl_name [FROM db_name] [LIKE wild]
or SHOW [FULL] COLUMNS FROM tbl_name [FROM db_name] [LIKE wild]
or SHOW INDEX FROM tbl_name [FROM db_name]
or SHOW TABLE STATUS [FROM db_name] [LIKE wild]
or SHOW STATUS [LIKE wild]
......@@ -20188,10 +20188,11 @@ db_name}.
the table cache. @xref{Table cache}. The @code{Comment} field tells
how many times the table is @code{cached} and @code{in_use}.
@code{SHOW COLUMNS} lists the columns in a given table. If the column
types are different than you expect them to be based on a @code{CREATE
TABLE} statement, note that @strong{MySQL} sometimes changes column
types. @xref{Silent column changes}.
@code{SHOW COLUMNS} lists the columns in a given table. If you specify
the @code{FULL} option, you will also get the privileges you have for
each column. If the column types are different than you expect them to
be based on a @code{CREATE TABLE} statement, note that @strong{MySQL}
sometimes changes column types. @xref{Silent column changes}.
The @code{DESCRIBE} statement provides information similar to
@code{SHOW COLUMNS}.
......@@ -40712,6 +40713,9 @@ not yet 100 % confident in this code.
@appendixsubsec Changes in release 3.23.32
@itemize @bullet
@item
Added option @code{FULL} to @code{SHOW COLUMNS}. Now we only show the
privilege list for the columns if this option is given.
@item
Fixed bug in @code{SHOW LOGS} when there wheren't any BDB logs.
@item
Fixed a timing problem in replication that could delay sending an update
......@@ -397,7 +397,7 @@ list_fields(MYSQL *mysql,const char *db,const char *table,
mysql_error(mysql));
return 1;
}
end=strmov(strmov(query,"show columns from "),table);
end=strmov(strmov(query,"show /*!32332 FULL */ columns from "),table);
if (wild && wild[0])
strxmov(end," like '",wild,"'",NullS);
if (mysql_query(mysql,query) || !(result=mysql_store_result(mysql)))
......
......@@ -12,6 +12,14 @@ test.t1 check status OK
Table Op Msg_type Msg_text
test.t2 check error Table 't2' was not locked with LOCK TABLES
test.t1 check status OK
Field Type Null Key Default Extra
a int(11) PRI 0
b int(11) MUL 0
c int(11) 0
Field Type Null Key Default Extra Privileges
a int(11) PRI 0 select,insert,update,references
b int(11) MUL 0 select,insert,update,references
c int(11) 0 select,insert,update,references
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Comment
t1 0 PRIMARY 1 a A 4 NULL NULL
t1 1 b 1 b A 1 NULL NULL
......
......@@ -34,7 +34,7 @@ PRIMARY KEY (GROUP_ID,LANG_ID),
KEY NAME (NAME));
#show table status like "t1";
ALTER TABLE t1 CHANGE NAME NAME CHAR(80) not null;
SHOW COLUMNS FROM t1;
SHOW FULL COLUMNS FROM t1;
DROP TABLE t1;
#
......
......@@ -12,6 +12,7 @@ insert into foo values(1),(2);
save_master_pos;
connection slave;
sync_with_master;
sleep 1;
use test;
select * from foo;
select sum(length(word)) from t1;
......
......@@ -9,6 +9,7 @@ save_master_pos;
connection slave;
use test;
sync_with_master;
sleep 1;
@r/rpl000002.result select * from t1;
connection master;
drop table t1;
......
......@@ -7,6 +7,7 @@ insert into t1 values (3);
save_master_pos;
connection slave;
sync_with_master;
sleep 1;
@r/rpl000003.result select * from t1;
connection master;
drop table t1;
......
......@@ -18,6 +18,7 @@ insert into bar values(15);
save_master_pos;
connection slave;
sync_with_master;
sleep 1;
@r/rpl000007.result select foo.n,bar.m from foo,bar;
connection master;
drop table if exists bar,foo;
......
......@@ -20,6 +20,7 @@ insert into choo values(55);
save_master_pos;
connection slave;
sync_with_master;
sleep 1;
@r/rpl000008.result select foo.n,bar.m,choo.k from foo,bar,choo;
connection master;
drop table if exists foo,bar,choo;
......
......@@ -22,6 +22,7 @@ insert into bar.bar values(15);
save_master_pos;
connection slave;
sync_with_master;
sleep 1;
@r/rpl000009.result select foo.foo.n,bar.bar.m from foo.foo,bar.bar;
connection master;
drop database if exists bar;
......
......@@ -11,6 +11,7 @@ insert into t1 values(2);
save_master_pos;
connection slave;
sync_with_master;
sleep 1;
@r/rpl000010.result select n from t1;
connection master;
drop table t1;
......
......@@ -16,6 +16,7 @@ save_master_pos;
connection slave;
#let slave catch up
sync_with_master;
sleep 1;
@r/rpl000011.result select * from t1;
connection master;
drop table t1;
......
......@@ -19,6 +19,7 @@ connection master2;
save_master_pos;
connection slave;
sync_with_master;
sleep 1;
@r/rpl000012.result select * from t2;
@r/rpl000012.status.result show status like 'Slave_open_temp_tables';
#
......
......@@ -22,6 +22,7 @@ connection master2;
save_master_pos;
connection slave;
sync_with_master;
sleep 1;
@r/rpl000013.result select * from t2;
@r/rpl000013.status.result show status like 'Slave_open_temp_tables';
#
......
......@@ -24,6 +24,7 @@ save_master_pos;
connection slave;
change master to master_log_pos=73;
sync_with_master;
sleep 1;
select * from foo;
connection master;
drop table foo;
......
......@@ -21,6 +21,7 @@ insert into foo values (10),(45),(90);
save_master_pos;
connection slave;
sync_with_master;
sleep 1;
select * from foo;
connection master;
drop table foo;
......
......@@ -18,6 +18,7 @@ insert into t1 values('Could not break slave'),('Tried hard');
save_master_pos;
connection slave;
sync_with_master;
sleep 1;
select * from t1;
connection master;
flush logs;
......@@ -32,6 +33,7 @@ insert into t2 values (65);
save_master_pos;
connection slave;
sync_with_master;
sleep 1;
select * from t2;
drop table if exists t1,t2;
connection master;
......
......@@ -1705,9 +1705,9 @@ select period as "Nuvarande period" from t1 group by "Nuvarande period" limit 1;
show tables;
show tables from test like "s%";
show tables from test like "t?";
show columns from t2;
show columns from t2 from test like 'f%';
show columns from t2 from test like 's%';
show full columns from t2;
show full columns from t2 from test like 'f%';
show full columns from t2 from test like 's%';
show keys from t2;
#
......
......@@ -11,6 +11,8 @@ repair table t1,t2;
check table t2,t1;
lock tables t1 read;
check table t2,t1;
show columns from t1;
show full columns from t1;
show keys from t1;
drop table t1,t2;
......
......@@ -37,9 +37,9 @@ insert into t1 values (NULL,NULL,NULL,NULL);
update t1 set c="",b=null where c="1";
lock tables t1 READ;
show fields from t1;
show full fields from t1;
lock tables t1 WRITE;
show fields from t1;
show full fields from t1;
unlock tables;
select t from t1 where t like "hello";
......
......@@ -7,7 +7,7 @@ select 6e-05, -6e-05, --6e-05, -6e-05+1.000000;
drop table if exists t1;
create table t1 (f1 float(24),f2 float(52));
show columns from t1;
show full columns from t1;
insert into t1 values(10,10),(1e+5,1e+5),(1234567890,1234567890),(1e+10,1e+10),(1e+15,1e+15),(1e+20,1e+20),(1e+50,1e+50),(1e+150,1e+150);
insert into t1 values(-10,-10),(1e-5,1e-5),(1e-10,1e-10),(1e-15,1e-15),(1e-20,1e-20),(1e-50,1e-50),(1e-150,1e-150);
select * from t1;
......@@ -32,7 +32,7 @@ drop table t1;
#
create table t1 (f float, f2 float(24), f3 float(6,2), d double, d2 float(53), d3 double(10,3), de decimal, de2 decimal(6), de3 decimal(5,2), n numeric, n2 numeric(8), n3 numeric(5,6));
show columns from t1;
show full columns from t1;
drop table t1;
create table t1 (a decimal(7,3) not null, key (a));
......
......@@ -43,7 +43,7 @@ CREATE TABLE t1 (
KEY (options,flags)
);
show fields from t1;
show full fields from t1;
show keys from t1;
CREATE UNIQUE INDEX test on t1 ( auto ) ;
......@@ -117,15 +117,15 @@ drop table t2;
create table t2 select * from t1;
update t2 set string="changed" where auto=16;
show columns from t1;
show columns from t2;
show full columns from t1;
show full columns from t2;
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 not (t1.string<=>t2.string and t1.tiny<=>t2.tiny and t1.short<=>t2.short and t1.medium<=>t2.medium and t1.long_int<=>t2.long_int and t1.longlong<=>t2.longlong and t1.real_float<=>t2.real_float and t1.real_double<=>t2.real_double and t1.utiny<=>t2.utiny and t1.ushort<=>t2.ushort and t1.umedium<=>t2.umedium and t1.ulong<=>t2.ulong and t1.ulonglong<=>t2.ulonglong and t1.time_stamp<=>t2.time_stamp and t1.date_field<=>t2.date_field and t1.time_field<=>t2.time_field and t1.date_time<=>t2.date_time and t1.new_blob_col<=>t2.new_blob_col and t1.tinyblob_col<=>t2.tinyblob_col and t1.mediumblob_col<=>t2.mediumblob_col and t1.options<=>t2.options and t1.flags<=>t2.flags and t1.new_field<=>t2.new_field);
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 from t1;
show columns from t2;
show full columns from t2;
select * from t2;
drop table t1,t2;
......@@ -134,7 +134,7 @@ insert into t1 values(1),(2);
create table t2 select * from t1;
!$1060 create table t3 select * from t1, t2; # Should give an error
create table t3 select t1.c AS c1, t2.c AS c2,1 as "const" from t1, t2;
show columns from t3;
show full columns from t3;
drop table t1,t2,t3;
create table t1 ( myfield INT NOT NULL, UNIQUE INDEX (myfield), unique (myfield), index(myfield));
......
......@@ -362,7 +362,8 @@ int mysqld_show_dbs(THD *thd,const char *wild);
int mysqld_show_open_tables(THD *thd,const char *db,const char *wild);
int mysqld_show_tables(THD *thd,const char *db,const char *wild);
int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild);
int mysqld_show_fields(THD *thd,TABLE_LIST *table, const char *wild);
int mysqld_show_fields(THD *thd,TABLE_LIST *table, const char *wild,
bool verbose);
int mysqld_show_keys(THD *thd, TABLE_LIST *table);
int mysqld_show_logs(THD *thd);
void mysqld_list_fields(THD *thd,TABLE_LIST *table, const char *wild);
......
......@@ -1545,7 +1545,8 @@ mysql_execute_command(void)
if (grant_option && check_grant(thd,SELECT_ACL,tables,2))
goto error;
res= mysqld_show_fields(thd,tables,
(lex->wild ? lex->wild->ptr() : NullS));
(lex->wild ? lex->wild->ptr() : NullS),
lex->verbose);
break;
}
#endif
......
......@@ -412,7 +412,8 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild)
***************************************************************************/
int
mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild)
mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
bool verbose)
{
TABLE *table;
handler *file;
......@@ -437,7 +438,8 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild)
field_list.push_back(new Item_empty_string("Key",3));
field_list.push_back(new Item_empty_string("Default",NAME_LEN));
field_list.push_back(new Item_empty_string("Extra",20));
field_list.push_back(new Item_empty_string("Privileges",80));
if (verbose)
field_list.push_back(new Item_empty_string("Privileges",80));
// Send first number of fields and records
{
......@@ -502,18 +504,21 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild)
end=strmov(tmp,"auto_increment");
net_store_data(packet,tmp,(uint) (end-tmp));
/* Add grant options */
col_access= get_column_grant(thd,table_list,field) & COL_ACLS;
end=tmp;
for (uint bitnr=0; col_access ; col_access>>=1,bitnr++)
{
if (col_access & 1)
{
*end++=',';
end=strmov(end,grant_types.type_names[bitnr]);
}
}
net_store_data(packet,tmp+1,end == tmp ? 0 : (uint) (end-tmp-1));
if (verbose)
{
/* Add grant options */
col_access= get_column_grant(thd,table_list,field) & COL_ACLS;
end=tmp;
for (uint bitnr=0; col_access ; col_access>>=1,bitnr++)
{
if (col_access & 1)
{
*end++=',';
end=strmov(end,grant_types.type_names[bitnr]);
}
}
net_store_data(packet,tmp+1,end == tmp ? 0 : (uint) (end-tmp-1));
}
if (my_net_write(&thd->net,(char*) packet->ptr(),packet->length()))
DBUG_RETURN(1);
}
......
......@@ -2159,12 +2159,12 @@ show_param:
Lex->db= $3;
Lex->options=0;
}
| COLUMNS FROM table_ident opt_db wild
| opt_full COLUMNS FROM table_ident opt_db wild
{
Lex->sql_command= SQLCOM_SHOW_FIELDS;
if ($4)
$3->change_db($4);
if (!add_table_to_list($3,NULL,0))
if ($5)
$4->change_db($5);
if (!add_table_to_list($4,NULL,0))
YYABORT;
}
| MASTER_SYM LOGS_SYM
......@@ -2181,10 +2181,8 @@ show_param:
}
| STATUS_SYM wild
{ Lex->sql_command= SQLCOM_SHOW_STATUS; }
| PROCESSLIST_SYM
{ Lex->sql_command= SQLCOM_SHOW_PROCESSLIST; Lex->verbose=0; }
| FULL PROCESSLIST_SYM
{ Lex->sql_command= SQLCOM_SHOW_PROCESSLIST; Lex->verbose=1; }
| opt_full PROCESSLIST_SYM
{ Lex->sql_command= SQLCOM_SHOW_PROCESSLIST;}
| VARIABLES wild
{ Lex->sql_command= SQLCOM_SHOW_VARIABLES; }
| LOGS_SYM
......@@ -2215,11 +2213,16 @@ wild:
/* empty */
| LIKE text_string { Lex->wild= $2; }
opt_full:
/* empty */ { Lex->verbose=0; }
| FULL { Lex->verbose=1; }
/* A Oracle compatible synonym for show */
describe:
describe_command table_ident
{
Lex->wild=0;
Lex->verbose=0;
Lex->sql_command=SQLCOM_SHOW_FIELDS;
if (!add_table_to_list($2, NULL,0))
YYABORT;
......
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