summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2010-08-23 12:52:57 +0300
committerMichael Widenius <monty@askmonty.org>2010-08-23 12:52:57 +0300
commit53310c6ee7d602768998856c85519b9420820f46 (patch)
tree95ffbb4f77cca73b89f42c9555a10da251608017
parentb6fe4713fe14c059c4bceca60ed1863a90b7e512 (diff)
downloadmariadb-git-53310c6ee7d602768998856c85519b9420820f46.tar.gz
Trivial fixes, more safe DBUG_ASSERT()'s and some more DBUG_
- CTRL-C now aborts 'source' commands in mysql client - Fix that thread id's are removed in convert-debug-for-diff.sh client/mysql.cc: CTRL-C now aborts 'source' commands scripts/convert-debug-for-diff.sh: Fix expression to remove thread id storage/maria/ha_maria.cc: Don't call DBUG_ASSERT() when we kill a query during REPAIR / ALTER TABLE storage/maria/ma_bitmap.c: Added DBUG_ASSERT() if we call _ma_bitmap_set_full_page_bits() storage/maria/ma_key_recover.c: Don't do an assert if table is marked crashed. storage/maria/ma_recovery.c: Added DBUG_ENTER
-rw-r--r--client/mysql.cc15
-rwxr-xr-xscripts/convert-debug-for-diff.sh2
-rw-r--r--storage/maria/ha_maria.cc2
-rw-r--r--storage/maria/ma_bitmap.c7
-rw-r--r--storage/maria/ma_key_recover.c5
-rw-r--r--storage/maria/ma_recovery.c13
6 files changed, 30 insertions, 14 deletions
diff --git a/client/mysql.cc b/client/mysql.cc
index fb090cd74d5..39ca04ccbb9 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -156,6 +156,7 @@ static my_bool ignore_errors=0,wait_flag=0,quick=0,
static my_bool debug_info_flag, debug_check_flag, batch_abort_on_error;
static my_bool column_types_flag;
static my_bool preserve_comments= 0;
+static my_bool in_com_source, aborted= 0;
static ulong opt_max_allowed_packet, opt_net_buffer_length;
static uint verbose=0,opt_silent=0,opt_mysql_port=0, opt_local_infile=0;
static uint my_end_arg;
@@ -1087,6 +1088,7 @@ int main(int argc,char *argv[])
"\\N [\\d]> ",MYF(MY_WME));
current_prompt = my_strdup(default_prompt,MYF(MY_WME));
prompt_counter=0;
+ aborted= 0;
outfile[0]=0; // no (default) outfile
strmov(pager, "stdout"); // the default, if --pager wasn't given
@@ -1281,8 +1283,10 @@ sig_handler mysql_end(int sig)
/*
This function handles sigint calls
If query is in process, kill query
+ If 'source' is executed, abort source command
no query in process, terminate like previous behavior
*/
+
sig_handler handle_sigint(int sig)
{
char kill_buffer[40];
@@ -1321,7 +1325,8 @@ sig_handler handle_sigint(int sig)
mysql_close(kill_mysql);
tee_fprintf(stdout, "Ctrl-C -- query killed. Continuing normally.\n");
interrupted_query= 0;
-
+ if (in_com_source)
+ aborted= 1; // Abort source command
return;
err:
@@ -1886,7 +1891,7 @@ static int read_and_execute(bool interactive)
bool truncated= 0;
status.exit_status=1;
- for (;;)
+ while (!aborted)
{
if (!interactive)
{
@@ -4066,17 +4071,19 @@ static int com_source(String *buffer, char *line)
status.file_name=source_name;
glob_buffer.length(0); // Empty command buffer
ignore_errors= !batch_abort_on_error;
+ in_com_source= 1;
error= read_and_execute(false);
ignore_errors= save_ignore_errors;
status=old_status; // Continue as before
+ in_com_source= aborted= 0;
my_fclose(sql_file,MYF(0));
batch_readline_end(line_buff);
/*
If we got an error during source operation, don't abort the client
if ignore_errors is set
*/
- if (error && batch_abort_on_error && ignore_errors)
- error= -1;
+ if (error && !batch_abort_on_error && ignore_errors)
+ error= -1; // Ignore error
return error;
}
diff --git a/scripts/convert-debug-for-diff.sh b/scripts/convert-debug-for-diff.sh
index 2c4c86acd3c..b6c837504cb 100755
--- a/scripts/convert-debug-for-diff.sh
+++ b/scripts/convert-debug-for-diff.sh
@@ -18,7 +18,7 @@
while (<>)
{
- s/^T@[0-9]+://g;
+ s/^T@[0-9]+\s*://g;
s/0x[0-9a-f]+(\s|\n|\))/#$1/g;
s/size: [0-9]+/size: #/g;
print $_;
diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc
index 1d117dddab5..bbfe2c3ccbb 100644
--- a/storage/maria/ha_maria.cc
+++ b/storage/maria/ha_maria.cc
@@ -1814,7 +1814,7 @@ int ha_maria::enable_indexes(uint mode)
"retrying",
my_errno, param.db_name, param.table_name);
/* This should never fail normally */
- DBUG_ASSERT(0);
+ DBUG_ASSERT(thd->killed != 0);
/* Repairing by sort failed. Now try standard repair method. */
param.testflag &= ~T_REP_BY_SORT;
error= (repair(thd, &param, 0) != HA_ADMIN_OK);
diff --git a/storage/maria/ma_bitmap.c b/storage/maria/ma_bitmap.c
index cec7cd782be..a76b36e1115 100644
--- a/storage/maria/ma_bitmap.c
+++ b/storage/maria/ma_bitmap.c
@@ -2063,6 +2063,13 @@ my_bool _ma_bitmap_set_full_page_bits(MARIA_HA *info,
safe_mutex_assert_owner(&info->s->bitmap.bitmap_lock);
bitmap_page= page - page % bitmap->pages_covered;
+ if (page == bitmap_page ||
+ page + page_count >= bitmap_page + bitmap->pages_covered)
+ {
+ DBUG_ASSERT(0); /* Wrong in data */
+ DBUG_RETURN(1);
+ }
+
if (bitmap_page != bitmap->page &&
_ma_change_bitmap_page(info, bitmap, bitmap_page))
DBUG_RETURN(1);
diff --git a/storage/maria/ma_key_recover.c b/storage/maria/ma_key_recover.c
index 6d6cc2b4da1..82f8099fe6a 100644
--- a/storage/maria/ma_key_recover.c
+++ b/storage/maria/ma_key_recover.c
@@ -64,8 +64,9 @@ void _ma_unpin_all_pages(MARIA_HA *info, LSN undo_lsn)
builds.
*/
#ifdef EXTRA_DEBUG
- DBUG_ASSERT(!pinned_page->changed ||
- undo_lsn != LSN_IMPOSSIBLE || !info->s->now_transactional);
+ DBUG_ASSERT((!pinned_page->changed ||
+ undo_lsn != LSN_IMPOSSIBLE || !info->s->now_transactional) ||
+ (info->s->state.changed & STATE_CRASHED));
#endif
pagecache_unlock_by_link(info->s->pagecache, pinned_page->link,
pinned_page->unlock, PAGECACHE_UNPIN,
diff --git a/storage/maria/ma_recovery.c b/storage/maria/ma_recovery.c
index 4a62ae8948d..a10fac9a15d 100644
--- a/storage/maria/ma_recovery.c
+++ b/storage/maria/ma_recovery.c
@@ -2397,6 +2397,7 @@ static int run_redo_phase(LSN lsn, LSN lsn_end, enum maria_apply_log_way apply)
struct st_translog_scanner_data scanner;
int len;
uint i;
+ DBUG_ENTER("run_redo_phase");
/* install hooks for execution */
#define install_redo_exec_hook(R) \
@@ -2461,7 +2462,7 @@ static int run_redo_phase(LSN lsn, LSN lsn_end, enum maria_apply_log_way apply)
{
tprint(tracef, "checkpoint address refers to the log end log or "
"log is empty, nothing to do.\n");
- return 0;
+ DBUG_RETURN(0);
}
len= translog_read_record_header(lsn, &rec);
@@ -2469,12 +2470,12 @@ static int run_redo_phase(LSN lsn, LSN lsn_end, enum maria_apply_log_way apply)
if (len == RECHEADER_READ_ERROR)
{
eprint(tracef, "Failed to read header of the first record.");
- return 1;
+ DBUG_RETURN(1);
}
if (translog_scanner_init(lsn, 1, &scanner, 1))
{
tprint(tracef, "Scanner init failed\n");
- return 1;
+ DBUG_RETURN(1);
}
for (i= 1;;i++)
{
@@ -2527,7 +2528,7 @@ static int run_redo_phase(LSN lsn, LSN lsn_end, enum maria_apply_log_way apply)
LSN_IN_PARTS(rec2.lsn));
translog_destroy_scanner(&scanner);
translog_free_record_header(&rec);
- return(0);
+ DBUG_RETURN(0);
}
if (translog_scanner_init(rec2.lsn, 1, &scanner2, 1))
@@ -2625,12 +2626,12 @@ static int run_redo_phase(LSN lsn, LSN lsn_end, enum maria_apply_log_way apply)
fflush(stderr);
procent_printed= 1;
}
- return 0;
+ DBUG_RETURN(0);
err:
translog_destroy_scanner(&scanner);
translog_free_record_header(&rec);
- return 1;
+ DBUG_RETURN(1);
}