1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Simplify logging code a bit (to make code smaller and faster)

Moved duplicated code to inline function store_timestamp()
Save thd->time_zone_used when logging to table as CSV internally cases it to be changed
Added MYSQL_LOCK_IGNORE_FLUSH to log tables to avoid deadlock in case of flush tables.
Mark log tables with TIMESTAMP_NO_AUTO_SET to avoid automatic timestamping
Set TABLE->no_replicate on open



client/mysqlbinlog.cc:
  Fixed several memory leaks (most in case of error situations)
mysql-test/r/events_logs_tests.result:
  Made long_query_timeout smaller to ensure next query comes into log
mysql-test/r/variables.result:
  Make it safe to run test with --log
mysql-test/t/events_logs_tests.test:
  Made long_query_timeout smaller to ensure next query comes into log
mysql-test/t/variables.test:
  Make it safe to run test with --log
sql/field.cc:
  Moved duplicated code to inline function store_timestamp()
sql/field.h:
  Moved duplicated code to inline function store_timestamp()
sql/handler.cc:
  Reorder checks in likely order
  Simplify checks if we should do binary logging
  (no_replicate is set once and for all when table is opened)
sql/log.cc:
  Save thd->time_zone_used as CVS internally cases it to be changed
  Use Field_timestamp->store_timestamp instead of automatic timestamps.
  This gives us correct timestamp even if thd->set_time() is not called (in case
  of connect) and we don't have to store thd->query_start_used anymore.
sql/sql_base.cc:
  Removed not needed comment
  Moved LINT_INIT() to after declaration
  Renamed temporary variable to avoid compiler warning
  Added MYSQL_LOCK_IGNORE_FLUSH to log tables to avoid deadlock in case of flush tables.
  Mark log tables with TIMESTAMP_NO_AUTO_SET to avoid automatic timestamping
sql/table.cc:
  Set TABLE->no_replicate on open
This commit is contained in:
unknown
2007-08-03 01:14:27 +03:00
parent dcf1fd73d9
commit 720ea4041e
11 changed files with 89 additions and 68 deletions

View File

@ -1314,24 +1314,20 @@ void close_temporary_tables(THD *thd)
{
TABLE *table;
TABLE *next;
/*
TODO: 5.1 maintains prev link in temporary_tables
double-linked list so we could fix it. But it is not necessary
at this time when the list is being destroyed
*/
TABLE *prev_table;
/* Assume thd->options has OPTION_QUOTE_SHOW_CREATE */
bool was_quote_show= TRUE;
LINT_INIT(next);
if (!thd->temporary_tables)
return;
if (!mysql_bin_log.is_open() || thd->current_stmt_binlog_row_based)
{
TABLE *next;
for (table= thd->temporary_tables; table; table= next)
TABLE *tmp_next;
for (table= thd->temporary_tables; table; table= tmp_next)
{
next=table->next;
tmp_next= table->next;
close_temporary(table, 1, 1);
}
thd->temporary_tables= 0;
@ -1344,13 +1340,12 @@ void close_temporary_tables(THD *thd)
char buf[256];
String s_query= String(buf, sizeof(buf), system_charset_info);
bool found_user_tables= FALSE;
LINT_INIT(next);
memcpy(buf, stub, stub_len);
/*
insertion sort of temp tables by pseudo_thread_id to build ordered list
of sublists of equal pseudo_thread_id
Insertion sort of temp tables by pseudo_thread_id to build ordered list
of sublists of equal pseudo_thread_id
*/
for (prev_table= thd->temporary_tables, table= prev_table->next;
@ -7731,23 +7726,30 @@ TABLE *
open_performance_schema_table(THD *thd, TABLE_LIST *one_table,
Open_tables_state *backup)
{
uint flags= ( MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK
| MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY
| MYSQL_LOCK_PERF_SCHEMA );
uint flags= ( MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK |
MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY |
MYSQL_LOCK_IGNORE_FLUSH |
MYSQL_LOCK_PERF_SCHEMA);
TABLE *table;
/* Save value that is changed in mysql_lock_tables() */
ulonglong save_utime_after_lock= thd->utime_after_lock;
DBUG_ENTER("open_performance_schema_table");
thd->reset_n_backup_open_tables_state(backup);
TABLE *table= open_ltable(thd, one_table, one_table->lock_type, flags);
if (table)
if ((table= open_ltable(thd, one_table, one_table->lock_type, flags)))
{
DBUG_ASSERT(table->s->table_category == TABLE_CATEGORY_PERFORMANCE);
/* Make sure all columns get assigned to a default value */
table->use_all_columns();
table->no_replicate= 1;
/*
Don't set automatic timestamps as we may want to use time of logging,
not from query start
*/
table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET;
}
thd->utime_after_lock= save_utime_after_lock;
DBUG_RETURN(table);
}