Below is the list of changes that have just been committed into a local
5.1 repository of cps. When cps does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.1950 05/11/15 14:00:33 petr@stripped +30 -0
WL #1019 SELECT FROM logs: the first patch
mysql-test/t/log_tables.test
1.1 05/11/15 13:52:27 petr@stripped +86 -0
New BitKeeper file ``mysql-test/t/log_tables.test''
mysql-test/t/log_tables.test
1.0 05/11/15 13:52:27 petr@stripped +0 -0
BitKeeper file /home/cps/mysql/devel/mysql-5.1-logs-curr/mysql-test/t/log_tables.test
mysql-test/r/log_tables.result
1.1 05/11/15 13:52:26 petr@stripped +35 -0
New BitKeeper file ``mysql-test/r/log_tables.result''
sql/table.h
1.116 05/11/15 13:52:26 petr@stripped +5 -0
add a flag to mark the log tables in TABLE_SHARE
sql/sql_table.cc
1.277 05/11/15 13:52:26 petr@stripped +3 -2
don't reoped the log tables for admin purposes
sql/sql_show.cc
1.276 05/11/15 13:52:26 petr@stripped +2 -2
convert old logging routine calls to use new API
sql/sql_prepare.cc
1.154 05/11/15 13:52:26 petr@stripped +2 -2
convert old logging routine calls to use new API
sql/sql_parse.cc
1.481 05/11/15 13:52:26 petr@stripped +30 -30
convert old logging routine calls to use new API
sql/sql_db.cc
1.120 05/11/15 13:52:26 petr@stripped +2 -2
convert old logging routine calls to use new API
sql/sql_class.h
1.268 05/11/15 13:52:26 petr@stripped +3 -1
change signature
sql/sql_base.cc
1.278 05/11/15 13:52:26 petr@stripped +16 -4
never close log tables
sql/slave.cc
1.257 05/11/15 13:52:26 petr@stripped +2 -2
convert old logging routine calls to use new API
mysql-test/r/log_tables.result
1.0 05/11/15 13:52:26 petr@stripped +0 -0
BitKeeper file /home/cps/mysql/devel/mysql-5.1-logs-curr/mysql-test/r/log_tables.result
sql/mysqld.cc
1.489 05/11/15 13:52:25 petr@stripped +65 -28
add support for new logging: use log tables by default
sql/mysql_priv.h
1.342 05/11/15 13:52:25 petr@stripped +22 -1
delclare new logging routines and required structures
sql/log_event.cc
1.190 05/11/15 13:52:25 petr@stripped +3 -2
convert old logging routines calls to use new API
sql/log.cc
1.175 05/11/15 13:52:25 petr@stripped +586 -11
added support for pluggable log handlers. Added code to manage log tables
sql/examples/ha_tina.h
1.8 05/11/15 13:52:25 petr@stripped +5 -1
ha_tina: added locking for the log tables.
sql/examples/ha_tina.cc
1.22 05/11/15 13:52:25 petr@stripped +134 -14
ha_tina: added locking for the log tables. ported some critical bugfixes
from 4.1/5.0 by hand
scripts/mysql_fix_privilege_tables.sql
1.28 05/11/15 13:52:25 petr@stripped +28 -0
add new log tables
scripts/mysql_create_system_tables.sh
1.26 05/11/15 13:52:25 petr@stripped +44 -0
new system tables: slow_log and general_log
mysql-test/t/system_mysql_db_fix.test
1.20 05/11/15 13:52:25 petr@stripped +4 -1
correct test with respect to the log tables
mysql-test/r/system_mysql_db.result
1.31 05/11/15 13:52:25 petr@stripped +27 -0
correct test with respect to the log tables
mysql-test/r/show_check.result
1.77 05/11/15 13:52:25 petr@stripped +18 -6
correct test with respect to the log tables
mysql-test/r/mysqlcheck.result
1.3 05/11/15 13:52:25 petr@stripped +8 -0
correct test with respect to the log tables
mysql-test/r/information_schema.result
1.89 05/11/15 13:52:25 petr@stripped +4 -2
correct test with respect to the log tables
mysql-test/r/im_utils.result
1.2 05/11/15 13:52:24 petr@stripped +2 -0
correct test with respect to the log tables
mysql-test/r/connect.result
1.22 05/11/15 13:52:24 petr@stripped +6 -0
correct test with respect to the log tables
mysql-test/mysql-test-run.pl
1.41 05/11/15 13:52:24 petr@stripped +3 -0
Add old logs flag to IM tests. As IM could only deal with
old logs (this feature is not needed with log tables)
mysql-test/lib/init_db.sql
1.16 05/11/15 13:52:24 petr@stripped +23 -0
testDB should also create log tables now
mysql-test/include/system_db_struct.inc
1.6 05/11/15 13:52:24 petr@stripped +2 -0
correct test include with respect to the log tables
include/my_base.h
1.74 05/11/15 13:52:24 petr@stripped +2 -1
add new handler flag for ::extra()
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: petr
# Host: owlet.
# Root: /home/cps/mysql/devel/mysql-5.1-logs-curr
--- 1.73/include/my_base.h 2005-11-05 14:20:31 +03:00
+++ 1.74/include/my_base.h 2005-11-15 13:52:24 +03:00
@@ -152,7 +152,8 @@
other fields intact. When this is off (by default) InnoDB will use memcpy
to overwrite entire row.
*/
- HA_EXTRA_KEYREAD_PRESERVE_FIELDS
+ HA_EXTRA_KEYREAD_PRESERVE_FIELDS,
+ HA_EXTRA_MARK_AS_LOG_TABLE
};
/* The following is parameter to ha_panic() */
--- 1.174/sql/log.cc 2005-11-07 18:24:41 +03:00
+++ 1.175/sql/log.cc 2005-11-15 13:52:25 +03:00
@@ -34,6 +34,60 @@
#include "message.h"
#endif
+/*
+ Currently we have only 3 kinds of logging functions: old-fashioned
+ logs, stdout and csv logging routines.
+*/
+#define MAX_LOG_HANDLERS_NUM 3
+
+/* the following vars are used for the log tables */
+uint is_csv_logs_initialized= FALSE;
+/*
+ We create artificial THD for each of the logs. Since they are shared
+ between threads.
+*/
+THD *general_log_thd= NULL, *slow_log_thd= NULL;
+TABLE_LIST general_log, slow_log;
+
+/* typedefs for log processing functions */
+typedef int (*error_log_handler)(enum loglevel level, const char *format,
+ va_list args);
+
+typedef bool (*slow_log_handler)(THD *thd, const char *query, uint query_length,
+ time_t query_start_arg);
+
+typedef bool (*general_log_handler)(THD *thd,enum enum_server_command command,
+ const char *format, va_list args_arg);
+
+
+/* Class which manages the log tables */
+class Logger
+{
+ /* NULL-terminated arrays of logging functions*/
+ error_log_handler error_log_print_list[MAX_LOG_HANDLERS_NUM + 1];
+ slow_log_handler slow_log_print_list[MAX_LOG_HANDLERS_NUM + 1];
+ general_log_handler general_log_print_list[MAX_LOG_HANDLERS_NUM + 1];
+
+public:
+
+ int error_log_print(enum loglevel level, const char *format,
+ va_list args);
+ bool slow_log_print(THD *thd, const char *query, uint query_length,
+ time_t query_start_arg);
+ bool general_log_print(THD *thd,enum enum_server_command command,
+ const char *format, va_list args);
+ int init_csv_logs();
+ int init(enum enum_printer error_log_printer,
+ enum enum_printer slow_log_printer,
+ enum enum_printer general_log_printer);
+ void init_error_log(enum enum_printer error_log_printer);
+ void init_slow_log(enum enum_printer slow_log_printer);
+ void init_general_log(enum enum_printer general_log_printer);
+};
+
+Logger logger;
+
+
MYSQL_LOG mysql_log, mysql_slow_log, mysql_bin_log;
ulong sync_binlog_counter= 0;
@@ -81,6 +135,491 @@
};
+
+/*
+ Open general log table
+
+ SYNOPSYS
+ general_log_table_open()
+ tables pointer to the TABLE_LIST structure which will be used
+ to open the general log. Later we'll use tables->table
+ to perform logging in log_general_to_csv()
+
+ DESCRIPTION
+
+ The function is used during the server startup. We open the log tables and
+ mark them as such. This is needed to provide approproate locking for the
+ log tables: the log tables downgrade all locks to TL_WRITE_ALLOW_WRITE,
+ so that nobody could lock down the system. Log tables are opened during
+ the whole time, while server is running.
+
+ RETURN
+ 0 - ok
+ 1 - error occured
+*/
+
+int general_log_table_open(TABLE_LIST *tables)
+{
+
+ DBUG_ENTER("general_log_table_open");
+
+ if (!general_log_thd)
+ DBUG_RETURN(1);
+
+ general_log_thd->store_globals();
+
+ general_log_thd->db= my_strdup("mysql",MYF(0));
+ general_log_thd->db_length= 5;
+ bzero((char*) tables, sizeof(TABLE_LIST));
+ tables->alias= tables->table_name=(char*) "general_log";
+ tables->lock_type= TL_WRITE_ALLOW_WRITE;
+ tables->db= general_log_thd->db;
+
+ if (simple_open_n_lock_tables(general_log_thd, tables))
+ DBUG_RETURN(1);
+
+ if (tables->table->file->extra(HA_EXTRA_MARK_AS_LOG_TABLE))
+ DBUG_RETURN(1);
+
+ if (tables->table->file->ha_rnd_init(0))
+ DBUG_RETURN(1);
+
+ DBUG_RETURN(0);
+}
+
+
+/*
+ Open slow log table
+
+ SYNOPSYS
+ slow_log_table_open()
+ tables pointer to the TABLE_LIST structure which will be used
+ to open the slow log.
+
+ DESCRIPTION
+
+ The function is used during the server startup. For more details see
+ comment to general_log_table_open()
+
+ RETURN
+ 0 - ok
+ 1 - error occured
+*/
+
+int slow_log_table_open(TABLE_LIST *tables)
+{
+ DBUG_ENTER("slow_log_table_open");
+
+ if (!slow_log_thd)
+ DBUG_RETURN(1);
+
+ slow_log_thd->store_globals();
+
+ slow_log_thd->db= my_strdup("mysql",MYF(0));
+ slow_log_thd->db_length= 5;
+ bzero((char*) tables, sizeof(TABLE_LIST));
+ tables->alias= tables->table_name=(char*) "slow_log";
+ tables->lock_type= TL_WRITE_ALLOW_WRITE;
+ tables->db= slow_log_thd->db;
+
+ if (simple_open_n_lock_tables(slow_log_thd, tables))
+ DBUG_RETURN(1);
+
+ if (tables->table->file->extra(HA_EXTRA_MARK_AS_LOG_TABLE))
+ DBUG_RETURN(1);
+
+ /* init handler */
+ tables->table->file->ha_rnd_init(0);
+
+ DBUG_RETURN(0);
+}
+
+/* log handlers */
+
+/*
+ Log command to the general log table
+
+ SYNOPSYS
+ log_general_to_csv()
+ thd THD of the query
+ command the type of the command being logged
+ format format string for the command. as in printf()
+ args arguments for the command
+
+ DESCRIPTION
+
+ Log given command to the general log table
+
+ RETURN
+ 0 - ok
+ 1 - error occured
+*/
+
+bool log_general_to_csv(THD *thd,enum enum_server_command command,
+ const char *format, va_list args)
+{
+ TABLE *table= general_log.table;
+ char message_buff[1024];
+ Security_context *sctx= thd->security_ctx;
+
+ DBUG_ENTER("log_general_to_csv");
+
+ if (!general_log_thd)
+ DBUG_RETURN(1);
+
+ /* for CURRENT_TIMESTAMP to work */
+ general_log_thd->start_time= time((time_t*) 0);
+
+ /* print the message to the buffer */
+
+ if (what_to_log & (1L << (uint) command))
+ {
+ ulong id;
+
+ if (thd)
+ { /* Normal thread */
+ if ((thd->options & OPTION_LOG_OFF)
+#ifndef NO_EMBEDDED_ACCESS_CHECKS
+ && (sctx->master_access & SUPER_ACL)
+#endif
+ )
+ {
+ DBUG_RETURN(0); /* No logging */
+ }
+ id= thd->thread_id;
+ }
+ else
+ id=0; /* Log from connect handler */
+
+ /* set CURRENT_TIMESTAMP */
+ table->field[0]->set_null();
+
+ /* fill in user_host value */
+ sprintf(message_buff, "%s[%s] @ %s [%s]",
+ sctx->priv_user ? sctx->priv_user : "",
+ sctx->user ? sctx->user : "",
+ sctx->host ? sctx->host : "",
+ sctx->ip ? sctx->ip : "");
+
+ /* store the value */
+ table->field[1]->store(message_buff,
+ strlen(message_buff),
+ &my_charset_latin1);
+
+ table->field[2]->store((longlong) id);
+ table->field[3]->store((longlong) server_id);
+ table->field[4]->store(command_name[(uint) command],
+ strlen(command_name[(uint) command]),
+ &my_charset_latin1);
+ /* prepare message */
+ if (format)
+ my_vsnprintf(message_buff,
+ sizeof(message_buff), format, args);
+ else
+ message_buff[0]= '\0';
+
+ /* store the message */
+ table->field[5]->store(message_buff,
+ strlen(message_buff),
+ &my_charset_latin1);
+ table->file->write_row(table->record[0]);
+
+ }
+
+ DBUG_RETURN(0);
+}
+
+
+/*
+ Log a query to the slow log table
+
+ SYNOPSYS
+ log_slow_to_csv()
+ thd THD of the query
+ query the very query in a text form
+ query_string length of the query string
+ query_start_arg time when the query was started
+
+ DESCRIPTION
+
+ Log a query to the slow log table
+
+ RETURN
+ 0 - ok
+ 1 - error occured
+*/
+
+bool log_slow_to_csv(THD *thd,const char *query, uint query_length,
+ time_t query_start_arg)
+{
+ my_time_t current_time;
+ Security_context *sctx= thd->security_ctx;
+
+ /* table variables */
+ TABLE *table= slow_log.table;
+ char message_buff[1024];
+
+ DBUG_ENTER("log_slow_to_csv");
+
+ if (!slow_log_thd)
+ DBUG_RETURN(1);
+
+ /* for CURRENT_TIMESTAMP to work */
+ slow_log_thd->start_time= time((time_t*) 0);
+
+ /* compute current time */
+ current_time= time(NULL);
+
+ /* set default value (which is CURRENT_TIMESTAMP) */
+ table->field[0]->set_null();
+
+ /* fill in user_host value */
+ sprintf(message_buff, "%s[%s] @ %s [%s]",
+ sctx->priv_user ? sctx->priv_user : "",
+ sctx->user ? sctx->user : "",
+ sctx->host ? sctx->host : "",
+ sctx->ip ? sctx->ip : "");
+
+ /* store the value */
+ table->field[1]->store(message_buff,
+ strlen(message_buff),
+ &my_charset_latin1);
+
+ if (query_start_arg)
+ {
+ /* query_time */
+ table->field[2]->store((longlong) (current_time - query_start_arg));
+ /* lock_time */
+ table->field[3]->store((longlong)
+ (thd->time_after_lock - query_start_arg));
+ /* rows_sent */
+ table->field[4]->store((longlong) thd->sent_row_count);
+ /* rows_sent rows_examined*/
+ table->field[5]->store((longlong) thd->examined_row_count);
+ }
+ else
+ {
+ table->field[2]->set_null();
+ table->field[3]->set_null();
+ table->field[4]->set_null();
+ table->field[5]->set_null();
+ }
+
+ if (thd->db)
+ /* fill databes field */
+ table->field[6]->store(thd->db,
+ strlen(thd->db),
+ &my_charset_latin1);
+ else
+ table->field[6]->set_null();
+
+ if (thd->last_insert_id_used)
+ table->field[7]->store((longlong) thd->current_insert_id);
+ else
+ table->field[7]->set_null();
+
+ /* set value if we do an insert on autoincrement column */
+ if (thd->insert_id_used)
+ {
+ /* insert_id */
+ if (!(specialflag & SPECIAL_SHORT_LOG_FORMAT))
+ table->field[8]->store((longlong) thd->last_insert_id);
+ else
+ table->field[8]->set_null();
+ }
+ else
+ table->field[8]->set_null();
+
+ table->field[9]->store((longlong) server_id);
+
+ if (!query)
+ /* sql_text */
+ table->field[10]->store(command_name[thd->command],
+ strlen(command_name[thd->command]),
+ &my_charset_latin1);
+ else
+ table->field[10]->store(query,
+ query_length,
+ &my_charset_latin1);
+
+ /* write the row */
+ table->file->write_row(table->record[0]);
+
+ DBUG_RETURN(0);
+}
+
+int log_error_old(enum loglevel level, const char *format,
+ va_list args)
+{
+ return vprint_msg_to_log(level, format, args);
+}
+
+bool log_slow_old(THD *thd, const char *query, uint query_length,
+ time_t query_start_arg)
+{
+ return mysql_slow_log.write(thd, query, query_length, query_start_arg);
+}
+
+bool log_general_old(THD *thd, enum enum_server_command command,
+ const char *format, va_list args)
+{
+ return mysql_log.write(thd, command, format, args);
+}
+
+
+int Logger::error_log_print(enum loglevel level, const char *format,
+ va_list args)
+{
+ uint error= 0;
+ error_log_handler *current_handler= error_log_print_list;
+
+ while (*current_handler)
+ error+= (*current_handler++)(level, format, args);
+
+ return error;
+}
+
+bool Logger::slow_log_print(THD *thd, const char *query, uint query_length,
+ time_t query_start_arg)
+{
+ uint error= 0;
+ slow_log_handler *current_handler= slow_log_print_list;
+
+ while (*current_handler)
+ error+= (*current_handler++)(thd, query, query_length, query_start_arg);
+
+ return error;
+}
+
+bool Logger::general_log_print(THD *thd,enum enum_server_command command,
+ const char *format, va_list args)
+{
+ uint error= 0;
+ general_log_handler *current_handler= general_log_print_list;
+
+ while (*current_handler)
+ error+= (*current_handler++)(thd, command, format, args);
+
+ return error;
+}
+
+int Logger::init_csv_logs()
+{
+ if (!is_csv_logs_initialized ||
+ !(general_log_thd && slow_log_thd))
+ {
+ if ((!(general_log_thd= new THD)) || general_log_table_open(&general_log))
+ return 1;
+ if ((!(slow_log_thd= new THD)) || slow_log_table_open(&slow_log))
+ return 1;
+ is_csv_logs_initialized= TRUE;
+ }
+
+ return 0;
+}
+
+
+void Logger::init_error_log(enum enum_printer error_log_printer)
+{
+ switch (error_log_printer) {
+ case NONE:
+ error_log_print_list[0]= 0;
+ break;
+ case LEGACY:
+ error_log_print_list[0]= vprint_msg_to_log;
+ error_log_print_list[1]= 0;
+ break;
+ /* these two are disabled for now */
+ case CSV:
+ DBUG_ASSERT(0);
+ break;
+ case LEGACY_AND_CSV:
+ DBUG_ASSERT(0);
+ break;
+ }
+}
+
+void Logger::init_slow_log(enum enum_printer slow_log_printer)
+{
+ switch (slow_log_printer) {
+ case NONE:
+ slow_log_print_list[0]= 0;
+ break;
+ case LEGACY:
+ slow_log_print_list[0]= log_slow_old;
+ slow_log_print_list[1]= 0;
+ break;
+ case CSV:
+ slow_log_print_list[0]= log_slow_to_csv;
+ slow_log_print_list[1]= 0;
+ break;
+ case LEGACY_AND_CSV:
+ slow_log_print_list[0]= log_slow_old;
+ slow_log_print_list[1]= log_slow_to_csv;
+ slow_log_print_list[2]= 0;
+ break;
+ }
+}
+
+void Logger::init_general_log(enum enum_printer general_log_printer)
+{
+ switch (general_log_printer) {
+ case NONE:
+ general_log_print_list[0]= 0;
+ break;
+ case LEGACY:
+ general_log_print_list[0]= log_general_old;
+ general_log_print_list[1]= 0;
+ break;
+ case CSV:
+ general_log_print_list[0]= log_general_to_csv;
+ general_log_print_list[1]= 0;
+ break;
+ case LEGACY_AND_CSV:
+ general_log_print_list[0]= log_general_old;
+ general_log_print_list[1]= log_general_to_csv;
+ general_log_print_list[2]= 0;
+ break;
+ }
+}
+
+
+int Logger::init(enum enum_printer error_log_printer,
+ enum enum_printer slow_log_printer,
+ enum enum_printer general_log_printer)
+{
+ int error;
+
+ /* error log table is not supported yet */
+ DBUG_ASSERT(error_log_printer != CSV);
+
+ /* no error log table yet */
+ if (slow_log_printer == CSV ||
+ general_log_printer == CSV)
+ error= init_csv_logs();
+
+ init_error_log(error_log_printer);
+ init_slow_log(slow_log_printer);
+ init_general_log(general_log_printer);
+
+ return error;
+}
+
+void close_log_tables()
+{
+ if (is_csv_logs_initialized)
+ {
+ /* finalize work with tables */
+ (general_log.table)->file->ha_rnd_end();
+ (slow_log.table)->file->ha_rnd_end();
+ /* now we can close the log tables */
+ close_thread_tables(general_log_thd);
+ close_thread_tables(slow_log_thd);
+ is_csv_logs_initialized= FALSE;
+ }
+}
+
+
/*
this function is mostly a placeholder.
conceptually, binlog initialization (now mostly done in MYSQL_LOG::open)
@@ -1499,7 +2038,7 @@
*/
bool MYSQL_LOG::write(THD *thd,enum enum_server_command command,
- const char *format,...)
+ const char *format, va_list args)
{
if (is_open() && (what_to_log & (1L << (uint) command)))
{
@@ -1512,8 +2051,6 @@
{
time_t skr;
ulong id;
- va_list args;
- va_start(args,format);
char buff[32];
if (thd)
@@ -1575,7 +2112,6 @@
write_error=1;
sql_print_error(ER(ER_ERROR_ON_WRITE),name,error);
}
- va_end(args);
}
VOID(pthread_mutex_unlock(&LOCK_log));
return error != 0;
@@ -1583,6 +2119,7 @@
return 0;
}
+
bool MYSQL_LOG::flush_and_sync()
{
int err=0, fd=log_file.file;
@@ -1793,6 +2330,40 @@
DBUG_RETURN(error);
}
+
+int error_log_print(enum loglevel level, const char *format,
+ va_list args)
+{
+ return logger.error_log_print(level, format, args);
+}
+
+bool slow_log_print(THD *thd, const char *query, uint query_length,
+ time_t query_start_arg)
+{
+ return logger.slow_log_print(thd, query, query_length, query_start_arg);
+}
+
+bool general_log_print(THD *thd,enum enum_server_command command,
+ const char *format,...)
+{
+ va_list args;
+ uint error= 0;
+
+ va_start(args, format);
+ error= logger.general_log_print(thd, command, format, args);
+ va_end(args);
+
+ return error;
+}
+
+int mysql_init_logs(enum enum_printer error_log_printer,
+ enum enum_printer slow_log_printer,
+ enum enum_printer general_log_printer)
+{
+ return logger.init(error_log_printer, slow_log_printer,
+ general_log_printer);
+}
+
void MYSQL_LOG::rotate_and_purge(uint flags)
{
if (!(flags & RP_LOCK_LOG_IS_ALREADY_LOCKED))
@@ -2259,6 +2830,7 @@
skr=time(NULL);
localtime_r(&skr, &tm_tmp);
start=&tm_tmp;
+
fprintf(stderr, "%02d%02d%02d %2d:%02d:%02d [%s] %s\n",
start->tm_year % 100,
start->tm_mon+1,
@@ -2434,23 +3006,26 @@
to other functions to write that message to other logging sources.
RETURN VALUES
- void
+ The function always returns 0. The return value is present in the
+ signature to be compatible with other logging routines, which could
+ return an error (e.g. logging to the log tables)
*/
-void vprint_msg_to_log(enum loglevel level, const char *format, va_list args)
+int vprint_msg_to_log(enum loglevel level, const char *format, va_list args)
{
char buff[1024];
uint length;
DBUG_ENTER("vprint_msg_to_log");
- length= my_vsnprintf(buff, sizeof(buff)-5, format, args);
+ /* "- 5" is because of print_buffer_to_nt_eventlog() */
+ length= my_vsnprintf(buff, sizeof(buff) - 5, format, args);
print_buffer_to_file(level, buff);
#ifdef __NT__
print_buffer_to_nt_eventlog(level, buff, length, sizeof(buff));
#endif
- DBUG_VOID_RETURN;
+ DBUG_RETURN(0);
}
@@ -2460,7 +3035,7 @@
DBUG_ENTER("sql_print_error");
va_start(args, format);
- vprint_msg_to_log(ERROR_LEVEL, format, args);
+ error_log_print(ERROR_LEVEL, format, args);
va_end(args);
DBUG_VOID_RETURN;
@@ -2473,7 +3048,7 @@
DBUG_ENTER("sql_print_warning");
va_start(args, format);
- vprint_msg_to_log(WARNING_LEVEL, format, args);
+ error_log_print(WARNING_LEVEL, format, args);
va_end(args);
DBUG_VOID_RETURN;
@@ -2486,7 +3061,7 @@
DBUG_ENTER("sql_print_information");
va_start(args, format);
- vprint_msg_to_log(INFORMATION_LEVEL, format, args);
+ error_log_print(INFORMATION_LEVEL, format, args);
va_end(args);
DBUG_VOID_RETURN;
--- 1.189/sql/log_event.cc 2005-11-04 23:09:55 +03:00
+++ 1.190/sql/log_event.cc 2005-11-15 13:52:25 +03:00
@@ -1722,7 +1722,7 @@
/* If the query was not ignored, it is printed to the general log */
if (thd->net.last_errno != ER_SLAVE_IGNORED_TABLE)
- mysql_log.write(thd,COM_QUERY,"%s",thd->query);
+ general_log_print(thd,COM_QUERY,"%s",thd->query);
compare_errors:
@@ -3407,7 +3407,8 @@
int Xid_log_event::exec_event(struct st_relay_log_info* rli)
{
/* For a slave Xid_log_event is COMMIT */
- mysql_log.write(thd,COM_QUERY,"COMMIT /* implicit, from Xid_log_event */");
+ general_log_print(thd, COM_QUERY,
+ "COMMIT /* implicit, from Xid_log_event */");
return end_trans(thd, COMMIT) || Log_event::exec_event(rli);
}
#endif /* !MYSQL_CLIENT */
--- 1.341/sql/mysql_priv.h 2005-11-07 18:24:41 +03:00
+++ 1.342/sql/mysql_priv.h 2005-11-15 13:52:25 +03:00
@@ -1085,12 +1085,32 @@
bool init_errmessage(void);
void sql_perror(const char *message);
-void vprint_msg_to_log(enum loglevel level, const char *format, va_list args);
+int vprint_msg_to_log(enum loglevel level, const char *format, va_list args);
void sql_print_error(const char *format, ...);
void sql_print_warning(const char *format, ...);
void sql_print_information(const char *format, ...);
+enum enum_printer
+{
+ NONE,
+ LEGACY,
+ CSV,
+ LEGACY_AND_CSV
+};
+
+int mysql_init_logs(enum enum_printer error_log_printer,
+ enum enum_printer slow_log_printer,
+ enum enum_printer general_log_printer);
+void close_log_tables();
+int error_log_print(enum loglevel level, const char *format,
+ va_list args);
+
+bool slow_log_print(THD *thd, const char *query, uint query_length,
+ time_t query_start_arg);
+
+bool general_log_print(THD *thd, enum enum_server_command command,
+ const char *format,...);
bool fn_format_relative_to_data_home(my_string to, const char *name,
const char *dir, const char *extension);
@@ -1185,6 +1205,7 @@
extern bool opt_using_transactions, mysqld_embedded;
extern bool using_update_log, opt_large_files, server_id_supplied;
extern bool opt_log, opt_update_log, opt_bin_log, opt_slow_log, opt_error_log;
+extern bool opt_old_log_format;
extern bool opt_disable_networking, opt_skip_show_db;
extern my_bool opt_character_set_client_handshake;
extern bool volatile abort_loop, shutdown_in_progress, grant_option;
--- 1.488/sql/mysqld.cc 2005-11-07 18:24:41 +03:00
+++ 1.489/sql/mysqld.cc 2005-11-15 13:52:25 +03:00
@@ -329,7 +329,7 @@
/* Global variables */
bool opt_log, opt_update_log, opt_bin_log, opt_slow_log;
-bool opt_error_log= IF_WIN(1,0);
+bool opt_error_log= IF_WIN(1,0), opt_old_log_format;
bool opt_disable_networking=0, opt_skip_show_db=0;
my_bool opt_character_set_client_handshake= 1;
bool server_id_supplied = 0;
@@ -2310,6 +2310,12 @@
#ifdef EXTRA_DEBUG
sql_print_information("Got signal %d to shutdown mysqld",sig);
#endif
+ /* close log tables, since we cannot log into them during shutdown */
+ close_log_tables();
+ /* switch to the old log message processing */
+ mysql_init_logs(opt_error_log ? LEGACY:NONE,
+ opt_slow_log ? LEGACY:NONE,
+ opt_log ? LEGACY:NONE);
DBUG_PRINT("info",("Got signal: %d abort_loop: %d",sig,abort_loop));
if (!abort_loop)
{
@@ -2337,6 +2343,10 @@
REFRESH_THREADS | REFRESH_HOSTS),
(TABLE_LIST*) 0, ¬_used); // Flush logs
}
+ /* reenable logs after the options were reloaded */
+ mysql_init_logs(opt_error_log ? LEGACY:NONE,
+ opt_slow_log ? CSV:NONE,
+ opt_log ? CSV:NONE);
break;
#ifdef USE_ONE_SIGNAL_HAND
case THR_SERVER_ALARM:
@@ -2943,9 +2953,48 @@
#ifdef HAVE_REPLICATION
init_slave_list();
#endif
- /* Setup log files */
- if (opt_log)
- mysql_log.open_query_log(opt_logname);
+ /* Setup logs */
+
+ /* enable old-fashioned error log */
+ if (opt_error_log)
+ {
+ if (!log_error_file_ptr[0])
+ fn_format(log_error_file, glob_hostname, mysql_data_home, ".err",
+ MY_REPLACE_EXT); /* replace '.<domain>' by '.err', bug#4997 */
+ else
+ fn_format(log_error_file, log_error_file_ptr, mysql_data_home, ".err",
+ MY_UNPACK_FILENAME | MY_SAFE_PATH);
+ if (!log_error_file[0])
+ opt_error_log= 1; // Too long file name
+ else
+ {
+#ifndef EMBEDDED_LIBRARY
+ if (freopen(log_error_file, "a+", stdout))
+#endif
+ freopen(log_error_file, "a+", stderr);
+ }
+ }
+
+ if (opt_old_log_format || (have_csv_db != SHOW_OPTION_YES))
+ {
+ /* enable old-fashioned slow log */
+ if (opt_slow_log)
+ mysql_slow_log.open_slow_log(opt_slow_logname);
+
+
+ /* enable old-fashioned general log */
+ if (opt_log)
+ mysql_log.open_query_log(opt_logname);
+
+ mysql_init_logs(opt_error_log ? LEGACY:NONE,
+ opt_slow_log ? LEGACY:NONE,
+ opt_log ? LEGACY:NONE);
+ }
+ else
+ mysql_init_logs(opt_error_log ? LEGACY:NONE,
+ opt_slow_log ? CSV:NONE,
+ opt_log ? CSV:NONE);
+
if (opt_update_log)
{
/*
@@ -3005,9 +3054,6 @@
unireg_abort(1);
}
- if (opt_slow_log)
- mysql_slow_log.open_slow_log(opt_slow_logname);
-
#ifdef HAVE_REPLICATION
if (opt_log_slave_updates && replicate_same_server_id)
{
@@ -3019,25 +3065,6 @@
}
#endif
- if (opt_error_log)
- {
- if (!log_error_file_ptr[0])
- fn_format(log_error_file, glob_hostname, mysql_data_home, ".err",
- MY_REPLACE_EXT); /* replace '.<domain>' by '.err', bug#4997 */
- else
- fn_format(log_error_file, log_error_file_ptr, mysql_data_home, ".err",
- MY_UNPACK_FILENAME | MY_SAFE_PATH);
- if (!log_error_file[0])
- opt_error_log= 1; // Too long file name
- else
- {
-#ifndef EMBEDDED_LIBRARY
- if (freopen(log_error_file, "a+", stdout))
-#endif
- stderror_file= freopen(log_error_file, "a+", stderr);
- }
- }
-
if (opt_bin_log)
{
char buf[FN_REFLEN];
@@ -3282,6 +3309,8 @@
#endif
{
DEBUGGER_OFF;
+ /* Set logs to legacy during startup. In fact this affects only error log */
+ mysql_init_logs(LEGACY, LEGACY, LEGACY);
rpl_filter= new Rpl_filter;
binlog_filter= new Rpl_filter;
@@ -4486,7 +4515,7 @@
OPT_REPLICATE_IGNORE_TABLE, OPT_REPLICATE_WILD_DO_TABLE,
OPT_REPLICATE_WILD_IGNORE_TABLE, OPT_REPLICATE_SAME_SERVER_ID,
OPT_DISCONNECT_SLAVE_EVENT_COUNT, OPT_TC_HEURISTIC_RECOVER,
- OPT_ABORT_SLAVE_EVENT_COUNT,
+ OPT_ABORT_SLAVE_EVENT_COUNT, OPT_OLD_LOG_FORMAT,
OPT_INNODB_DATA_HOME_DIR,
OPT_INNODB_DATA_FILE_PATH,
OPT_INNODB_LOG_GROUP_HOME_DIR,
@@ -4970,6 +4999,10 @@
"Log slow queries to this log file. Defaults logging to hostname-slow.log file. Must be enabled to activate other slow log options.",
(gptr*) &opt_slow_logname, (gptr*) &opt_slow_logname, 0, GET_STR, OPT_ARG,
0, 0, 0, 0, 0, 0},
+ {"old-log-format", OPT_OLD_LOG_FORMAT,
+ "Enable old log file format. (No SELECT * FROM logs)",
+ (gptr*) &opt_old_log_format, 0, 0, GET_BOOL, OPT_ARG,
+ 0, 0, 0, 0, 0, 0},
{"log-tc", OPT_LOG_TC,
"Path to transaction coordinator log (used for transactions that affect "
"more than one storage engine, when binary log is disabled)",
@@ -6267,6 +6300,7 @@
opt_skip_slave_start= opt_reckless_slave = 0;
mysql_home[0]= pidfile_name[0]= log_error_file[0]= 0;
opt_log= opt_update_log= opt_slow_log= 0;
+ opt_old_log_format= 0;
opt_bin_log= 0;
opt_disable_networking= opt_skip_show_db=0;
opt_logname= opt_update_logname= opt_binlog_index_name= opt_slow_logname= 0;
@@ -6648,7 +6682,10 @@
}
#endif /* HAVE_REPLICATION */
case (int) OPT_SLOW_QUERY_LOG:
- opt_slow_log=1;
+ opt_slow_log= 1;
+ break;
+ case (int) OPT_OLD_LOG_FORMAT:
+ opt_old_log_format= 1;
break;
case (int) OPT_SKIP_NEW:
opt_specialflag|= SPECIAL_NO_NEW_FUNC;
--- 1.256/sql/slave.cc 2005-11-04 23:09:55 +03:00
+++ 1.257/sql/slave.cc 2005-11-15 13:52:26 +03:00
@@ -4248,8 +4248,8 @@
else
{
change_rpl_status(RPL_IDLE_SLAVE,RPL_ACTIVE_SLAVE);
- mysql_log.write(thd, COM_CONNECT_OUT, "%s@%s:%d",
- mi->user, mi->host, mi->port);
+ general_log_print(thd, COM_CONNECT_OUT, "%s@%s:%d",
+ mi->user, mi->host, mi->port);
}
#ifdef SIGNAL_WITH_VIO_CLOSE
thd->set_active_vio(mysql->net.vio);
--- 1.277/sql/sql_base.cc 2005-11-04 23:09:56 +03:00
+++ 1.278/sql/sql_base.cc 2005-11-15 13:52:26 +03:00
@@ -289,7 +289,8 @@
bool found=0;
for (TABLE_LIST *table= tables; table; table= table->next_local)
{
- if (remove_table_from_cache(thd, table->db, table->table_name,
+ if ((!table->table || !table->table->s->log_table) &&
+ remove_table_from_cache(thd, table->db, table->table_name,
RTFC_OWNED_BY_THD_FLAG))
found=1;
}
@@ -322,7 +323,8 @@
for (uint idx=0 ; idx < open_cache.records ; idx++)
{
TABLE *table=(TABLE*) hash_element(&open_cache,idx);
- if ((table->s->version) < refresh_version && table->db_stat)
+ if (!table->s->log_table &&
+ ((table->s->version) < refresh_version && table->db_stat))
{
found=1;
pthread_cond_wait(&COND_refresh,&LOCK_open);
@@ -1227,7 +1229,7 @@
if (!thd->open_tables)
thd->version=refresh_version;
else if ((thd->version != refresh_version) &&
- ! (flags & MYSQL_LOCK_IGNORE_FLUSH))
+ ! (flags & MYSQL_LOCK_IGNORE_FLUSH) && !table->s->log_table)
{
/* Someone did a refresh while thread was opening tables */
if (refresh)
@@ -1246,7 +1248,11 @@
{
if (table->s->version != refresh_version)
{
- if (flags & MYSQL_LOCK_IGNORE_FLUSH)
+ /*
+ Don't close tables if we are working with a log table or were
+ asked not to close the table explicitly
+ */
+ if (flags & MYSQL_LOCK_IGNORE_FLUSH || table->s->log_table)
{
/* Force close at once after usage */
thd->version= table->s->version;
@@ -1852,6 +1858,11 @@
!my_strcasecmp(system_charset_info, name, "proc"))
entry->s->system_table= 1;
+ if (!my_strcasecmp(system_charset_info, db, "mysql") &&
+ (!my_strcasecmp(system_charset_info, name, "slow_log") ||
+ !my_strcasecmp(system_charset_info, name, "general_log")))
+ entry->s->log_table= 1;
+
if (Table_triggers_list::check_n_load(thd, db, name, entry, 0))
goto err;
@@ -5190,6 +5201,7 @@
table = (TABLE*) hash_next(&open_cache,(byte*) key,key_length))
{
THD *in_use;
+
table->s->version=0L; /* Free when thread is ready */
if (!(in_use=table->in_use))
{
--- 1.267/sql/sql_class.h 2005-11-07 18:24:42 +03:00
+++ 1.268/sql/sql_class.h 2005-11-15 13:52:26 +03:00
@@ -305,8 +305,10 @@
bool open_index_file(const char *index_file_name_arg,
const char *log_name);
void new_file(bool need_lock);
+ /* log a command to the old-fashioned general log */
bool write(THD *thd, enum enum_server_command command,
- const char *format,...);
+ const char *format, va_list args);
+ /* log a query to the old-fashioned slow query log */
bool write(THD *thd, const char *query, uint query_length,
time_t query_start=0);
bool write(Log_event* event_info); // binary log write
--- 1.119/sql/sql_db.cc 2005-09-30 18:51:29 +04:00
+++ 1.120/sql/sql_db.cc 2005-11-15 13:52:26 +03:00
@@ -1144,8 +1144,8 @@
sctx->priv_user,
sctx->priv_host,
dbname);
- mysql_log.write(thd, COM_INIT_DB, ER(ER_DBACCESS_DENIED_ERROR),
- sctx->priv_user, sctx->priv_host, dbname);
+ general_log_print(thd, COM_INIT_DB, ER(ER_DBACCESS_DENIED_ERROR),
+ sctx->priv_user, sctx->priv_host, dbname);
my_free(dbname,MYF(0));
DBUG_RETURN(1);
}
--- 1.480/sql/sql_parse.cc 2005-11-07 18:24:43 +03:00
+++ 1.481/sql/sql_parse.cc 2005-11-15 13:52:26 +03:00
@@ -309,7 +309,7 @@
if (opt_secure_auth_local && passwd_len == SCRAMBLE_LENGTH_323)
{
net_printf_error(thd, ER_NOT_SUPPORTED_AUTH_MODE);
- mysql_log.write(thd, COM_CONNECT, ER(ER_NOT_SUPPORTED_AUTH_MODE));
+ general_log_print(thd, COM_CONNECT, ER(ER_NOT_SUPPORTED_AUTH_MODE));
DBUG_RETURN(-1);
}
if (passwd_len != 0 &&
@@ -343,9 +343,9 @@
net_printf_error(thd, ER_SERVER_IS_IN_SECURE_AUTH_MODE,
thd->main_security_ctx.user,
thd->main_security_ctx.host_or_ip);
- mysql_log.write(thd, COM_CONNECT, ER(ER_SERVER_IS_IN_SECURE_AUTH_MODE),
- thd->main_security_ctx.user,
- thd->main_security_ctx.host_or_ip);
+ general_log_print(thd, COM_CONNECT, ER(ER_SERVER_IS_IN_SECURE_AUTH_MODE),
+ thd->main_security_ctx.user,
+ thd->main_security_ctx.host_or_ip);
DBUG_RETURN(-1);
}
/* We have to read very specific packet size */
@@ -393,14 +393,14 @@
}
/* Why logging is performed before all checks've passed? */
- mysql_log.write(thd, command,
- (thd->main_security_ctx.priv_user ==
- thd->main_security_ctx.user ?
- (char*) "%s@%s on %s" :
- (char*) "%s@%s as anonymous on %s"),
- thd->main_security_ctx.user,
- thd->main_security_ctx.host_or_ip,
- db ? db : (char*) "");
+ general_log_print(thd, command,
+ (thd->main_security_ctx.priv_user ==
+ thd->main_security_ctx.user ?
+ (char*) "%s@%s on %s" :
+ (char*) "%s@%s as anonymous on %s"),
+ thd->main_security_ctx.user,
+ thd->main_security_ctx.host_or_ip,
+ db ? db : (char*) "");
/*
This is the default access rights for the current database. It's
@@ -447,17 +447,17 @@
else if (res == 2) // client gave short hash, server has long hash
{
net_printf_error(thd, ER_NOT_SUPPORTED_AUTH_MODE);
- mysql_log.write(thd,COM_CONNECT,ER(ER_NOT_SUPPORTED_AUTH_MODE));
+ general_log_print(thd,COM_CONNECT,ER(ER_NOT_SUPPORTED_AUTH_MODE));
DBUG_RETURN(-1);
}
net_printf_error(thd, ER_ACCESS_DENIED_ERROR,
thd->main_security_ctx.user,
thd->main_security_ctx.host_or_ip,
passwd_len ? ER(ER_YES) : ER(ER_NO));
- mysql_log.write(thd, COM_CONNECT, ER(ER_ACCESS_DENIED_ERROR),
- thd->main_security_ctx.user,
- thd->main_security_ctx.host_or_ip,
- passwd_len ? ER(ER_YES) : ER(ER_NO));
+ general_log_print(thd, COM_CONNECT, ER(ER_ACCESS_DENIED_ERROR),
+ thd->main_security_ctx.user,
+ thd->main_security_ctx.host_or_ip,
+ passwd_len ? ER(ER_YES) : ER(ER_NO));
DBUG_RETURN(-1);
#endif /* NO_EMBEDDED_ACCESS_CHECKS */
}
@@ -1549,7 +1549,7 @@
packet, strlen(packet), thd->charset());
if (!mysql_change_db(thd, tmp.str, FALSE))
{
- mysql_log.write(thd,command,"%s",thd->db);
+ general_log_print(thd,command,"%s",thd->db);
send_ok(thd);
}
break;
@@ -1682,7 +1682,7 @@
if (alloc_query(thd, packet, packet_length))
break; // fatal error is set
char *packet_end= thd->query + thd->query_length;
- mysql_log.write(thd,command,"%s",thd->query);
+ general_log_print(thd,command,"%s",thd->query);
DBUG_PRINT("query",("%-.4096s",thd->query));
if (!(specialflag & SPECIAL_NO_PRIOR))
@@ -1791,7 +1791,7 @@
thd->query_length= strlen(packet); // for simplicity: don't optimize
if (!(thd->query=fields=thd->memdup(packet,thd->query_length+1)))
break;
- mysql_log.write(thd,command,"%s %s",table_list.table_name, fields);
+ general_log_print(thd,command,"%s %s",table_list.table_name, fields);
if (lower_case_table_names)
my_casedn_str(files_charset_info, table_list.table_name);
remove_escape(table_list.table_name); // This can't have wildcards
@@ -1820,7 +1820,7 @@
#endif
case COM_QUIT:
/* We don't calculate statistics for this command */
- mysql_log.write(thd,command,NullS);
+ general_log_print(thd,command,NullS);
net->error=0; // Don't give 'abort' message
error=TRUE; // End server
break;
@@ -1840,7 +1840,7 @@
}
if (check_access(thd,CREATE_ACL,db,0,1,0,is_schema_db(db)))
break;
- mysql_log.write(thd,command,packet);
+ general_log_print(thd,command,packet);
bzero(&create_info, sizeof(create_info));
mysql_create_db(thd, (lower_case_table_names == 2 ? alias : db),
&create_info, 0);
@@ -1865,7 +1865,7 @@
ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));
break;
}
- mysql_log.write(thd,command,db);
+ general_log_print(thd,command,db);
mysql_rm_db(thd, db, 0, 0);
break;
}
@@ -1889,7 +1889,7 @@
kill_zombie_dump_threads(slave_server_id);
thd->server_id = slave_server_id;
- mysql_log.write(thd, command, "Log: '%s' Pos: %ld", packet+10,
+ general_log_print(thd, command, "Log: '%s' Pos: %ld", packet+10,
(long) pos);
mysql_binlog_send(thd, thd->strdup(packet + 10), (my_off_t) pos, flags);
unregister_slave(thd,1,1);
@@ -1907,7 +1907,7 @@
ulong options= (ulong) (uchar) packet[0];
if (check_global_access(thd,RELOAD_ACL))
break;
- mysql_log.write(thd,command,NullS);
+ general_log_print(thd,command,NullS);
if (!reload_acl_and_cache(thd, options, (TABLE_LIST*) 0, ¬_used))
send_ok(thd);
break;
@@ -1935,7 +1935,7 @@
break;
}
DBUG_PRINT("quit",("Got shutdown command for level %u", level));
- mysql_log.write(thd,command,NullS);
+ general_log_print(thd, command, NullS);
send_eof(thd);
#ifdef __WIN__
sleep(1); // must wait after eof()
@@ -1952,7 +1952,7 @@
#endif
case COM_STATISTICS:
{
- mysql_log.write(thd,command,NullS);
+ general_log_print(thd, command, NullS);
statistic_increment(thd->status_var.com_stat[SQLCOM_SHOW_STATUS],
&LOCK_status);
#ifndef EMBEDDED_LIBRARY
@@ -1991,7 +1991,7 @@
if (!thd->security_ctx->priv_user[0] &&
check_global_access(thd, PROCESS_ACL))
break;
- mysql_log.write(thd,command,NullS);
+ general_log_print(thd, command, NullS);
mysqld_list_processes(thd,
thd->security_ctx->master_access & PROCESS_ACL ?
NullS : thd->security_ctx->priv_user, 0);
@@ -2028,7 +2028,7 @@
if (check_global_access(thd, SUPER_ACL))
break; /* purecov: inspected */
mysql_print_status();
- mysql_log.write(thd,command,NullS);
+ general_log_print(thd, command, NullS);
send_eof(thd);
break;
case COM_SLEEP:
@@ -2110,7 +2110,7 @@
(specialflag & SPECIAL_LOG_QUERIES_NOT_USING_INDEXES)))
{
thd->status_var.long_query_count++;
- mysql_slow_log.write(thd, thd->query, thd->query_length, start_of_query);
+ slow_log_print(thd, thd->query, thd->query_length, start_of_query);
}
}
}
--- 1.275/sql/sql_show.cc 2005-11-07 18:24:44 +03:00
+++ 1.276/sql/sql_show.cc 2005-11-15 13:52:26 +03:00
@@ -442,8 +442,8 @@
{
my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
sctx->priv_user, sctx->host_or_ip, dbname);
- mysql_log.write(thd,COM_INIT_DB,ER(ER_DBACCESS_DENIED_ERROR),
- sctx->priv_user, sctx->host_or_ip, dbname);
+ general_log_print(thd,COM_INIT_DB,ER(ER_DBACCESS_DENIED_ERROR),
+ sctx->priv_user, sctx->host_or_ip, dbname);
DBUG_RETURN(TRUE);
}
#endif
--- 1.276/sql/sql_table.cc 2005-11-07 18:24:44 +03:00
+++ 1.277/sql/sql_table.cc 2005-11-15 13:52:26 +03:00
@@ -2420,7 +2420,8 @@
}
/* Close all instances of the table to allow repair to rename files */
- if (lock_type == TL_WRITE && table->table->s->version)
+ if (lock_type == TL_WRITE && table->table->s->version &&
+ !table->table->s->log_table)
{
pthread_mutex_lock(&LOCK_open);
const char *old_message=thd->enter_cond(&COND_refresh, &LOCK_open,
@@ -2575,7 +2576,7 @@
}
if (fatal_error)
table->table->s->version=0; // Force close of table
- else if (open_for_modify)
+ else if (open_for_modify && !table->table->s->log_table)
{
pthread_mutex_lock(&LOCK_open);
remove_table_from_cache(thd, table->table->s->db,
--- 1.115/sql/table.h 2005-11-07 18:24:45 +03:00
+++ 1.116/sql/table.h 2005-11-15 13:52:26 +03:00
@@ -185,6 +185,11 @@
locking of this table for writing. FALSE - otherwise.
*/
my_bool system_table;
+ /*
+ This flag is set for the log tables. Used during FLUSH instances to skip
+ log tables, while closing tables (since logs must be always available)
+ */
+ my_bool log_table;
} TABLE_SHARE;
--- 1.1/mysql-test/r/im_utils.result 2005-10-01 01:14:38 +04:00
+++ 1.2/mysql-test/r/im_utils.result 2005-11-15 13:52:24 +03:00
@@ -21,6 +21,7 @@
skip-innodb VALUE
skip-bdb VALUE
skip-ndbcluster VALUE
+old-log-format VALUE
SHOW INSTANCE OPTIONS mysqld2;
option_name value
instance_name VALUE
@@ -41,6 +42,7 @@
skip-innodb VALUE
skip-bdb VALUE
skip-ndbcluster VALUE
+old-log-format VALUE
START INSTANCE mysqld2;
STOP INSTANCE mysqld2;
SHOW mysqld1 LOG FILES;
--- 1.21/sql/examples/ha_tina.cc 2005-11-07 18:24:36 +03:00
+++ 1.22/sql/examples/ha_tina.cc 2005-11-15 13:52:25 +03:00
@@ -87,7 +87,7 @@
NULL, /* Flush logs */
NULL, /* Show status */
NULL, /* Replication Report Sent Binlog */
- HTON_CAN_RECREATE
+ HTON_NO_FLAGS /* Disable recreate during TRUCATE */
};
/*****************************************************************************
@@ -99,7 +99,11 @@
*/
int sort_set (tina_set *a, tina_set *b)
{
- return ( a->begin > b->begin ? 1 : ( a->begin < b->begin ? -1 : 0 ) );
+ /*
+ Note for the merge: this is a bugfix, which should come along with
+ the merge from 4.1 (bug 13894).
+ */
+ return ( a->begin > b->begin ? -1 : ( a->begin < b->begin ? 1 : 0 ) );
}
static byte* tina_get_key(TINA_SHARE *share,uint *length,
@@ -175,6 +179,11 @@
}
pthread_mutex_lock(&tina_mutex);
length=(uint) strlen(table_name);
+
+ /*
+ If share is not present in the hash, create a new share and
+ initialize its members.
+ */
if (!(share=(TINA_SHARE*) hash_search(&tina_open_tables,
(byte*) table_name,
length)))
@@ -190,6 +199,7 @@
}
share->use_count= 0;
+ share->is_log_table= FALSE;
share->table_name_length= length;
share->table_name= tmp_name;
strmov(share->table_name, table_name);
@@ -200,7 +210,9 @@
thr_lock_init(&share->lock);
pthread_mutex_init(&share->mutex,MY_MUTEX_INIT_FAST);
- if ((share->data_file= my_open(data_file_name, O_RDWR, MYF(0))) == -1)
+ /* Note for the merge: O_APPEND should come with a bugfix from 4.1 (bug14672) */
+ if ((share->data_file= my_open(data_file_name, O_RDWR|O_APPEND,
+ MYF(0))) == -1)
goto error2;
/*
@@ -300,6 +312,21 @@
chain= chain_buffer;
}
+
+void ha_tina::tina_lock()
+{
+ if (share->is_log_table)
+ pthread_mutex_lock(&share->mutex);
+}
+
+
+int ha_tina::tina_unlock()
+{
+ if (share->is_log_table)
+ pthread_mutex_unlock(&share->mutex);
+}
+
+
/*
Encode a buffer into the quoted format.
*/
@@ -367,8 +394,8 @@
*/
int ha_tina::chain_append()
{
- if ( chain_ptr != chain && (chain_ptr -1)->end == current_position)
- (chain_ptr -1)->end= next_position;
+ if (chain_ptr != chain && (chain_ptr - 1)->end == current_position)
+ (chain_ptr - 1)->end= next_position;
else
{
/* We set up for the next position */
@@ -407,14 +434,21 @@
*/
int ha_tina::find_current_row(byte *buf)
{
- byte *mapped_ptr= (byte *)share->mapped_file + current_position;
+ byte *mapped_ptr;
byte *end_ptr;
DBUG_ENTER("ha_tina::find_current_row");
+ tina_lock();
+
+ mapped_ptr= (byte *)share->mapped_file + current_position;
+
/* EOF should be counted as new line */
if ((end_ptr= find_eoln(share->mapped_file, current_position,
share->file_stat.st_size)) == 0)
+ {
+ tina_unlock();
DBUG_RETURN(HA_ERR_END_OF_FILE);
+ }
for (Field **field=table->field ; *field ; field++)
{
@@ -454,6 +488,7 @@
/* Maybe use \N for null? */
memset(buf, 0, table->s->null_bytes); /* We do not implement nulls! */
+ tina_unlock();
DBUG_RETURN(0);
}
@@ -510,6 +545,7 @@
int size;
DBUG_ENTER("ha_tina::write_row");
+ tina_lock();
statistic_increment(table->in_use->status_var.ha_write_count, &LOCK_status);
if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT)
@@ -518,7 +554,10 @@
size= encode_quote(buf);
if (my_write(share->data_file, buffer.ptr(), size, MYF(MY_WME | MY_NABP)))
+ {
+ tina_unlock();
DBUG_RETURN(-1);
+ }
/*
Ok, this is means that we will be doing potentially bad things
@@ -528,7 +567,12 @@
might be a solution for this.
*/
if (get_mmap(share, 0) > 0)
+ {
+ tina_unlock();
DBUG_RETURN(-1);
+ }
+
+ tina_unlock();
DBUG_RETURN(0);
}
@@ -546,6 +590,8 @@
int size;
DBUG_ENTER("ha_tina::update_row");
+ tina_lock();
+
statistic_increment(table->in_use->status_var.ha_read_rnd_next_count,
&LOCK_status);
@@ -555,10 +601,29 @@
size= encode_quote(new_data);
if (chain_append())
+ {
+ tina_unlock();
DBUG_RETURN(-1);
+ }
if (my_write(share->data_file, buffer.ptr(), size, MYF(MY_WME | MY_NABP)))
+ {
+ tina_unlock();
DBUG_RETURN(-1);
+ }
+
+ /*
+ rewrite the file to remove "holes". We have to do it since now
+ we use tl_write_allow_write, and don't want to allow others to
+ read inconsistent mmap'ed memory area.
+ */
+ if (share->is_log_table)
+ {
+ rnd_end();
+ chain_ptr= chain;
+ }
+
+ tina_unlock();
DBUG_RETURN(0);
}
@@ -577,11 +642,27 @@
DBUG_ENTER("ha_tina::delete_row");
statistic_increment(table->in_use->status_var.ha_delete_count,
&LOCK_status);
+ tina_lock();
if (chain_append())
+ {
+ tina_unlock();
DBUG_RETURN(-1);
+ }
--records;
+ /*
+ rewrite the file to remove "holes". We have to do it since now
+ we use tl_write_allow_write, and don't want to allow others to
+ read inconsistent mmap'ed memory area.
+ */
+ if (share->is_log_table)
+ {
+ rnd_end();
+ chain_ptr= chain;
+ }
+
+ tina_unlock();
DBUG_RETURN(0);
}
@@ -789,6 +870,12 @@
int ha_tina::extra(enum ha_extra_function operation)
{
DBUG_ENTER("ha_tina::extra");
+ if (operation == HA_EXTRA_MARK_AS_LOG_TABLE)
+ {
+ pthread_mutex_lock(&tina_mutex);
+ share->is_log_table= TRUE;
+ pthread_mutex_unlock(&tina_mutex);
+ }
DBUG_RETURN(0);
}
@@ -836,14 +923,12 @@
(qsort_cmp)sort_set);
for (ptr= chain; ptr < chain_ptr; ptr++)
{
- /* We peek a head to see if this is the last chain */
- if (ptr+1 == chain_ptr)
- memmove(share->mapped_file + ptr->begin, share->mapped_file + ptr->end,
- length - (size_t)ptr->end);
- else
- memmove((caddr_t)share->mapped_file + ptr->begin,
- (caddr_t)share->mapped_file + ptr->end,
- (size_t)((ptr++)->begin - ptr->end));
+ /*
+ Note for the merge: this change should come along with the merge
+ from 4.1 (bug 13894)
+ */
+ memmove(share->mapped_file + ptr->begin, share->mapped_file + ptr->end,
+ length - (size_t)ptr->end);
length= length - (size_t)(ptr->end - ptr->begin);
}
@@ -895,9 +980,44 @@
THR_LOCK_DATA **to,
enum thr_lock_type lock_type)
{
+ if (!(share->is_log_table))
+ {
+ if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK)
+ lock.type=lock_type;
+ *to++= &lock;
+ return to;
+ }
+
+ /* special logging for the log tables: only physical consistency is obeyed */
+
if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK)
+ {
+ /*
+ Set write_allow_write lock. Here we don't check for
+ thd->in_lock_tables since we don't want to lock log tables
+ in any case.
+ */
+
+ if ((lock_type >= TL_WRITE_CONCURRENT_INSERT &&
+ lock_type <= TL_WRITE))
+ lock_type = TL_WRITE_ALLOW_WRITE;
+
+ /*
+ In queries of type INSERT INTO t1 SELECT ... FROM t2 ...
+ MySQL would use the lock TL_READ_NO_INSERT on t2, and that
+ would conflict with TL_WRITE_ALLOW_WRITE, blocking all inserts
+ to t2. Convert the lock to a normal read lock to allow
+ concurrent inserts to t2.
+ */
+
+ if (lock_type == TL_READ_NO_INSERT)
+ lock_type = TL_READ;
+
lock.type=lock_type;
+ }
+
*to++= &lock;
+
return to;
}
--- 1.7/sql/examples/ha_tina.h 2005-11-07 18:24:36 +03:00
+++ 1.8/sql/examples/ha_tina.h 2005-11-15 13:52:25 +03:00
@@ -23,7 +23,7 @@
typedef struct st_tina_share {
char *table_name;
byte *mapped_file; /* mapped region of file */
- uint table_name_length,use_count;
+ uint table_name_length, use_count, is_log_table;
MY_STAT file_stat; /* Stat information for the data file */
File data_file; /* Current open data file */
pthread_mutex_t mutex;
@@ -53,6 +53,10 @@
tina_set *chain_ptr;
byte chain_alloced;
uint32 chain_size;
+
+private:
+ void tina_lock();
+ int tina_unlock();
public:
ha_tina(TABLE *table_arg);
--- 1.88/mysql-test/r/information_schema.result 2005-11-06 15:12:47 +03:00
+++ 1.89/mysql-test/r/information_schema.result 2005-11-15 13:52:25 +03:00
@@ -55,6 +55,7 @@
columns_priv
db
func
+general_log
help_category
help_keyword
help_relation
@@ -63,6 +64,7 @@
plugin
proc
procs_priv
+slow_log
tables_priv
time_zone
time_zone_leap_second
@@ -710,7 +712,7 @@
CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
count(*)
-102
+104
drop view a2, a1;
drop table t_crashme;
select table_schema,table_name, column_name from
@@ -780,7 +782,7 @@
SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
table_schema count(*)
information_schema 16
-mysql 18
+mysql 20
create table t1 (i int, j int);
create trigger trg1 before insert on t1 for each row
begin
--- 1.2/mysql-test/r/mysqlcheck.result 2005-11-06 15:12:47 +03:00
+++ 1.3/mysql-test/r/mysqlcheck.result 2005-11-15 13:52:25 +03:00
@@ -1,6 +1,8 @@
mysql.columns_priv OK
mysql.db OK
mysql.func OK
+mysql.general_log
+note : The storage engine for the table doesn't support optimize
mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
@@ -9,6 +11,8 @@
mysql.plugin OK
mysql.proc OK
mysql.procs_priv OK
+mysql.slow_log
+note : The storage engine for the table doesn't support optimize
mysql.tables_priv OK
mysql.time_zone OK
mysql.time_zone_leap_second OK
@@ -19,6 +23,8 @@
mysql.columns_priv OK
mysql.db OK
mysql.func OK
+mysql.general_log
+note : The storage engine for the table doesn't support optimize
mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
@@ -27,6 +33,8 @@
mysql.plugin OK
mysql.proc OK
mysql.procs_priv OK
+mysql.slow_log
+note : The storage engine for the table doesn't support optimize
mysql.tables_priv OK
mysql.time_zone OK
mysql.time_zone_leap_second OK
--- 1.15/mysql-test/lib/init_db.sql 2005-11-06 22:50:47 +03:00
+++ 1.16/mysql-test/lib/init_db.sql 2005-11-15 13:52:24 +03:00
@@ -566,3 +566,26 @@
comment char(64) collate utf8_bin DEFAULT '' NOT NULL,
PRIMARY KEY (db,name,type)
) character set utf8 comment='Stored Procedures';
+
+CREATE TABLE general_log (
+ event_time TIMESTAMP NOT NULL,
+ user_host MEDIUMTEXT,
+ thread_id INTEGER,
+ server_id INTEGER,
+ command_type VARCHAR(64),
+ argument MEDIUMTEXT
+) engine=CSV CHARACTER SET utf8 comment='General log';
+
+CREATE TABLE slow_log (
+ start_time TIMESTAMP NOT NULL,
+ user_host MEDIUMTEXT NOT NULL,
+ query_time TIME NOT NULL,
+ lock_time TIME NOT NULL,
+ rows_sent INTEGER NOT NULL,
+ rows_examined INTEGER NOT NULL,
+ db VARCHAR(512),
+ last_insert_id INTEGER,
+ insert_id INTEGER,
+ server_id INTEGER,
+ sql_text MEDIUMTEXT NOT NULL
+) engine=CSV CHARACTER SET utf8 comment='Slow log';
--- 1.40/mysql-test/mysql-test-run.pl 2005-11-04 23:09:53 +03:00
+++ 1.41/mysql-test/mysql-test-run.pl 2005-11-15 13:52:24 +03:00
@@ -859,6 +859,7 @@
path_datadir => "$opt_vardir/im_mysqld_1.data",
path_sock => "$opt_tmpdir/mysqld_1.sock",
path_pid => "$opt_vardir/run/mysqld_1.pid",
+ old_log_format => 1
};
$instance_manager->{'instances'}->[1]=
@@ -869,6 +870,7 @@
path_sock => "$opt_tmpdir/mysqld_2.sock",
path_pid => "$opt_vardir/run/mysqld_2.pid",
nonguarded => 1,
+ old_log_format => 1
};
if ( $opt_extern )
@@ -1602,6 +1604,7 @@
;
print OUT "nonguarded\n" if $instance->{'nonguarded'};
+ print OUT "old-log-format\n" if $instance->{'old_log_format'};
print OUT "\n";
}
--- 1.76/mysql-test/r/show_check.result 2005-11-07 18:24:34 +03:00
+++ 1.77/mysql-test/r/show_check.result 2005-11-15 13:52:25 +03:00
@@ -145,10 +145,14 @@
flush tables;
show open tables;
Database Table In_use Name_locked
+mysql general_log 1 0
+mysql slow_log 1 0
create table t1(n int);
insert into t1 values (1);
show open tables;
Database Table In_use Name_locked
+mysql general_log 1 0
+mysql slow_log 1 0
test t1 0 0
drop table t1;
create table t1 (a int not null, b VARCHAR(10), INDEX (b) ) AVG_ROW_LENGTH=10 CHECKSUM=1 COMMENT="test" ENGINE=MYISAM MIN_ROWS=10 MAX_ROWS=100 PACK_KEYS=1 DELAY_KEY_WRITE=1 ROW_FORMAT=fixed;
@@ -527,20 +531,24 @@
1
SHOW OPEN TABLES;
Database Table In_use Name_locked
-mysql db 0 0
+mysql proc 0 0
test urkunde 0 0
mysql time_zone 0 0
-mysql user 0 0
+mysql db 0 0
test txt1 0 0
-mysql proc 0 0
+mysql slow_log 1 0
test tyt2 0 0
+mysql general_log 1 0
+mysql user 0 0
mysql time_zone_name 0 0
SHOW OPEN TABLES FROM mysql;
Database Table In_use Name_locked
-mysql db 0 0
+mysql proc 0 0
mysql time_zone 0 0
+mysql db 0 0
+mysql slow_log 1 0
+mysql general_log 1 0
mysql user 0 0
-mysql proc 0 0
mysql time_zone_name 0 0
SHOW OPEN TABLES FROM mysql LIKE 'u%';
Database Table In_use Name_locked
@@ -553,12 +561,16 @@
mysql time_zone_name 0 0
SHOW OPEN TABLES LIKE '%o%';
Database Table In_use Name_locked
-mysql time_zone 0 0
mysql proc 0 0
+mysql time_zone 0 0
+mysql slow_log 1 0
+mysql general_log 1 0
mysql time_zone_name 0 0
FLUSH TABLES;
SHOW OPEN TABLES;
Database Table In_use Name_locked
+mysql general_log 1 0
+mysql slow_log 1 0
DROP TABLE txt1;
DROP TABLE tyt2;
DROP TABLE urkunde;
--- 1.27/scripts/mysql_fix_privilege_tables.sql 2005-11-06 15:12:48 +03:00
+++ 1.28/scripts/mysql_fix_privilege_tables.sql 2005-11-15 13:52:25 +03:00
@@ -526,3 +526,31 @@
char(77) collate utf8_bin DEFAULT '' NOT NULL,
MODIFY comment
char(64) collate utf8_bin DEFAULT '' NOT NULL;
+
+
+--
+-- Create missing log tables (5.1)
+--
+
+CREATE TABLE IF NOT EXISTS general_log (
+event_time TIMESTAMP NOT NULL,
+user_host MEDIUMTEXT,
+thread_id INTEGER,
+server_id INTEGER,
+command_type VARCHAR(64),
+argument MEDIUMTEXT
+) engine=CSV CHARACTER SET utf8 comment='General log';
+
+CREATE TABLE IF NOT EXISTS slow_log (
+start_time TIMESTAMP NOT NULL,
+user_host MEDIUMTEXT NOT NULL,
+query_time TIME NOT NULL,
+lock_time TIME NOT NULL,
+rows_sent INTEGER NOT NULL,
+rows_examined INTEGER NOT NULL,
+db VARCHAR(512),
+last_insert_id INTEGER,
+insert_id INTEGER,
+server_id INTEGER,
+sql_text MEDIUMTEXT NOT NULL
+) engine=CSV CHARACTER SET utf8 comment='Slow log';
--- 1.21/mysql-test/r/connect.result 2005-11-08 00:42:56 +03:00
+++ 1.22/mysql-test/r/connect.result 2005-11-15 13:52:24 +03:00
@@ -4,6 +4,7 @@
columns_priv
db
func
+general_log
help_category
help_keyword
help_relation
@@ -12,6 +13,7 @@
plugin
proc
procs_priv
+slow_log
tables_priv
time_zone
time_zone_leap_second
@@ -32,6 +34,7 @@
columns_priv
db
func
+general_log
help_category
help_keyword
help_relation
@@ -40,6 +43,7 @@
plugin
proc
procs_priv
+slow_log
tables_priv
time_zone
time_zone_leap_second
@@ -68,6 +72,7 @@
columns_priv
db
func
+general_log
help_category
help_keyword
help_relation
@@ -76,6 +81,7 @@
plugin
proc
procs_priv
+slow_log
tables_priv
time_zone
time_zone_leap_second
--- New file ---
+++ mysql-test/r/log_tables.result 05/11/15 13:52:26
use mysql;
truncate table general_log;
select * from general_log;
event_time user_host thread_id server_id command_type argument
TIMESTAMP root[root] @ localhost [] 1 1 Query select * from general_log
truncate table slow_log;
select * from slow_log;
start_time user_host query_time lock_time rows_sent rows_examined db last_insert_id insert_id server_id sql_text
lock tables mysql.general_log WRITE;
select "This query should be logged in general log ok"
as "basic log table test";
basic log table test
This query should be logged in general log ok
select * from mysql.general_log where argument like '%query should be%';
event_time user_host thread_id server_id command_type argument
TIMESTAMP root[root] @ localhost [] 3 1 Query select "This query should be logged in general log ok"
as "basic log table test"
TIMESTAMP root[root] @ localhost [] 3 1 Query select * from mysql.general_log where argument like '%query should be%'
unlock tables;
use test;
create table test_csv_locking (val integer) engine = csv;
insert into test_csv_locking values (1);
lock tables test_csv_locking read;
insert into test_csv_locking values (2);
ERROR HY000: Table 'test_csv_locking' was locked with a READ lock and can't be updated
select * from test_csv_locking;
val
1
unlock tables;
drop table test_csv_locking;
use mysql;
truncate table general_log;
select * from general_log where argument like '%general_log%';
event_time user_host thread_id server_id command_type argument
TIMESTAMP root[root] @ localhost [] 2 1 Query select * from general_log where argument like '%general_log%'
--- New file ---
+++ mysql-test/t/log_tables.test 05/11/15 13:52:27
#
# Basic log tables test
#
# check that CSV engine was compiled in
-- source include/have_csv.inc
use mysql;
#
# Check that log tables work and we can do basic selects
#
truncate table general_log;
--replace_column 1 TIMESTAMP
select * from general_log;
truncate table slow_log;
--replace_column 1 TIMESTAMP
select * from slow_log;
#
# Check locking of the log tables
#
connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
connection con1;
# this call should result in TL_WRITE_ALLOW_WRITE lock on the log table
lock tables mysql.general_log WRITE;
connection con2;
#
# Should pass ok despite of the write lock on general_log as log tables
# ignore locks (otherwise we could lock down the whole server).
#
select "This query should be logged in general log ok"
as "basic log table test";
--replace_column 1 TIMESTAMP
select * from mysql.general_log where argument like '%query should be%';
connection con1;
unlock tables;
# switch to the test database to create test CSV table
use test;
# Check that usual CSV locking is in place
create table test_csv_locking (val integer) engine = csv;
# insert something to the table
insert into test_csv_locking values (1);
# Obtain read lock on the table. locking rules for the lock tables would
# have downgraded this to TL_WRITE_ALLOW_WRITE, but for ordinary CSV tables
# this should not happen
lock tables test_csv_locking read;
# should give an error with usual locking rules
--error 1099
insert into test_csv_locking values (2);
select * from test_csv_locking;
unlock tables;
# cleanup
drop table test_csv_locking;
# test that queries are actually logged into general_log
use mysql;
truncate table general_log;
--replace_column 1 TIMESTAMP
select * from general_log where argument like '%general_log%';
disconnect con2;
disconnect con1;
--- 1.153/sql/sql_prepare.cc 2005-11-07 18:24:44 +03:00
+++ 1.154/sql/sql_prepare.cc 2005-11-15 13:52:26 +03:00
@@ -1864,7 +1864,7 @@
thd->stmt_map.erase(stmt);
}
else
- mysql_log.write(thd, COM_STMT_PREPARE, "[%lu] %s", stmt->id, packet);
+ general_log_print(thd, COM_STMT_PREPARE, "[%lu] %s", stmt->id, packet);
/* check_prepared_statemnt sends the metadata packet in case of success */
DBUG_VOID_RETURN;
@@ -2225,7 +2225,7 @@
if (!(specialflag & SPECIAL_NO_PRIOR))
my_pthread_setprio(pthread_self(), WAIT_PRIOR);
if (error == 0)
- mysql_log.write(thd, COM_STMT_EXECUTE, "[%lu] %s", stmt->id, thd->query);
+ general_log_print(thd, COM_STMT_EXECUTE, "[%lu] %s", stmt->id, thd->query);
DBUG_VOID_RETURN;
--- 1.5/mysql-test/include/system_db_struct.inc 2005-10-17 19:08:49 +04:00
+++ 1.6/mysql-test/include/system_db_struct.inc 2005-11-15 13:52:24 +03:00
@@ -12,3 +12,5 @@
show create table columns_priv;
show create table procs_priv;
show create table proc;
+show create table general_log;
+show create table slow_log;
--- 1.30/mysql-test/r/system_mysql_db.result 2005-11-06 15:12:47 +03:00
+++ 1.31/mysql-test/r/system_mysql_db.result 2005-11-15 13:52:25 +03:00
@@ -4,6 +4,7 @@
columns_priv
db
func
+general_log
help_category
help_keyword
help_relation
@@ -12,6 +13,7 @@
plugin
proc
procs_priv
+slow_log
tables_priv
time_zone
time_zone_leap_second
@@ -181,5 +183,30 @@
`comment` char(64) character set utf8 collate utf8_bin NOT NULL default '',
PRIMARY KEY (`db`,`name`,`type`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Stored Procedures'
+show create table general_log;
+Table Create Table
+general_log CREATE TABLE `general_log` (
+ `event_time` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
+ `user_host` mediumtext,
+ `thread_id` int(11) default NULL,
+ `server_id` int(11) default NULL,
+ `command_type` varchar(64) default NULL,
+ `argument` mediumtext
+) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='General log'
+show create table slow_log;
+Table Create Table
+slow_log CREATE TABLE `slow_log` (
+ `start_time` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
+ `user_host` mediumtext NOT NULL,
+ `query_time` time NOT NULL,
+ `lock_time` time NOT NULL,
+ `rows_sent` int(11) NOT NULL,
+ `rows_examined` int(11) NOT NULL,
+ `db` varchar(512) default NULL,
+ `last_insert_id` int(11) default NULL,
+ `insert_id` int(11) default NULL,
+ `server_id` int(11) default NULL,
+ `sql_text` mediumtext NOT NULL
+) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log'
show tables;
Tables_in_test
--- 1.19/mysql-test/t/system_mysql_db_fix.test 2005-11-07 18:24:35 +03:00
+++ 1.20/mysql-test/t/system_mysql_db_fix.test 2005-11-15 13:52:25 +03:00
@@ -85,7 +85,10 @@
-- disable_query_log
-DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type;
+DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv,
+procs_priv, help_category, help_keyword, help_relation, help_topic, proc,
+time_zone, time_zone_leap_second, time_zone_name, time_zone_transition,
+time_zone_transition_type, general_log, slow_log;
-- enable_query_log
--- 1.25/scripts/mysql_create_system_tables.sh 2005-11-06 15:12:48 +03:00
+++ 1.26/scripts/mysql_create_system_tables.sh 2005-11-15 13:52:25 +03:00
@@ -42,6 +42,7 @@
c_tzn="" c_tz="" c_tzt="" c_tztt="" c_tzls="" c_pl=""
i_tzn="" i_tz="" i_tzt="" i_tztt="" i_tzls="" i_pl=""
c_p="" c_pp=""
+c_gl="" c_sl=""
# Check for old tables
if test ! -f $mdata/db.frm
@@ -352,6 +353,46 @@
c_hr="$c_hr comment='keyword-topic relation';"
fi
+
+if test ! -f $mdata/general_log.frm
+then
+ if test "$1" = "verbose" ; then
+ echo "Preparing general_log table" 1>&2;
+ fi
+
+ c_gl="$c_gl CREATE TABLE general_log ("
+ c_gl="$c_gl event_time TIMESTAMP NOT NULL,"
+ c_gl="$c_gl user_host MEDIUMTEXT,"
+ c_gl="$c_gl thread_id INTEGER,"
+ c_gl="$c_gl server_id INTEGER,"
+ c_gl="$c_gl command_type VARCHAR(64),"
+ c_gl="$c_gl argument MEDIUMTEXT"
+ c_gl="$c_gl ) engine=CSV CHARACTER SET utf8 comment='General log';"
+fi
+
+
+if test ! -f $mdata/slow_log.frm
+then
+ if test "$1" = "verbose" ; then
+ echo "Preparing slow_log table" 1>&2;
+ fi
+
+ c_sl="$c_sl CREATE TABLE slow_log ("
+ c_sl="$c_sl start_time TIMESTAMP NOT NULL,"
+ c_sl="$c_sl user_host MEDIUMTEXT NOT NULL,"
+ c_sl="$c_sl query_time TIME NOT NULL,"
+ c_sl="$c_sl lock_time TIME NOT NULL,"
+ c_sl="$c_sl rows_sent INTEGER NOT NULL,"
+ c_sl="$c_sl rows_examined INTEGER NOT NULL,"
+ c_sl="$c_sl db VARCHAR(512),"
+ c_sl="$c_sl last_insert_id INTEGER,"
+ c_sl="$c_sl insert_id INTEGER,"
+ c_sl="$c_sl server_id INTEGER,"
+ c_sl="$c_sl sql_text MEDIUMTEXT NOT NULL"
+ c_sl="$c_sl ) engine=CSV CHARACTER SET utf8 comment='Slow log';"
+fi
+
+
if test ! -f $mdata/time_zone_name.frm
then
if test "$1" = "verbose" ; then
@@ -777,6 +818,9 @@
$i_tztt
$c_tzls
$i_tzls
+
+$c_gl
+$c_sl
$c_p
$c_pp
| Thread |
|---|
| • bk commit into 5.1 tree (petr:1.1950) | Petr Chardin | 15 Nov |