Commit 68d0f88c authored by unknown's avatar unknown

merge


BitKeeper/etc/logging_ok:
  auto-union
parents 7322a906 bf4fb50f
......@@ -7,3 +7,4 @@ paul@central.snake.net
sasha@mysql.sashanet.com
sasha@work.mysql.com
serg@serg.mysql.com
tim@cane.mysql.fi
......@@ -19895,6 +19895,7 @@ or SHOW INDEX FROM tbl_name [FROM db_name]
or SHOW TABLE STATUS [FROM db_name] [LIKE wild]
or SHOW STATUS [LIKE wild]
or SHOW VARIABLES [LIKE wild]
or SHOW LOGS
or SHOW [FULL] PROCESSLIST
or SHOW GRANTS FOR user
or SHOW CREATE TABLE table_name
......@@ -19916,6 +19917,7 @@ and @samp{_} wild-card characters.
* SHOW TABLE STATUS::
* SHOW STATUS::
* SHOW VARIABLES::
* SHOW LOGS::
* SHOW PROCESSLIST::
* SHOW GRANTS::
* SHOW CREATE TABLE::
......@@ -20160,7 +20162,7 @@ your @code{mysqld} @code{sort_buffer} variables is probably too small.
tables.
@end itemize
@node SHOW VARIABLES, SHOW PROCESSLIST, SHOW STATUS, SHOW
@node SHOW VARIABLES, SHOW LOGS, SHOW STATUS, SHOW
@subsection SHOW VARIABLES
@code{SHOW VARIABLES} shows the values of some @strong{MySQL} system
......@@ -20620,11 +20622,27 @@ closing it. See also @code{interactive_timeout}.
The manual section that describes tuning @strong{MySQL} contains some
information of how to tune the above variables. @xref{Server parameters}.
@node SHOW LOGS, SHOW PROCESSLIST, SHOW VARIABLES, SHOW
@subsection SHOW Information About Log Files
@code{SHOW LOGS} shows you status information about existing log
files. It currently only displays information about Berkeley DB log
files.
@itemize @bullet
@item @code{File} shows the full path to the log file
@item @code{Type} shows the type of the log file (@code{BDB} for Berkeley
DB log files)
@item @code{Status} shows the status of the log file (@code{FREE} if the
file can be removed, or @code{IN USE} if the file is needed by the transaction
subsystem)
@end itemize
@cindex threads, display
@cindex processes, display
@findex threads
@findex PROCESSLIST
@node SHOW PROCESSLIST, SHOW GRANTS, SHOW VARIABLES, SHOW
@node SHOW PROCESSLIST, SHOW GRANTS, SHOW LOGS, SHOW
@subsection SHOW Information About Connected Threads (Processes)
@code{SHOW PROCESSLIST} shows you which threads are running. You can
......@@ -39789,6 +39807,8 @@ Fixed bug in @code{REPLACE} with BDB tables.
@code{LPAD()} and @code{RPAD()} will shorten the result string if it's longer
than the length argument.
@item
Added @code{SHOW LOGS} command.
@item
Remove not used BDB logs on shutdown.
@item
When creating a table, put @code{PRIMARY} keys first, followed by
......@@ -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)
{
......
......@@ -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);
......@@ -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);
......
......@@ -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,
......
......@@ -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 */
......
......@@ -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);
......
......@@ -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; }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment