Loading Docs/manual.texi +5 −1 Original line number Diff line number Diff line Loading @@ -19889,7 +19889,7 @@ commands to examine and kill threads. @example SHOW DATABASES [LIKE wild] or SHOW TABLES [FROM db_name] [LIKE wild] or SHOW [OPEN] TABLES [FROM db_name] [LIKE wild] or SHOW 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] Loading Loading @@ -19945,6 +19945,10 @@ get this list using the @code{mysqlshow db_name} command. will not show up in the output from @code{SHOW TABLES} or @code{mysqlshow db_name}. @code{SHOW OPEN TABLES} lists the tables that are currently open in 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 sql/gen_lex_hash.cc +1 −1 Original line number Diff line number Diff line Loading @@ -472,7 +472,7 @@ int main(int argc,char **argv) int error; MY_INIT(argv[0]); start_value=2610463L; best_t1=8358376L; best_t2=860646L; best_type=2; /* mode=4111 add=8 func_type: 0 */ start_value=5206280L; best_t1=590774L; best_t2=5977654L; best_type=1; /* mode=6229 add=2 func_type: 0 */ if (get_options(argc,(char **) argv)) exit(1); Loading sql/lex.h +1 −0 Original line number Diff line number Diff line Loading @@ -223,6 +223,7 @@ static SYMBOL symbols[] = { { "NOT", SYM(NOT),0,0}, { "NULL", SYM(NULL_SYM),0,0}, { "ON", SYM(ON),0,0}, { "OPEN", SYM(OPEN_SYM),0,0}, { "OPTIMIZE", SYM(OPTIMIZE),0,0}, { "OPTION", SYM(OPTION),0,0}, { "OPTIONALLY", SYM(OPTIONALLY),0,0}, Loading sql/mysql_priv.h +3 −0 Original line number Diff line number Diff line Loading @@ -354,6 +354,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 *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); Loading Loading @@ -418,6 +419,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); int list_open_tables(THD *thd,List<char> *files, const char *db,const char *wild); char* query_table_status(THD *thd,const char *db,const char *table_name); /* sql_calc.cc */ bool eval_const_cond(COND *cond); Loading sql/sql_base.cc +68 −0 Original line number Diff line number Diff line Loading @@ -112,6 +112,74 @@ static void check_unused(void) #define check_unused() #endif int list_open_tables(THD *thd,List<char> *tables, const char *db,const char *wild) { int result = 0; uint col_access=thd->col_access; TABLE_LIST table_list; DBUG_ENTER("list_open_tables"); VOID(pthread_mutex_lock(&LOCK_open)); bzero((char*) &table_list,sizeof(table_list)); for (uint idx=0 ; result == 0 && idx < open_cache.records; idx++) { TABLE *entry=(TABLE*) hash_element(&open_cache,idx); if ((!entry->real_name) || strcmp(entry->table_cache_key,db)) continue; if (wild && wild[0] && wild_compare(entry->real_name,wild)) continue; if (db && !(col_access & TABLE_ACLS)) { table_list.db= (char*) db; table_list.real_name= entry->real_name;/*real name*/ table_list.grant.privilege=col_access; if (check_grant(thd,TABLE_ACLS,&table_list,1)) continue; } /* need to check if he have't already listed it */ List_iterator<char> it(*tables); char *table_name; int check = 0; while (check == 0 && (table_name=it++)) { if (!strcmp(table_name,entry->real_name)) check++; } if (check) continue; if (tables->push_back(thd->strdup(entry->real_name))) { result = -1; } } VOID(pthread_mutex_unlock(&LOCK_open)); DBUG_RETURN(result); } char* query_table_status(THD *thd,const char *db,const char *table_name) { int cached = 0, in_use = 0; char info[256]; for (uint idx=0 ; idx < open_cache.records; idx++) { TABLE *entry=(TABLE*) hash_element(&open_cache,idx); if (strcmp(entry->table_cache_key,db) || strcmp(entry->real_name,table_name)) continue; cached++; if (entry->in_use) in_use++; } sprintf(info, "cached=%d, in_use=%d", cached, in_use); return thd->strdup(info); } /****************************************************************************** Loading Loading
Docs/manual.texi +5 −1 Original line number Diff line number Diff line Loading @@ -19889,7 +19889,7 @@ commands to examine and kill threads. @example SHOW DATABASES [LIKE wild] or SHOW TABLES [FROM db_name] [LIKE wild] or SHOW [OPEN] TABLES [FROM db_name] [LIKE wild] or SHOW 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] Loading Loading @@ -19945,6 +19945,10 @@ get this list using the @code{mysqlshow db_name} command. will not show up in the output from @code{SHOW TABLES} or @code{mysqlshow db_name}. @code{SHOW OPEN TABLES} lists the tables that are currently open in 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
sql/gen_lex_hash.cc +1 −1 Original line number Diff line number Diff line Loading @@ -472,7 +472,7 @@ int main(int argc,char **argv) int error; MY_INIT(argv[0]); start_value=2610463L; best_t1=8358376L; best_t2=860646L; best_type=2; /* mode=4111 add=8 func_type: 0 */ start_value=5206280L; best_t1=590774L; best_t2=5977654L; best_type=1; /* mode=6229 add=2 func_type: 0 */ if (get_options(argc,(char **) argv)) exit(1); Loading
sql/lex.h +1 −0 Original line number Diff line number Diff line Loading @@ -223,6 +223,7 @@ static SYMBOL symbols[] = { { "NOT", SYM(NOT),0,0}, { "NULL", SYM(NULL_SYM),0,0}, { "ON", SYM(ON),0,0}, { "OPEN", SYM(OPEN_SYM),0,0}, { "OPTIMIZE", SYM(OPTIMIZE),0,0}, { "OPTION", SYM(OPTION),0,0}, { "OPTIONALLY", SYM(OPTIONALLY),0,0}, Loading
sql/mysql_priv.h +3 −0 Original line number Diff line number Diff line Loading @@ -354,6 +354,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 *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); Loading Loading @@ -418,6 +419,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); int list_open_tables(THD *thd,List<char> *files, const char *db,const char *wild); char* query_table_status(THD *thd,const char *db,const char *table_name); /* sql_calc.cc */ bool eval_const_cond(COND *cond); Loading
sql/sql_base.cc +68 −0 Original line number Diff line number Diff line Loading @@ -112,6 +112,74 @@ static void check_unused(void) #define check_unused() #endif int list_open_tables(THD *thd,List<char> *tables, const char *db,const char *wild) { int result = 0; uint col_access=thd->col_access; TABLE_LIST table_list; DBUG_ENTER("list_open_tables"); VOID(pthread_mutex_lock(&LOCK_open)); bzero((char*) &table_list,sizeof(table_list)); for (uint idx=0 ; result == 0 && idx < open_cache.records; idx++) { TABLE *entry=(TABLE*) hash_element(&open_cache,idx); if ((!entry->real_name) || strcmp(entry->table_cache_key,db)) continue; if (wild && wild[0] && wild_compare(entry->real_name,wild)) continue; if (db && !(col_access & TABLE_ACLS)) { table_list.db= (char*) db; table_list.real_name= entry->real_name;/*real name*/ table_list.grant.privilege=col_access; if (check_grant(thd,TABLE_ACLS,&table_list,1)) continue; } /* need to check if he have't already listed it */ List_iterator<char> it(*tables); char *table_name; int check = 0; while (check == 0 && (table_name=it++)) { if (!strcmp(table_name,entry->real_name)) check++; } if (check) continue; if (tables->push_back(thd->strdup(entry->real_name))) { result = -1; } } VOID(pthread_mutex_unlock(&LOCK_open)); DBUG_RETURN(result); } char* query_table_status(THD *thd,const char *db,const char *table_name) { int cached = 0, in_use = 0; char info[256]; for (uint idx=0 ; idx < open_cache.records; idx++) { TABLE *entry=(TABLE*) hash_element(&open_cache,idx); if (strcmp(entry->table_cache_key,db) || strcmp(entry->real_name,table_name)) continue; cached++; if (entry->in_use) in_use++; } sprintf(info, "cached=%d, in_use=%d", cached, in_use); return thd->strdup(info); } /****************************************************************************** Loading