mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
WL1019: complete patch. Reapplied patch to the clean
tree to get rid of multiple typos in CS comments and unify the patch. configure.in: CSV is compiled in by default now include/my_base.h: add new ha_extra flag for the log tables mysql-test/include/im_check_os.inc: we should only run im tests if csv is on for now: im relies on mysqld options available only in csv build. mysql-test/include/system_db_struct.inc: check log tables structure mysql-test/lib/init_db.sql: create log tables when running tests. mysql-test/mysql-test-run.pl: 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/r/connect.result: update result mysql-test/r/csv.result: update result mysql-test/r/im_utils.result: update result mysql-test/r/information_schema.result: update result mysql-test/r/mysqlcheck.result: update result mysql-test/r/show_check.result: update result mysql-test/r/system_mysql_db.result: update result mysql-test/t/connect.test: disable test if CSV engine is not in: result depends on the presence of CSV-based log tables mysql-test/t/csv.test: add tests for concurrent insert (the functionality is added to CSV in this patch) mysql-test/t/information_schema.test: disable test if CSV engine is not in: result depends on the presence of CSV-based log tables mysql-test/t/mysqlcheck.test: disable test if CSV engine is not in: result depends on the presence of CSV-based log tables mysql-test/t/show_check.test: disable test if CSV engine is not in: result depends on the presence of CSV-based log tables mysql-test/t/system_mysql_db.test: disable test if CSV engine is not in: result depends on the presence of CSV-based log tables mysql-test/t/system_mysql_db_fix.test: disable test if CSV engine is not in: result depends on the presence of CSV-based log tables scripts/mysql_create_system_tables.sh: new system tables: slow_log and general_log scripts/mysql_fix_privilege_tables.sql: add new log tables: use an SP to create them for non-csv build to work fine. sql/ha_myisam.cc: move locking-related checks to the hanlder sql/ha_myisam.h: new function declared sql/handler.h: new virtual function is added: we should check for handler-related locking issues in the handler sql/lock.cc: from now on we check for handler-related locking issues in the handler itself rather then in lock.cc sql/log.cc: Add log tables support, refactoring: there are log event handlers with common interface. They are used by the LOGGER class, which is responsible for their initialization, cleanup and managment. Logging to the tables provided by one of the log event handler types. sql/log.h: declare new log classes sql/log_event.cc: convert old logging routines calls to use new API sql/mysql_priv.h: define common log routines and objects sql/mysqld.cc: Add support for the log tables. Their initalization, cleanup and specific options. sql/share/errmsg.txt: add new error messages for the log tables sql/slave.cc: convert old logging routines calls to use new API sql/sql_base.cc: TABLE objects used by the logger should be skipped during refreshes (as log tables are always opened and locked). fix table_is_used to skip them. This is needed for FLUSH LOGS to work sql/sql_db.cc: convert old logging routines calls to use new API sql/sql_delete.cc: fix TRUNCATE to work with log tables sql/sql_parse.cc: command_name is now an array of LEX_STRINGs sql/sql_prepare.cc: convert old logging routines calls to use new API sql/sql_show.cc: convert old logging routines calls to use new API sql/sql_table.cc: don't reoped the log tables for admin purposes sql/table.cc: mark log tables as such during the open sql/table.h: add log-related info storage/csv/ha_tina.cc: add support for concurrent insert (see bk commit - 5.1 tree (petr:1.1910) for standalone patch), add log tables-specific csv table handling. storage/csv/ha_tina.h: enable concurrent insert for CSV, add log table flag mysql-test/r/log_tables.result: New BitKeeper file ``mysql-test/r/log_tables.result'' mysql-test/t/log_tables.test: New BitKeeper file ``mysql-test/t/log_tables.test''
This commit is contained in:
@@ -73,14 +73,23 @@ static bool append_file_to_dir(THD *thd, const char **filename_ptr,
|
||||
|
||||
const char *any_db="*any*"; // Special symbol for check_access
|
||||
|
||||
const char *command_name[]={
|
||||
"Sleep", "Quit", "Init DB", "Query", "Field List", "Create DB",
|
||||
"Drop DB", "Refresh", "Shutdown", "Statistics", "Processlist",
|
||||
"Connect","Kill","Debug","Ping","Time","Delayed insert","Change user",
|
||||
"Binlog Dump","Table Dump", "Connect Out", "Register Slave",
|
||||
"Prepare", "Execute", "Long Data", "Close stmt",
|
||||
"Reset stmt", "Set option", "Fetch", "Daemon",
|
||||
"Error" // Last command number
|
||||
LEX_STRING command_name[]={
|
||||
STRING_WITH_LEN("Sleep"), STRING_WITH_LEN("Quit"),
|
||||
STRING_WITH_LEN("Init DB"), STRING_WITH_LEN("Query"),
|
||||
STRING_WITH_LEN("Field List"), STRING_WITH_LEN("Create DB"),
|
||||
STRING_WITH_LEN("Drop DB"), STRING_WITH_LEN("Refresh"),
|
||||
STRING_WITH_LEN("Shutdown"), STRING_WITH_LEN("Statistics"),
|
||||
STRING_WITH_LEN("Processlist"), STRING_WITH_LEN("Connect"),
|
||||
STRING_WITH_LEN("Kill"), STRING_WITH_LEN("Debug"),
|
||||
STRING_WITH_LEN("Ping"), STRING_WITH_LEN("Time"),
|
||||
STRING_WITH_LEN("Delayed insert"), STRING_WITH_LEN("Change user"),
|
||||
STRING_WITH_LEN("Binlog Dump"), STRING_WITH_LEN("Table Dump"),
|
||||
STRING_WITH_LEN("Connect Out"), STRING_WITH_LEN("Register Slave"),
|
||||
STRING_WITH_LEN("Prepare"), STRING_WITH_LEN("Execute"),
|
||||
STRING_WITH_LEN("Long Data"), STRING_WITH_LEN("Close stmt"),
|
||||
STRING_WITH_LEN("Reset stmt"), STRING_WITH_LEN("Set option"),
|
||||
STRING_WITH_LEN("Fetch"), STRING_WITH_LEN("Daemon"),
|
||||
STRING_WITH_LEN("Error") // Last command number
|
||||
};
|
||||
|
||||
const char *xa_state_names[]={
|
||||
@@ -322,7 +331,7 @@ int check_user(THD *thd, enum enum_server_command command,
|
||||
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 &&
|
||||
@@ -356,9 +365,9 @@ int check_user(THD *thd, enum enum_server_command command,
|
||||
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 */
|
||||
@@ -406,14 +415,14 @@ int check_user(THD *thd, enum enum_server_command command,
|
||||
}
|
||||
|
||||
/* 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
|
||||
@@ -460,17 +469,17 @@ int check_user(THD *thd, enum enum_server_command command,
|
||||
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 */
|
||||
}
|
||||
@@ -1570,7 +1579,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
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;
|
||||
@@ -1703,7 +1712,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
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))
|
||||
@@ -1812,7 +1821,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
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
|
||||
@@ -1841,7 +1850,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
#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;
|
||||
@@ -1861,7 +1870,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
}
|
||||
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);
|
||||
@@ -1886,7 +1895,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
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;
|
||||
}
|
||||
@@ -1910,7 +1919,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
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);
|
||||
@@ -1928,7 +1937,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
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;
|
||||
@@ -1956,7 +1965,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
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()
|
||||
@@ -1973,7 +1982,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
#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
|
||||
@@ -2013,7 +2022,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
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);
|
||||
@@ -2050,7 +2059,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
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:
|
||||
@@ -2132,7 +2141,7 @@ void log_slow_statement(THD *thd)
|
||||
(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6541,7 +6550,8 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables,
|
||||
{
|
||||
/*
|
||||
Flush the normal query log, the update log, the binary log,
|
||||
the slow query log, and the relay log (if it exists).
|
||||
the slow query log, the relay log (if it exists) and the log
|
||||
tables.
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -6551,14 +6561,16 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables,
|
||||
than it would help them)
|
||||
*/
|
||||
tmp_write_to_binlog= 0;
|
||||
mysql_log.new_file(1);
|
||||
mysql_slow_log.new_file(1);
|
||||
mysql_bin_log.rotate_and_purge(RP_FORCE_ROTATE);
|
||||
#ifdef HAVE_REPLICATION
|
||||
pthread_mutex_lock(&LOCK_active_mi);
|
||||
rotate_relay_log(active_mi);
|
||||
pthread_mutex_unlock(&LOCK_active_mi);
|
||||
#endif
|
||||
|
||||
/* flush slow and general logs */
|
||||
logger.flush_logs(thd);
|
||||
|
||||
if (ha_flush_logs(NULL))
|
||||
result=1;
|
||||
if (flush_error_log())
|
||||
|
||||
Reference in New Issue
Block a user