diff options
author | sasha@mysql.sashanet.com <> | 2001-07-07 15:35:23 -0600 |
---|---|---|
committer | sasha@mysql.sashanet.com <> | 2001-07-07 15:35:23 -0600 |
commit | 27561841d17002a1b0f3b88ff070a3f927fae561 (patch) | |
tree | 2c2c91a54c739acfc0a214de49f4a8488c3a2894 /sql/sql_show.cc | |
parent | 6bedc859773a283cb8cd3b5ab38339685c4f3734 (diff) | |
parent | cc35643e1cbe0c4a1988b3eac1ee540726f639a3 (diff) | |
download | mariadb-git-27561841d17002a1b0f3b88ff070a3f927fae561.tar.gz |
merged latest changes in 3.23
Diffstat (limited to 'sql/sql_show.cc')
-rw-r--r-- | sql/sql_show.cc | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 199d6a764e0..000994d5d1f 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -95,34 +95,38 @@ mysqld_show_dbs(THD *thd,const char *wild) ** List all open tables in a database ***************************************************************************/ -int mysqld_show_open_tables(THD *thd,const char *wild) +int mysqld_show_open_tables(THD *thd,const char *db,const char *wild) { + Item_string *field=new Item_string("",0); List<Item> field_list; - OPEN_TABLE_LIST *open_list; - CONVERT *convert=thd->convert_set; + char *end,*table_name; + List<char> tables; DBUG_ENTER("mysqld_show_open_tables"); - field_list.push_back(new Item_empty_string("Database",NAME_LEN)); - field_list.push_back(new Item_empty_string("Table",NAME_LEN)); - field_list.push_back(new Item_int("In_use",0, 4)); - field_list.push_back(new Item_int("Name_locked",0, 4)); + 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 (!(open_list=list_open_tables(thd,wild))) + if (list_open_tables(thd,&tables,db,wild)) DBUG_RETURN(-1); - for ( ; open_list ; open_list=open_list->next) + List_iterator<char> it(tables); + while ((table_name=it++)) { thd->packet.length(0); - net_store_data(&thd->packet,convert, open_list->db); - net_store_data(&thd->packet,convert, open_list->table); - net_store_data(&thd->packet,open_list->in_use); - net_store_data(&thd->packet,open_list->locked); + 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); } |