summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <sasha@mysql.sashanet.com>2001-07-07 19:15:41 -0600
committerunknown <sasha@mysql.sashanet.com>2001-07-07 19:15:41 -0600
commit24638d06bd497d0ee756ca68bb045d3bbb3e75ba (patch)
tree22e94a9a53c70287a33e1657ee4bd4371ec04fb8
parent8aac0529c78052e90b6cf2fed36cc9d107796654 (diff)
downloadmariadb-git-24638d06bd497d0ee756ca68bb045d3bbb3e75ba.tar.gz
post-merge fixes
test SHOW OPEN TABLES mysql-test/r/show_check.result: updated result mysql-test/t/show_check.test: test show open tables sql/mysql_priv.h: post-merge fixes sql/sql_base.cc: post-merge fixes sql/sql_parse.cc: post-merge fixes
-rw-r--r--mysql-test/r/show_check.result3
-rw-r--r--mysql-test/t/show_check.test7
-rw-r--r--sql/mysql_priv.h6
-rw-r--r--sql/sql_base.cc45
-rw-r--r--sql/sql_parse.cc9
5 files changed, 61 insertions, 9 deletions
diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result
index 099ea2fa109..4d3b1b66e95 100644
--- a/mysql-test/r/show_check.result
+++ b/mysql-test/r/show_check.result
@@ -90,3 +90,6 @@ t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL default '0',
PRIMARY KEY (`a`)
) TYPE=MyISAM
+Open_tables_in_test Comment
+Open_tables_in_test Comment
+t1 cached=1, in_use=0
diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test
index 476d8dcdf0d..95b5a0fb0f1 100644
--- a/mysql-test/t/show_check.test
+++ b/mysql-test/t/show_check.test
@@ -72,3 +72,10 @@ drop table t1;
create table t1 (a int not null, primary key (a));
show create table t1;
drop table t1;
+
+flush tables;
+show open tables;
+create table t1(n int);
+insert into t1 values (1);
+show open tables;
+drop table t1;
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 63c9478d236..11caa3b5463 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -45,6 +45,7 @@ char *sql_strmake(const char *str,uint len);
gptr sql_memdup(const void * ptr,unsigned size);
void sql_element_free(void *ptr);
void kill_one_thread(THD *thd, ulong id);
+char* query_table_status(THD *thd,const char *db,const char *table_name);
#define x_free(A) { my_free((gptr) (A),MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR)); }
#define safeFree(x) { if(x) { my_free((gptr) x,MYF(0)); x = NULL; } }
@@ -373,7 +374,7 @@ Field *find_field_in_table(THD *thd,TABLE *table,const char *name,uint length,
/* sql_list.c */
int mysqld_show_dbs(THD *thd,const char *wild);
-int mysqld_show_open_tables(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,
@@ -450,7 +451,8 @@ bool close_cached_tables(THD *thd, bool wait_for_refresh, TABLE_LIST *tables);
void copy_field_from_tmp_record(Field *field,int offset);
int fill_record(List<Item> &fields,List<Item> &values);
int fill_record(Field **field,List<Item> &values);
-OPEN_TABLE_LIST *list_open_tables(THD *thd,const char *wild);
+int list_open_tables(THD *thd,List<char> *tables, const char *db,
+ const char *wild);
/* sql_calc.cc */
bool eval_const_cond(COND *cond);
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index cafe9810051..6587c4609ed 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -34,8 +34,6 @@ HASH open_cache; /* Used by mysql_test */
static int open_unireg_entry(THD *thd,TABLE *entry,const char *db,
const char *name, const char *alias, bool locked);
-static bool insert_fields(THD *thd,TABLE_LIST *tables, const char *db_name,
- const char *table_name, List_iterator<Item> *it);
static void free_cache_entry(TABLE *entry);
static void mysql_rm_tmp_tables(void);
static key_map get_key_map_from_key_list(TABLE *table,
@@ -407,6 +405,47 @@ bool close_cached_tables(THD *thd, bool if_wait_for_refresh,
DBUG_RETURN(result);
}
+/* move one table to free list */
+
+bool close_thread_table(THD *thd, TABLE **table_ptr)
+{
+ DBUG_ENTER("close_thread_table");
+
+ bool found_old_table=0;
+ TABLE *table=*table_ptr;
+
+ *table_ptr=table->next;
+ if (table->version != refresh_version ||
+ thd->version != refresh_version || !table->db_stat)
+ {
+ VOID(hash_delete(&open_cache,(byte*) table));
+ found_old_table=1;
+ }
+ else
+ {
+ if (table->flush_version != flush_version)
+ {
+ table->flush_version=flush_version;
+ table->file->extra(HA_EXTRA_FLUSH);
+ }
+ else
+ {
+ // Free memory and reset for next loop
+ table->file->extra(HA_EXTRA_RESET);
+ }
+ table->in_use=0;
+ if (unused_tables)
+ {
+ table->next=unused_tables; /* Link in last */
+ table->prev=unused_tables->prev;
+ unused_tables->prev=table;
+ table->prev->next=table;
+ }
+ else
+ unused_tables=table->next=table->prev=table;
+ }
+ DBUG_RETURN(found_old_table);
+}
/* Put all tables used by thread in free list */
@@ -1832,7 +1871,7 @@ static key_map get_key_map_from_key_list(TABLE *table,
** Returns pointer to last inserted field if ok
****************************************************************************/
-static bool
+bool
insert_fields(THD *thd,TABLE_LIST *tables, const char *db_name,
const char *table_name, List_iterator<Item> *it)
{
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 62075c1be5b..bfc6e8185bd 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1819,6 +1819,7 @@ mysql_execute_command(void)
}
#endif
case SQLCOM_SHOW_TABLES:
+ case SQLCOM_SHOW_OPEN_TABLES:
/* FALL THROUGH */
#ifdef DONT_ALLOW_SHOW_COMMANDS
send_error(&thd->net,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */
@@ -1840,7 +1841,10 @@ mysql_execute_command(void)
if (check_access(thd,SELECT_ACL,db,&thd->col_access))
goto error; /* purecov: inspected */
/* grant is checked in mysqld_show_tables */
- if (select_lex->options & SELECT_DESCRIBE)
+ if (lex->sql_command == SQLCOM_SHOW_OPEN_TABLES)
+ res= mysqld_show_open_tables(thd, db,
+ (lex->wild ? lex->wild->ptr() : NullS));
+ else if (select_lex->options & SELECT_DESCRIBE)
res= mysqld_extend_show_tables(thd,db,
(lex->wild ? lex->wild->ptr() : NullS));
else
@@ -1849,9 +1853,6 @@ mysql_execute_command(void)
break;
}
#endif
- case SQLCOM_SHOW_OPEN_TABLES:
- res= mysqld_show_open_tables(thd,(lex->wild ? lex->wild->ptr() : NullS));
- break;
case SQLCOM_SHOW_FIELDS:
#ifdef DONT_ALLOW_SHOW_COMMANDS
send_error(&thd->net,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */