summaryrefslogtreecommitdiff
path: root/sql/sql_show.cc
diff options
context:
space:
mode:
authorunknown <tim@cane.mysql.fi>2000-12-18 23:22:20 +0200
committerunknown <tim@cane.mysql.fi>2000-12-18 23:22:20 +0200
commit22f0ffed87c94ff5983ed8874cdcf1b4a5113c83 (patch)
tree6c7a3e5744b99f5ca62385fc84624366492f5c0b /sql/sql_show.cc
parenta765e56fa17f03e000c86d876dd3c0c1cf33f498 (diff)
downloadmariadb-git-22f0ffed87c94ff5983ed8874cdcf1b4a5113c83.tar.gz
Added SHOW OPEN TABLES. Thanks to Antony T Curtis <antony@abacus.co.uk>
for the code. Docs/manual.texi: - added SHOW OPEN TABLES sql/gen_lex_hash.cc: - added SHOW OPEN TABLES sql/lex.h: - added SHOW OPEN TABLES sql/mysql_priv.h: - added SHOW OPEN TABLES sql/sql_base.cc: - added SHOW OPEN TABLES sql/sql_lex.h: - added SHOW OPEN TABLES sql/sql_parse.cc: - added SHOW OPEN TABLES sql/sql_show.cc: - added SHOW OPEN TABLES sql/sql_yacc.yy: - added SHOW OPEN TABLES
Diffstat (limited to 'sql/sql_show.cc')
-rw-r--r--sql/sql_show.cc45
1 files changed, 43 insertions, 2 deletions
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index a05a5fcebe9..05464dab954 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -87,6 +87,47 @@ mysqld_show_dbs(THD *thd,const char *wild)
}
/***************************************************************************
+** List all open tables in a database
+***************************************************************************/
+
+int mysqld_show_open_tables(THD *thd,const char *db,const char *wild)
+{
+ Item_string *field=new Item_string("",0);
+ List<Item> field_list;
+ char *end,*table_name;
+ List<char> tables;
+ DBUG_ENTER("mysqld_show_open_tables");
+
+ field->name=(char*) thd->alloc(20+(uint) strlen(db)+(wild ? (uint) strlen(wild)+4:0));
+ end=strxmov(field->name,"Open_tables_in_",db,NullS);
+ if (wild && wild[0])
+ strxmov(end," (",wild,")",NullS);
+ field->max_length=NAME_LEN;
+ field_list.push_back(field);
+ field_list.push_back(new Item_empty_string("Comment",80));
+
+ if (send_fields(thd,field_list,1))
+ DBUG_RETURN(1);
+
+ if (list_open_tables(thd,&tables,db,wild))
+ DBUG_RETURN(-1);
+
+ List_iterator<char> it(tables);
+ while ((table_name=it++))
+ {
+ thd->packet.length(0);
+ net_store_data(&thd->packet,table_name);
+ net_store_data(&thd->packet,query_table_status(thd,db,table_name));
+ if (my_net_write(&thd->net,(char*) thd->packet.ptr(),thd->packet.length()))
+ DBUG_RETURN(-1);
+ }
+
+
+ send_eof(&thd->net);
+ DBUG_RETURN(0);
+}
+
+/***************************************************************************
** List all tables in a database (fast version)
** A table is a .frm file in the current databasedir
***************************************************************************/
@@ -161,9 +202,9 @@ mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path,
}
else
{
- // Return only .frm files which isn't temp files.
+ // Return only .frm files which aren't temp files.
if (my_strcasecmp(ext=fn_ext(file->name),reg_ext) ||
- is_prefix(file->name,tmp_file_prefix)) // Mysql temp table
+ is_prefix(file->name,tmp_file_prefix))
continue;
*ext=0;
if (wild && wild[0] && wild_compare(file->name,wild))