diff options
author | unknown <monty@donna.mysql.com> | 2000-12-15 16:18:00 +0200 |
---|---|---|
committer | unknown <monty@donna.mysql.com> | 2000-12-15 16:18:00 +0200 |
commit | 68d0f88c5e85c412ba2539e7e107a6de54e03af5 (patch) | |
tree | 9a2b6170f02f0aca853d98a59720a9258c7d851a /sql | |
parent | 7322a906a860c9aa17ba3bf681f65b2d7f2497ee (diff) | |
parent | bf4fb50fb4b0979b5e30e83e0189ff5d314530f5 (diff) | |
download | mariadb-git-68d0f88c5e85c412ba2539e7e107a6de54e03af5.tar.gz |
merge
BitKeeper/etc/logging_ok:
auto-union
Diffstat (limited to 'sql')
-rw-r--r-- | sql/ha_berkeley.cc | 41 | ||||
-rw-r--r-- | sql/ha_berkeley.h | 1 | ||||
-rw-r--r-- | sql/mysql_priv.h | 5 | ||||
-rw-r--r-- | sql/sql_lex.h | 2 | ||||
-rw-r--r-- | sql/sql_parse.cc | 12 | ||||
-rw-r--r-- | sql/sql_show.cc | 33 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 4 |
7 files changed, 94 insertions, 4 deletions
diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc index 0436b16fddc..1a29de32ed4 100644 --- a/sql/ha_berkeley.cc +++ b/sql/ha_berkeley.cc @@ -93,6 +93,7 @@ u_int32_t berkeley_lock_types[]= { DB_LOCK_DEFAULT, DB_LOCK_OLDEST, DB_LOCK_RANDOM }; TYPELIB berkeley_lock_typelib= {array_elements(berkeley_lock_names),"", berkeley_lock_names}; +static MEM_ROOT show_logs_root; static void berkeley_print_error(const char *db_errpfx, char *buffer); static byte* bdb_get_key(BDB_SHARE *share,uint *length, @@ -210,6 +211,46 @@ int berkeley_rollback(THD *thd, void *trans) DBUG_RETURN(error); } +static void *show_logs_alloc(size_t size) +{ + return alloc_root(&show_logs_root, size); +} + +int berkeley_show_logs(THD *thd) +{ + char **all_logs, **free_logs; + String *packet= &thd->packet; + int error; + DBUG_ENTER("berkeley_show_logs"); + + init_alloc_root(&show_logs_root, 1024, 1024); + if ((error= log_archive(db_env, &all_logs, DB_ARCH_ABS|DB_ARCH_LOG, show_logs_alloc)) || + (error= log_archive(db_env, &free_logs, DB_ARCH_ABS, show_logs_alloc))) + { + DBUG_PRINT("error", ("log_archive failed (error %d)", error)); + db_env->err(db_env, error, "log_archive: DB_ARCH_ABS"); + DBUG_RETURN(1); + } + + for (char **a = all_logs, **f = free_logs; *a; ++a) + { + packet->length(0); + net_store_data(packet,*a); + net_store_data(packet,"BDB"); + if (f && *f && strcmp(*a, *f) == 0) + { + net_store_data(packet, SHOW_LOG_STATUS_FREE); + ++f; + } + else + net_store_data(packet, SHOW_LOG_STATUS_INUSE); + + if (my_net_write(&thd->net,(char*) packet->ptr(),packet->length())) + DBUG_RETURN(1); /* purecov: inspected */ + } + free_root(&show_logs_root,MYF(0)); + DBUG_RETURN(0); +} static void berkeley_print_error(const char *db_errpfx, char *buffer) { diff --git a/sql/ha_berkeley.h b/sql/ha_berkeley.h index b17d0f041ba..b84a195e81c 100644 --- a/sql/ha_berkeley.h +++ b/sql/ha_berkeley.h @@ -168,3 +168,4 @@ bool berkeley_end(void); bool berkeley_flush_logs(void); int berkeley_commit(THD *thd, void *trans); int berkeley_rollback(THD *thd, void *trans); +int berkeley_show_logs(THD *thd); diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index e4641d1a0b7..067e17c4356 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -175,6 +175,10 @@ void kill_one_thread(THD *thd, ulong id); #define BINLOG_DUMP_NON_BLOCK 1 +/* sql_show.cc:show_log_files() */ +#define SHOW_LOG_STATUS_FREE "FREE" +#define SHOW_LOG_STATUS_INUSE "IN USE" + /* Some portable defines */ #define portable_sizeof_char_ptr 8 @@ -354,6 +358,7 @@ 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_keys(THD *thd, TABLE_LIST *table); +int mysqld_show_logs(THD *thd); void mysqld_list_fields(THD *thd,TABLE_LIST *table, const char *wild); int mysqld_dump_create_info(THD *thd, TABLE *table, int fd = -1); int mysqld_show_create(THD *thd, TABLE_LIST *table_list); diff --git a/sql/sql_lex.h b/sql/sql_lex.h index dd7e1cf7b30..46ff08e0a47 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -39,7 +39,7 @@ enum enum_sql_command { SQLCOM_DELETE, SQLCOM_TRUNCATE, SQLCOM_DROP_TABLE, SQLCOM_DROP_INDEX, SQLCOM_SHOW_DATABASES, SQLCOM_SHOW_TABLES, SQLCOM_SHOW_FIELDS, - SQLCOM_SHOW_KEYS, SQLCOM_SHOW_VARIABLES, SQLCOM_SHOW_STATUS, + SQLCOM_SHOW_KEYS, SQLCOM_SHOW_VARIABLES, SQLCOM_SHOW_LOGS, SQLCOM_SHOW_STATUS, SQLCOM_SHOW_PROCESSLIST, SQLCOM_SHOW_MASTER_STAT, SQLCOM_SHOW_SLAVE_STAT, SQLCOM_SHOW_GRANTS, SQLCOM_SHOW_CREATE, diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 15cbf40f85d..fef35ed88d0 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1475,6 +1475,18 @@ mysql_execute_command(void) res= mysqld_show(thd, (lex->wild ? lex->wild->ptr() : NullS), init_vars); break; + case SQLCOM_SHOW_LOGS: +#ifdef DONT_ALLOW_SHOW_COMMANDS + send_error(&thd->net,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ + DBUG_VOID_RETURN; +#else + { + if (grant_option && check_access(thd, FILE_ACL, any_db)) + goto error; + res= mysqld_show_logs(thd); + break; + } +#endif case SQLCOM_SHOW_TABLES: #ifdef DONT_ALLOW_SHOW_COMMANDS send_error(&thd->net,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 367ed9a0acb..8e7b12936ba 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -24,6 +24,10 @@ #include "sql_acl.h" #include <my_dir.h> +#ifdef HAVE_BERKELEY_DB +#include "ha_berkeley.h" // For berkeley_show_logs +#endif + /* extern "C" pthread_mutex_t THR_LOCK_keycache; */ static const char *grant_names[]={ @@ -402,6 +406,7 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild) restore_record(table,2); // Get empty record Field **ptr,*field; + String *packet= &thd->packet; for (ptr=table->field; (field= *ptr) ; ptr++) { if (!wild || !wild[0] || !wild_case_compare(field->field_name,wild)) @@ -414,7 +419,7 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild) { byte *pos; uint flags=field->flags; - String *packet= &thd->packet,type(tmp,sizeof(tmp)); + String type(tmp,sizeof(tmp)); uint col_access; bool null_default_value=0; @@ -526,6 +531,30 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list) } +#ifdef HAVE_BERKELEY_DB +int +mysqld_show_logs(THD *thd) +{ + DBUG_ENTER("mysqld_show_logs"); + + List<Item> field_list; + Item *item; + field_list.push_back(new Item_empty_string("File",FN_REFLEN)); + field_list.push_back(new Item_empty_string("Type",10)); + field_list.push_back(new Item_empty_string("Status",10)); + + if (send_fields(thd,field_list,1)) + DBUG_RETURN(1); + + if (berkeley_show_logs(thd)) + DBUG_RETURN(1); + + send_eof(&thd->net); + DBUG_RETURN(0); +} +#endif + + int mysqld_show_keys(THD *thd, TABLE_LIST *table_list) { @@ -562,13 +591,13 @@ mysqld_show_keys(THD *thd, TABLE_LIST *table_list) if (send_fields(thd,field_list,1)) DBUG_RETURN(1); + String *packet= &thd->packet; KEY *key_info=table->key_info; table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK | HA_STATUS_TIME); for (uint i=0 ; i < table->keys ; i++,key_info++) { KEY_PART_INFO *key_part= key_info->key_part; char *end; - String *packet= &thd->packet; for (uint j=0 ; j < key_info->key_parts ; j++,key_part++) { packet->length(0); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index e301c290894..84e55d46c71 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -14,7 +14,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* sql_yacc.y */ +/* sql_yacc.yy */ %{ #define MYSQL_YACC @@ -2179,6 +2179,8 @@ show_param: { Lex->sql_command= SQLCOM_SHOW_PROCESSLIST; Lex->verbose=1; } | VARIABLES wild { Lex->sql_command= SQLCOM_SHOW_VARIABLES; } + | LOGS_SYM + { Lex->sql_command= SQLCOM_SHOW_LOGS; } | GRANTS FOR_SYM user { Lex->sql_command= SQLCOM_SHOW_GRANTS; Lex->grant_user=$3; Lex->grant_user->password.str=NullS; } |