summaryrefslogtreecommitdiff
path: root/innobase
diff options
context:
space:
mode:
Diffstat (limited to 'innobase')
-rw-r--r--innobase/btr/btr0btr.c2
-rw-r--r--innobase/btr/btr0cur.c4
-rw-r--r--innobase/buf/buf0buf.c16
-rw-r--r--innobase/buf/buf0flu.c10
-rw-r--r--innobase/buf/buf0lru.c4
-rw-r--r--innobase/buf/buf0rea.c10
-rw-r--r--innobase/data/data0type.c2
-rw-r--r--innobase/dict/dict0boot.c105
-rw-r--r--innobase/dict/dict0crea.c22
-rw-r--r--innobase/dict/dict0dict.c63
-rw-r--r--innobase/dict/dict0load.c55
-rw-r--r--innobase/dict/dict0mem.c6
-rw-r--r--innobase/fil/fil0fil.c453
-rw-r--r--innobase/fsp/fsp0fsp.c6
-rw-r--r--innobase/fut/fut0lst.c2
-rw-r--r--innobase/ha/ha0ha.c2
-rw-r--r--innobase/ha/hash0hash.c38
-rw-r--r--innobase/ibuf/ibuf0ibuf.c19
-rw-r--r--innobase/include/Makefile.am2
-rw-r--r--innobase/include/btr0btr.h2
-rw-r--r--innobase/include/buf0buf.h10
-rw-r--r--innobase/include/buf0buf.ic6
-rw-r--r--innobase/include/buf0flu.h2
-rw-r--r--innobase/include/buf0lru.h2
-rw-r--r--innobase/include/data0data.h6
-rw-r--r--innobase/include/data0type.h3
-rw-r--r--innobase/include/dict0dict.h14
-rw-r--r--innobase/include/dict0mem.h17
-rw-r--r--innobase/include/fil0fil.h8
-rw-r--r--innobase/include/fsp0fsp.h2
-rw-r--r--innobase/include/fut0lst.h3
-rw-r--r--innobase/include/hash0hash.h20
-rw-r--r--innobase/include/hash0hash.ic8
-rw-r--r--innobase/include/lock0lock.h6
-rw-r--r--innobase/include/log0log.h39
-rw-r--r--innobase/include/log0log.ic38
-rw-r--r--innobase/include/log0recv.h19
-rw-r--r--innobase/include/mach0data.h6
-rw-r--r--innobase/include/mach0data.ic4
-rw-r--r--innobase/include/mem0dbg.h17
-rw-r--r--innobase/include/mem0dbg.ic7
-rw-r--r--innobase/include/mem0mem.h12
-rw-r--r--innobase/include/mem0mem.ic18
-rw-r--r--innobase/include/mem0pool.h3
-rw-r--r--innobase/include/mtr0log.h4
-rw-r--r--innobase/include/mtr0log.ic4
-rw-r--r--innobase/include/mtr0mtr.h28
-rw-r--r--innobase/include/os0file.h7
-rw-r--r--innobase/include/os0thread.h4
-rw-r--r--innobase/include/pars0opt.h2
-rw-r--r--innobase/include/que0que.h38
-rw-r--r--innobase/include/que0que.ic18
-rw-r--r--innobase/include/row0ins.h5
-rw-r--r--innobase/include/row0mysql.h3
-rw-r--r--innobase/include/row0upd.h5
-rw-r--r--innobase/include/srv0que.h53
-rw-r--r--innobase/include/srv0srv.h11
-rw-r--r--innobase/include/sync0rw.h2
-rw-r--r--innobase/include/sync0rw.ic2
-rw-r--r--innobase/include/sync0sync.h2
-rw-r--r--innobase/include/sync0sync.ic2
-rw-r--r--innobase/include/trx0roll.h21
-rw-r--r--innobase/include/trx0sys.h8
-rw-r--r--innobase/include/trx0trx.h31
-rw-r--r--innobase/include/usr0sess.h6
-rw-r--r--innobase/include/ut0mem.h31
-rw-r--r--innobase/lock/lock0lock.c16
-rw-r--r--innobase/log/log0log.c227
-rw-r--r--innobase/log/log0recv.c103
-rw-r--r--innobase/mem/mem0dbg.c134
-rw-r--r--innobase/mem/mem0pool.c2
-rw-r--r--innobase/mtr/mtr0mtr.c201
-rw-r--r--innobase/os/os0file.c131
-rw-r--r--innobase/os/os0thread.c9
-rw-r--r--innobase/page/page0page.c4
-rw-r--r--innobase/pars/lexyy.c262
-rw-r--r--innobase/pars/pars0lex.l45
-rw-r--r--innobase/pars/pars0opt.c2
-rw-r--r--innobase/pars/pars0pars.c4
-rw-r--r--innobase/que/que0que.c117
-rw-r--r--innobase/rem/rem0cmp.c8
-rw-r--r--innobase/row/row0ins.c33
-rw-r--r--innobase/row/row0mysql.c284
-rw-r--r--innobase/row/row0sel.c18
-rw-r--r--innobase/row/row0upd.c6
-rw-r--r--innobase/srv/Makefile.am2
-rw-r--r--innobase/srv/srv0que.c113
-rw-r--r--innobase/srv/srv0srv.c87
-rw-r--r--innobase/srv/srv0start.c76
-rw-r--r--innobase/sync/sync0rw.c8
-rw-r--r--innobase/sync/sync0sync.c14
-rw-r--r--innobase/thr/thr0loc.c10
-rw-r--r--innobase/trx/trx0purge.c3
-rw-r--r--innobase/trx/trx0roll.c95
-rw-r--r--innobase/trx/trx0sys.c44
-rw-r--r--innobase/trx/trx0trx.c177
-rw-r--r--innobase/usr/usr0sess.c2
-rw-r--r--innobase/ut/ut0mem.c75
98 files changed, 2072 insertions, 1620 deletions
diff --git a/innobase/btr/btr0btr.c b/innobase/btr/btr0btr.c
index 09f5c66f687..27d798f925a 100644
--- a/innobase/btr/btr0btr.c
+++ b/innobase/btr/btr0btr.c
@@ -2165,7 +2165,6 @@ btr_discard_page(
ut_ad(btr_check_node_ptr(tree, merge_page, mtr));
}
-#ifdef UNIV_DEBUG
/*****************************************************************
Prints size info of a B-tree. */
@@ -2287,7 +2286,6 @@ btr_print_tree(
btr_validate_tree(tree);
}
-#endif /* UNIV_DEBUG */
/****************************************************************
Checks that the node pointer to a page is appropriate. */
diff --git a/innobase/btr/btr0cur.c b/innobase/btr/btr0cur.c
index 5829cc2c406..2e9194ff30f 100644
--- a/innobase/btr/btr0cur.c
+++ b/innobase/btr/btr0cur.c
@@ -2937,7 +2937,7 @@ btr_cur_mark_dtuple_inherited_extern(
if (!is_updated) {
dfield = dtuple_get_nth_field(entry, ext_vec[i]);
- data = dfield_get_data(dfield);
+ data = (byte*) dfield_get_data(dfield);
len = dfield_get_len(dfield);
len -= BTR_EXTERN_FIELD_REF_SIZE;
@@ -2997,7 +2997,7 @@ btr_cur_unmark_dtuple_extern_fields(
for (i = 0; i < n_ext_vec; i++) {
dfield = dtuple_get_nth_field(entry, ext_vec[i]);
- data = dfield_get_data(dfield);
+ data = (byte*) dfield_get_data(dfield);
len = dfield_get_len(dfield);
len -= BTR_EXTERN_FIELD_REF_SIZE;
diff --git a/innobase/buf/buf0buf.c b/innobase/buf/buf0buf.c
index 4d83fb4c9f2..5ec8998473d 100644
--- a/innobase/buf/buf0buf.c
+++ b/innobase/buf/buf0buf.c
@@ -223,14 +223,12 @@ in the free list to the frames.
buf_pool_t* buf_pool = NULL; /* The buffer buf_pool of the database */
-#ifdef UNIV_DEBUG
-static ulint buf_dbg_counter = 0; /* This is used to insert validation
+ulint buf_dbg_counter = 0; /* This is used to insert validation
operations in excution in the
debug version */
ibool buf_debug_prints = FALSE; /* If this is set TRUE,
the program prints info whenever
read-ahead or flush occurs */
-#endif /* UNIV_DEBUG */
/************************************************************************
Calculates a page checksum which is stored to the page when it is written
@@ -719,7 +717,9 @@ buf_awe_map_page_to_frame(
{
buf_block_t* bck;
+#ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&(buf_pool->mutex)));
+#endif /* UNIV_SYNC_DEBUG */
ut_ad(block);
if (block->frame) {
@@ -1727,12 +1727,10 @@ buf_page_create(
/* If we get here, the page was not in buf_pool: init it there */
-#ifdef UNIV_DEBUG
if (buf_debug_prints) {
fprintf(stderr, "Creating space %lu page %lu to buffer\n",
(ulong) space, (ulong) offset);
}
-#endif /* UNIV_DEBUG */
block = free_block;
@@ -1883,11 +1881,9 @@ buf_page_io_complete(
rw_lock_x_unlock_gen(&(block->lock), BUF_IO_READ);
-#ifdef UNIV_DEBUG
if (buf_debug_prints) {
fputs("Has read ", stderr);
}
-#endif /* UNIV_DEBUG */
} else {
ut_ad(io_type == BUF_IO_WRITE);
@@ -1900,21 +1896,17 @@ buf_page_io_complete(
buf_pool->n_pages_written++;
-#ifdef UNIV_DEBUG
if (buf_debug_prints) {
fputs("Has written ", stderr);
}
-#endif /* UNIV_DEBUG */
}
mutex_exit(&(buf_pool->mutex));
-#ifdef UNIV_DEBUG
if (buf_debug_prints) {
fprintf(stderr, "page space %lu page no %lu\n",
(ulong) block->space, (ulong) block->offset);
}
-#endif /* UNIV_DEBUG */
}
/*************************************************************************
@@ -1943,7 +1935,6 @@ buf_pool_invalidate(void)
mutex_exit(&(buf_pool->mutex));
}
-#ifdef UNIV_DEBUG
/*************************************************************************
Validates the buffer buf_pool data structure. */
@@ -2143,7 +2134,6 @@ buf_print(void)
ut_a(buf_validate());
}
-#endif /* UNIV_DEBUG */
/*************************************************************************
Returns the number of pending buf pool ios. */
diff --git a/innobase/buf/buf0flu.c b/innobase/buf/buf0flu.c
index 885bcf06456..6cefdb60956 100644
--- a/innobase/buf/buf0flu.c
+++ b/innobase/buf/buf0flu.c
@@ -32,7 +32,6 @@ flushed along with the original page. */
#define BUF_FLUSH_AREA ut_min(BUF_READ_AHEAD_AREA,\
buf_pool->curr_size / 16)
-#ifdef UNIV_DEBUG
/**********************************************************************
Validates the flush list. */
static
@@ -40,7 +39,6 @@ ibool
buf_flush_validate_low(void);
/*========================*/
/* out: TRUE if ok */
-#endif /* UNIV_DEBUG */
/************************************************************************
Inserts a modified block into the flush list. */
@@ -513,13 +511,11 @@ buf_flush_try_page(
rw_lock_s_lock_gen(&(block->lock), BUF_IO_WRITE);
}
-#ifdef UNIV_DEBUG
if (buf_debug_prints) {
fprintf(stderr,
"Flushing page space %lu, page no %lu \n",
(ulong) block->space, (ulong) block->offset);
}
-#endif /* UNIV_DEBUG */
buf_flush_write_block_low(block);
@@ -603,14 +599,12 @@ buf_flush_try_page(
rw_lock_s_lock_gen(&(block->lock), BUF_IO_WRITE);
-#ifdef UNIV_DEBUG
if (buf_debug_prints) {
fprintf(stderr,
"Flushing single page space %lu, page no %lu \n",
(ulong) block->space,
(ulong) block->offset);
}
-#endif /* UNIV_DEBUG */
buf_flush_write_block_low(block);
@@ -837,7 +831,6 @@ buf_flush_batch(
buf_flush_buffered_writes();
-#ifdef UNIV_DEBUG
if (buf_debug_prints && page_count > 0) {
ut_a(flush_type == BUF_FLUSH_LRU
|| flush_type == BUF_FLUSH_LIST);
@@ -846,7 +839,6 @@ buf_flush_batch(
: "Flushed %lu pages in flush list flush\n",
(ulong) page_count);
}
-#endif /* UNIV_DEBUG */
return(page_count);
}
@@ -938,7 +930,6 @@ buf_flush_free_margin(void)
}
}
-#ifdef UNIV_DEBUG
/**********************************************************************
Validates the flush list. */
static
@@ -988,4 +979,3 @@ buf_flush_validate(void)
return(ret);
}
-#endif /* UNIV_DEBUG */
diff --git a/innobase/buf/buf0lru.c b/innobase/buf/buf0lru.c
index 053161986e4..796311f0157 100644
--- a/innobase/buf/buf0lru.c
+++ b/innobase/buf/buf0lru.c
@@ -209,14 +209,12 @@ buf_LRU_search_and_free_block(
ut_a(block->in_LRU_list);
if (buf_flush_ready_for_replace(block)) {
-#ifdef UNIV_DEBUG
if (buf_debug_prints) {
fprintf(stderr,
"Putting space %lu page %lu to free list\n",
(ulong) block->space,
(ulong) block->offset);
}
-#endif /* UNIV_DEBUG */
buf_LRU_block_remove_hashed_page(block);
@@ -888,7 +886,6 @@ buf_LRU_block_free_hashed_page(
buf_LRU_block_free_non_file_page(block);
}
-#ifdef UNIV_DEBUG
/**************************************************************************
Validates the LRU list. */
@@ -1019,4 +1016,3 @@ buf_LRU_print(void)
mutex_exit(&(buf_pool->mutex));
}
-#endif /* UNIV_DEBUG */
diff --git a/innobase/buf/buf0rea.c b/innobase/buf/buf0rea.c
index e0f8291977e..71e885ff439 100644
--- a/innobase/buf/buf0rea.c
+++ b/innobase/buf/buf0rea.c
@@ -284,14 +284,12 @@ buf_read_ahead_random(
os_aio_simulated_wake_handler_threads();
-#ifdef UNIV_DEBUG
if (buf_debug_prints && (count > 0)) {
fprintf(stderr,
"Random read-ahead space %lu offset %lu pages %lu\n",
(ulong) space, (ulong) offset,
(ulong) count);
}
-#endif /* UNIV_DEBUG */
return(count);
}
@@ -571,13 +569,11 @@ buf_read_ahead_linear(
/* Flush pages from the end of the LRU list if necessary */
buf_flush_free_margin();
-#ifdef UNIV_DEBUG
if (buf_debug_prints && (count > 0)) {
fprintf(stderr,
"LINEAR read-ahead space %lu offset %lu pages %lu\n",
(ulong) space, (ulong) offset, (ulong) count);
}
-#endif /* UNIV_DEBUG */
return(count);
}
@@ -636,13 +632,11 @@ buf_read_ibuf_merge_pages(
/* Flush pages from the end of the LRU list if necessary */
buf_flush_free_margin();
-#ifdef UNIV_DEBUG
if (buf_debug_prints) {
fprintf(stderr,
"Ibuf merge read-ahead space %lu pages %lu\n",
- (ulong) space, (ulong) n_stored);
+ (ulong) space_ids[0], (ulong) n_stored);
}
-#endif /* UNIV_DEBUG */
}
/************************************************************************
@@ -706,10 +700,8 @@ buf_read_recv_pages(
/* Flush pages from the end of the LRU list if necessary */
buf_flush_free_margin();
-#ifdef UNIV_DEBUG
if (buf_debug_prints) {
fprintf(stderr,
"Recovery applies read-ahead pages %lu\n", (ulong) n_stored);
}
-#endif /* UNIV_DEBUG */
}
diff --git a/innobase/data/data0type.c b/innobase/data/data0type.c
index 698b5361dfa..97d93b1b0ec 100644
--- a/innobase/data/data0type.c
+++ b/innobase/data/data0type.c
@@ -104,7 +104,6 @@ dtype_form_prtype(
return(old_prtype + (charset_coll << 16));
}
-#ifdef UNIV_DEBUG
/*************************************************************************
Validates a data type structure. */
@@ -123,7 +122,6 @@ dtype_validate(
return(TRUE);
}
-#endif /* UNIV_DEBUG */
/*************************************************************************
Prints a data type structure. */
diff --git a/innobase/dict/dict0boot.c b/innobase/dict/dict0boot.c
index 8e1629819f3..f156cf67a18 100644
--- a/innobase/dict/dict0boot.c
+++ b/innobase/dict/dict0boot.c
@@ -254,29 +254,26 @@ dict_boot(void)
/* Insert into the dictionary cache the descriptions of the basic
system tables */
/*-------------------------*/
- table = dict_mem_table_create((char *) "SYS_TABLES", DICT_HDR_SPACE,8);
-
- dict_mem_table_add_col(table, (char *) "NAME", DATA_BINARY, 0, 0, 0);
- dict_mem_table_add_col(table, (char *) "ID", DATA_BINARY, 0, 0, 0);
- dict_mem_table_add_col(table, (char *) "N_COLS", DATA_INT, 0, 4, 0);
- dict_mem_table_add_col(table, (char *) "TYPE", DATA_INT, 0, 4, 0);
- dict_mem_table_add_col(table, (char *) "MIX_ID", DATA_BINARY, 0, 0, 0);
- dict_mem_table_add_col(table, (char *) "MIX_LEN", DATA_INT, 0, 4, 0);
- dict_mem_table_add_col(table, (char *) "CLUSTER_NAME", DATA_BINARY,
- 0, 0, 0);
- dict_mem_table_add_col(table, (char *) "SPACE", DATA_INT, 0, 4, 0);
+ table = dict_mem_table_create("SYS_TABLES", DICT_HDR_SPACE,8);
+
+ dict_mem_table_add_col(table, "NAME", DATA_BINARY, 0, 0, 0);
+ dict_mem_table_add_col(table, "ID", DATA_BINARY, 0, 0, 0);
+ dict_mem_table_add_col(table, "N_COLS", DATA_INT, 0, 4, 0);
+ dict_mem_table_add_col(table, "TYPE", DATA_INT, 0, 4, 0);
+ dict_mem_table_add_col(table, "MIX_ID", DATA_BINARY, 0, 0, 0);
+ dict_mem_table_add_col(table, "MIX_LEN", DATA_INT, 0, 4, 0);
+ dict_mem_table_add_col(table, "CLUSTER_NAME", DATA_BINARY, 0, 0, 0);
+ dict_mem_table_add_col(table, "SPACE", DATA_INT, 0, 4, 0);
table->id = DICT_TABLES_ID;
dict_table_add_to_cache(table);
dict_sys->sys_tables = table;
- index = dict_mem_index_create((char *) "SYS_TABLES", (char *)
- "CLUST_IND",
- DICT_HDR_SPACE,
- DICT_UNIQUE | DICT_CLUSTERED, 1);
+ index = dict_mem_index_create("SYS_TABLES", "CLUST_IND",
+ DICT_HDR_SPACE, DICT_UNIQUE | DICT_CLUSTERED, 1);
- dict_mem_index_add_field(index, (char *) "NAME", 0, 0);
+ dict_mem_index_add_field(index, "NAME", 0, 0);
index->page_no = mtr_read_ulint(dict_hdr + DICT_HDR_TABLES,
MLOG_4BYTES, &mtr);
@@ -284,52 +281,50 @@ dict_boot(void)
ut_a(dict_index_add_to_cache(table, index));
/*-------------------------*/
- index = dict_mem_index_create((char *) "SYS_TABLES",
- (char *) "ID_IND", DICT_HDR_SPACE,
- DICT_UNIQUE, 1);
- dict_mem_index_add_field(index, (char *) "ID", 0, 0);
+ index = dict_mem_index_create("SYS_TABLES", "ID_IND",
+ DICT_HDR_SPACE, DICT_UNIQUE, 1);
+ dict_mem_index_add_field(index, "ID", 0, 0);
index->page_no = mtr_read_ulint(dict_hdr + DICT_HDR_TABLE_IDS,
MLOG_4BYTES, &mtr);
index->id = DICT_TABLE_IDS_ID;
ut_a(dict_index_add_to_cache(table, index));
/*-------------------------*/
- table = dict_mem_table_create((char *) "SYS_COLUMNS",DICT_HDR_SPACE,7);
-
- dict_mem_table_add_col(table, (char *) "TABLE_ID", DATA_BINARY,0,0,0);
- dict_mem_table_add_col(table, (char *) "POS", DATA_INT, 0, 4, 0);
- dict_mem_table_add_col(table, (char *) "NAME", DATA_BINARY, 0, 0, 0);
- dict_mem_table_add_col(table, (char *) "MTYPE", DATA_INT, 0, 4, 0);
- dict_mem_table_add_col(table, (char *) "PRTYPE", DATA_INT, 0, 4, 0);
- dict_mem_table_add_col(table, (char *) "LEN", DATA_INT, 0, 4, 0);
- dict_mem_table_add_col(table, (char *) "PREC", DATA_INT, 0, 4, 0);
+ table = dict_mem_table_create("SYS_COLUMNS",DICT_HDR_SPACE,7);
+
+ dict_mem_table_add_col(table, "TABLE_ID", DATA_BINARY,0,0,0);
+ dict_mem_table_add_col(table, "POS", DATA_INT, 0, 4, 0);
+ dict_mem_table_add_col(table, "NAME", DATA_BINARY, 0, 0, 0);
+ dict_mem_table_add_col(table, "MTYPE", DATA_INT, 0, 4, 0);
+ dict_mem_table_add_col(table, "PRTYPE", DATA_INT, 0, 4, 0);
+ dict_mem_table_add_col(table, "LEN", DATA_INT, 0, 4, 0);
+ dict_mem_table_add_col(table, "PREC", DATA_INT, 0, 4, 0);
table->id = DICT_COLUMNS_ID;
dict_table_add_to_cache(table);
dict_sys->sys_columns = table;
- index = dict_mem_index_create((char *) "SYS_COLUMNS",
- (char *) "CLUST_IND", DICT_HDR_SPACE,
- DICT_UNIQUE | DICT_CLUSTERED, 2);
+ index = dict_mem_index_create("SYS_COLUMNS", "CLUST_IND",
+ DICT_HDR_SPACE, DICT_UNIQUE | DICT_CLUSTERED, 2);
- dict_mem_index_add_field(index, (char *) "TABLE_ID", 0, 0);
- dict_mem_index_add_field(index, (char *) "POS", 0, 0);
+ dict_mem_index_add_field(index, "TABLE_ID", 0, 0);
+ dict_mem_index_add_field(index, "POS", 0, 0);
index->page_no = mtr_read_ulint(dict_hdr + DICT_HDR_COLUMNS,
MLOG_4BYTES, &mtr);
index->id = DICT_COLUMNS_ID;
ut_a(dict_index_add_to_cache(table, index));
/*-------------------------*/
- table = dict_mem_table_create((char *) "SYS_INDEXES",DICT_HDR_SPACE,7);
+ table = dict_mem_table_create("SYS_INDEXES",DICT_HDR_SPACE,7);
- dict_mem_table_add_col(table, (char *) "TABLE_ID", DATA_BINARY, 0,0,0);
- dict_mem_table_add_col(table, (char *) "ID", DATA_BINARY, 0, 0, 0);
- dict_mem_table_add_col(table, (char *) "NAME", DATA_BINARY, 0, 0, 0);
- dict_mem_table_add_col(table, (char *) "N_FIELDS", DATA_INT, 0, 4, 0);
- dict_mem_table_add_col(table, (char *) "TYPE", DATA_INT, 0, 4, 0);
- dict_mem_table_add_col(table, (char *) "SPACE", DATA_INT, 0, 4, 0);
- dict_mem_table_add_col(table, (char *) "PAGE_NO", DATA_INT, 0, 4, 0);
+ dict_mem_table_add_col(table, "TABLE_ID", DATA_BINARY, 0,0,0);
+ dict_mem_table_add_col(table, "ID", DATA_BINARY, 0, 0, 0);
+ dict_mem_table_add_col(table, "NAME", DATA_BINARY, 0, 0, 0);
+ dict_mem_table_add_col(table, "N_FIELDS", DATA_INT, 0, 4, 0);
+ dict_mem_table_add_col(table, "TYPE", DATA_INT, 0, 4, 0);
+ dict_mem_table_add_col(table, "SPACE", DATA_INT, 0, 4, 0);
+ dict_mem_table_add_col(table, "PAGE_NO", DATA_INT, 0, 4, 0);
/* The '+ 2' below comes from the 2 system fields */
#if DICT_SYS_INDEXES_PAGE_NO_FIELD != 6 + 2
@@ -343,34 +338,32 @@ dict_boot(void)
dict_table_add_to_cache(table);
dict_sys->sys_indexes = table;
- index = dict_mem_index_create((char *) "SYS_INDEXES",
- (char *) "CLUST_IND", DICT_HDR_SPACE,
- DICT_UNIQUE | DICT_CLUSTERED, 2);
+ index = dict_mem_index_create("SYS_INDEXES", "CLUST_IND",
+ DICT_HDR_SPACE, DICT_UNIQUE | DICT_CLUSTERED, 2);
- dict_mem_index_add_field(index, (char *) "TABLE_ID", 0, 0);
- dict_mem_index_add_field(index, (char *) "ID", 0, 0);
+ dict_mem_index_add_field(index, "TABLE_ID", 0, 0);
+ dict_mem_index_add_field(index, "ID", 0, 0);
index->page_no = mtr_read_ulint(dict_hdr + DICT_HDR_INDEXES,
MLOG_4BYTES, &mtr);
index->id = DICT_INDEXES_ID;
ut_a(dict_index_add_to_cache(table, index));
/*-------------------------*/
- table = dict_mem_table_create((char *) "SYS_FIELDS", DICT_HDR_SPACE,3);
+ table = dict_mem_table_create("SYS_FIELDS", DICT_HDR_SPACE,3);
- dict_mem_table_add_col(table, (char *) "INDEX_ID", DATA_BINARY, 0,0,0);
- dict_mem_table_add_col(table, (char *) "POS", DATA_INT, 0, 4, 0);
- dict_mem_table_add_col(table, (char *) "COL_NAME", DATA_BINARY, 0,0,0);
+ dict_mem_table_add_col(table, "INDEX_ID", DATA_BINARY, 0,0,0);
+ dict_mem_table_add_col(table, "POS", DATA_INT, 0, 4, 0);
+ dict_mem_table_add_col(table, "COL_NAME", DATA_BINARY, 0,0,0);
table->id = DICT_FIELDS_ID;
dict_table_add_to_cache(table);
dict_sys->sys_fields = table;
- index = dict_mem_index_create((char *) "SYS_FIELDS",
- (char *) "CLUST_IND", DICT_HDR_SPACE,
- DICT_UNIQUE | DICT_CLUSTERED, 2);
+ index = dict_mem_index_create("SYS_FIELDS", "CLUST_IND",
+ DICT_HDR_SPACE, DICT_UNIQUE | DICT_CLUSTERED, 2);
- dict_mem_index_add_field(index, (char *) "INDEX_ID", 0, 0);
- dict_mem_index_add_field(index, (char *) "POS", 0, 0);
+ dict_mem_index_add_field(index, "INDEX_ID", 0, 0);
+ dict_mem_index_add_field(index, "POS", 0, 0);
index->page_no = mtr_read_ulint(dict_hdr + DICT_HDR_FIELDS,
MLOG_4BYTES, &mtr);
diff --git a/innobase/dict/dict0crea.c b/innobase/dict/dict0crea.c
index f0b5906ec50..fd8e02585ae 100644
--- a/innobase/dict/dict0crea.c
+++ b/innobase/dict/dict0crea.c
@@ -1004,12 +1004,12 @@ dict_create_or_check_foreign_constraint_tables(void)
que_t* graph;
ulint error;
trx_t* trx;
- char* str;
+ const char* str;
mutex_enter(&(dict_sys->mutex));
- table1 = dict_table_get_low((char *) "SYS_FOREIGN");
- table2 = dict_table_get_low((char *) "SYS_FOREIGN_COLS");
+ table1 = dict_table_get_low("SYS_FOREIGN");
+ table2 = dict_table_get_low("SYS_FOREIGN_COLS");
if (table1 && table2
&& UT_LIST_GET_LEN(table1->indexes) == 3
@@ -1027,20 +1027,20 @@ dict_create_or_check_foreign_constraint_tables(void)
trx = trx_allocate_for_mysql();
- trx->op_info = (char *) "creating foreign key sys tables";
+ trx->op_info = "creating foreign key sys tables";
row_mysql_lock_data_dictionary(trx);
if (table1) {
fprintf(stderr,
"InnoDB: dropping incompletely created SYS_FOREIGN table\n");
- row_drop_table_for_mysql((char*)"SYS_FOREIGN", trx, TRUE);
+ row_drop_table_for_mysql("SYS_FOREIGN", trx, TRUE);
}
if (table2) {
fprintf(stderr,
"InnoDB: dropping incompletely created SYS_FOREIGN_COLS table\n");
- row_drop_table_for_mysql((char*)"SYS_FOREIGN_COLS", trx, TRUE);
+ row_drop_table_for_mysql("SYS_FOREIGN_COLS", trx, TRUE);
}
fprintf(stderr,
@@ -1050,7 +1050,7 @@ dict_create_or_check_foreign_constraint_tables(void)
there are 2 secondary indexes on SYS_FOREIGN, and they
are defined just like below */
- str = (char *)
+ str =
"PROCEDURE CREATE_FOREIGN_SYS_TABLES_PROC () IS\n"
"BEGIN\n"
"CREATE TABLE\n"
@@ -1090,15 +1090,15 @@ dict_create_or_check_foreign_constraint_tables(void)
fprintf(stderr,
"InnoDB: dropping incompletely created SYS_FOREIGN tables\n");
- row_drop_table_for_mysql((char*)"SYS_FOREIGN", trx, TRUE);
- row_drop_table_for_mysql((char*)"SYS_FOREIGN_COLS", trx, TRUE);
+ row_drop_table_for_mysql("SYS_FOREIGN", trx, TRUE);
+ row_drop_table_for_mysql("SYS_FOREIGN_COLS", trx, TRUE);
error = DB_MUST_GET_MORE_FILE_SPACE;
}
que_graph_free(graph);
- trx->op_info = (char *) "";
+ trx->op_info = "";
row_mysql_unlock_data_dictionary(trx);
@@ -1161,7 +1161,7 @@ dict_create_add_foreigns_to_dictionary(
ut_ad(mutex_own(&(dict_sys->mutex)));
#endif /* UNIV_SYNC_DEBUG */
- if (NULL == dict_table_get_low((char *) "SYS_FOREIGN")) {
+ if (NULL == dict_table_get_low("SYS_FOREIGN")) {
fprintf(stderr,
"InnoDB: table SYS_FOREIGN not found from internal data dictionary\n");
diff --git a/innobase/dict/dict0dict.c b/innobase/dict/dict0dict.c
index 6a6ac2492f8..71cf908db4e 100644
--- a/innobase/dict/dict0dict.c
+++ b/innobase/dict/dict0dict.c
@@ -198,13 +198,14 @@ dict_tables_have_same_db(
/************************************************************************
Return the end of table name where we have removed dbname and '/'. */
static
-char*
+const char*
dict_remove_db_name(
/*================*/
- /* out: table name */
- char* name) /* in: table name in the form dbname '/' tablename */
+ /* out: table name */
+ const char* name) /* in: table name in the form
+ dbname '/' tablename */
{
- char* s;
+ const char* s;
s = strchr(name, '/');
ut_a(s);
if (s) s++;
@@ -680,7 +681,7 @@ dict_init(void)
rw_lock_create(&dict_operation_lock);
rw_lock_set_level(&dict_operation_lock, SYNC_DICT_OPERATION);
- dict_foreign_err_file = tmpfile();
+ dict_foreign_err_file = os_file_create_tmpfile();
mutex_create(&dict_foreign_err_mutex);
mutex_set_level(&dict_foreign_err_mutex, SYNC_ANY_LATCH);
}
@@ -783,23 +784,33 @@ dict_table_add_to_cache(
The clustered index will not always physically contain all
system columns. */
- dict_mem_table_add_col(table, (char *) "DB_ROW_ID", DATA_SYS,
+ dict_mem_table_add_col(table, "DB_ROW_ID", DATA_SYS,
DATA_ROW_ID, 0, 0);
- ut_ad(DATA_ROW_ID == 0);
- dict_mem_table_add_col(table, (char *) "DB_TRX_ID", DATA_SYS,
+#if DATA_ROW_ID != 0
+#error "DATA_ROW_ID != 0"
+#endif
+ dict_mem_table_add_col(table, "DB_TRX_ID", DATA_SYS,
DATA_TRX_ID, 0, 0);
- ut_ad(DATA_TRX_ID == 1);
- dict_mem_table_add_col(table, (char *) "DB_ROLL_PTR", DATA_SYS,
- DATA_ROLL_PTR,
- 0, 0);
- ut_ad(DATA_ROLL_PTR == 2);
+#if DATA_TRX_ID != 1
+#error "DATA_TRX_ID != 1"
+#endif
+ dict_mem_table_add_col(table, "DB_ROLL_PTR", DATA_SYS,
+ DATA_ROLL_PTR, 0, 0);
+#if DATA_ROLL_PTR != 2
+#error "DATA_ROLL_PTR != 2"
+#endif
- dict_mem_table_add_col(table, (char *) "DB_MIX_ID", DATA_SYS,
+ dict_mem_table_add_col(table, "DB_MIX_ID", DATA_SYS,
DATA_MIX_ID, 0, 0);
- ut_ad(DATA_MIX_ID == 3);
- ut_ad(DATA_N_SYS_COLS == 4); /* This assert reminds that if a new
- system column is added to the program,
- it should be dealt with here */
+#if DATA_MIX_ID != 3
+#error "DATA_MIX_ID != 3"
+#endif
+
+ /* This check reminds that if a new system column is added to
+ the program, it should be dealt with here */
+#if DATA_N_SYS_COLS != 4
+#error "DATA_N_SYS_COLS != 4"
+#endif
/* Look for a table with the same name: error if such exists */
{
@@ -1107,7 +1118,9 @@ dict_table_change_id_in_cache(
dulint new_id) /* in: new id to set */
{
ut_ad(table);
+#ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&(dict_sys->mutex)));
+#endif /* UNIV_SYNC_DEBUG */
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
/* Remove the table from the hash table of id's */
@@ -1973,7 +1986,7 @@ dict_foreign_find(
/*==============*/
/* out: foreign constraint */
dict_table_t* table, /* in: table object */
- char* id) /* in: foreign constraint id */
+ const char* id) /* in: foreign constraint id */
{
dict_foreign_t* foreign;
@@ -2367,7 +2380,7 @@ dict_scan_id(
*id = mem_heap_strdupl(heap, s, len);
} else {
/* no heap given: id will point to source string */
- *id = (char*) s;
+ *id = s;
}
return(ptr);
@@ -2750,7 +2763,7 @@ dict_create_foreign_constraints_low(
ut_ad(mutex_own(&(dict_sys->mutex)));
#endif /* UNIV_SYNC_DEBUG */
- table = dict_table_get_low((char*) name);
+ table = dict_table_get_low(name);
if (table == NULL) {
mutex_enter(&dict_foreign_err_mutex);
@@ -3475,9 +3488,9 @@ dict_tree_create(
tree->id = index->id;
UT_LIST_INIT(tree->tree_indexes);
-#ifdef UNIV_DEBUG
+
tree->magic_n = DICT_TREE_MAGIC_N;
-#endif /* UNIV_DEBUG */
+
rw_lock_create(&(tree->lock));
rw_lock_set_level(&(tree->lock), SYNC_INDEX_TREE);
@@ -3916,7 +3929,6 @@ dict_foreign_print_low(
fputs(" )\n", stderr);
}
-#ifdef UNIV_DEBUG
/**************************************************************************
Prints a table data. */
@@ -3936,7 +3948,7 @@ Prints a table data when we know the table name. */
void
dict_table_print_by_name(
/*=====================*/
- char* name)
+ const char* name)
{
dict_table_t* table;
@@ -3949,7 +3961,6 @@ dict_table_print_by_name(
dict_table_print_low(table);
mutex_exit(&(dict_sys->mutex));
}
-#endif /* UNIV_DEBUG */
/**************************************************************************
Prints a table data. */
diff --git a/innobase/dict/dict0load.c b/innobase/dict/dict0load.c
index 071a3b4c684..ee4ae9dd1a1 100644
--- a/innobase/dict/dict0load.c
+++ b/innobase/dict/dict0load.c
@@ -51,7 +51,7 @@ dict_get_first_table_name_in_db(
mtr_start(&mtr);
- sys_tables = dict_table_get_low((char *) "SYS_TABLES");
+ sys_tables = dict_table_get_low("SYS_TABLES");
sys_index = UT_LIST_GET_FIRST(sys_tables->indexes);
tuple = dtuple_create(heap, 1);
@@ -127,7 +127,7 @@ dict_print(void)
mtr_start(&mtr);
- sys_tables = dict_table_get_low((char *) "SYS_TABLES");
+ sys_tables = dict_table_get_low("SYS_TABLES");
sys_index = UT_LIST_GET_FIRST(sys_tables->indexes);
btr_pcur_open_at_index_side(TRUE, sys_index, BTR_SEARCH_LEAF, &pcur,
@@ -207,13 +207,12 @@ dict_check_tablespaces_or_store_max_id(
ulint space_id;
ulint max_space_id = 0;
mtr_t mtr;
- char name[OS_FILE_MAX_PATH];
mutex_enter(&(dict_sys->mutex));
mtr_start(&mtr);
- sys_tables = dict_table_get_low((char *) "SYS_TABLES");
+ sys_tables = dict_table_get_low("SYS_TABLES");
sys_index = UT_LIST_GET_FIRST(sys_tables->indexes);
btr_pcur_open_at_index_side(TRUE, sys_index, BTR_SEARCH_LEAF, &pcur,
@@ -247,9 +246,7 @@ loop:
/* We found one */
- ut_a(len < OS_FILE_MAX_PATH - 10);
- ut_memcpy(name, field, len);
- name[len] = '\0';
+ char* name = mem_strdupl(field, len);
field = rec_get_nth_field(rec, 9, &len);
ut_a(len == 4);
@@ -267,7 +264,9 @@ loop:
fil_space_for_table_exists_in_mem(space_id, name,
TRUE, TRUE);
}
-
+
+ mem_free(name);
+
if (space_id > max_space_id) {
max_space_id = space_id;
}
@@ -312,7 +311,7 @@ dict_load_columns(
mtr_start(&mtr);
- sys_columns = dict_table_get_low((char*) "SYS_COLUMNS");
+ sys_columns = dict_table_get_low("SYS_COLUMNS");
sys_index = UT_LIST_GET_FIRST(sys_columns->indexes);
tuple = dtuple_create(heap, 1);
@@ -342,7 +341,7 @@ dict_load_columns(
ut_ad(len == 4);
ut_a(i == mach_read_from_4(field));
- ut_a(0 == ut_strcmp((char*) "NAME",
+ ut_a(0 == ut_strcmp("NAME",
dict_field_get_col(
dict_index_get_nth_field(
dict_table_get_first_index(sys_columns), 4))->name));
@@ -368,7 +367,7 @@ dict_load_columns(
field = rec_get_nth_field(rec, 7, &len);
col_len = mach_read_from_4(field);
- ut_a(0 == ut_strcmp((char*) "PREC",
+ ut_a(0 == ut_strcmp("PREC",
dict_field_get_col(
dict_index_get_nth_field(
dict_table_get_first_index(sys_columns), 8))->name));
@@ -438,7 +437,7 @@ dict_load_fields(
mtr_start(&mtr);
- sys_fields = dict_table_get_low((char*) "SYS_FIELDS");
+ sys_fields = dict_table_get_low("SYS_FIELDS");
sys_index = UT_LIST_GET_FIRST(sys_fields->indexes);
tuple = dtuple_create(heap, 1);
@@ -489,7 +488,7 @@ dict_load_fields(
prefix_len = 0;
}
- ut_a(0 == ut_strcmp((char*) "COL_NAME",
+ ut_a(0 == ut_strcmp("COL_NAME",
dict_field_get_col(
dict_index_get_nth_field(
dict_table_get_first_index(sys_fields), 4))->name));
@@ -551,7 +550,7 @@ dict_load_indexes(
mtr_start(&mtr);
- sys_indexes = dict_table_get_low((char*) "SYS_INDEXES");
+ sys_indexes = dict_table_get_low("SYS_INDEXES");
sys_index = UT_LIST_GET_FIRST(sys_indexes->indexes);
tuple = dtuple_create(heap, 1);
@@ -594,7 +593,7 @@ dict_load_indexes(
ut_ad(len == 8);
id = mach_read_from_8(field);
- ut_a(0 == ut_strcmp((char*) "NAME",
+ ut_a(0 == ut_strcmp("NAME",
dict_field_get_col(
dict_index_get_nth_field(
dict_table_get_first_index(sys_indexes), 4))->name));
@@ -611,7 +610,7 @@ dict_load_indexes(
field = rec_get_nth_field(rec, 7, &len);
space = mach_read_from_4(field);
- ut_a(0 == ut_strcmp((char*) "PAGE_NO",
+ ut_a(0 == ut_strcmp("PAGE_NO",
dict_field_get_col(
dict_index_get_nth_field(
dict_table_get_first_index(sys_indexes), 8))->name));
@@ -654,7 +653,7 @@ dict_load_indexes(
&& ((type & DICT_CLUSTERED)
|| ((table == dict_sys->sys_tables)
&& (name_len == (sizeof "ID_IND") - 1)
- && (0 == ut_memcmp(name_buf, (char*) "ID_IND",
+ && (0 == ut_memcmp(name_buf, "ID_IND",
name_len))))) {
/* The index was created in memory already at booting
@@ -721,7 +720,7 @@ dict_load_table(
mtr_start(&mtr);
- sys_tables = dict_table_get_low((char *) "SYS_TABLES");
+ sys_tables = dict_table_get_low("SYS_TABLES");
sys_index = UT_LIST_GET_FIRST(sys_tables->indexes);
tuple = dtuple_create(heap, 1);
@@ -757,7 +756,7 @@ dict_load_table(
return(NULL);
}
- ut_a(0 == ut_strcmp((char *) "SPACE",
+ ut_a(0 == ut_strcmp("SPACE",
dict_field_get_col(
dict_index_get_nth_field(
dict_table_get_first_index(sys_tables), 9))->name));
@@ -782,7 +781,7 @@ dict_load_table(
}
}
- ut_a(0 == ut_strcmp((char *) "N_COLS",
+ ut_a(0 == ut_strcmp("N_COLS",
dict_field_get_col(
dict_index_get_nth_field(
dict_table_get_first_index(sys_tables), 4))->name));
@@ -794,7 +793,7 @@ dict_load_table(
table->ibd_file_missing = ibd_file_missing;
- ut_a(0 == ut_strcmp((char *) "ID",
+ ut_a(0 == ut_strcmp("ID",
dict_field_get_col(
dict_index_get_nth_field(
dict_table_get_first_index(sys_tables), 3))->name));
@@ -983,7 +982,7 @@ static
void
dict_load_foreign_cols(
/*===================*/
- char* id, /* in: foreign constraint id as a null-
+ const char* id, /* in: foreign constraint id as a null-
terminated string */
dict_foreign_t* foreign)/* in: foreign constraint object */
{
@@ -1009,7 +1008,7 @@ dict_load_foreign_cols(
foreign->n_fields * sizeof(void*));
mtr_start(&mtr);
- sys_foreign_cols = dict_table_get_low((char *) "SYS_FOREIGN_COLS");
+ sys_foreign_cols = dict_table_get_low("SYS_FOREIGN_COLS");
sys_index = UT_LIST_GET_FIRST(sys_foreign_cols->indexes);
tuple = dtuple_create(foreign->heap, 1);
@@ -1056,9 +1055,9 @@ static
ulint
dict_load_foreign(
/*==============*/
- /* out: DB_SUCCESS or error code */
- char* id) /* in: foreign constraint id as a null-terminated
- string */
+ /* out: DB_SUCCESS or error code */
+ const char* id) /* in: foreign constraint id as a
+ null-terminated string */
{
dict_foreign_t* foreign;
dict_table_t* sys_foreign;
@@ -1081,7 +1080,7 @@ dict_load_foreign(
mtr_start(&mtr);
- sys_foreign = dict_table_get_low((char *) "SYS_FOREIGN");
+ sys_foreign = dict_table_get_low("SYS_FOREIGN");
sys_index = UT_LIST_GET_FIRST(sys_foreign->indexes);
tuple = dtuple_create(heap2, 1);
@@ -1207,7 +1206,7 @@ dict_load_foreigns(
ut_ad(mutex_own(&(dict_sys->mutex)));
#endif /* UNIV_SYNC_DEBUG */
- sys_foreign = dict_table_get_low((char *) "SYS_FOREIGN");
+ sys_foreign = dict_table_get_low("SYS_FOREIGN");
if (sys_foreign == NULL) {
/* No foreign keys defined yet in this database */
diff --git a/innobase/dict/dict0mem.c b/innobase/dict/dict0mem.c
index 936b06b1905..8f05475df47 100644
--- a/innobase/dict/dict0mem.c
+++ b/innobase/dict/dict0mem.c
@@ -87,9 +87,9 @@ dict_mem_table_create(
mutex_set_level(&(table->autoinc_mutex), SYNC_DICT_AUTOINC_MUTEX);
table->autoinc_inited = FALSE;
-#ifdef UNIV_DEBUG
+
table->magic_n = DICT_TABLE_MAGIC_N;
-#endif /* UNIV_DEBUG */
+
return(table);
}
@@ -205,9 +205,7 @@ dict_mem_index_create(
index->stat_n_diff_key_vals = NULL;
index->cached = FALSE;
-#ifdef UNIV_DEBUG
index->magic_n = DICT_INDEX_MAGIC_N;
-#endif /* UNIV_DEBUG */
return(index);
}
diff --git a/innobase/fil/fil0fil.c b/innobase/fil/fil0fil.c
index 28eea0ba188..59fbd6f785d 100644
--- a/innobase/fil/fil0fil.c
+++ b/innobase/fil/fil0fil.c
@@ -274,7 +274,7 @@ fil_get_space_id_for_table(
/*=======================*/
/* out: space id, ULINT_UNDEFINED if not
found */
- char* name); /* in: table name in the standard
+ const char* name); /* in: table name in the standard
'databasename/tablename' format */
@@ -463,8 +463,9 @@ fil_node_open_file(
ulint size_high;
ibool ret;
+#ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&(system->mutex)));
-
+#endif /* UNIV_SYNC_DEBUG */
ut_a(node->n_pending == 0);
ut_a(node->open == FALSE);
@@ -575,8 +576,9 @@ fil_try_to_close_file_in_LRU(
fil_system_t* system = fil_system;
fil_node_t* node;
+#ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&(system->mutex)));
-
+#endif /* UNIV_SYNC_DEBUG */
node = UT_LIST_GET_LAST(system->LRU);
if (print_info) {
@@ -630,7 +632,9 @@ fil_mutex_enter_and_prepare_for_io(
ulint count = 0;
ulint count2 = 0;
+#ifdef UNIV_SYNC_DEBUG
ut_ad(!mutex_own(&(system->mutex)));
+#endif /* UNIV_SYNC_DEBUG */
retry:
mutex_enter(&(system->mutex));
@@ -1311,13 +1315,12 @@ fil_write_lsn_and_arch_no_to_file(
ulint sum_of_sizes, /* in: combined size of previous files in
space, in database pages */
dulint lsn, /* in: lsn to write */
- ulint arch_log_no) /* in: archived log number to write */
+ ulint arch_log_no /* in: archived log number to write */
+ __attribute__((unused)))
{
byte* buf1;
byte* buf;
- UT_NOT_USED(arch_log_no);
-
buf1 = mem_alloc(2 * UNIV_PAGE_SIZE);
buf = ut_align(buf1, UNIV_PAGE_SIZE);
@@ -1396,17 +1399,17 @@ fil_read_flushed_lsn_and_arch_log_no(
os_file_t data_file, /* in: open data file */
ibool one_read_already, /* in: TRUE if min and max parameters
below already contain sensible data */
- dulint* min_flushed_lsn, /* in/out: */
+#ifdef UNIV_LOG_ARCHIVE
ulint* min_arch_log_no, /* in/out: */
- dulint* max_flushed_lsn, /* in/out: */
- ulint* max_arch_log_no) /* in/out: */
+ ulint* max_arch_log_no, /* in/out: */
+#endif /* UNIV_LOG_ARCHIVE */
+ dulint* min_flushed_lsn, /* in/out: */
+ dulint* max_flushed_lsn) /* in/out: */
{
byte* buf;
byte* buf2;
dulint flushed_lsn;
- ulint arch_log_no = 0; /* since InnoDB does not archive
- its own logs under MySQL, this
- parameter is not relevant */
+
buf2 = ut_malloc(2 * UNIV_PAGE_SIZE);
/* Align the memory for a possible read from a raw device */
buf = ut_align(buf2, UNIV_PAGE_SIZE);
@@ -1420,9 +1423,10 @@ fil_read_flushed_lsn_and_arch_log_no(
if (!one_read_already) {
*min_flushed_lsn = flushed_lsn;
*max_flushed_lsn = flushed_lsn;
+#ifdef UNIV_LOG_ARCHIVE
*min_arch_log_no = arch_log_no;
*max_arch_log_no = arch_log_no;
-
+#endif /* UNIV_LOG_ARCHIVE */
return;
}
@@ -1432,12 +1436,14 @@ fil_read_flushed_lsn_and_arch_log_no(
if (ut_dulint_cmp(*max_flushed_lsn, flushed_lsn) < 0) {
*max_flushed_lsn = flushed_lsn;
}
+#ifdef UNIV_LOG_ARCHIVE
if (*min_arch_log_no > arch_log_no) {
*min_arch_log_no = arch_log_no;
}
if (*max_arch_log_no < arch_log_no) {
*max_arch_log_no = arch_log_no;
}
+#endif /* UNIV_LOG_ARCHIVE */
}
/*================ SINGLE-TABLE TABLESPACES ==========================*/
@@ -1507,33 +1513,31 @@ fil_decr_pending_ibuf_merges(
mutex_exit(&(system->mutex));
}
-/************************************************************
-Creates the database directory for a table if it does not exist yet. */
static
void
fil_create_directory_for_tablename(
/*===============================*/
- char* name) /* in: name in the standard 'databasename/tablename'
- format */
+ const char* name) /* in: name in the standard
+ 'databasename/tablename' format */
{
- char* ptr;
- char path[OS_FILE_MAX_PATH];
+ const char* namend;
+ char* path;
+ ulint len;
- sprintf(path, "%s/%s", fil_path_to_mysql_datadir, name);
+ len = strlen(fil_path_to_mysql_datadir);
+ namend = strchr(name, '/');
+ ut_a(namend);
+ path = mem_alloc(len + (namend - name) + 2);
- ptr = path + ut_strlen(path);
-
- while (*ptr != '/') {
- ptr--;
-
- ut_a(ptr >= path);
- }
-
- *ptr = '\0';
+ memcpy(path, fil_path_to_mysql_datadir, len);
+ path[len] = '/';
+ memcpy(path + len + 1, name, namend - name);
+ path[len + (namend - name) + 1] = 0;
srv_normalize_path_for_win(path);
ut_a(os_file_create_directory(path, FALSE));
+ mem_free(path);
}
#ifndef UNIV_HOTBACKUP
@@ -1615,10 +1619,10 @@ fil_op_log_parse_or_replay(
the tablespace in question; otherwise
ignored */
{
- ulint name_len;
- ulint new_name_len;
- char* name;
- char* new_name = NULL;
+ ulint name_len;
+ ulint new_name_len;
+ const char* name;
+ const char* new_name = NULL;
if (end_ptr < ptr + 2) {
@@ -1634,7 +1638,7 @@ fil_op_log_parse_or_replay(
return(NULL);
}
- name = (char*) ptr;
+ name = (const char*) ptr;
ptr += name_len;
@@ -1653,7 +1657,7 @@ fil_op_log_parse_or_replay(
return(NULL);
}
- new_name = (char*) ptr;
+ new_name = (const char*) ptr;
ptr += new_name_len;
}
@@ -1746,7 +1750,7 @@ fil_delete_tablespace(
fil_space_t* space;
fil_node_t* node;
ulint count = 0;
- char path[OS_FILE_MAX_PATH];
+ char* path;
ut_a(id != 0);
stop_ibuf_merges:
@@ -1803,11 +1807,8 @@ try_again:
}
ut_a(space);
- ut_a(strlen(space->name) < OS_FILE_MAX_PATH);
ut_a(space->n_pending_ibuf_merges == 0);
- strcpy(path, space->name);
-
space->is_being_deleted = TRUE;
ut_a(UT_LIST_GET_LEN(space->chain) == 1);
@@ -1831,6 +1832,8 @@ try_again:
goto try_again;
}
+ path = mem_strdup(space->name);
+
mutex_exit(&(system->mutex));
#ifndef UNIV_HOTBACKUP
/* Invalidate in the buffer pool all pages belonging to the
@@ -1848,29 +1851,30 @@ try_again:
if (success) {
success = os_file_delete(path);
+ }
- if (success) {
- /* Write a log record about the deletion of the .ibd
- file, so that ibbackup can replay it in the
- --apply-log phase. We use a dummy mtr and the familiar
- log write mechanism. */
+ if (success) {
#ifndef UNIV_HOTBACKUP
- {
- mtr_t mtr;
+ /* Write a log record about the deletion of the .ibd
+ file, so that ibbackup can replay it in the
+ --apply-log phase. We use a dummy mtr and the familiar
+ log write mechanism. */
+ mtr_t mtr;
- /* When replaying the operation in ibbackup, do not try
- to write any log record */
- mtr_start(&mtr);
+ /* When replaying the operation in ibbackup, do not try
+ to write any log record */
+ mtr_start(&mtr);
- fil_op_write_log(MLOG_FILE_DELETE, id, path,
- NULL, &mtr);
- mtr_commit(&mtr);
- }
+ fil_op_write_log(MLOG_FILE_DELETE, id, path, NULL, &mtr);
+ mtr_commit(&mtr);
#endif
- return(TRUE);
- }
+ mem_free(path);
+
+ return(TRUE);
}
+ mem_free(path);
+
return(FALSE);
}
@@ -1916,11 +1920,11 @@ fil_rename_tablespace_in_mem(
/* out: TRUE if success */
fil_space_t* space, /* in: tablespace memory object */
fil_node_t* node, /* in: file node of that tablespace */
- char* path) /* in: new name */
+ const char* path) /* in: new name */
{
fil_system_t* system = fil_system;
fil_space_t* space2;
- char* old_name = space->name;
+ const char* old_name = space->name;
HASH_SEARCH(name_hash, system->name_hash, ut_fold_string(old_name),
space2, 0 == strcmp(old_name, space2->name));
@@ -1945,11 +1949,8 @@ fil_rename_tablespace_in_mem(
mem_free(space->name);
mem_free(node->name);
- space->name = mem_alloc(strlen(path) + 1);
- node->name = mem_alloc(strlen(path) + 1);
-
- strcpy(space->name, path);
- strcpy(node->name, path);
+ space->name = mem_strdup(path);
+ node->name = mem_strdup(path);
HASH_INSERT(fil_space_t, name_hash, system->name_hash,
ut_fold_string(path), space);
@@ -1957,6 +1958,29 @@ fil_rename_tablespace_in_mem(
}
/***********************************************************************
+Allocates a file name for a single-table tablespace.
+The string must be freed by caller with mem_free(). */
+static
+char*
+fil_make_ibd_name(
+/*==============*/
+ /* out, own: file name */
+ const char* name) /* in: table name */
+{
+ ulint namelen = strlen(name);
+ ulint dirlen = strlen(fil_path_to_mysql_datadir);
+ char* filename = mem_alloc(namelen + dirlen + sizeof "/.ibd");
+
+ memcpy(filename, fil_path_to_mysql_datadir, dirlen);
+ filename[dirlen] = '/';
+ memcpy(filename + dirlen + 1, name, namelen);
+ memcpy(filename + dirlen + namelen + 1, ".ibd", sizeof ".ibd");
+
+ srv_normalize_path_for_win(filename);
+ return(filename);
+}
+
+/***********************************************************************
Renames a single-table tablespace. The tablespace must be cached in the
tablespace memory cache. */
@@ -1978,14 +2002,14 @@ fil_rename_tablespace(
fil_space_t* space;
fil_node_t* node;
ulint count = 0;
- char* path = NULL;
+ char* path;
ibool old_name_was_specified = TRUE;
- char old_path[OS_FILE_MAX_PATH];
+ char* old_path;
ut_a(id != 0);
if (old_name == NULL) {
- old_name = (char*)"(name not specified)";
+ old_name = "(name not specified)";
old_name_was_specified = FALSE;
}
retry:
@@ -2059,48 +2083,33 @@ retry:
/* Check that the old name in the space is right */
if (old_name_was_specified) {
- ut_a(strlen(old_name) + strlen(fil_path_to_mysql_datadir)
- < OS_FILE_MAX_PATH - 10);
- sprintf(old_path, "%s/%s.ibd", fil_path_to_mysql_datadir,
- old_name);
- srv_normalize_path_for_win(old_path);
+ old_path = fil_make_ibd_name(old_name);
ut_a(strcmp(space->name, old_path) == 0);
ut_a(strcmp(node->name, old_path) == 0);
} else {
- sprintf(old_path, "%s", space->name);
+ old_path = mem_strdup(space->name);
}
/* Rename the tablespace and the node in the memory cache */
-
- ut_a(strlen(new_name) + strlen(fil_path_to_mysql_datadir)
- < OS_FILE_MAX_PATH - 10);
- path = mem_alloc(OS_FILE_MAX_PATH);
-
- sprintf(path, "%s/%s.ibd", fil_path_to_mysql_datadir, new_name);
-
- srv_normalize_path_for_win(path);
-
+ path = fil_make_ibd_name(new_name);
success = fil_rename_tablespace_in_mem(space, node, path);
- if (!success) {
-
- goto func_exit;
- }
-
- success = os_file_rename(old_path, path);
+ if (success) {
+ success = os_file_rename(old_path, path);
- if (!success) {
- /* We have to revert the changes we made to the tablespace
- memory cache */
+ if (!success) {
+ /* We have to revert the changes we made
+ to the tablespace memory cache */
- ut_a(fil_rename_tablespace_in_mem(space, node, old_path));
+ ut_a(fil_rename_tablespace_in_mem(space, node,
+ old_path));
+ }
}
-func_exit:
- if (path) {
- mem_free(path);
- }
+ mem_free(path);
+ mem_free(old_path);
+
space->stop_ios = FALSE;
mutex_exit(&(system->mutex));
@@ -2142,17 +2151,14 @@ fil_create_new_single_table_tablespace(
os_file_t file;
ibool ret;
ulint err;
+ byte* buf2;
byte* page;
ibool success;
- char path[OS_FILE_MAX_PATH];
+ char* path;
ut_a(size >= FIL_IBD_FILE_INITIAL_SIZE);
- ut_a(strlen(tablename) + strlen(fil_path_to_mysql_datadir)
- < OS_FILE_MAX_PATH - 10);
- sprintf(path, "%s/%s.ibd", fil_path_to_mysql_datadir, tablename);
-
- srv_normalize_path_for_win(path);
+ path = fil_make_ibd_name(tablename);
file = os_file_create(path, OS_FILE_CREATE, OS_FILE_NORMAL,
OS_DATA_FILE, &ret);
@@ -2175,26 +2181,32 @@ fil_create_new_single_table_tablespace(
"InnoDB: resolve the problem by removing the file %s\n"
"InnoDB: under the 'datadir' of MySQL.\n", path);
+ mem_free(path);
return(DB_TABLESPACE_ALREADY_EXISTS);
}
if (err == OS_FILE_DISK_FULL) {
+ mem_free(path);
return(DB_OUT_OF_FILE_SPACE);
}
+ mem_free(path);
return(DB_ERROR);
}
- page = ut_malloc(UNIV_PAGE_SIZE);
+ buf2 = ut_malloc(2 * UNIV_PAGE_SIZE);
+ /* Align the memory for file i/o if we might have O_DIRECT set */
+ page = ut_align(buf2, UNIV_PAGE_SIZE);
ret = os_file_set_size(path, file, size * UNIV_PAGE_SIZE, 0);
if (!ret) {
- ut_free(page);
+ ut_free(buf2);
os_file_close(file);
os_file_delete(path);
+ mem_free(path);
return(DB_OUT_OF_FILE_SPACE);
}
@@ -2205,10 +2217,13 @@ fil_create_new_single_table_tablespace(
/* printf("Creating tablespace %s id %lu\n", path, *space_id); */
if (*space_id == ULINT_UNDEFINED) {
- ut_free(page);
+ ut_free(buf2);
+ error_exit:
os_file_close(file);
+ error_exit2:
os_file_delete(path);
+ mem_free(path);
return(DB_ERROR);
}
@@ -2229,16 +2244,12 @@ fil_create_new_single_table_tablespace(
ret = os_file_write(path, file, page, 0, 0, UNIV_PAGE_SIZE);
- ut_free(page);
+ ut_free(buf2);
if (!ret) {
fprintf(stderr,
"InnoDB: Error: could not write the first page to tablespace %s\n", path);
-
- os_file_close(file);
- os_file_delete(path);
-
- return(DB_ERROR);
+ goto error_exit;
}
ret = os_file_flush(file);
@@ -2246,27 +2257,19 @@ fil_create_new_single_table_tablespace(
if (!ret) {
fprintf(stderr,
"InnoDB: Error: file flush of tablespace %s failed\n", path);
-
- os_file_close(file);
- os_file_delete(path);
-
- return(DB_ERROR);
+ goto error_exit;
}
os_file_close(file);
if (*space_id == ULINT_UNDEFINED) {
- os_file_delete(path);
-
- return(DB_ERROR);
+ goto error_exit2;
}
success = fil_space_create(path, *space_id, FIL_TABLESPACE);
if (!success) {
- os_file_delete(path);
-
- return(DB_ERROR);
+ goto error_exit2;
}
fil_node_create(path, size, *space_id, FALSE);
@@ -2282,6 +2285,7 @@ fil_create_new_single_table_tablespace(
mtr_commit(&mtr);
}
#endif
+ mem_free(path);
return(DB_SUCCESS);
}
@@ -2308,6 +2312,7 @@ fil_reset_too_high_lsns(
os_file_t file;
char* filepath;
byte* page;
+ byte* buf2;
dulint flush_lsn;
ulint space_id;
ib_longlong file_size;
@@ -2315,25 +2320,21 @@ fil_reset_too_high_lsns(
ulint page_no;
ibool success;
- filepath = ut_malloc(OS_FILE_MAX_PATH);
-
- ut_a(strlen(name) < OS_FILE_MAX_PATH - 10);
-
- sprintf(filepath, "%s/%s.ibd", fil_path_to_mysql_datadir, name);
-
- srv_normalize_path_for_win(filepath);
+ filepath = fil_make_ibd_name(name);
file = os_file_create_simple_no_error_handling(filepath, OS_FILE_OPEN,
OS_FILE_READ_WRITE, &success);
if (!success) {
- ut_free(filepath);
+ mem_free(filepath);
return(FALSE);
}
/* Read the first page of the tablespace */
- page = ut_malloc(UNIV_PAGE_SIZE);
+ buf2 = ut_malloc(2 * UNIV_PAGE_SIZE);
+ /* Align the memory for file i/o if we might have O_DIRECT set */
+ page = ut_align(buf2, UNIV_PAGE_SIZE);
success = os_file_read(file, page, 0, 0, UNIV_PAGE_SIZE);
if (!success) {
@@ -2420,8 +2421,8 @@ fil_reset_too_high_lsns(
success = os_file_flush(file);
func_exit:
os_file_close(file);
- ut_free(page);
- ut_free(filepath);
+ ut_free(buf2);
+ mem_free(filepath);
return(success);
}
@@ -2446,17 +2447,12 @@ fil_open_single_table_tablespace(
os_file_t file;
char* filepath;
ibool success;
+ byte* buf2;
byte* page;
ulint space_id;
ibool ret = TRUE;
- filepath = ut_malloc(OS_FILE_MAX_PATH);
-
- ut_a(strlen(name) < OS_FILE_MAX_PATH - 10);
-
- sprintf(filepath, "%s/%s.ibd", fil_path_to_mysql_datadir, name);
-
- srv_normalize_path_for_win(filepath);
+ filepath = fil_make_ibd_name(name);
file = os_file_create_simple_no_error_handling(filepath, OS_FILE_OPEN,
OS_FILE_READ_ONLY, &success);
@@ -2475,14 +2471,16 @@ fil_open_single_table_tablespace(
"InnoDB: You can look from section 15.1 of http://www.innodb.com/ibman.html\n"
"InnoDB: how to resolve the issue.\n");
- ut_free(filepath);
+ mem_free(filepath);
return(FALSE);
}
/* Read the first page of the tablespace */
- page = ut_malloc(UNIV_PAGE_SIZE);
+ buf2 = ut_malloc(2 * UNIV_PAGE_SIZE);
+ /* Align the memory for file i/o if we might have O_DIRECT set */
+ page = ut_align(buf2, UNIV_PAGE_SIZE);
success = os_file_read(file, page, 0, 0, UNIV_PAGE_SIZE);
@@ -2519,12 +2517,34 @@ fil_open_single_table_tablespace(
fil_node_create(filepath, 0, space_id, FALSE);
func_exit:
os_file_close(file);
- ut_free(page);
- ut_free(filepath);
+ ut_free(buf2);
+ mem_free(filepath);
return(ret);
}
+#ifdef UNIV_HOTBACKUP
+/***********************************************************************
+Allocates a file name for an old version of a single-table tablespace.
+The string must be freed by caller with mem_free()! */
+static
+char*
+fil_make_ibbackup_old_name(
+/*=======================*/
+ /* out, own: file name */
+ const char* name) /* in: original file name */
+{
+ static const char suffix[] = "_ibbackup_old_vers_";
+ ulint len = strlen(name);
+ char* path = mem_alloc(len + (15 + sizeof suffix));
+
+ memcpy(path, name, len);
+ memcpy(path + len, suffix, (sizeof suffix) - 1);
+ ut_sprintf_timestamp_without_extra_chars(path + len + sizeof suffix);
+ return(path);
+}
+#endif /* UNIV_HOTBACKUP */
+
/************************************************************************
Opens an .ibd file and adds the associated single-table tablespace to the
InnoDB fil0fil.c data structures. */
@@ -2532,13 +2552,14 @@ static
void
fil_load_single_table_tablespace(
/*=============================*/
- char* dbname, /* in: database name */
- char* filename) /* in: file name (not a path), including the
- .ibd extension */
+ const char* dbname, /* in: database name */
+ const char* filename) /* in: file name (not a path),
+ including the .ibd extension */
{
os_file_t file;
char* filepath;
ibool success;
+ byte* buf2;
byte* page;
ulint space_id;
ulint size_low;
@@ -2547,10 +2568,8 @@ fil_load_single_table_tablespace(
#ifdef UNIV_HOTBACKUP
fil_space_t* space;
#endif
- filepath = ut_malloc(OS_FILE_MAX_PATH);
-
- ut_a(strlen(dbname) + strlen(filename)
- + strlen(fil_path_to_mysql_datadir) < OS_FILE_MAX_PATH - 100);
+ filepath = mem_alloc(strlen(dbname) + strlen(filename)
+ + strlen(fil_path_to_mysql_datadir) + 3);
sprintf(filepath, "%s/%s/%s", fil_path_to_mysql_datadir, dbname,
filename);
@@ -2564,11 +2583,30 @@ fil_load_single_table_tablespace(
fprintf(stderr,
"InnoDB: Error: could not open single-table tablespace file\n"
-"InnoDB: %s!", filepath);
-
- ut_free(filepath);
+"InnoDB: %s!\n"
+"InnoDB: We do not continue crash recovery, because the table will become\n"
+"InnoDB: corrupt if we cannot apply the log records in the InnoDB log to it.\n"
+"InnoDB: To fix the problem and start mysqld:\n"
+"InnoDB: 1) If there is a permission problem in the file and mysqld cannot\n"
+"InnoDB: open the file, you should modify the permissions.\n"
+"InnoDB: 2) If the table is not needed, or you can restore it from a backup,\n"
+"InnoDB: then you can remove the .ibd file, and InnoDB will do a normal\n"
+"InnoDB: crash recovery and ignore that table.\n"
+"InnoDB: 3) If the file system or the disk is broken, and you cannot remove\n"
+"InnoDB: the .ibd file, you can set innodb_force_recovery > 0 in my.cnf\n"
+"InnoDB: and force InnoDB to continue crash recovery here.\n", filepath);
+
+ mem_free(filepath);
+
+ if (srv_force_recovery > 0) {
+ fprintf(stderr,
+"InnoDB: innodb_force_recovery was set to %lu. Continuing crash recovery\n"
+"InnoDB: even though we cannot access the .ibd file of this table.\n",
+ srv_force_recovery);
+ return;
+ }
- return;
+ exit(1);
}
success = os_file_get_size(file, &size_low, &size_high);
@@ -2579,14 +2617,36 @@ fil_load_single_table_tablespace(
fprintf(stderr,
"InnoDB: Error: could not measure the size of single-table tablespace file\n"
-"InnoDB: %s!", filepath);
+"InnoDB: %s!\n"
+"InnoDB: We do not continue crash recovery, because the table will become\n"
+"InnoDB: corrupt if we cannot apply the log records in the InnoDB log to it.\n"
+"InnoDB: To fix the problem and start mysqld:\n"
+"InnoDB: 1) If there is a permission problem in the file and mysqld cannot\n"
+"InnoDB: access the file, you should modify the permissions.\n"
+"InnoDB: 2) If the table is not needed, or you can restore it from a backup,\n"
+"InnoDB: then you can remove the .ibd file, and InnoDB will do a normal\n"
+"InnoDB: crash recovery and ignore that table.\n"
+"InnoDB: 3) If the file system or the disk is broken, and you cannot remove\n"
+"InnoDB: the .ibd file, you can set innodb_force_recovery > 0 in my.cnf\n"
+"InnoDB: and force InnoDB to continue crash recovery here.\n", filepath);
os_file_close(file);
- ut_free(filepath);
+ mem_free(filepath);
- return;
+ if (srv_force_recovery > 0) {
+ fprintf(stderr,
+"InnoDB: innodb_force_recovery was set to %lu. Continuing crash recovery\n"
+"InnoDB: even though we cannot access the .ibd file of this table.\n",
+ srv_force_recovery);
+ return;
+ }
+
+ exit(1);
}
+ /* TODO: What to do in other cases where we cannot access an .ibd
+ file during a crash recovery? */
+
/* Every .ibd file is created >= 4 pages in size. Smaller files
cannot be ok. */
@@ -2599,14 +2659,16 @@ fil_load_single_table_tablespace(
(ulong) size_high,
(ulong) size_low, (ulong) (4 * UNIV_PAGE_SIZE));
os_file_close(file);
- ut_free(filepath);
+ mem_free(filepath);
return;
}
#endif
/* Read the first page of the tablespace if the size big enough */
- page = ut_malloc(UNIV_PAGE_SIZE);
+ buf2 = ut_malloc(2 * UNIV_PAGE_SIZE);
+ /* Align the memory for file i/o if we might have O_DIRECT set */
+ page = ut_align(buf2, UNIV_PAGE_SIZE);
if (size >= FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {
success = os_file_read(file, page, 0, 0, UNIV_PAGE_SIZE);
@@ -2639,16 +2701,12 @@ fil_load_single_table_tablespace(
filepath, space_id, filepath, size);
os_file_close(file);
- new_path = ut_malloc(OS_FILE_MAX_PATH);
-
- sprintf(new_path, "%s_ibbackup_old_vers_", filepath);
- ut_sprintf_timestamp_without_extra_chars(
- new_path + ut_strlen(new_path));
+ new_path = fil_make_ibbackup_old_name(filepath);
ut_a(os_file_rename(filepath, new_path));
- ut_free(page);
- ut_free(filepath);
- ut_free(new_path);
+ ut_free(buf2);
+ mem_free(filepath);
+ mem_free(new_path);
return;
}
@@ -2676,18 +2734,15 @@ fil_load_single_table_tablespace(
space->name);
os_file_close(file);
- new_path = ut_malloc(OS_FILE_MAX_PATH);
+ new_path = fil_make_ibbackup_old_name(filepath);
- sprintf(new_path, "%s_ibbackup_old_vers_", filepath);
- ut_sprintf_timestamp_without_extra_chars(
- new_path + ut_strlen(new_path));
mutex_exit(&(fil_system->mutex));
ut_a(os_file_rename(filepath, new_path));
- ut_free(page);
- ut_free(filepath);
- ut_free(new_path);
+ ut_free(buf2);
+ mem_free(filepath);
+ mem_free(new_path);
return;
}
@@ -2706,8 +2761,8 @@ fil_load_single_table_tablespace(
fil_node_create(filepath, 0, space_id, FALSE);
func_exit:
os_file_close(file);
- ut_free(page);
- ut_free(filepath);
+ ut_free(buf2);
+ mem_free(filepath);
}
/************************************************************************
@@ -2724,7 +2779,8 @@ fil_load_single_table_tablespaces(void)
/* out: DB_SUCCESS or error number */
{
int ret;
- char* dbpath;
+ char* dbpath = NULL;
+ ulint dbpath_len = 100;
os_file_dir_t dir;
os_file_dir_t dbdir;
os_file_stat_t dbinfo;
@@ -2732,21 +2788,22 @@ fil_load_single_table_tablespaces(void)
/* The datadir of MySQL is always the default directory of mysqld */
- dir = os_file_opendir((char*) fil_path_to_mysql_datadir, TRUE);
+ dir = os_file_opendir(fil_path_to_mysql_datadir, TRUE);
if (dir == NULL) {
return(DB_ERROR);
}
- dbpath = ut_malloc(OS_FILE_MAX_PATH);
+ dbpath = mem_alloc(dbpath_len);
/* Scan all directories under the datadir. They are the database
directories of MySQL. */
- ret = os_file_readdir_next_file((char*) fil_path_to_mysql_datadir, dir,
+ ret = os_file_readdir_next_file(fil_path_to_mysql_datadir, dir,
&dbinfo);
while (ret == 0) {
+ ulint len;
/* printf("Looking at %s in datadir\n", dbinfo.name); */
if (dbinfo.type == OS_FILE_TYPE_FILE
@@ -2757,9 +2814,18 @@ fil_load_single_table_tablespaces(void)
/* We found a symlink or a directory; try opening it to see
if a symlink is a directory */
-
- ut_a(strlen(dbinfo.name) < OS_FILE_MAX_PATH - 10);
+ len = strlen(fil_path_to_mysql_datadir)
+ + strlen (dbinfo.name) + 2;
+ if (len > dbpath_len) {
+ dbpath_len = len;
+
+ if (dbpath) {
+ mem_free(dbpath);
+ }
+
+ dbpath = mem_alloc(dbpath_len);
+ }
sprintf(dbpath, "%s/%s", fil_path_to_mysql_datadir,
dbinfo.name);
srv_normalize_path_for_win(dbpath);
@@ -2805,11 +2871,11 @@ next_file_item:
}
next_datadir_item:
- ret = os_file_readdir_next_file((char*) fil_path_to_mysql_datadir,
+ ret = os_file_readdir_next_file(fil_path_to_mysql_datadir,
dir, &dbinfo);
}
- ut_free(dbpath);
+ mem_free(dbpath);
/* At the end of directory we should get 1 as the return value, -1
if there was an error */
@@ -2962,14 +3028,13 @@ fil_space_for_table_exists_in_mem(
fil_system_t* system = fil_system;
fil_space_t* namespace;
fil_space_t* space;
- char path[OS_FILE_MAX_PATH];
+ char* path;
ut_ad(system);
mutex_enter(&(system->mutex));
- sprintf(path, "%s/%s.ibd", fil_path_to_mysql_datadir, name);
- srv_normalize_path_for_win(path);
+ path = fil_make_ibd_name(name);
/* Look if there is a space with the same id */
@@ -2988,6 +3053,7 @@ fil_space_for_table_exists_in_mem(
space->mark = TRUE;
}
+ mem_free(path);
mutex_exit(&(system->mutex));
return(TRUE);
@@ -2995,6 +3061,7 @@ fil_space_for_table_exists_in_mem(
if (!print_error_if_does_not_exist) {
+ mem_free(path);
mutex_exit(&(system->mutex));
return(FALSE);
@@ -3024,6 +3091,7 @@ fil_space_for_table_exists_in_mem(
"InnoDB: You can look from section 15.1 of http://www.innodb.com/ibman.html\n"
"InnoDB: how to resolve the issue.\n");
+ mem_free(path);
mutex_exit(&(system->mutex));
return(FALSE);
@@ -3047,11 +3115,13 @@ fil_space_for_table_exists_in_mem(
"InnoDB: You can look from section 15.1 of http://www.innodb.com/ibman.html\n"
"InnoDB: how to resolve the issue.\n");
+ mem_free(path);
mutex_exit(&(system->mutex));
return(FALSE);
}
+ mem_free(path);
mutex_exit(&(system->mutex));
return(FALSE);
@@ -3066,20 +3136,19 @@ fil_get_space_id_for_table(
/*=======================*/
/* out: space id, ULINT_UNDEFINED if not
found */
- char* name) /* in: table name in the standard
+ const char* name) /* in: table name in the standard
'databasename/tablename' format */
{
fil_system_t* system = fil_system;
fil_space_t* namespace;
ulint id = ULINT_UNDEFINED;
- char path[OS_FILE_MAX_PATH];
+ char* path;
ut_ad(system);
mutex_enter(&(system->mutex));
- sprintf(path, "%s/%s.ibd", fil_path_to_mysql_datadir, name);
- srv_normalize_path_for_win(path);
+ path = fil_make_ibd_name(name);
/* Look if there is a space with the same name; the name is the
directory path to the file */
@@ -3091,6 +3160,8 @@ fil_get_space_id_for_table(
id = namespace->id;
}
+ mem_free(path);
+
mutex_exit(&(system->mutex));
return(id);
@@ -3219,7 +3290,7 @@ fil_extend_space_to_desired_size(
/************************************************************************
Extends all tablespaces to the size stored in the space header. During the
ibbackup --apply-log phase we extended the spaces on-demand so that log records
-could be appllied, but that may have left spaces still too small compared to
+could be applied, but that may have left spaces still too small compared to
the size stored in the space header. */
void
diff --git a/innobase/fsp/fsp0fsp.c b/innobase/fsp/fsp0fsp.c
index e7b97e88f32..34b6de76ff4 100644
--- a/innobase/fsp/fsp0fsp.c
+++ b/innobase/fsp/fsp0fsp.c
@@ -3476,8 +3476,7 @@ fseg_validate_low(
return(TRUE);
}
-
-#ifdef UNIV_DEBUG
+
/***********************************************************************
Validates a segment. */
@@ -3502,7 +3501,6 @@ fseg_validate(
return(ret);
}
-#endif /* UNIV_DEBUG */
/***********************************************************************
Writes info of a segment. */
@@ -3554,7 +3552,6 @@ fseg_print_low(
(ulong) n_used);
}
-#ifdef UNIV_DEBUG
/***********************************************************************
Writes info of a segment. */
@@ -3575,7 +3572,6 @@ fseg_print(
fseg_print_low(inode, mtr);
}
-#endif /* UNIV_DEBUG */
/***********************************************************************
Validates the file space system and its segments. */
diff --git a/innobase/fut/fut0lst.c b/innobase/fut/fut0lst.c
index 3d92aaba1ef..8deaa8adb3f 100644
--- a/innobase/fut/fut0lst.c
+++ b/innobase/fut/fut0lst.c
@@ -490,7 +490,6 @@ flst_validate(
return(TRUE);
}
-#ifdef UNIV_DEBUG
/************************************************************************
Prints info of a file-based list. */
@@ -517,4 +516,3 @@ flst_print(
(ulong) buf_frame_get_page_no(frame),
(ulong) (base - frame), (ulong) len);
}
-#endif /* UNIV_DEBUG */
diff --git a/innobase/ha/ha0ha.c b/innobase/ha/ha0ha.c
index e8082f016b9..ad1391ff83e 100644
--- a/innobase/ha/ha0ha.c
+++ b/innobase/ha/ha0ha.c
@@ -211,7 +211,9 @@ ha_search_and_update_if_found(
{
ha_node_t* node;
+#ifdef UNIV_SYNC_DEBUG
ut_ad(!table->mutexes || mutex_own(hash_get_mutex(table, fold)));
+#endif /* UNIV_SYNC_DEBUG */
node = ha_search_with_data(table, fold, data);
diff --git a/innobase/ha/hash0hash.c b/innobase/ha/hash0hash.c
index 372104e54b3..facdea66198 100644
--- a/innobase/ha/hash0hash.c
+++ b/innobase/ha/hash0hash.c
@@ -22,7 +22,6 @@ hash_mutex_enter(
hash_table_t* table, /* in: hash table */
ulint fold) /* in: fold */
{
- ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
mutex_enter(hash_get_mutex(table, fold));
}
@@ -35,10 +34,41 @@ hash_mutex_exit(
hash_table_t* table, /* in: hash table */
ulint fold) /* in: fold */
{
- ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
mutex_exit(hash_get_mutex(table, fold));
}
+/****************************************************************
+Reserves all the mutexes of a hash table, in an ascending order. */
+
+void
+hash_mutex_enter_all(
+/*=================*/
+ hash_table_t* table) /* in: hash table */
+{
+ ulint i;
+
+ for (i = 0; i < table->n_mutexes; i++) {
+
+ mutex_enter(table->mutexes + i);
+ }
+}
+
+/****************************************************************
+Releases all the mutexes of a hash table. */
+
+void
+hash_mutex_exit_all(
+/*================*/
+ hash_table_t* table) /* in: hash table */
+{
+ ulint i;
+
+ for (i = 0; i < table->n_mutexes; i++) {
+
+ mutex_exit(table->mutexes + i);
+ }
+}
+
/*****************************************************************
Creates a hash table with >= n array cells. The actual number of cells is
chosen to be a prime number slightly bigger than n. */
@@ -68,9 +98,7 @@ hash_create(
table->mutexes = NULL;
table->heaps = NULL;
table->heap = NULL;
-#ifdef UNIV_DEBUG
table->magic_n = HASH_TABLE_MAGIC_N;
-#endif /* UNIV_DEBUG */
/* Initialize the cell array */
@@ -91,7 +119,6 @@ hash_table_free(
/*============*/
hash_table_t* table) /* in, own: hash table */
{
- ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
ut_a(table->mutexes == NULL);
ut_free(table->array);
@@ -113,7 +140,6 @@ hash_create_mutexes(
ulint i;
ut_a(n_mutexes == ut_2_power_up(n_mutexes));
- ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
table->mutexes = mem_alloc(n_mutexes * sizeof(mutex_t));
diff --git a/innobase/ibuf/ibuf0ibuf.c b/innobase/ibuf/ibuf0ibuf.c
index 9246bb03138..f05e69863a3 100644
--- a/innobase/ibuf/ibuf0ibuf.c
+++ b/innobase/ibuf/ibuf0ibuf.c
@@ -201,15 +201,13 @@ because ibuf merge is done to a page when it is read in, and it is
still physically like the index page even if the index would have been
dropped! So, there seems to be no problem. */
-#ifdef UNIV_DEBUG
/**********************************************************************
Validates the ibuf data structures when the caller owns ibuf_mutex. */
-static
+
ibool
ibuf_validate_low(void);
/*===================*/
/* out: TRUE if ok */
-#endif /* UNIV_DEBUG */
/**********************************************************************
Sets the flag in the current OS thread local storage denoting that it is
@@ -530,18 +528,18 @@ ibuf_data_init_for_space(
table = dict_mem_table_create(buf, space, 2);
- dict_mem_table_add_col(table,(char *) "PAGE_NO", DATA_BINARY, 0, 0, 0);
- dict_mem_table_add_col(table,(char *) "TYPES", DATA_BINARY, 0, 0, 0);
+ dict_mem_table_add_col(table, "PAGE_NO", DATA_BINARY, 0, 0, 0);
+ dict_mem_table_add_col(table, "TYPES", DATA_BINARY, 0, 0, 0);
table->id = ut_dulint_add(DICT_IBUF_ID_MIN, space);
dict_table_add_to_cache(table);
- index = dict_mem_index_create(buf, (char *) "CLUST_IND", space,
+ index = dict_mem_index_create(buf, "CLUST_IND", space,
DICT_CLUSTERED | DICT_UNIVERSAL | DICT_IBUF,2);
- dict_mem_index_add_field(index, (char *) "PAGE_NO", 0, 0);
- dict_mem_index_add_field(index, (char *) "TYPES", 0, 0);
+ dict_mem_index_add_field(index, "PAGE_NO", 0, 0);
+ dict_mem_index_add_field(index, "TYPES", 0, 0);
index->page_no = FSP_IBUF_TREE_ROOT_PAGE_NO;
@@ -3278,10 +3276,10 @@ leave_loop:
mem_heap_free(heap);
}
-#ifdef UNIV_DEBUG
+
/**********************************************************************
Validates the ibuf data structures when the caller owns ibuf_mutex. */
-static
+
ibool
ibuf_validate_low(void)
/*===================*/
@@ -3308,7 +3306,6 @@ ibuf_validate_low(void)
return(TRUE);
}
-#endif /* UNIV_DEBUG */
/**********************************************************************
Looks if the insert buffer is empty. */
diff --git a/innobase/include/Makefile.am b/innobase/include/Makefile.am
index 5ec70da97a2..102d25566da 100644
--- a/innobase/include/Makefile.am
+++ b/innobase/include/Makefile.am
@@ -43,7 +43,7 @@ noinst_HEADERS = btr0btr.h btr0btr.ic btr0cur.h btr0cur.ic \
row0purge.ic row0row.h row0row.ic row0sel.h row0sel.ic \
row0types.h row0uins.h row0uins.ic row0umod.h row0umod.ic \
row0undo.h row0undo.ic row0upd.h row0upd.ic row0vers.h \
- row0vers.ic srv0srv.h srv0srv.ic srv0start.h \
+ row0vers.ic srv0que.h srv0srv.h srv0srv.ic srv0start.h \
sync0arr.h sync0arr.ic sync0rw.h \
sync0rw.ic sync0sync.h sync0sync.ic sync0types.h \
thr0loc.h thr0loc.ic trx0purge.h trx0purge.ic trx0rec.h \
diff --git a/innobase/include/btr0btr.h b/innobase/include/btr0btr.h
index e904db3272f..8606fcd2a5c 100644
--- a/innobase/include/btr0btr.h
+++ b/innobase/include/btr0btr.h
@@ -392,7 +392,6 @@ btr_page_free_low(
page_t* page, /* in: page to be freed, x-latched */
ulint level, /* in: page level */
mtr_t* mtr); /* in: mtr */
-#ifdef UNIV_DEBUG
/*****************************************************************
Prints size info of a B-tree. */
@@ -409,7 +408,6 @@ btr_print_tree(
dict_tree_t* tree, /* in: tree */
ulint width); /* in: print this many entries from start
and end */
-#endif /* UNIV_DEBUG */
/****************************************************************
Checks the size and number of fields in a record based on the definition of
the index. */
diff --git a/innobase/include/buf0buf.h b/innobase/include/buf0buf.h
index 9590fea1276..53599d03c73 100644
--- a/innobase/include/buf0buf.h
+++ b/innobase/include/buf0buf.h
@@ -54,11 +54,9 @@ Created 11/5/1995 Heikki Tuuri
#define BUF_KEEP_OLD 52
extern buf_pool_t* buf_pool; /* The buffer pool of the database */
-#ifdef UNIV_DEBUG
extern ibool buf_debug_prints;/* If this is set TRUE, the program
prints info whenever read or flush
occurs */
-#endif /* UNIV_DEBUG */
/************************************************************************
Creates the buffer pool. */
@@ -478,14 +476,12 @@ buf_pool_is_block(
/*==============*/
/* out: TRUE if pointer to block */
void* ptr); /* in: pointer to memory */
-#ifdef UNIV_DEBUG
/*************************************************************************
Validates the buffer pool data structure. */
ibool
buf_validate(void);
/*==============*/
-#endif /* UNIV_DEBUG */
/************************************************************************
Prints a page to stderr. */
@@ -897,7 +893,7 @@ struct buf_pool_struct{
ulint n_pend_reads; /* number of pending read operations */
- time_t last_printout_time; /* when buf_print_io was last time
+ time_t last_printout_time; /* when buf_print was last time
called */
ulint n_pages_read; /* number read operations */
ulint n_pages_written;/* number write operations */
@@ -912,10 +908,10 @@ struct buf_pool_struct{
ulint n_pages_awe_remapped; /* if AWE is enabled, the
number of remaps of blocks to
buffer frames */
- ulint n_page_gets_old;/* n_page_gets when buf_print_io was
+ ulint n_page_gets_old;/* n_page_gets when buf_print was
last time called: used to calculate
hit rate */
- ulint n_pages_read_old;/* n_pages_read when buf_print_io was
+ ulint n_pages_read_old;/* n_pages_read when buf_print was
last time called */
ulint n_pages_written_old;/* number write operations */
ulint n_pages_created_old;/* number of pages created in
diff --git a/innobase/include/buf0buf.ic b/innobase/include/buf0buf.ic
index 4d1173a0d7f..681a0ef000a 100644
--- a/innobase/include/buf0buf.ic
+++ b/innobase/include/buf0buf.ic
@@ -11,6 +11,10 @@ Created 11/5/1995 Heikki Tuuri
#include "buf0rea.h"
#include "mtr0mtr.h"
+extern ulint buf_dbg_counter; /* This is used to insert validation
+ operations in execution in the
+ debug version */
+
/************************************************************************
Recommends a move of a block to the start of the LRU list if there is danger
of dropping from the buffer pool. NOTE: does not reserve the buffer pool
@@ -508,7 +512,7 @@ void
buf_block_buf_fix_inc_debug(
/*========================*/
buf_block_t* block, /* in: block to bufferfix */
- char* file __attribute__ ((unused)), /* in: file name */
+ const char* file __attribute__ ((unused)), /* in: file name */
ulint line __attribute__ ((unused))) /* in: line */
{
#ifdef UNIV_SYNC_DEBUG
diff --git a/innobase/include/buf0flu.h b/innobase/include/buf0flu.h
index 6f39eef7210..1b40acaa269 100644
--- a/innobase/include/buf0flu.h
+++ b/innobase/include/buf0flu.h
@@ -97,7 +97,6 @@ buf_flush_ready_for_replace(
/* out: TRUE if can replace immediately */
buf_block_t* block); /* in: buffer control block, must be in state
BUF_BLOCK_FILE_PAGE and in the LRU list */
-#ifdef UNIV_DEBUG
/**********************************************************************
Validates the flush list. */
@@ -105,7 +104,6 @@ ibool
buf_flush_validate(void);
/*====================*/
/* out: TRUE if ok */
-#endif /* UNIV_DEBUG */
/* When buf_flush_free_margin is called, it tries to make this many blocks
available to replacement in the free list and at the end of the LRU list (to
diff --git a/innobase/include/buf0lru.h b/innobase/include/buf0lru.h
index 98aa0252e12..69a376f8cab 100644
--- a/innobase/include/buf0lru.h
+++ b/innobase/include/buf0lru.h
@@ -112,7 +112,6 @@ void
buf_LRU_make_block_old(
/*===================*/
buf_block_t* block); /* in: control block */
-#ifdef UNIV_DEBUG
/**************************************************************************
Validates the LRU list. */
@@ -125,7 +124,6 @@ Prints the LRU list. */
void
buf_LRU_print(void);
/*===============*/
-#endif /* UNIV_DEBUG */
#ifndef UNIV_NONINL
#include "buf0lru.ic"
diff --git a/innobase/include/data0data.h b/innobase/include/data0data.h
index e2de13d0520..2136de0f9b3 100644
--- a/innobase/include/data0data.h
+++ b/innobase/include/data0data.h
@@ -395,11 +395,9 @@ struct dtuple_struct {
UT_LIST_NODE_T(dtuple_t) tuple_list;
/* data tuples can be linked into a
list using this field */
-#ifdef UNIV_DEBUG
- ulint magic_n;
-#define DATA_TUPLE_MAGIC_N 65478679
-#endif /* UNIV_DEBUG */
+ ulint magic_n;
};
+#define DATA_TUPLE_MAGIC_N 65478679
/* A slot for a field in a big rec vector */
diff --git a/innobase/include/data0type.h b/innobase/include/data0type.h
index 2138df97392..fe38a224a66 100644
--- a/innobase/include/data0type.h
+++ b/innobase/include/data0type.h
@@ -305,7 +305,7 @@ dtype_new_read_for_order_and_null_size(
/*===================================*/
dtype_t* type, /* in: type struct */
byte* buf); /* in: buffer for stored type order info */
-#ifdef UNIV_DEBUG
+
/*************************************************************************
Validates a data type structure. */
@@ -314,7 +314,6 @@ dtype_validate(
/*===========*/
/* out: TRUE if ok */
dtype_t* type); /* in: type struct to validate */
-#endif /* UNIV_DEBUG */
/*************************************************************************
Prints a data type structure. */
diff --git a/innobase/include/dict0dict.h b/innobase/include/dict0dict.h
index fe04359d6f1..ebb34f7dda0 100644
--- a/innobase/include/dict0dict.h
+++ b/innobase/include/dict0dict.h
@@ -325,19 +325,18 @@ dict_table_get_index_noninline(
dict_table_t* table, /* in: table */
const char* name); /* in: index name */
/**************************************************************************
-Prints a table data. */
+Prints a table definition. */
void
-dict_table_print_low(
-/*=================*/
+dict_table_print(
+/*=============*/
dict_table_t* table); /* in: table */
-#ifdef UNIV_DEBUG
/**************************************************************************
-Prints a table definition. */
+Prints a table data. */
void
-dict_table_print(
-/*=============*/
+dict_table_print_low(
+/*=================*/
dict_table_t* table); /* in: table */
/**************************************************************************
Prints a table data when we know the table name. */
@@ -346,7 +345,6 @@ void
dict_table_print_by_name(
/*=====================*/
const char* name);
-#endif /* UNIV_DEBUG */
/**************************************************************************
Outputs info on foreign keys of a table. */
diff --git a/innobase/include/dict0mem.h b/innobase/include/dict0mem.h
index f141ea9da09..3fc3e850987 100644
--- a/innobase/include/dict0mem.h
+++ b/innobase/include/dict0mem.h
@@ -188,12 +188,11 @@ struct dict_tree_struct{
the list; if the tree is of the mixed
type, the first index in the list is the
index of the cluster which owns the tree */
-#ifdef UNIV_DEBUG
ulint magic_n;/* magic number */
-#define DICT_TREE_MAGIC_N 7545676
-#endif /* UNIV_DEBUG */
};
+#define DICT_TREE_MAGIC_N 7545676
+
/* Data structure for an index */
struct dict_index_struct{
dulint id; /* id of the index */
@@ -238,10 +237,7 @@ struct dict_index_struct{
ulint stat_n_leaf_pages;
/* approximate number of leaf pages in the
index tree */
-#ifdef UNIV_DEBUG
ulint magic_n;/* magic number */
-#define DICT_INDEX_MAGIC_N 76789786
-#endif /* UNIV_DEBUG */
};
/* Data structure for a foreign key constraint; an example:
@@ -292,6 +288,9 @@ a foreign key constraint is enforced, therefore RESTRICT just means no flag */
#define DICT_FOREIGN_ON_DELETE_NO_ACTION 16
#define DICT_FOREIGN_ON_UPDATE_NO_ACTION 32
+
+#define DICT_INDEX_MAGIC_N 76789786
+
/* Data structure for a database table */
struct dict_table_struct{
dulint id; /* id of the table or cluster */
@@ -410,12 +409,10 @@ struct dict_table_struct{
inited; MySQL gets the init value by executing
SELECT MAX(auto inc column) */
ib_longlong autoinc;/* autoinc counter value to give to the
- next inserted row */
-#ifdef UNIV_DEBUG
+ next inserted row */
ulint magic_n;/* magic number */
-#define DICT_TABLE_MAGIC_N 76333786
-#endif /* UNIV_DEBUG */
};
+#define DICT_TABLE_MAGIC_N 76333786
#ifndef UNIV_NONINL
#include "dict0mem.ic"
diff --git a/innobase/include/fil0fil.h b/innobase/include/fil0fil.h
index b750e9b38f2..45549aee63c 100644
--- a/innobase/include/fil0fil.h
+++ b/innobase/include/fil0fil.h
@@ -248,10 +248,12 @@ fil_read_flushed_lsn_and_arch_log_no(
os_file_t data_file, /* in: open data file */
ibool one_read_already, /* in: TRUE if min and max parameters
below already contain sensible data */
- dulint* min_flushed_lsn, /* in/out: */
+#ifdef UNIV_LOG_ARCHIVE
ulint* min_arch_log_no, /* in/out: */
- dulint* max_flushed_lsn, /* in/out: */
- ulint* max_arch_log_no); /* in/out: */
+ ulint* max_arch_log_no, /* in/out: */
+#endif /* UNIV_LOG_ARCHIVE */
+ dulint* min_flushed_lsn, /* in/out: */
+ dulint* max_flushed_lsn); /* in/out: */
/***********************************************************************
Increments the count of pending insert buffer page merges, if space is not
being deleted. */
diff --git a/innobase/include/fsp0fsp.h b/innobase/include/fsp0fsp.h
index 20f4f4c2abd..2fcde882df7 100644
--- a/innobase/include/fsp0fsp.h
+++ b/innobase/include/fsp0fsp.h
@@ -332,7 +332,6 @@ void
fsp_print(
/*======*/
ulint space); /* in: space id */
-#ifdef UNIV_DEBUG
/***********************************************************************
Validates a segment. */
@@ -350,7 +349,6 @@ fseg_print(
/*=======*/
fseg_header_t* header, /* in: segment header */
mtr_t* mtr); /* in: mtr */
-#endif /* UNIV_DEBUG */
/* Flags for fsp_reserve_free_extents */
#define FSP_NORMAL 1000000
diff --git a/innobase/include/fut0lst.h b/innobase/include/fut0lst.h
index 3f679d61ab5..5427e2248da 100644
--- a/innobase/include/fut0lst.h
+++ b/innobase/include/fut0lst.h
@@ -181,7 +181,6 @@ flst_validate(
/* out: TRUE if ok */
flst_base_node_t* base, /* in: pointer to base node of list */
mtr_t* mtr1); /* in: mtr */
-#ifdef UNIV_DEBUG
/************************************************************************
Prints info of a file-based list. */
@@ -190,7 +189,7 @@ flst_print(
/*=======*/
flst_base_node_t* base, /* in: pointer to base node of list */
mtr_t* mtr); /* in: mtr */
-#endif /* UNIV_DEBUG */
+
#ifndef UNIV_NONINL
#include "fut0lst.ic"
diff --git a/innobase/include/hash0hash.h b/innobase/include/hash0hash.h
index 79efe016324..51315e40875 100644
--- a/innobase/include/hash0hash.h
+++ b/innobase/include/hash0hash.h
@@ -283,6 +283,21 @@ hash_mutex_exit(
/*============*/
hash_table_t* table, /* in: hash table */
ulint fold); /* in: fold */
+/****************************************************************
+Reserves all the mutexes of a hash table, in an ascending order. */
+
+void
+hash_mutex_enter_all(
+/*=================*/
+ hash_table_t* table); /* in: hash table */
+/****************************************************************
+Releases all the mutexes of a hash table. */
+
+void
+hash_mutex_exit_all(
+/*================*/
+ hash_table_t* table); /* in: hash table */
+
struct hash_cell_struct{
void* node; /* hash chain node, NULL if none */
@@ -303,12 +318,11 @@ struct hash_table_struct {
memory heaps; there are then n_mutexes many of
these heaps */
mem_heap_t* heap;
-#ifdef UNIV_DEBUG
ulint magic_n;
-#define HASH_TABLE_MAGIC_N 76561114
-#endif /* UNIV_DEBUG */
};
+#define HASH_TABLE_MAGIC_N 76561114
+
#ifndef UNIV_NONINL
#include "hash0hash.ic"
#endif
diff --git a/innobase/include/hash0hash.ic b/innobase/include/hash0hash.ic
index 1b9acfa2f34..0d713140c13 100644
--- a/innobase/include/hash0hash.ic
+++ b/innobase/include/hash0hash.ic
@@ -18,7 +18,6 @@ hash_get_nth_cell(
hash_table_t* table, /* in: hash table */
ulint n) /* in: cell index */
{
- ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
ut_ad(n < table->n_cells);
return(table->array + n);
@@ -33,7 +32,6 @@ hash_get_n_cells(
/* out: number of cells */
hash_table_t* table) /* in: table */
{
- ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
return(table->n_cells);
}
@@ -47,7 +45,6 @@ hash_calc_hash(
ulint fold, /* in: folded value */
hash_table_t* table) /* in: hash table */
{
- ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
return(ut_hash_ulint(fold, table->n_cells));
}
@@ -61,7 +58,6 @@ hash_get_mutex_no(
hash_table_t* table, /* in: hash table */
ulint fold) /* in: fold */
{
- ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
return(ut_2pow_remainder(fold, table->n_mutexes));
}
@@ -75,7 +71,6 @@ hash_get_nth_heap(
hash_table_t* table, /* in: hash table */
ulint i) /* in: index of the heap */
{
- ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
ut_ad(i < table->n_mutexes);
return(table->heaps[i]);
@@ -93,8 +88,6 @@ hash_get_heap(
{
ulint i;
- ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
-
if (table->heap) {
return(table->heap);
}
@@ -114,7 +107,6 @@ hash_get_nth_mutex(
hash_table_t* table, /* in: hash table */
ulint i) /* in: index of the mutex */
{
- ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
ut_ad(i < table->n_mutexes);
return(table->mutexes + i);
diff --git a/innobase/include/lock0lock.h b/innobase/include/lock0lock.h
index b1f9a10ee05..9c5f35c6674 100644
--- a/innobase/include/lock0lock.h
+++ b/innobase/include/lock0lock.h
@@ -19,9 +19,7 @@ Created 5/7/1996 Heikki Tuuri
#include "read0types.h"
#include "hash0hash.h"
-#ifdef UNIV_DEBUG
extern ibool lock_print_waits;
-#endif /* UNIV_DEBUG */
/* Buffer for storing information about the most recent deadlock error */
extern FILE* lock_latest_err_file;
@@ -475,7 +473,6 @@ lock_check_trx_id_sanity(
dict_index_t* index, /* in: clustered index */
ibool has_kernel_mutex);/* in: TRUE if the caller owns the
kernel mutex */
-#ifdef UNIV_DEBUG
/*************************************************************************
Validates the lock queue on a single record. */
@@ -485,7 +482,6 @@ lock_rec_queue_validate(
/* out: TRUE if ok */
rec_t* rec, /* in: record to look at */
dict_index_t* index); /* in: index, or NULL if not known */
-#endif /* UNIV_DEBUG */
/*************************************************************************
Prints info of a table lock. */
@@ -509,7 +505,6 @@ void
lock_print_info(
/*============*/
FILE* file); /* in: file where to print */
-#ifdef UNIV_DEBUG
/*************************************************************************
Validates the lock queue on a table. */
@@ -534,7 +529,6 @@ ibool
lock_validate(void);
/*===============*/
/* out: TRUE if ok */
-#endif /* UNIV_DEBUG */
/* The lock system */
extern lock_sys_t* lock_sys;
diff --git a/innobase/include/log0log.h b/innobase/include/log0log.h
index 4badd2cd7b3..d14a116072d 100644
--- a/innobase/include/log0log.h
+++ b/innobase/include/log0log.h
@@ -18,9 +18,7 @@ typedef struct log_struct log_t;
typedef struct log_group_struct log_group_t;
extern ibool log_do_write;
-#ifdef UNIV_LOG_DEBUG
extern ibool log_debug_writes;
-#endif /* UNIV_LOG_DEBUG */
/* Wait modes for log_write_up_to */
#define LOG_NO_WAIT 91
@@ -114,20 +112,6 @@ dulint
log_get_lsn(void);
/*=============*/
/* out: current lsn */
-/****************************************************************************
-Gets the online backup lsn. */
-UNIV_INLINE
-dulint
-log_get_online_backup_lsn_low(void);
-/*===============================*/
-/****************************************************************************
-Gets the online backup state. */
-UNIV_INLINE
-ibool
-log_get_online_backup_state_low(void);
-/*=================================*/
- /* out: online backup state, the caller must
- own the log_sys mutex */
/**********************************************************
Initializes the log. */
@@ -326,20 +310,6 @@ log_archived_file_name_gen(
char* buf, /* in: buffer where to write */
ulint id, /* in: group id */
ulint file_no);/* in: file number */
-/**********************************************************
-Switches the database to the online backup state. */
-
-ulint
-log_switch_backup_state_on(void);
-/*============================*/
- /* out: DB_SUCCESS or DB_ERROR */
-/**********************************************************
-Switches the online backup state off. */
-
-ulint
-log_switch_backup_state_off(void);
-/*=============================*/
- /* out: DB_SUCCESS or DB_ERROR */
/************************************************************************
Checks that there is enough free space in the log to start a new query step.
Flushes the log buffer or makes a new checkpoint if necessary. NOTE: this
@@ -719,13 +689,11 @@ struct log_struct{
ulint max_buf_free; /* recommended maximum value of
buf_free, after which the buffer is
flushed */
-#ifdef UNIV_LOG_DEBUG
ulint old_buf_free; /* value of buf free when log was
last time opened; only in the debug
version */
dulint old_lsn; /* value of lsn when log was last time
opened; only in the debug version */
-#endif /* UNIV_LOG_DEBUG */
ibool check_flush_or_checkpoint;
/* this is set to TRUE when there may
be need to flush the log buffer, or
@@ -878,13 +846,6 @@ struct log_struct{
os_event_t archiving_on; /* if archiving has been stopped,
a thread can wait for this event to
become signaled */
- /* Fields involved in online backups */
- ibool online_backup_state;
- /* TRUE if the database is in the
- online backup state */
- dulint online_backup_lsn;
- /* lsn when the state was changed to
- the online backup state */
};
#define LOG_ARCH_ON 71
diff --git a/innobase/include/log0log.ic b/innobase/include/log0log.ic
index e273b6a292b..ca7531783a2 100644
--- a/innobase/include/log0log.ic
+++ b/innobase/include/log0log.ic
@@ -10,7 +10,6 @@ Created 12/9/1995 Heikki Tuuri
#include "mach0data.h"
#include "mtr0mtr.h"
-#ifdef UNIV_LOG_DEBUG
/**********************************************************
Checks by parsing that the catenated log segment for a single mtr is
consistent. */
@@ -22,7 +21,6 @@ log_check_log_recs(
in the log_sys->buf log buffer */
ulint len, /* in: segment length in bytes */
dulint buf_start_lsn); /* in: buffer start lsn */
-#endif /* UNIV_LOG_DEBUG */
/****************************************************************
Gets a log block flush bit. */
@@ -318,8 +316,7 @@ log_reserve_and_write_fast(
data_len = len + log->buf_free % OS_FILE_LOG_BLOCK_SIZE;
- if (log->online_backup_state
- || (data_len >= OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_TRL_SIZE)) {
+ if (data_len >= OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_TRL_SIZE) {
/* The string does not fit within the current log block
or the log block would become full */
@@ -403,36 +400,3 @@ log_free_check(void)
log_check_margins();
}
}
-
-/****************************************************************************
-Gets the online backup lsn. */
-UNIV_INLINE
-dulint
-log_get_online_backup_lsn_low(void)
-/*===============================*/
- /* out: online_backup_lsn, the caller must
- own the log_sys mutex */
-{
-#ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&(log_sys->mutex)));
-#endif /* UNIV_SYNC_DEBUG */
- ut_ad(log_sys->online_backup_state);
-
- return(log_sys->online_backup_lsn);
-}
-
-/****************************************************************************
-Gets the online backup state. */
-UNIV_INLINE
-ibool
-log_get_online_backup_state_low(void)
-/*=================================*/
- /* out: online backup state, the caller must
- own the log_sys mutex */
-{
-#ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&(log_sys->mutex)));
-#endif /* UNIV_SYNC_DEBUG */
-
- return(log_sys->online_backup_state);
-}
diff --git a/innobase/include/log0recv.h b/innobase/include/log0recv.h
index c972c3ce977..658df4d5586 100644
--- a/innobase/include/log0recv.h
+++ b/innobase/include/log0recv.h
@@ -15,7 +15,9 @@ Created 9/20/1997 Heikki Tuuri
#include "hash0hash.h"
#include "log0log.h"
+#ifdef UNIV_HOTBACKUP
extern ibool recv_replay_file_ops;
+#endif /* UNIV_HOTBACKUP */
/***********************************************************************
Reads the checkpoint info needed in hot backup. */
@@ -134,20 +136,25 @@ recv_reset_logs(
dulint lsn, /* in: reset to this lsn rounded up to
be divisible by OS_FILE_LOG_BLOCK_SIZE,
after which we add LOG_BLOCK_HDR_SIZE */
+#ifdef UNIV_LOG_ARCHIVE
ulint arch_log_no, /* in: next archived log file number */
+#endif /* UNIV_LOG_ARCHIVE */
ibool new_logs_created);/* in: TRUE if resetting logs is done
at the log creation; FALSE if it is done
after archive recovery */
+#ifdef UNIV_HOTBACKUP
/**********************************************************
Creates new log files after a backup has been restored. */
void
recv_reset_log_files_for_backup(
/*============================*/
- char* log_dir, /* in: log file directory path */
- ulint n_log_files, /* in: number of log files */
- ulint log_file_size, /* in: log file size */
- dulint lsn); /* in: new start lsn */
+ const char* log_dir, /* in: log file directory path */
+ ulint n_log_files, /* in: number of log files */
+ ulint log_file_size, /* in: log file size */
+ dulint lsn); /* in: new start lsn, must be
+ divisible by OS_FILE_LOG_BLOCK_SIZE */
+#endif /* UNIV_HOTBACKUP */
/************************************************************
Creates the recovery system. */
@@ -185,6 +192,7 @@ void
recv_apply_log_recs_for_backup(void);
/*================================*/
#endif
+#ifdef UNIV_LOG_ARCHIVE
/************************************************************
Recovers from archived log files, and also from log files, if they exist. */
@@ -205,6 +213,7 @@ Completes recovery from archive. */
void
recv_recovery_from_archive_finish(void);
/*===================================*/
+#endif /* UNIV_LOG_ARCHIVE */
/***********************************************************************
Checks that a replica of a space is identical to the original space. */
@@ -333,7 +342,9 @@ extern ibool recv_no_ibuf_operations;
extern ibool recv_needed_recovery;
extern ibool recv_lsn_checks_on;
+#ifdef UNIV_HOTBACKUP
extern ibool recv_is_making_a_backup;
+#endif /* UNIV_HOTBACKUP */
extern ulint recv_max_parsed_page_no;
/* Size of the parsing buffer; it must accommodate RECV_SCAN_SIZE many
diff --git a/innobase/include/mach0data.h b/innobase/include/mach0data.h
index f28c9422670..7ad760cd60f 100644
--- a/innobase/include/mach0data.h
+++ b/innobase/include/mach0data.h
@@ -89,7 +89,7 @@ mach_read_from_4(
/* out: ulint integer */
byte* b); /* in: pointer to four bytes */
/*************************************************************
-Writes a ulint in a compressed form. */
+Writes a ulint in a compressed form (1..5 bytes). */
UNIV_INLINE
ulint
mach_write_compressed(
@@ -168,7 +168,7 @@ mach_read_from_8(
/* out: dulint integer */
byte* b); /* in: pointer to 8 bytes */
/*************************************************************
-Writes a dulint in a compressed form. */
+Writes a dulint in a compressed form (5..9 bytes). */
UNIV_INLINE
ulint
mach_dulint_write_compressed(
@@ -193,7 +193,7 @@ mach_dulint_read_compressed(
/* out: read dulint */
byte* b); /* in: pointer to memory from where to read */
/*************************************************************
-Writes a dulint in a compressed form. */
+Writes a dulint in a compressed form (1..11 bytes). */
UNIV_INLINE
ulint
mach_dulint_write_much_compressed(
diff --git a/innobase/include/mach0data.ic b/innobase/include/mach0data.ic
index 3ccdcf1dc0a..3ffb9baa344 100644
--- a/innobase/include/mach0data.ic
+++ b/innobase/include/mach0data.ic
@@ -366,7 +366,7 @@ mach_read_from_6(
}
/*************************************************************
-Writes a dulint in a compressed form. */
+Writes a dulint in a compressed form (5..9 bytes). */
UNIV_INLINE
ulint
mach_dulint_write_compressed(
@@ -422,7 +422,7 @@ mach_dulint_read_compressed(
}
/*************************************************************
-Writes a dulint in a compressed form. */
+Writes a dulint in a compressed form (1..11 bytes). */
UNIV_INLINE
ulint
mach_dulint_write_much_compressed(
diff --git a/innobase/include/mem0dbg.h b/innobase/include/mem0dbg.h
index 61c66cc218c..96f30842df6 100644
--- a/innobase/include/mem0dbg.h
+++ b/innobase/include/mem0dbg.h
@@ -31,7 +31,6 @@ check fields at the both ends of the field. */
#define MEM_SPACE_NEEDED(N) ut_calc_align((N), UNIV_MEM_ALIGNMENT)
#endif
-#ifdef UNIV_DEBUG
/*******************************************************************
Checks a memory heap for consistency and prints the contents if requested.
Outputs the sum of sizes of buffers given to the user (only in
@@ -61,7 +60,6 @@ mem_heap_validate_or_print(
ulint* n_blocks); /* out: number of blocks in the heap,
if a NULL pointer is passed as this
argument, it is ignored */
-#endif /* UNIV_DEBUG */
#ifdef UNIV_MEM_DEBUG
/******************************************************************
Prints the contents of a memory heap. */
@@ -71,7 +69,6 @@ mem_heap_print(
/*===========*/
mem_heap_t* heap); /* in: memory heap */
#endif /* UNIV_MEM_DEBUG */
-#ifdef UNIV_DEBUG
/******************************************************************
Checks that an object is a memory heap (or a block of it) */
@@ -88,7 +85,6 @@ mem_heap_validate(
/*==============*/
/* out: TRUE if ok */
mem_heap_t* heap); /* in: memory heap */
-#endif /* UNIV_DEBUG */
#ifdef UNIV_MEM_DEBUG
/*********************************************************************
TRUE if no memory is currently allocated. */
@@ -120,4 +116,17 @@ void
mem_analyze_corruption(
/*===================*/
byte* ptr); /* in: pointer to place of possible corruption */
+/*********************************************************************
+Prints information of dynamic memory usage and currently allocated memory
+heaps or buffers. Can only be used in the debug version. */
+void
+mem_print_info(void);
+/*================*/
+/*********************************************************************
+Prints information of dynamic memory usage and currently allocated memory
+heaps or buffers since the last ..._print_info or..._print_new_info. */
+
+void
+mem_print_new_info(void);
+/*====================*/
diff --git a/innobase/include/mem0dbg.ic b/innobase/include/mem0dbg.ic
index 2e79c814529..7ce5f6f1ba5 100644
--- a/innobase/include/mem0dbg.ic
+++ b/innobase/include/mem0dbg.ic
@@ -54,9 +54,8 @@ void
mem_hash_insert(
/*============*/
mem_heap_t* heap, /* in: the created heap */
- char* file_name, /* in: file name of creation */
+ const char* file_name, /* in: file name of creation */
ulint line); /* in: line where created */
-#ifdef UNIV_MEM_DEBUG
/*******************************************************************
Removes a memory heap (which is going to be freed by the caller)
from the list of live memory heaps. Returns the size of the heap
@@ -70,9 +69,9 @@ void
mem_hash_remove(
/*============*/
mem_heap_t* heap, /* in: the heap to be freed */
- char* file_name, /* in: file name of freeing */
+ const char* file_name, /* in: file name of freeing */
ulint line); /* in: line where freed */
-#endif /* UNIV_MEM_DEBUG */
+
void
mem_field_header_set_len(byte* field, ulint len);
diff --git a/innobase/include/mem0mem.h b/innobase/include/mem0mem.h
index 18bffe5732e..cd01ac77bf3 100644
--- a/innobase/include/mem0mem.h
+++ b/innobase/include/mem0mem.h
@@ -261,18 +261,6 @@ mem_free_func(
const char* file_name, /* in: file name where created */
ulint line /* in: line where created */
);
-/*******************************************************************
-Implements realloc. */
-UNIV_INLINE
-void*
-mem_realloc(
-/*========*/
- /* out, own: free storage,
- NULL if did not succeed */
- void* buf, /* in: pointer to an old buffer */
- ulint n, /* in: desired number of bytes */
- const char* file_name, /* in: file name where called */
- ulint line); /* in: line where called */
/**************************************************************************
Duplicates a NUL-terminated string. */
diff --git a/innobase/include/mem0mem.ic b/innobase/include/mem0mem.ic
index df3dbf9b576..d97b7d6c4dd 100644
--- a/innobase/include/mem0mem.ic
+++ b/innobase/include/mem0mem.ic
@@ -562,24 +562,6 @@ mem_heap_get_size(
return(size);
}
-/*******************************************************************
-Implements realloc. */
-UNIV_INLINE
-void*
-mem_realloc(
-/*========*/
- /* out, own: free storage,
- NULL if did not succeed */
- void* buf, /* in: pointer to an old buffer */
- ulint n, /* in: desired number of bytes */
- const char* file_name, /* in: file name where called */
- ulint line) /* in: line where called */
-{
- mem_free(buf);
-
- return(mem_alloc_func(n, file_name, line));
-}
-
/**************************************************************************
Duplicates a NUL-terminated string. */
UNIV_INLINE
diff --git a/innobase/include/mem0pool.h b/innobase/include/mem0pool.h
index 95cf19676fb..43707bd5f61 100644
--- a/innobase/include/mem0pool.h
+++ b/innobase/include/mem0pool.h
@@ -83,7 +83,6 @@ Releases the mem pool mutex. */
void
mem_pool_mutex_exit(void);
/*=====================*/
-#ifdef UNIV_DEBUG
/************************************************************************
Validates a memory pool. */
@@ -100,7 +99,7 @@ mem_pool_print_info(
/*================*/
FILE* outfile,/* in: output file to write to */
mem_pool_t* pool); /* in: memory pool */
-#endif /* UNIV_DEBUG */
+
#ifndef UNIV_NONINL
#include "mem0pool.ic"
diff --git a/innobase/include/mtr0log.h b/innobase/include/mtr0log.h
index f50c1dfcb6a..41be168a371 100644
--- a/innobase/include/mtr0log.h
+++ b/innobase/include/mtr0log.h
@@ -121,7 +121,9 @@ mlog_close(
mtr_t* mtr, /* in: mtr */
byte* ptr); /* in: buffer space from ptr up was not used */
/************************************************************
-Writes the initial part of a log record. */
+Writes the initial part of a log record (3..11 bytes).
+If the implementation of this function is changed, all
+size parameters to mlog_open() should be adjusted accordingly! */
UNIV_INLINE
byte*
mlog_write_initial_log_record_fast(
diff --git a/innobase/include/mtr0log.ic b/innobase/include/mtr0log.ic
index c02e0a96a81..aa3f945c202 100644
--- a/innobase/include/mtr0log.ic
+++ b/innobase/include/mtr0log.ic
@@ -137,7 +137,9 @@ mlog_catenate_dulint_compressed(
}
/************************************************************
-Writes the initial part of a log record. */
+Writes the initial part of a log record (3..11 bytes).
+If the implementation of this function is changed, all
+size parameters to mlog_open() should be adjusted accordingly! */
UNIV_INLINE
byte*
mlog_write_initial_log_record_fast(
diff --git a/innobase/include/mtr0mtr.h b/innobase/include/mtr0mtr.h
index f6dfe23bc41..e8c68a91dad 100644
--- a/innobase/include/mtr0mtr.h
+++ b/innobase/include/mtr0mtr.h
@@ -82,7 +82,7 @@ flag value must give the length also! */
predefined minimum record */
#define MLOG_IBUF_BITMAP_INIT ((byte)27) /* initialize an ibuf bitmap
page */
-#define MLOG_FULL_PAGE ((byte)28) /* full contents of a page */
+/*#define MLOG_FULL_PAGE ((byte)28) full contents of a page */
#define MLOG_INIT_FILE_PAGE ((byte)29) /* this means that a file page
is taken into use and the prior
contents of the page should be
@@ -236,16 +236,6 @@ mtr_memo_release(
mtr_t* mtr, /* in: mtr */
void* object, /* in: object */
ulint type); /* in: object type: MTR_MEMO_S_LOCK, ... */
-/****************************************************************
-Parses a log record which contains the full contents of a page. */
-
-byte*
-mtr_log_parse_full_page(
-/*====================*/
- /* out: end of log record or NULL */
- byte* ptr, /* in: buffer */
- byte* end_ptr,/* in: buffer end */
- page_t* page); /* in: page or NULL */
/**************************************************************
Checks if memo contains the given item. */
UNIV_INLINE
@@ -256,7 +246,6 @@ mtr_memo_contains(
mtr_t* mtr, /* in: mtr */
void* object, /* in: object to search */
ulint type); /* in: type of object */
-#ifdef UNIV_DEBUG
/*************************************************************
Prints info of an mtr handle. */
@@ -264,7 +253,6 @@ void
mtr_print(
/*======*/
mtr_t* mtr); /* in: mtr */
-#endif /* UNIV_DEBUG */
/*######################################################################*/
#define MTR_BUF_MEMO_SIZE 200 /* number of slots in memo */
@@ -297,12 +285,7 @@ struct mtr_memo_slot_struct{
/* Mini-transaction handle and buffer */
struct mtr_struct{
-#ifdef UNIV_DEBUG
ulint state; /* MTR_ACTIVE, MTR_COMMITTING, MTR_COMMITTED */
-#define MTR_ACTIVE 12231
-#define MTR_COMMITTING 56456
-#define MTR_COMMITTED 34676
-#endif /* UNIV_DEBUG */
dyn_array_t memo; /* memo stack for locks etc. */
dyn_array_t log; /* mini-transaction log */
ibool modifications;
@@ -317,12 +300,15 @@ struct mtr_struct{
this mtr */
dulint end_lsn;/* end lsn of the possible log entry for
this mtr */
-#ifdef UNIV_DEBUG
ulint magic_n;
-#define MTR_MAGIC_N 54551
-#endif /* UNIV_DEBUG */
};
+#define MTR_MAGIC_N 54551
+
+#define MTR_ACTIVE 12231
+#define MTR_COMMITTING 56456
+#define MTR_COMMITTED 34676
+
#ifndef UNIV_NONINL
#include "mtr0mtr.ic"
#endif
diff --git a/innobase/include/os0file.h b/innobase/include/os0file.h
index 930390241d3..6549a3748df 100644
--- a/innobase/include/os0file.h
+++ b/innobase/include/os0file.h
@@ -169,6 +169,13 @@ void
os_io_init_simple(void);
/*===================*/
/***************************************************************************
+Creates a temporary file. In case of error, causes abnormal termination. */
+
+FILE*
+os_file_create_tmpfile(void);
+/*========================*/
+ /* out: temporary file handle (never NULL) */
+/***************************************************************************
The os_file_opendir() function opens a directory stream corresponding to the
directory named by the dirname argument. The directory stream is positioned
at the first entry. In both Unix and Windows we automatically skip the '.'
diff --git a/innobase/include/os0thread.h b/innobase/include/os0thread.h
index 6603229e524..c00d28baf60 100644
--- a/innobase/include/os0thread.h
+++ b/innobase/include/os0thread.h
@@ -78,6 +78,10 @@ os_thread_create(
function */
os_thread_id_t* thread_id); /* out: id of the created
thread */
+int
+os_thread_join(
+/*=============*/
+ os_thread_id_t thread_id); /* in: id of the thread to join */
/*********************************************************************
Exits the current thread. */
diff --git a/innobase/include/pars0opt.h b/innobase/include/pars0opt.h
index ac0e885d05a..d091c3ee2d0 100644
--- a/innobase/include/pars0opt.h
+++ b/innobase/include/pars0opt.h
@@ -43,7 +43,6 @@ opt_find_all_cols(
to add new found columns */
plan_t* plan, /* in: plan or NULL */
que_node_t* exp); /* in: expression or condition */
-#ifdef UNIV_SQL_DEBUG
/************************************************************************
Prints info of a query plan. */
@@ -51,7 +50,6 @@ void
opt_print_query_plan(
/*=================*/
sel_node_t* sel_node); /* in: select node */
-#endif /* UNIV_SQL_DEBUG */
#ifndef UNIV_NONINL
#include "pars0opt.ic"
diff --git a/innobase/include/que0que.h b/innobase/include/que0que.h
index a438116781f..e1874edcaf2 100644
--- a/innobase/include/que0que.h
+++ b/innobase/include/que0que.h
@@ -152,6 +152,17 @@ que_run_threads(
/*============*/
que_thr_t* thr); /* in: query thread which is run initially */
/**************************************************************************
+After signal handling is finished, returns control to a query graph error
+handling routine. (Currently, just returns the control to the root of the
+graph so that the graph can communicate an error message to the client.) */
+
+void
+que_fork_error_handle(
+/*==================*/
+ trx_t* trx, /* in: trx */
+ que_t* fork); /* in: query graph which was run before signal
+ handling started, NULL not allowed */
+/**************************************************************************
Handles an SQL error noticed during query thread execution. At the moment,
does nothing! */
@@ -170,15 +181,18 @@ a single worker thread to execute it. This function should be used to end
the wait state of a query thread waiting for a lock or a stored procedure
completion. */
-que_thr_t*
+void
que_thr_end_wait(
/*=============*/
- /* out: next query thread to run;
- NULL if none */
- que_thr_t* thr); /* in: query thread in the
+ que_thr_t* thr, /* in: query thread in the
QUE_THR_LOCK_WAIT,
or QUE_THR_PROCEDURE_WAIT, or
QUE_THR_SIG_REPLY_WAIT state */
+ que_thr_t** next_thr); /* in/out: next query thread to run;
+ if the value which is passed in is
+ a pointer to a NULL pointer, then the
+ calling function can start running
+ a new query thread */
/**************************************************************************
Same as que_thr_end_wait, but no parameter next_thr available. */
@@ -293,6 +307,22 @@ que_thr_peek_stop(
mutex reserved is necessary before deciding
the actual stopping */
que_thr_t* thr); /* in: query thread */
+/***************************************************************************
+Returns TRUE if the query graph is for a SELECT statement. */
+UNIV_INLINE
+ibool
+que_graph_is_select(
+/*================*/
+ /* out: TRUE if a select */
+ que_t* graph); /* in: graph */
+/**************************************************************************
+Prints info of an SQL query graph node. */
+
+void
+que_node_print_info(
+/*================*/
+ que_node_t* node); /* in: query graph node */
+
/* Query graph query thread node: the fields are protected by the kernel
mutex with the exceptions named below */
diff --git a/innobase/include/que0que.ic b/innobase/include/que0que.ic
index a63922f8c80..ae4ed10560f 100644
--- a/innobase/include/que0que.ic
+++ b/innobase/include/que0que.ic
@@ -238,3 +238,21 @@ que_thr_peek_stop(
return(FALSE);
}
+
+/***************************************************************************
+Returns TRUE if the query graph is for a SELECT statement. */
+UNIV_INLINE
+ibool
+que_graph_is_select(
+/*================*/
+ /* out: TRUE if a select */
+ que_t* graph) /* in: graph */
+{
+ if (graph->fork_type == QUE_FORK_SELECT_SCROLL
+ || graph->fork_type == QUE_FORK_SELECT_NON_SCROLL) {
+
+ return(TRUE);
+ }
+
+ return(FALSE);
+}
diff --git a/innobase/include/row0ins.h b/innobase/include/row0ins.h
index f3f0b7e8eca..a5b4b74e7fc 100644
--- a/innobase/include/row0ins.h
+++ b/innobase/include/row0ins.h
@@ -145,12 +145,11 @@ struct ins_node_struct{
entry_list and sys fields are stored here;
if this is NULL, entry list should be created
and buffers for sys fields in row allocated */
-#ifdef UNIV_DEBUG
ulint magic_n;
-#define INS_NODE_MAGIC_N 15849075
-#endif /* UNIV_DEBUG */
};
+#define INS_NODE_MAGIC_N 15849075
+
/* Insert node types */
#define INS_SEARCHED 0 /* INSERT INTO ... SELECT ... */
#define INS_VALUES 1 /* INSERT INTO ... VALUES ... */
diff --git a/innobase/include/row0mysql.h b/innobase/include/row0mysql.h
index 364ac006ba7..768279fefd4 100644
--- a/innobase/include/row0mysql.h
+++ b/innobase/include/row0mysql.h
@@ -558,6 +558,9 @@ struct row_prebuilt_struct {
dtuple_t* clust_ref; /* prebuilt dtuple used in
sel/upd/del */
ulint select_lock_type;/* LOCK_NONE, LOCK_S, or LOCK_X */
+ ulint stored_select_lock_type;/* inside LOCK TABLES, either
+ LOCK_S or LOCK_X depending on the lock
+ type */
ulint mysql_row_len; /* length in bytes of a row in the
MySQL format */
ulint n_rows_fetched; /* number of rows fetched after
diff --git a/innobase/include/row0upd.h b/innobase/include/row0upd.h
index 687e90deee5..f5e0a88231f 100644
--- a/innobase/include/row0upd.h
+++ b/innobase/include/row0upd.h
@@ -384,12 +384,11 @@ struct upd_node_struct{
sym_node_t* table_sym;/* table node in symbol table */
que_node_t* col_assign_list;
/* column assignment list */
-#ifdef UNIV_DEBUG
ulint magic_n;
-#define UPD_NODE_MAGIC_N 1579975
-#endif /* UNIV_DEBUG */
};
+#define UPD_NODE_MAGIC_N 1579975
+
/* Node execution states */
#define UPD_NODE_SET_IX_LOCK 1 /* execution came to the node from
a node above and if the field
diff --git a/innobase/include/srv0que.h b/innobase/include/srv0que.h
new file mode 100644
index 00000000000..05c339cdd32
--- /dev/null
+++ b/innobase/include/srv0que.h
@@ -0,0 +1,53 @@
+/******************************************************
+Server query execution
+
+(c) 1996 Innobase Oy
+
+Created 6/5/1996 Heikki Tuuri
+*******************************************************/
+
+
+#ifndef srv0que_h
+#define srv0que_h
+
+#include "univ.i"
+#include "que0types.h"
+
+/**************************************************************************
+Checks if there is work to do in the server task queue. If there is, the
+thread starts processing a task. Before leaving, it again checks the task
+queue and picks a new task if any exists. This is called by a SRV_WORKER
+thread. */
+
+void
+srv_que_task_queue_check(void);
+/*==========================*/
+/**************************************************************************
+Performs round-robin on the server tasks. This is called by a SRV_WORKER
+thread every second or so. */
+
+que_thr_t*
+srv_que_round_robin(
+/*================*/
+ /* out: the new (may be == thr) query thread
+ to run */
+ que_thr_t* thr); /* in: query thread */
+/**************************************************************************
+Enqueues a task to server task queue and releases a worker thread, if
+there exists one suspended. */
+
+void
+srv_que_task_enqueue(
+/*=================*/
+ que_thr_t* thr); /* in: query thread */
+/**************************************************************************
+Enqueues a task to server task queue and releases a worker thread, if
+there exists one suspended. */
+
+void
+srv_que_task_enqueue_low(
+/*=====================*/
+ que_thr_t* thr); /* in: query thread */
+
+#endif
+
diff --git a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
index 7f067c75466..c527d40bc79 100644
--- a/innobase/include/srv0srv.h
+++ b/innobase/include/srv0srv.h
@@ -16,10 +16,7 @@ Created 10/10/1995 Heikki Tuuri
#include "que0types.h"
#include "trx0types.h"
-extern char* srv_main_thread_op_info;
-
-/* Buffer which can be used in printing fatal error messages */
-extern char srv_fatal_errbuf[];
+extern const char* srv_main_thread_op_info;
/* When this event is set the lock timeout and InnoDB monitor
thread starts running */
@@ -40,7 +37,9 @@ extern FILE* srv_monitor_file;
/* Server parameters which are read from the initfile */
extern char* srv_data_home;
+#ifdef UNIV_LOG_ARCHIVE
extern char* srv_arch_dir;
+#endif /* UNIV_LOG_ARCHIVE */
extern ibool srv_file_per_table;
@@ -62,7 +61,6 @@ extern char** srv_log_group_home_dirs;
extern ulint srv_n_log_groups;
extern ulint srv_n_log_files;
extern ulint srv_log_file_size;
-extern ibool srv_log_archive_on;
extern ulint srv_log_buffer_size;
extern ulint srv_flush_log_at_trx_commit;
@@ -75,8 +73,11 @@ extern ulint srv_lock_table_size;
extern ulint srv_n_file_io_threads;
+#ifdef UNIV_LOG_ARCHIVE
+extern ibool srv_log_archive_on;
extern ibool srv_archive_recovery;
extern dulint srv_archive_recovery_limit_lsn;
+#endif /* UNIV_LOG_ARCHIVE */
extern ulint srv_lock_wait_timeout;
diff --git a/innobase/include/sync0rw.h b/innobase/include/sync0rw.h
index 63b01ffac80..9a988a03e92 100644
--- a/innobase/include/sync0rw.h
+++ b/innobase/include/sync0rw.h
@@ -85,7 +85,6 @@ void
rw_lock_free(
/*=========*/
rw_lock_t* lock); /* in: rw-lock */
-#ifdef UNIV_DEBUG
/**********************************************************************
Checks that the rw-lock has been initialized and that there are no
simultaneous shared and exclusive locks. */
@@ -94,7 +93,6 @@ ibool
rw_lock_validate(
/*=============*/
rw_lock_t* lock);
-#endif /* UNIV_DEBUG */
/******************************************************************
NOTE! The following macros should be used in rw s-locking, not the
corresponding function. */
diff --git a/innobase/include/sync0rw.ic b/innobase/include/sync0rw.ic
index 655bd7f6517..3a92100ba01 100644
--- a/innobase/include/sync0rw.ic
+++ b/innobase/include/sync0rw.ic
@@ -30,7 +30,7 @@ rw_lock_add_debug_info(
rw_lock_t* lock, /* in: rw-lock */
ulint pass, /* in: pass value */
ulint lock_type, /* in: lock type */
- char* file_name, /* in: file where requested */
+ const char* file_name, /* in: file where requested */
ulint line); /* in: line where requested */
/**********************************************************************
Removes a debug information struct for an rw-lock. */
diff --git a/innobase/include/sync0sync.h b/innobase/include/sync0sync.h
index 4307ca5ba0c..8e0ec715b12 100644
--- a/innobase/include/sync0sync.h
+++ b/innobase/include/sync0sync.h
@@ -143,7 +143,6 @@ void
sync_print(
/*=======*/
FILE* file); /* in: file where to print */
-#ifdef UNIV_DEBUG
/**********************************************************************
Checks that the mutex has been initialized. */
@@ -151,7 +150,6 @@ ibool
mutex_validate(
/*===========*/
mutex_t* mutex);
-#endif /* UNIV_DEBUG */
/**********************************************************************
Sets the mutex latching level field. */
diff --git a/innobase/include/sync0sync.ic b/innobase/include/sync0sync.ic
index ecb498918e2..aaf5e1fd9e9 100644
--- a/innobase/include/sync0sync.ic
+++ b/innobase/include/sync0sync.ic
@@ -33,7 +33,7 @@ void
mutex_set_debug_info(
/*=================*/
mutex_t* mutex, /* in: mutex */
- char* file_name, /* in: file where requested */
+ const char* file_name, /* in: file where requested */
ulint line); /* in: line where requested */
#endif /* UNIV_SYNC_DEBUG */
/**********************************************************************
diff --git a/innobase/include/trx0roll.h b/innobase/include/trx0roll.h
index aa88fc249fc..6004551f456 100644
--- a/innobase/include/trx0roll.h
+++ b/innobase/include/trx0roll.h
@@ -91,12 +91,16 @@ trx_undo_rec_release(
/*************************************************************************
Starts a rollback operation. */
-que_thr_t*
+void
trx_rollback(
/*=========*/
- /* out: next query thread to run */
trx_t* trx, /* in: transaction */
- trx_sig_t* sig); /* in: signal starting the rollback */
+ trx_sig_t* sig, /* in: signal starting the rollback */
+ que_thr_t** next_thr);/* in/out: next query thread to run;
+ if the value which is passed in is
+ a pointer to a NULL pointer, then the
+ calling function can start running
+ a new query thread */
/***********************************************************************
Rollback or clean up transactions which have no user session. If the
transaction already was committed, then we clean up a possible insert
@@ -108,12 +112,17 @@ trx_rollback_or_clean_all_without_sess(void);
/********************************************************************
Finishes a transaction rollback. */
-que_thr_t*
+void
trx_finish_rollback_off_kernel(
/*===========================*/
- /* out: next query thread to run */
que_t* graph, /* in: undo graph which can now be freed */
- trx_t* trx); /* in: transaction */
+ trx_t* trx, /* in: transaction */
+ que_thr_t** next_thr);/* in/out: next query thread to run;
+ if the value which is passed in is
+ a pointer to a NULL pointer, then the
+ calling function can start running
+ a new query thread; if this parameter is
+ NULL, it is ignored */
/********************************************************************
Builds an undo 'query' graph for a transaction. The actual rollback is
performed by executing this query graph like a query subprocedure call.
diff --git a/innobase/include/trx0sys.h b/innobase/include/trx0sys.h
index 7d20455ffdf..8f402881224 100644
--- a/innobase/include/trx0sys.h
+++ b/innobase/include/trx0sys.h
@@ -32,6 +32,14 @@ or there was no master log position info inside InnoDB. */
extern char trx_sys_mysql_master_log_name[];
extern ib_longlong trx_sys_mysql_master_log_pos;
+/* If this MySQL server uses binary logging, after InnoDB has been inited
+and if it has done a crash recovery, we store the binlog file name and position
+here. If .._pos is -1, it means there was no binlog position info inside
+InnoDB. */
+
+extern char trx_sys_mysql_bin_log_name[];
+extern ib_longlong trx_sys_mysql_bin_log_pos;
+
/* The transaction system */
extern trx_sys_t* trx_sys;
diff --git a/innobase/include/trx0trx.h b/innobase/include/trx0trx.h
index 9b7ac22e617..a8c1df534da 100644
--- a/innobase/include/trx0trx.h
+++ b/innobase/include/trx0trx.h
@@ -194,10 +194,9 @@ trx_end_lock_wait(
/********************************************************************
Sends a signal to a trx object. */
-que_thr_t*
+ibool
trx_sig_send(
/*=========*/
- /* out: next query thread to run */
/* out: TRUE if the signal was
successfully delivered */
trx_t* trx, /* in: trx handle */
@@ -207,17 +206,27 @@ trx_sig_send(
que_thr_t* receiver_thr, /* in: query thread which wants the
reply, or NULL; if type is
TRX_SIG_END_WAIT, this must be NULL */
- trx_savept_t* savept); /* in: possible rollback savepoint, or
+ trx_savept_t* savept, /* in: possible rollback savepoint, or
NULL */
+ que_thr_t** next_thr); /* in/out: next query thread to run;
+ if the value which is passed in is
+ a pointer to a NULL pointer, then the
+ calling function can start running
+ a new query thread; if the parameter
+ is NULL, it is ignored */
/********************************************************************
Send the reply message when a signal in the queue of the trx has
been handled. */
-que_thr_t*
+void
trx_sig_reply(
/*==========*/
- /* out: next query thread to run */
- trx_sig_t* sig); /* in: signal */
+ trx_sig_t* sig, /* in: signal */
+ que_thr_t** next_thr); /* in/out: next query thread to run;
+ if the value which is passed in is
+ a pointer to a NULL pointer, then the
+ calling function can start running
+ a new query thread */
/********************************************************************
Removes the signal object from a trx signal queue. */
@@ -229,11 +238,15 @@ trx_sig_remove(
/********************************************************************
Starts handling of a trx signal. */
-que_thr_t*
+void
trx_sig_start_handle(
/*=================*/
- /* out: next query thread to run, or NULL */
- trx_t* trx); /* in: trx handle */
+ trx_t* trx, /* in: trx handle */
+ que_thr_t** next_thr); /* in/out: next query thread to run;
+ if the value which is passed in is
+ a pointer to a NULL pointer, then the
+ calling function can start running
+ a new query thread */
/********************************************************************
Ends signal handling. If the session is in the error state, and
trx->graph_before_signal_handling != NULL, returns control to the error
diff --git a/innobase/include/usr0sess.h b/innobase/include/usr0sess.h
index aeff7191e68..c7bcfb20fed 100644
--- a/innobase/include/usr0sess.h
+++ b/innobase/include/usr0sess.h
@@ -38,6 +38,7 @@ sess_try_close(
/* The session handle. All fields are protected by the kernel mutex */
struct sess_struct{
+ ulint state; /* state of the session */
trx_t* trx; /* transaction object permanently
assigned for the session: the
transaction instance designated by the
@@ -48,6 +49,11 @@ struct sess_struct{
session */
};
+/* Session states */
+#define SESS_ACTIVE 1
+#define SESS_ERROR 2 /* session contains an error message
+ which has not yet been communicated
+ to the client */
#ifndef UNIV_NONINL
#include "usr0sess.ic"
#endif
diff --git a/innobase/include/ut0mem.h b/innobase/include/ut0mem.h
index 85b99efff68..2e02b3f0b6b 100644
--- a/innobase/include/ut0mem.h
+++ b/innobase/include/ut0mem.h
@@ -67,6 +67,37 @@ ut_free(
/*====*/
void* ptr); /* in, own: memory block */
/**************************************************************************
+Implements realloc. This is needed by /pars/lexyy.c. Otherwise, you should not
+use this function because the allocation functions in mem0mem.h are the
+recommended ones in InnoDB.
+
+man realloc in Linux, 2004:
+
+ realloc() changes the size of the memory block pointed to
+ by ptr to size bytes. The contents will be unchanged to
+ the minimum of the old and new sizes; newly allocated mem­
+ ory will be uninitialized. If ptr is NULL, the call is
+ equivalent to malloc(size); if size is equal to zero, the
+ call is equivalent to free(ptr). Unless ptr is NULL, it
+ must have been returned by an earlier call to malloc(),
+ calloc() or realloc().
+
+RETURN VALUE
+ realloc() returns a pointer to the newly allocated memory,
+ which is suitably aligned for any kind of variable and may
+ be different from ptr, or NULL if the request fails. If
+ size was equal to 0, either NULL or a pointer suitable to
+ be passed to free() is returned. If realloc() fails the
+ original block is left untouched - it is not freed or
+ moved. */
+
+void*
+ut_realloc(
+/*=======*/
+ /* out, own: pointer to new mem block or NULL */
+ void* ptr, /* in: pointer to old block or NULL */
+ ulint size); /* in: desired size */
+/**************************************************************************
Frees in shutdown all allocated memory not freed yet. */
void
diff --git a/innobase/lock/lock0lock.c b/innobase/lock/lock0lock.c
index 223d9af78d1..be0806590a9 100644
--- a/innobase/lock/lock0lock.c
+++ b/innobase/lock/lock0lock.c
@@ -292,9 +292,7 @@ waiting, in its lock queue. Solution: We can copy the locks as gap type
locks, so that also the waiting locks are transformed to granted gap type
locks on the inserted record. */
-#ifdef UNIV_DEBUG
ibool lock_print_waits = FALSE;
-#endif /* UNIV_DEBUG */
/* The lock system */
lock_sys_t* lock_sys = NULL;
@@ -510,7 +508,7 @@ lock_sys_create(
/* hash_create_mutexes(lock_sys->rec_hash, 2, SYNC_REC_LOCK); */
- lock_latest_err_file = tmpfile();
+ lock_latest_err_file = os_file_create_tmpfile();
}
/*************************************************************************
@@ -1354,8 +1352,7 @@ lock_rec_has_expl(
return(NULL);
}
-
-#ifdef UNIV_DEBUG
+
/*************************************************************************
Checks if some other transaction has a lock request in the queue. */
static
@@ -1398,7 +1395,6 @@ lock_rec_other_has_expl_req(
return(NULL);
}
-#endif /* UNIV_DEBUG */
/*************************************************************************
Checks if some other transaction has a conflicting explicit lock request
@@ -1688,13 +1684,11 @@ lock_rec_enqueue_waiting(
ut_a(que_thr_stop(thr));
-#ifdef UNIV_DEBUG
if (lock_print_waits) {
fprintf(stderr, "Lock wait for trx %lu in index ",
(ulong) ut_dulint_get_low(trx->id));
ut_print_name(stderr, index->name);
}
-#endif /* UNIV_DEBUG */
return(DB_LOCK_WAIT);
}
@@ -2034,12 +2028,10 @@ lock_grant(
lock->trx->n_tables_locked++;
}
-#ifdef UNIV_DEBUG
if (lock_print_waits) {
fprintf(stderr, "Lock wait for trx %lu ends\n",
(ulong) ut_dulint_get_low(lock->trx->id));
}
-#endif /* UNIV_DEBUG */
/* If we are resolving a deadlock by choosing another transaction
as a victim, then our original transaction may not be in the
@@ -3110,11 +3102,9 @@ lock_deadlock_recursive(
lock_table_print(ef, start->wait_lock);
}
-#ifdef UNIV_DEBUG
if (lock_print_waits) {
fputs("Deadlock detected\n", stderr);
}
-#endif /* UNIV_DEBUG */
if (ut_dulint_cmp(wait_lock->trx->undo_no,
start->undo_no) >= 0) {
@@ -4177,7 +4167,6 @@ loop:
goto loop;
}
-#ifdef UNIV_DEBUG
/*************************************************************************
Validates the lock queue on a table. */
@@ -4488,7 +4477,6 @@ lock_validate(void)
return(TRUE);
}
-#endif /* UNIV_DEBUG */
/*============ RECORD LOCK CHECKS FOR ROW OPERATIONS ====================*/
diff --git a/innobase/log/log0log.c b/innobase/log/log0log.c
index 292fed4b4ec..923ab448e07 100644
--- a/innobase/log/log0log.c
+++ b/innobase/log/log0log.c
@@ -32,18 +32,20 @@ ulint log_fsp_current_free_limit = 0;
log_t* log_sys = NULL;
ibool log_do_write = TRUE;
-#ifdef UNIV_LOG_DEBUG
+
ibool log_debug_writes = FALSE;
-#endif /* UNIV_LOG_DEBUG */
+
/* These control how often we print warnings if the last checkpoint is too
old */
ibool log_has_printed_chkp_warning = FALSE;
time_t log_last_warning_time;
+#ifdef UNIV_LOG_ARCHIVE
/* Pointer to this variable is used as the i/o-message when we do i/o to an
archive */
byte log_archive_io;
+#endif /* UNIV_LOG_ARCHIVE */
/* A margin for free space in the log buffer before a log entry is catenated */
#define LOG_BUF_WRITE_MARGIN (4 * OS_FILE_LOG_BLOCK_SIZE)
@@ -90,12 +92,14 @@ static
void
log_io_complete_checkpoint(void);
/*============================*/
+#ifdef UNIV_LOG_ARCHIVE
/**********************************************************
Completes an archiving i/o. */
static
void
log_io_complete_archive(void);
/*=========================*/
+#endif /* UNIV_LOG_ARCHIVE */
/********************************************************************
Sets the global variable log_fsp_current_free_limit. Also makes a checkpoint,
@@ -160,9 +164,13 @@ log_reserve_and_open(
{
log_t* log = log_sys;
ulint len_upper_limit;
+#ifdef UNIV_LOG_ARCHIVE
ulint archived_lsn_age;
- ulint count = 0;
ulint dummy;
+#endif /* UNIV_LOG_ARCHIVE */
+#ifdef UNIV_DEBUG
+ ulint count = 0;
+#endif /* UNIV_DEBUG */
ut_a(len < log->buf_size / 2);
loop:
@@ -182,13 +190,12 @@ loop:
log_buffer_flush_to_disk();
- count++;
-
- ut_ad(count < 50);
+ ut_ad(++count < 50);
goto loop;
}
+#ifdef UNIV_LOG_ARCHIVE
if (log->archiving_state != LOG_ARCH_OFF) {
archived_lsn_age = ut_dulint_minus(log->lsn,
@@ -204,13 +211,12 @@ loop:
log_archive_do(TRUE, &dummy);
- count++;
-
- ut_ad(count < 50);
+ ut_ad(++count < 50);
goto loop;
}
}
+#endif /* UNIV_LOG_ARCHIVE */
#ifdef UNIV_LOG_DEBUG
log->old_buf_free = log->buf_free;
@@ -378,6 +384,7 @@ function_exit:
return(lsn);
}
+#ifdef UNIV_LOG_ARCHIVE
/**********************************************************
Pads the current log block full with dummy log records. Used in producing
consistent archived log files. */
@@ -410,6 +417,7 @@ log_pad_current_log_block(void)
ut_a((ut_dulint_get_low(lsn) % OS_FILE_LOG_BLOCK_SIZE)
== LOG_BLOCK_HDR_SIZE);
}
+#endif /* UNIV_LOG_ARCHIVE */
/**********************************************************
Calculates the data capacity of a log group, when the log file headers are not
@@ -663,11 +671,13 @@ log_calc_max_ages(void)
/ LOG_POOL_CHECKPOINT_RATIO_ASYNC;
log_sys->max_checkpoint_age = margin;
+#ifdef UNIV_LOG_ARCHIVE
log_sys->max_archived_lsn_age = smallest_archive_margin;
log_sys->max_archived_lsn_age_async = smallest_archive_margin
- smallest_archive_margin /
LOG_ARCHIVE_RATIO_ASYNC;
+#endif /* UNIV_LOG_ARCHIVE */
failure:
mutex_exit(&(log_sys->mutex));
@@ -767,6 +777,7 @@ log_init(void)
memset(log_sys->checkpoint_buf, '\0', OS_FILE_LOG_BLOCK_SIZE);
/*----------------------------*/
+#ifdef UNIV_LOG_ARCHIVE
/* Under MySQL, log archiving is always off */
log_sys->archiving_state = LOG_ARCH_OFF;
log_sys->archived_lsn = log_sys->lsn;
@@ -788,13 +799,10 @@ log_init(void)
/* memset(log_sys->archive_buf, '\0', LOG_ARCHIVE_BUF_SIZE); */
log_sys->archiving_on = os_event_create(NULL);
+#endif /* UNIV_LOG_ARCHIVE */
/*----------------------------*/
-
- log_sys->online_backup_state = FALSE;
- /*----------------------------*/
-
log_block_init(log_sys->buf, log_sys->lsn);
log_block_set_first_rec_group(log_sys->buf, LOG_BLOCK_HDR_SIZE);
@@ -827,7 +835,8 @@ log_group_init(
ulint space_id, /* in: space id of the file space
which contains the log files of this
group */
- ulint archive_space_id) /* in: space id of the file space
+ ulint archive_space_id __attribute__((unused)))
+ /* in: space id of the file space
which contains some archived log
files for this group; currently, only
for the first log group this is
@@ -849,7 +858,9 @@ log_group_init(
group->n_pending_writes = 0;
group->file_header_bufs = mem_alloc(sizeof(byte*) * n_files);
+#ifdef UNIV_LOG_ARCHIVE
group->archive_file_header_bufs = mem_alloc(sizeof(byte*) * n_files);
+#endif /* UNIV_LOG_ARCHIVE */
for (i = 0; i < n_files; i++) {
*(group->file_header_bufs + i) = ut_align(
@@ -859,17 +870,21 @@ log_group_init(
memset(*(group->file_header_bufs + i), '\0',
LOG_FILE_HDR_SIZE);
+#ifdef UNIV_LOG_ARCHIVE
*(group->archive_file_header_bufs + i) = ut_align(
mem_alloc(LOG_FILE_HDR_SIZE + OS_FILE_LOG_BLOCK_SIZE),
OS_FILE_LOG_BLOCK_SIZE);
memset(*(group->archive_file_header_bufs + i), '\0',
LOG_FILE_HDR_SIZE);
+#endif /* UNIV_LOG_ARCHIVE */
}
+#ifdef UNIV_LOG_ARCHIVE
group->archive_space_id = archive_space_id;
group->archived_file_no = 0;
group->archived_offset = 0;
+#endif /* UNIV_LOG_ARCHIVE */
group->checkpoint_buf = ut_align(
mem_alloc(2 * OS_FILE_LOG_BLOCK_SIZE),
@@ -930,12 +945,10 @@ log_group_check_flush_completion(
#endif /* UNIV_SYNC_DEBUG */
if (!log_sys->one_flushed && group->n_pending_writes == 0) {
-#ifdef UNIV_LOG_DEBUG
if (log_debug_writes) {
fprintf(stderr,
"Log flushed first to group %lu\n", (ulong) group->id);
}
-#endif /* UNIV_LOG_DEBUG */
log_sys->written_to_some_lsn = log_sys->write_lsn;
log_sys->one_flushed = TRUE;
@@ -943,12 +956,10 @@ log_group_check_flush_completion(
return(LOG_UNLOCK_NONE_FLUSHED_LOCK);
}
-#ifdef UNIV_LOG_DEBUG
if (log_debug_writes && (group->n_pending_writes == 0)) {
fprintf(stderr, "Log flushed to group %lu\n", (ulong) group->id);
}
-#endif /* UNIV_LOG_DEBUG */
return(0);
}
@@ -1006,6 +1017,7 @@ log_io_complete(
{
ulint unlock;
+#ifdef UNIV_LOG_ARCHIVE
if ((byte*)group == &log_archive_io) {
/* It was an archive write */
@@ -1013,6 +1025,7 @@ log_io_complete(
return;
}
+#endif /* UNIV_LOG_ARCHIVE */
if ((ulint)group & 0x1UL) {
/* It was a checkpoint write */
@@ -1024,13 +1037,11 @@ log_io_complete(
fil_flush(group->space_id);
}
-#ifdef UNIV_LOG_DEBUG
if (log_debug_writes) {
fprintf(stderr,
"Checkpoint info written to group %lu\n",
group->id);
}
-#endif /* UNIV_LOG_DEBUG */
log_io_complete_checkpoint();
@@ -1093,13 +1104,11 @@ log_group_file_header_flush(
dest_offset = nth_file * group->file_size;
-#ifdef UNIV_LOG_DEBUG
if (log_debug_writes) {
fprintf(stderr,
"Writing log file header to group %lu file %lu\n",
(ulong) group->id, (ulong) nth_file);
}
-#endif /* UNIV_LOG_DEBUG */
if (log_do_write) {
log_sys->n_log_ios++;
@@ -1183,7 +1192,6 @@ loop:
write_len = len;
}
-#ifdef UNIV_LOG_DEBUG
if (log_debug_writes) {
fprintf(stderr,
@@ -1193,7 +1201,7 @@ loop:
(ulong) group->id, (ulong) next_offset,
(ulong) write_len,
(ulong) ut_dulint_get_high(start_lsn),
- (ulong) ut_dulint_get_low(start_lsn).
+ (ulong) ut_dulint_get_low(start_lsn),
(ulong) log_block_get_hdr_no(buf),
(ulong) log_block_get_hdr_no(
buf + write_len - OS_FILE_LOG_BLOCK_SIZE));
@@ -1207,7 +1215,6 @@ loop:
+ i * OS_FILE_LOG_BLOCK_SIZE));
}
}
-#endif /* UNIV_LOG_DEBUG */
/* Calculate the checksums for each log block and write them to
the trailer fields of the log blocks */
@@ -1335,7 +1342,6 @@ loop:
return;
}
-#ifdef UNIV_LOG_DEBUG
if (log_debug_writes) {
fprintf(stderr,
"Writing log from %lu %lu up to lsn %lu %lu\n",
@@ -1344,7 +1350,6 @@ loop:
(ulong) ut_dulint_get_high(log_sys->lsn),
(ulong) ut_dulint_get_low(log_sys->lsn));
}
-#endif /* UNIV_LOG_DEBUG */
log_sys->n_pending_writes++;
@@ -1633,8 +1638,10 @@ log_group_checkpoint(
log_group_t* group) /* in: log group */
{
log_group_t* group2;
+#ifdef UNIV_LOG_ARCHIVE
dulint archived_lsn;
dulint next_archived_lsn;
+#endif /* UNIV_LOG_ARCHIVE */
ulint write_offset;
ulint fold;
byte* buf;
@@ -1657,6 +1664,7 @@ log_group_checkpoint(
mach_write_to_4(buf + LOG_CHECKPOINT_LOG_BUF_SIZE, log_sys->buf_size);
+#ifdef UNIV_LOG_ARCHIVE
if (log_sys->archiving_state == LOG_ARCH_OFF) {
archived_lsn = ut_dulint_max;
} else {
@@ -1668,8 +1676,11 @@ log_group_checkpoint(
/* For debugging only */
}
}
-
+
mach_write_to_8(buf + LOG_CHECKPOINT_ARCHIVED_LSN, archived_lsn);
+#else /* UNIV_LOG_ARCHIVE */
+ mach_write_to_8(buf + LOG_CHECKPOINT_ARCHIVED_LSN, ut_dulint_max);
+#endif /* UNIV_LOG_ARCHIVE */
for (i = 0; i < LOG_MAX_N_GROUPS; i++) {
log_checkpoint_set_nth_group_info(buf, i, 0, 0);
@@ -1679,8 +1690,13 @@ log_group_checkpoint(
while (group2) {
log_checkpoint_set_nth_group_info(buf, group2->id,
+#ifdef UNIV_LOG_ARCHIVE
group2->archived_file_no,
- group2->archived_offset);
+ group2->archived_offset
+#else /* UNIV_LOG_ARCHIVE */
+ 0, 0
+#endif /* UNIV_LOG_ARCHIVE */
+ );
group2 = UT_LIST_GET_NEXT(log_groups, group2);
}
@@ -1903,14 +1919,12 @@ log_checkpoint(
log_sys->next_checkpoint_lsn = oldest_lsn;
-#ifdef UNIV_LOG_DEBUG
if (log_debug_writes) {
fprintf(stderr, "Making checkpoint no %lu at lsn %lu %lu\n",
(ulong) ut_dulint_get_low(log_sys->next_checkpoint_no),
(ulong) ut_dulint_get_high(oldest_lsn),
(ulong) ut_dulint_get_low(oldest_lsn));
}
-#endif /* UNIV_LOG_DEBUG */
log_groups_write_checkpoint_info();
@@ -2106,16 +2120,18 @@ loop:
len = group->file_size - (source_offset % group->file_size);
}
+#ifdef UNIV_LOG_ARCHIVE
if (type == LOG_ARCHIVE) {
log_sys->n_pending_archive_ios++;
}
+#endif /* UNIV_LOG_ARCHIVE */
log_sys->n_log_ios++;
fil_io(OS_FILE_READ | OS_FILE_LOG, sync, group->space_id,
source_offset / UNIV_PAGE_SIZE, source_offset % UNIV_PAGE_SIZE,
- len, buf, &log_archive_io);
+ len, buf, NULL);
start_lsn = ut_dulint_add(start_lsn, len);
buf += len;
@@ -2126,6 +2142,7 @@ loop:
}
}
+#ifdef UNIV_LOG_ARCHIVE
/**********************************************************
Generates an archived log file name. */
@@ -2138,8 +2155,6 @@ log_archived_file_name_gen(
currently we only archive the first group */
ulint file_no)/* in: file number */
{
- ut_a(0);
-
sprintf(buf, "%sib_arch_log_%010lu", srv_arch_dir, (ulong) file_no);
}
@@ -2160,8 +2175,6 @@ log_group_archive_file_header_write(
ulint dest_offset;
#ifdef UNIV_SYNC_DEBUG
- ut_a(0);
-
ut_ad(mutex_own(&(log_sys->mutex)));
#endif /* UNIV_SYNC_DEBUG */
@@ -2201,8 +2214,6 @@ log_group_archive_completed_header_write(
ulint dest_offset;
#ifdef UNIV_SYNC_DEBUG
- ut_a(0);
-
ut_ad(mutex_own(&(log_sys->mutex)));
#endif /* UNIV_SYNC_DEBUG */
ut_a(nth_file < group->n_files);
@@ -2244,8 +2255,6 @@ log_group_archive(
ulint open_mode;
#ifdef UNIV_SYNC_DEBUG
- ut_a(0);
-
ut_ad(mutex_own(&(log_sys->mutex)));
#endif /* UNIV_SYNC_DEBUG */
@@ -2296,11 +2305,9 @@ loop:
exit(1);
}
-#ifdef UNIV_LOG_DEBUG
if (log_debug_writes) {
fprintf(stderr, "Created archive file %s\n", name);
}
-#endif /* UNIV_LOG_DEBUG */
ret = os_file_close(file_handle);
@@ -2327,7 +2334,6 @@ loop:
len = group->file_size - (next_offset % group->file_size);
}
-#ifdef UNIV_LOG_DEBUG
if (log_debug_writes) {
fprintf(stderr,
"Archiving starting at lsn %lu %lu, len %lu to group %lu\n",
@@ -2335,7 +2341,6 @@ loop:
(ulong) ut_dulint_get_low(start_lsn),
(ulong) len, (ulong) group->id);
}
-#endif /* UNIV_LOG_DEBUG */
log_sys->n_pending_archive_ios++;
@@ -2376,8 +2381,6 @@ log_archive_groups(void)
log_group_t* group;
#ifdef UNIV_SYNC_DEBUG
- ut_a(0);
-
ut_ad(mutex_own(&(log_sys->mutex)));
#endif /* UNIV_SYNC_DEBUG */
@@ -2403,8 +2406,6 @@ log_archive_write_complete_groups(void)
ulint i;
#ifdef UNIV_SYNC_DEBUG
- ut_a(0);
-
ut_ad(mutex_own(&(log_sys->mutex)));
#endif /* UNIV_SYNC_DEBUG */
@@ -2430,13 +2431,11 @@ log_archive_write_complete_groups(void)
trunc_files = n_files - 1;
}
-#ifdef UNIV_LOG_DEBUG
if (log_debug_writes && trunc_files) {
fprintf(stderr,
"Complete file(s) archived to group %lu\n",
(ulong) group->id);
}
-#endif /* UNIV_LOG_DEBUG */
/* Calculate the archive file space start lsn */
start_lsn = ut_dulint_subtract(log_sys->next_archived_lsn,
@@ -2459,11 +2458,9 @@ log_archive_write_complete_groups(void)
fil_space_truncate_start(group->archive_space_id,
trunc_files * group->file_size);
-#ifdef UNIV_LOG_DEBUG
if (log_debug_writes) {
fputs("Archiving writes completed\n", stderr);
}
-#endif /* UNIV_LOG_DEBUG */
}
/**********************************************************
@@ -2474,19 +2471,15 @@ log_archive_check_completion_low(void)
/*==================================*/
{
#ifdef UNIV_SYNC_DEBUG
- ut_a(0);
-
ut_ad(mutex_own(&(log_sys->mutex)));
#endif /* UNIV_SYNC_DEBUG */
if (log_sys->n_pending_archive_ios == 0
&& log_sys->archiving_phase == LOG_ARCHIVE_READ) {
-#ifdef UNIV_LOG_DEBUG
if (log_debug_writes) {
fputs("Archiving read completed\n", stderr);
}
-#endif /* UNIV_LOG_DEBUG */
/* Archive buffer has now been read in: start archive writes */
@@ -2515,8 +2508,6 @@ log_io_complete_archive(void)
{
log_group_t* group;
- ut_a(0);
-
mutex_enter(&(log_sys->mutex));
group = UT_LIST_GET_FIRST(log_sys->log_groups);
@@ -2552,8 +2543,6 @@ log_archive_do(
dulint start_lsn;
dulint limit_lsn;
- ut_a(0);
-
calc_new_limit = TRUE;
loop:
mutex_enter(&(log_sys->mutex));
@@ -2634,7 +2623,6 @@ loop:
log_sys->next_archived_lsn = limit_lsn;
-#ifdef UNIV_LOG_DEBUG
if (log_debug_writes) {
fprintf(stderr,
"Archiving from lsn %lu %lu to lsn %lu %lu\n",
@@ -2643,7 +2631,6 @@ loop:
(ulong) ut_dulint_get_high(limit_lsn),
(ulong) ut_dulint_get_low(limit_lsn));
}
-#endif /* UNIV_LOG_DEBUG */
/* Read the log segment to the archive buffer */
@@ -2682,8 +2669,6 @@ log_archive_all(void)
return;
}
- ut_a(0);
-
present_lsn = log_sys->lsn;
mutex_exit(&(log_sys->mutex));
@@ -2728,8 +2713,6 @@ log_archive_close_groups(
return;
}
- ut_a(0);
-
group = UT_LIST_GET_FIRST(log_sys->log_groups);
trunc_len = UNIV_PAGE_SIZE
@@ -2750,14 +2733,12 @@ log_archive_close_groups(
group->archived_file_no += 2;
}
-#ifdef UNIV_LOG_DEBUG
if (log_debug_writes) {
fprintf(stderr,
"Incrementing arch file no to %lu in log group %lu\n",
(ulong) group->archived_file_no + 2,
(ulong) group->id);
}
-#endif /* UNIV_LOG_DEBUG */
}
}
@@ -2774,8 +2755,6 @@ log_archive_stop(void)
{
ibool success;
- ut_a(0);
-
mutex_enter(&(log_sys->mutex));
if (log_sys->archiving_state != LOG_ARCH_ON) {
@@ -2838,8 +2817,6 @@ log_archive_start(void)
/*===================*/
/* out: DB_SUCCESS or DB_ERROR */
{
- ut_a(0);
-
mutex_enter(&(log_sys->mutex));
if (log_sys->archiving_state != LOG_ARCH_STOPPED) {
@@ -2866,7 +2843,6 @@ log_archive_noarchivelog(void)
/*==========================*/
/* out: DB_SUCCESS or DB_ERROR */
{
- ut_a(0);
loop:
mutex_enter(&(log_sys->mutex));
@@ -2899,7 +2875,6 @@ log_archive_archivelog(void)
/*========================*/
/* out: DB_SUCCESS or DB_ERROR */
{
- ut_a(0);
mutex_enter(&(log_sys->mutex));
if (log_sys->archiving_state == LOG_ARCH_OFF) {
@@ -2918,7 +2893,6 @@ log_archive_archivelog(void)
return(DB_ERROR);
}
-#ifdef notdefined
/********************************************************************
Tries to establish a big enough margin of free space in the log groups, such
that a new log entry can be catenated without an immediate need for
@@ -2972,7 +2946,7 @@ loop:
goto loop;
}
}
-#endif
+#endif /* UNIV_LOG_ARCHIVE */
/************************************************************************
Checks that there is enough free space in the log to start a new query step.
@@ -2989,7 +2963,9 @@ loop:
log_checkpoint_margin();
- /* log_archive_margin(); */
+#ifdef UNIV_LOG_ARCHIVE
+ log_archive_margin();
+#endif /* UNIV_LOG_ARCHIVE */
mutex_enter(&(log_sys->mutex));
@@ -3003,66 +2979,6 @@ loop:
mutex_exit(&(log_sys->mutex));
}
-/**********************************************************
-Switches the database to the online backup state. */
-
-ulint
-log_switch_backup_state_on(void)
-/*============================*/
- /* out: DB_SUCCESS or DB_ERROR */
-{
- dulint backup_lsn;
-
- mutex_enter(&(log_sys->mutex));
-
- if (log_sys->online_backup_state) {
-
- /* The database is already in that state */
-
- mutex_exit(&(log_sys->mutex));
-
- return(DB_ERROR);
- }
-
- log_sys->online_backup_state = TRUE;
-
- backup_lsn = log_sys->lsn;
-
- log_sys->online_backup_lsn = backup_lsn;
-
- mutex_exit(&(log_sys->mutex));
-
- /* log_checkpoint_and_mark_file_spaces(); */
-
- return(DB_SUCCESS);
-}
-
-/**********************************************************
-Switches the online backup state off. */
-
-ulint
-log_switch_backup_state_off(void)
-/*=============================*/
- /* out: DB_SUCCESS or DB_ERROR */
-{
- mutex_enter(&(log_sys->mutex));
-
- if (!log_sys->online_backup_state) {
-
- /* The database is already in that state */
-
- mutex_exit(&(log_sys->mutex));
-
- return(DB_ERROR);
- }
-
- log_sys->online_backup_state = FALSE;
-
- mutex_exit(&(log_sys->mutex));
-
- return(DB_SUCCESS);
-}
-
/********************************************************************
Makes a checkpoint at the latest lsn and writes it to first page of each
data file in the database, so that we know that the file spaces contain
@@ -3111,9 +3027,12 @@ loop:
mutex_enter(&(log_sys->mutex));
- if (log_sys->n_pending_archive_ios
- + log_sys->n_pending_checkpoint_writes
- + log_sys->n_pending_writes > 0) {
+ if (
+#ifdef UNIV_LOG_ARCHIVE
+ log_sys->n_pending_archive_ios ||
+#endif /* UNIV_LOG_ARCHIVE */
+ log_sys->n_pending_checkpoint_writes ||
+ log_sys->n_pending_writes) {
mutex_exit(&(log_sys->mutex));
@@ -3127,7 +3046,9 @@ loop:
goto loop;
}
- /* log_archive_all(); */
+#ifdef UNIV_LOG_ARCHIVE
+ log_archive_all();
+#endif /* UNIV_LOG_ARCHIVE */
log_make_checkpoint_at(ut_dulint_max, TRUE);
mutex_enter(&(log_sys->mutex));
@@ -3135,10 +3056,13 @@ loop:
lsn = log_sys->lsn;
if (ut_dulint_cmp(lsn, log_sys->last_checkpoint_lsn) != 0
+#ifdef UNIV_LOG_ARCHIVE
|| (srv_log_archive_on
&& ut_dulint_cmp(lsn,
ut_dulint_add(log_sys->archived_lsn, LOG_BLOCK_HDR_SIZE))
- != 0)) {
+ != 0)
+#endif /* UNIV_LOG_ARCHIVE */
+ ) {
mutex_exit(&(log_sys->mutex));
@@ -3146,15 +3070,17 @@ loop:
}
arch_log_no = 0;
-/*
- UT_LIST_GET_FIRST(log_sys->log_groups)->archived_file_no;
-
+
+#ifdef UNIV_LOG_ARCHIVE
+ UT_LIST_GET_FIRST(log_sys->log_groups)->archived_file_no;
+
if (0 == UT_LIST_GET_FIRST(log_sys->log_groups)->archived_offset) {
-
+
arch_log_no--;
}
-*/
- /* log_archive_close_groups(TRUE); */
+
+ log_archive_close_groups(TRUE);
+#endif /* UNIV_LOG_ARCHIVE */
mutex_exit(&(log_sys->mutex));
@@ -3227,7 +3153,6 @@ loop:
ut_a(0 == ut_dulint_cmp(lsn, log_sys->lsn));
}
-#ifdef UNIV_LOG_DEBUG
/**********************************************************
Checks by parsing that the catenated log segment for a single mtr is
consistent. */
@@ -3280,7 +3205,6 @@ log_check_log_recs(
return(TRUE);
}
-#endif /* UNIV_LOG_DEBUG */
/**********************************************************
Peeks the current lsn. */
@@ -3292,8 +3216,7 @@ log_peek_lsn(
log system mutex */
dulint* lsn) /* out: if returns TRUE, current lsn is here */
{
- if (0 == mutex_enter_nowait(&(log_sys->mutex), (char*)__FILE__,
- __LINE__)) {
+ if (0 == mutex_enter_nowait(&(log_sys->mutex), __FILE__, __LINE__)) {
*lsn = log_sys->lsn;
mutex_exit(&(log_sys->mutex));
diff --git a/innobase/log/log0recv.c b/innobase/log/log0recv.c
index 65fb3466ad5..7e57efcf9e1 100644
--- a/innobase/log/log0recv.c
+++ b/innobase/log/log0recv.c
@@ -34,10 +34,12 @@ Created 9/20/1997 Heikki Tuuri
#include "dict0boot.h"
#include "fil0fil.h"
+#ifdef UNIV_HOTBACKUP
/* This is set to FALSE if the backup was originally taken with the
ibbackup --include regexp option: then we do not want to create tables in
directories which were not included */
ibool recv_replay_file_ops = TRUE;
+#endif /* UNIV_HOTBACKUP */
/* Log records are stored in the hash table in chunks at most of this size;
this must be less than UNIV_PAGE_SIZE as it is stored in the buffer pool */
@@ -71,7 +73,11 @@ log scan */
ulint recv_scan_print_counter = 0;
ibool recv_is_from_backup = FALSE;
+#ifdef UNIV_HOTBACKUP
ibool recv_is_making_a_backup = FALSE;
+#else
+# define recv_is_making_a_backup FALSE
+#endif /* UNIV_HOTBACKUP */
ulint recv_previous_parsed_rec_type = 999999;
ulint recv_previous_parsed_rec_offset = 0;
@@ -183,7 +189,6 @@ recv_sys_empty_hash(void)
recv_sys->addr_hash = hash_create(buf_pool_get_curr_size() / 256);
}
-#ifndef UNIV_LOG_DEBUG
/************************************************************
Frees the recovery system. */
static
@@ -203,7 +208,6 @@ recv_sys_free(void)
mutex_exit(&(recv_sys->mutex));
}
-#endif /* !UNIV_LOG_DEBUG */
/************************************************************
Truncates possible corrupted or extra records from a log group. */
@@ -485,7 +489,6 @@ recv_find_max_checkpoint(
log_group_read_checkpoint_info(group, field);
if (!recv_check_cp_is_consistent(buf)) {
-#ifdef UNIV_LOG_DEBUG
if (log_debug_writes) {
fprintf(stderr,
"InnoDB: Checkpoint in group %lu at %lu invalid, %lu\n",
@@ -495,7 +498,6 @@ recv_find_max_checkpoint(
+ LOG_CHECKPOINT_CHECKSUM_1));
}
-#endif /* UNIV_LOG_DEBUG */
goto not_consistent;
}
@@ -509,14 +511,12 @@ recv_find_max_checkpoint(
checkpoint_no =
mach_read_from_8(buf + LOG_CHECKPOINT_NO);
-#ifdef UNIV_LOG_DEBUG
if (log_debug_writes) {
fprintf(stderr,
"InnoDB: Checkpoint number %lu found in group %lu\n",
(ulong) ut_dulint_get_low(checkpoint_no),
(ulong) group->id);
}
-#endif /* UNIV_LOG_DEBUG */
if (ut_dulint_cmp(checkpoint_no, max_no) >= 0) {
*max_group = group;
@@ -808,9 +808,6 @@ recv_parse_or_apply_log_rec_body(
} else if (type == MLOG_IBUF_BITMAP_INIT) {
new_ptr = ibuf_parse_bitmap_init(ptr, end_ptr, page, mtr);
- } else if (type == MLOG_FULL_PAGE) {
- new_ptr = mtr_log_parse_full_page(ptr, end_ptr, page);
-
} else if (type == MLOG_INIT_FILE_PAGE) {
new_ptr = fsp_parse_init_file_page(ptr, end_ptr, page);
@@ -1127,15 +1124,7 @@ recv_recover_page(
buf = ((byte*)(recv->data)) + sizeof(recv_data_t);
}
- if (recv->type == MLOG_INIT_FILE_PAGE
- || recv->type == MLOG_FULL_PAGE) {
- /* A new file page may have been taken into use,
- or we have stored the full contents of the page:
- in this case it may be that the original log record
- type was MLOG_INIT_FILE_PAGE, and we replaced it
- with MLOG_FULL_PAGE, thus we have to apply
- any record of type MLOG_FULL_PAGE */
-
+ if (recv->type == MLOG_INIT_FILE_PAGE) {
page_lsn = page_newest_lsn;
mach_write_to_8(page + UNIV_PAGE_SIZE
@@ -1151,7 +1140,6 @@ recv_recover_page(
start_lsn = recv->start_lsn;
}
-#ifdef UNIV_LOG_DEBUG
if (log_debug_writes) {
fprintf(stderr,
"InnoDB: Applying log rec type %lu len %lu to space %lu page no %lu\n",
@@ -1159,7 +1147,6 @@ recv_recover_page(
(ulong) recv_addr->space,
(ulong) recv_addr->page_no);
}
-#endif /* UNIV_LOG_DEBUG */
recv_parse_or_apply_log_rec_body(recv->type, buf,
buf + recv->len, page, &mtr);
@@ -1402,7 +1389,6 @@ loop:
mutex_exit(&(recv_sys->mutex));
}
-#ifdef UNIV_HOTBACKUP
/* This page is allocated from the buffer pool and used in the function
below */
page_t* recv_backup_application_page = NULL;
@@ -1527,7 +1513,6 @@ skip_this_recv_addr:
recv_sys_empty_hash();
}
-#endif
#ifdef notdefined
/***********************************************************************
@@ -1729,7 +1714,7 @@ recv_compare_spaces_low(
recv_compare_spaces(space1, space2, n_pages);
}
-#endif
+#endif /* UNIV_LOG_REPLICATE */
/***********************************************************************
Tries to parse a single log record and returns its length. */
@@ -1825,11 +1810,10 @@ recv_calc_lsn_on_data_add(
return(ut_dulint_add(lsn, lsn_len));
}
-#ifdef UNIV_LOG_DEBUG
/***********************************************************
Checks that the parser recognizes incomplete initial segments of a log
record as incomplete. */
-static
+
void
recv_check_incomplete_log_recs(
/*===========================*/
@@ -1847,7 +1831,6 @@ recv_check_incomplete_log_recs(
&page_no, &body));
}
}
-#endif /* UNIV_LOG_DEBUG */
/***********************************************************
Prints diagnostic info of corrupt log. */
@@ -1984,14 +1967,12 @@ loop:
recv_sys->recovered_offset += len;
recv_sys->recovered_lsn = new_recovered_lsn;
-#ifdef UNIV_LOG_DEBUG
if (log_debug_writes) {
fprintf(stderr,
"InnoDB: Parsed a single log rec type %lu len %lu space %lu page no %lu\n",
(ulong) type, (ulong) len, (ulong) space,
(ulong) page_no);
}
-#endif /* UNIV_LOG_DEBUG */
if (type == MLOG_DUMMY_RECORD) {
/* Do nothing */
@@ -2029,11 +2010,13 @@ loop:
becomes identical with the original page */
#ifdef UNIV_LOG_DEBUG
recv_check_incomplete_log_recs(ptr, len);
-#endif
-/* recv_update_replicate(type, space, page_no, body,
+#endif/* UNIV_LOG_DEBUG */
+#ifdef UNIV_LOG_REPLICATE
+ recv_update_replicate(type, space, page_no, body,
ptr + len);
recv_compare_replicate(space, page_no);
-*/
+#endif /* UNIV_LOG_REPLICATE */
+
}
} else {
/* Check that all the records associated with the single mtr
@@ -2066,21 +2049,19 @@ loop:
according to the log record */
#ifdef UNIV_LOG_DEBUG
recv_check_incomplete_log_recs(ptr, len);
-#endif
-/*
+#endif /* UNIV_LOG_DEBUG */
+#ifdef UNIV_LOG_REPLICATE
recv_update_replicate(type, space, page_no,
body, ptr + len);
-*/
+#endif /* UNIV_LOG_REPLICATE */
}
-#ifdef UNIV_LOG_DEBUG
if (log_debug_writes) {
fprintf(stderr,
"InnoDB: Parsed a multi log rec type %lu len %lu space %lu page no %lu\n",
(ulong) type, (ulong) len, (ulong) space,
(ulong) page_no);
}
-#endif /* UNIV_LOG_DEBUG */
total_len += len;
n_recs++;
@@ -2138,12 +2119,13 @@ loop:
recv_add_to_hash_table(type, space, page_no,
body, ptr + len, old_lsn,
new_recovered_lsn);
+#ifdef UNIV_LOG_REPLICATE
} else {
/* In debug checking, check that the replicate
page has become identical with the original
page */
-
-/* recv_compare_replicate(space, page_no); */
+ recv_compare_replicate(space, page_no);
+#endif /* UNIV_LOG_REPLICATE */
}
ptr += len;
@@ -2486,7 +2468,6 @@ recv_group_scan_log_recs(
start_lsn = end_lsn;
}
-#ifdef UNIV_LOG_DEBUG
if (log_debug_writes) {
fprintf(stderr,
"InnoDB: Scanned group %lu up to log sequence number %lu %lu\n",
@@ -2494,7 +2475,6 @@ recv_group_scan_log_recs(
(ulong) ut_dulint_get_high(*group_scanned_lsn),
(ulong) ut_dulint_get_low(*group_scanned_lsn));
}
-#endif /* UNIV_LOG_DEBUG */
}
/************************************************************
@@ -2587,15 +2567,16 @@ recv_recovery_from_checkpoint_start(
/* Wipe over the label now */
- ut_memcpy(log_hdr_buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP,
- (char*)" ", 4);
+ memset(log_hdr_buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP,
+ ' ', 4);
/* Write to the log file to wipe over the label */
fil_io(OS_FILE_WRITE | OS_FILE_LOG, TRUE,
max_cp_group->space_id,
0, 0, OS_FILE_LOG_BLOCK_SIZE,
log_hdr_buf, max_cp_group);
}
-
+
+#ifdef UNIV_LOG_ARCHIVE
group = UT_LIST_GET_FIRST(log_sys->log_groups);
while (group) {
@@ -2605,6 +2586,7 @@ recv_recovery_from_checkpoint_start(
group = UT_LIST_GET_NEXT(log_groups, group);
}
+#endif /* UNIV_LOG_ARCHIVE */
if (type == LOG_CHECKPOINT) {
/* Start reading the log groups from the checkpoint lsn up. The
@@ -2800,7 +2782,9 @@ recv_recovery_from_checkpoint_start(
log_sys->next_checkpoint_lsn = checkpoint_lsn;
log_sys->next_checkpoint_no = ut_dulint_add(checkpoint_no, 1);
+#ifdef UNIV_LOG_ARCHIVE
log_sys->archived_lsn = archived_lsn;
+#endif /* UNIV_LOG_ARCHIVE */
recv_synchronize_groups(up_to_date_group);
@@ -2833,10 +2817,12 @@ recv_recovery_from_checkpoint_start(
log_sys->next_checkpoint_no = ut_dulint_add(checkpoint_no, 1);
+#ifdef UNIV_LOG_ARCHIVE
if (ut_dulint_cmp(archived_lsn, ut_dulint_max) == 0) {
log_sys->archiving_state = LOG_ARCH_OFF;
}
+#endif /* UNIV_LOG_ARCHIVE */
mutex_enter(&(recv_sys->mutex));
@@ -2875,12 +2861,10 @@ recv_recovery_from_checkpoint_finish(void)
recv_apply_hashed_log_recs(TRUE);
}
-#ifdef UNIV_LOG_DEBUG
if (log_debug_writes) {
fprintf(stderr,
"InnoDB: Log records applied to the database\n");
}
-#endif /* UNIV_LOG_DEBUG */
if (recv_needed_recovery) {
trx_sys_print_mysql_master_log_pos();
@@ -2915,7 +2899,9 @@ recv_reset_logs(
dulint lsn, /* in: reset to this lsn rounded up to
be divisible by OS_FILE_LOG_BLOCK_SIZE,
after which we add LOG_BLOCK_HDR_SIZE */
+#ifdef UNIV_LOG_ARCHIVE
ulint arch_log_no, /* in: next archived log file number */
+#endif /* UNIV_LOG_ARCHIVE */
ibool new_logs_created)/* in: TRUE if resetting logs is done
at the log creation; FALSE if it is done
after archive recovery */
@@ -2932,9 +2918,10 @@ recv_reset_logs(
while (group) {
group->lsn = log_sys->lsn;
group->lsn_offset = LOG_FILE_HDR_SIZE;
-
+#ifdef UNIV_LOG_ARCHIVE
group->archived_file_no = arch_log_no;
group->archived_offset = 0;
+#endif /* UNIV_LOG_ARCHIVE */
if (!new_logs_created) {
recv_truncate_group(group, group->lsn, group->lsn,
@@ -2951,7 +2938,9 @@ recv_reset_logs(
log_sys->next_checkpoint_no = ut_dulint_zero;
log_sys->last_checkpoint_lsn = ut_dulint_zero;
+#ifdef UNIV_LOG_ARCHIVE
log_sys->archived_lsn = log_sys->lsn;
+#endif /* UNIV_LOG_ARCHIVE */
log_block_init(log_sys->buf, log_sys->lsn);
log_block_set_first_rec_group(log_sys->buf, LOG_BLOCK_HDR_SIZE);
@@ -2969,17 +2958,18 @@ recv_reset_logs(
mutex_enter(&(log_sys->mutex));
}
+#ifdef UNIV_HOTBACKUP
/**********************************************************
Creates new log files after a backup has been restored. */
void
recv_reset_log_files_for_backup(
/*============================*/
- char* log_dir, /* in: log file directory path */
- ulint n_log_files, /* in: number of log files */
- ulint log_file_size, /* in: log file size */
- dulint lsn) /* in: new start lsn, must be divisible by
- OS_FILE_LOG_BLOCK_SIZE */
+ const char* log_dir, /* in: log file directory path */
+ ulint n_log_files, /* in: number of log files */
+ ulint log_file_size, /* in: log file size */
+ dulint lsn) /* in: new start lsn, must be
+ divisible by OS_FILE_LOG_BLOCK_SIZE */
{
os_file_t log_file;
ibool success;
@@ -2987,8 +2977,8 @@ recv_reset_log_files_for_backup(
ulint i;
ulint log_dir_len;
char* name;
- static
- char logfilename[] = "ib_logfile";
+ static const
+ char logfilename[] = "ib_logfile";
log_dir_len = strlen(log_dir);
/* reserve space for log_dir, "ib_logfile" and a number */
@@ -3058,7 +3048,9 @@ recv_reset_log_files_for_backup(
mem_free(name);
ut_free(buf);
}
+#endif /* UNIV_HOTBACKUP */
+#ifdef UNIV_LOG_ARCHIVE
/**********************************************************
Reads from the archive of a log group and performs recovery. */
static
@@ -3202,7 +3194,6 @@ ask_again:
break;
}
-#ifdef UNIV_LOG_DEBUG
if (log_debug_writes) {
fprintf(stderr,
"InnoDB: Archive read starting at lsn %lu %lu, len %lu from file %s\n",
@@ -3210,7 +3201,6 @@ ask_again:
(ulong) ut_dulint_get_low(start_lsn),
(ulong) len, name);
}
-#endif /* UNIV_LOG_DEBUG */
fil_io(OS_FILE_READ | OS_FILE_LOG, TRUE,
group->archive_space_id, read_offset / UNIV_PAGE_SIZE,
@@ -3364,9 +3354,8 @@ void
recv_recovery_from_archive_finish(void)
/*===================================*/
{
- ut_a(0);
-
recv_recovery_from_checkpoint_finish();
recv_recovery_from_backup_on = FALSE;
}
+#endif /* UNIV_LOG_ARCHIVE */
diff --git a/innobase/mem/mem0dbg.c b/innobase/mem/mem0dbg.c
index 5ace0441180..ea8c296f8cf 100644
--- a/innobase/mem/mem0dbg.c
+++ b/innobase/mem/mem0dbg.c
@@ -22,6 +22,7 @@ static ulint mem_n_allocations = 0;
static ulint mem_total_allocated_memory = 0;
ulint mem_current_allocated_memory = 0;
static ulint mem_max_allocated_memory = 0;
+static ulint mem_last_print_info = 0;
/* Size of the hash table for memory management tracking */
#define MEM_HASH_SIZE 997
@@ -33,7 +34,7 @@ struct mem_hash_node_struct {
UT_LIST_NODE_T(mem_hash_node_t)
list; /* hash list node */
mem_heap_t* heap; /* memory heap */
- char* file_name;/* file where heap was created*/
+ const char* file_name;/* file where heap was created*/
ulint line; /* file line of creation */
ulint nth_heap;/* this is the nth heap created */
UT_LIST_NODE_T(mem_hash_node_t)
@@ -266,7 +267,7 @@ void
mem_hash_insert(
/*============*/
mem_heap_t* heap, /* in: the created heap */
- char* file_name, /* in: file name of creation */
+ const char* file_name, /* in: file name of creation */
ulint line) /* in: line where created */
{
mem_hash_node_t* new_node;
@@ -309,7 +310,7 @@ void
mem_hash_remove(
/*============*/
mem_heap_t* heap, /* in: the heap to be freed */
- char* file_name, /* in: file name of freeing */
+ const char* file_name, /* in: file name of freeing */
ulint line) /* in: line where freed */
{
mem_hash_node_t* node;
@@ -373,7 +374,6 @@ mem_hash_remove(
}
#endif /* UNIV_MEM_DEBUG */
-#ifdef UNIV_DEBUG
/*******************************************************************
Checks a memory heap for consistency and prints the contents if requested.
Outputs the sum of sizes of buffers given to the user (only in
@@ -603,7 +603,6 @@ mem_heap_validate(
return(TRUE);
}
-#endif /* UNIV_DEBUG */
#ifdef UNIV_MEM_DEBUG
/*********************************************************************
@@ -816,3 +815,128 @@ mem_analyze_corruption(
dist++;
}
}
+
+/*********************************************************************
+Prints information of dynamic memory usage and currently allocated
+memory heaps or buffers. Can only be used in the debug version. */
+static
+void
+mem_print_info_low(
+/*===============*/
+ ibool print_all) /* in: if TRUE, all heaps are printed,
+ else only the heaps allocated after the
+ previous call of this function */
+{
+#ifdef UNIV_MEM_DEBUG
+ mem_hash_node_t* node;
+ ulint n_heaps = 0;
+ ulint allocated_mem;
+ ulint ph_size;
+ ulint total_allocated_mem = 0;
+ ibool error;
+ ulint n_blocks;
+#endif
+ FILE* outfile;
+
+ /* outfile = fopen("ibdebug", "a"); */
+
+ outfile = stdout;
+
+ fprintf(outfile, "\n");
+ fprintf(outfile,
+ "________________________________________________________\n");
+ fprintf(outfile, "MEMORY ALLOCATION INFORMATION\n\n");
+
+#ifndef UNIV_MEM_DEBUG
+
+ UT_NOT_USED(print_all);
+
+ mem_pool_print_info(outfile, mem_comm_pool);
+
+ fprintf(outfile,
+ "Sorry, non-debug version cannot give more memory info\n");
+
+ /* fclose(outfile); */
+
+ return;
+#else
+ mutex_enter(&mem_hash_mutex);
+
+ fprintf(outfile, "LIST OF CREATED HEAPS AND ALLOCATED BUFFERS: \n\n");
+
+ if (!print_all) {
+ fprintf(outfile, "AFTER THE LAST PRINT INFO\n");
+ }
+
+ node = UT_LIST_GET_FIRST(mem_all_list_base);
+
+ while (node != NULL) {
+ n_heaps++;
+
+ if (!print_all && node->nth_heap < mem_last_print_info) {
+
+ goto next_heap;
+ }
+
+ mem_heap_validate_or_print(node->heap, NULL,
+ FALSE, &error, &allocated_mem,
+ &ph_size, &n_blocks);
+ total_allocated_mem += allocated_mem;
+
+ fprintf(outfile,
+ "%lu: file %s line %lu of size %lu phys.size %lu with %lu blocks, type %lu\n",
+ node->nth_heap, node->file_name, node->line,
+ allocated_mem, ph_size, n_blocks,
+ (node->heap)->type);
+ next_heap:
+ node = UT_LIST_GET_NEXT(all_list, node);
+ }
+
+ fprintf(outfile, "\n");
+
+ fprintf(outfile, "Current allocated memory : %lu\n",
+ mem_current_allocated_memory);
+ fprintf(outfile, "Current allocated heaps and buffers : %lu\n",
+ n_heaps);
+ fprintf(outfile, "Cumulative allocated memory : %lu\n",
+ mem_total_allocated_memory);
+ fprintf(outfile, "Maximum allocated memory : %lu\n",
+ mem_max_allocated_memory);
+ fprintf(outfile, "Cumulative created heaps and buffers : %lu\n",
+ mem_n_created_heaps);
+ fprintf(outfile, "Cumulative number of allocations : %lu\n",
+ mem_n_allocations);
+
+ mem_last_print_info = mem_n_created_heaps;
+
+ mutex_exit(&mem_hash_mutex);
+
+ mem_pool_print_info(outfile, mem_comm_pool);
+
+/* mem_validate(); */
+
+/* fclose(outfile); */
+#endif
+}
+
+/*********************************************************************
+Prints information of dynamic memory usage and currently allocated memory
+heaps or buffers. Can only be used in the debug version. */
+
+void
+mem_print_info(void)
+/*================*/
+{
+ mem_print_info_low(TRUE);
+}
+
+/*********************************************************************
+Prints information of dynamic memory usage and currently allocated memory
+heaps or buffers since the last ..._print_info or..._print_new_info. */
+
+void
+mem_print_new_info(void)
+/*====================*/
+{
+ mem_print_info_low(FALSE);
+}
diff --git a/innobase/mem/mem0pool.c b/innobase/mem/mem0pool.c
index 0227c2d0969..023369e8ec5 100644
--- a/innobase/mem/mem0pool.c
+++ b/innobase/mem/mem0pool.c
@@ -559,7 +559,6 @@ mem_area_free(
ut_ad(mem_pool_validate(pool));
}
-#ifdef UNIV_DEBUG
/************************************************************************
Validates a memory pool. */
@@ -637,7 +636,6 @@ mem_pool_print_info(
(ulong) pool->reserved);
mutex_exit(&(pool->mutex));
}
-#endif /* UNIV_DEBUG */
/************************************************************************
Returns the amount of reserved memory. */
diff --git a/innobase/mtr/mtr0mtr.c b/innobase/mtr/mtr0mtr.c
index fa1481dcb5f..6e918806eb1 100644
--- a/innobase/mtr/mtr0mtr.c
+++ b/innobase/mtr/mtr0mtr.c
@@ -106,179 +106,6 @@ mtr_memo_pop_all(
}
/****************************************************************
-Writes to the log the contents of a full page. This is called when the
-database is in the online backup state. */
-static
-void
-mtr_log_write_full_page(
-/*====================*/
- page_t* page, /* in: page to write */
- ulint i, /* in: i'th page for mtr */
- ulint n_pages,/* in: total number of pages for mtr */
- mtr_t* mtr) /* in: mtr */
-{
- byte* buf;
- byte* ptr;
- ulint len;
-
- buf = mem_alloc(UNIV_PAGE_SIZE + 50);
-
- ptr = mlog_write_initial_log_record_fast(page, MLOG_FULL_PAGE, buf,
- mtr);
- ut_memcpy(ptr, page, UNIV_PAGE_SIZE);
-
- len = (ptr - buf) + UNIV_PAGE_SIZE;
-
- if (i == n_pages - 1) {
- if (n_pages > 1) {
- *(buf + len) = MLOG_MULTI_REC_END;
- len++;
- } else {
- *buf = (byte)((ulint)*buf | MLOG_SINGLE_REC_FLAG);
- }
- }
-
- ut_ad(len < UNIV_PAGE_SIZE + 50);
-
- log_write_low(buf, len);
-
- mem_free(buf);
-}
-
-/****************************************************************
-Parses a log record which contains the full contents of a page. */
-
-byte*
-mtr_log_parse_full_page(
-/*====================*/
- /* out: end of log record or NULL */
- byte* ptr, /* in: buffer */
- byte* end_ptr,/* in: buffer end */
- page_t* page) /* in: page or NULL */
-{
- if (end_ptr < ptr + UNIV_PAGE_SIZE) {
-
- return(NULL);
- }
-
- if (page) {
- ut_memcpy(page, ptr, UNIV_PAGE_SIZE);
- }
-
- return(ptr + UNIV_PAGE_SIZE);
-}
-
-/****************************************************************
-Writes to the database log the full contents of the pages that this mtr has
-modified. */
-static
-void
-mtr_log_write_backup_full_pages(
-/*============================*/
- mtr_t* mtr, /* in: mini-transaction */
- ulint n_pages)/* in: number of pages modified by mtr */
-{
- mtr_memo_slot_t* slot;
- dyn_array_t* memo;
- buf_block_t* block;
- ulint offset;
- ulint type;
- ulint i;
-
- ut_ad(mtr);
- ut_ad(mtr->magic_n == MTR_MAGIC_N);
- ut_ad(mtr->state == MTR_COMMITTING);
-
- /* Open the database log for log_write_low */
- mtr->start_lsn = log_reserve_and_open(n_pages * (UNIV_PAGE_SIZE + 50));
-
- memo = &(mtr->memo);
-
- offset = dyn_array_get_data_size(memo);
-
- i = 0;
-
- while (offset > 0) {
- offset -= sizeof(mtr_memo_slot_t);
- slot = dyn_array_get_element(memo, offset);
-
- block = slot->object;
- type = slot->type;
-
- if ((block != NULL) && (type == MTR_MEMO_PAGE_X_FIX)) {
-
- mtr_log_write_full_page(block->frame, i, n_pages, mtr);
-
- i++;
- }
- }
-
- ut_ad(i == n_pages);
-}
-
-/****************************************************************
-Checks if mtr is the first to modify any page after online_backup_lsn. */
-static
-ibool
-mtr_first_to_modify_page_after_backup(
-/*==================================*/
- /* out: TRUE if first for a page */
- mtr_t* mtr, /* in: mini-transaction */
- ulint* n_pages) /* out: number of modified pages (all modified
- pages, backup_lsn does not matter here) */
-{
- mtr_memo_slot_t* slot;
- dyn_array_t* memo;
- ulint offset;
- buf_block_t* block;
- ulint type;
- dulint backup_lsn;
- ibool ret = FALSE;
-
- ut_ad(mtr);
- ut_ad(mtr->magic_n == MTR_MAGIC_N);
- ut_ad(mtr->state == MTR_COMMITTING);
-
- backup_lsn = log_get_online_backup_lsn_low();
-
- memo = &(mtr->memo);
-
- offset = dyn_array_get_data_size(memo);
-
- *n_pages = 0;
-
- while (offset > 0) {
- offset -= sizeof(mtr_memo_slot_t);
- slot = dyn_array_get_element(memo, offset);
-
- block = slot->object;
- type = slot->type;
-
- if ((block != NULL) && (type == MTR_MEMO_PAGE_X_FIX)) {
-
- *n_pages = *n_pages + 1;
-
- if (ut_dulint_cmp(buf_frame_get_newest_modification(
- block->frame),
- backup_lsn) <= 0) {
-
- fprintf(stderr,
- "Page %lu newest %lu backup %lu\n",
- (ulong) block->offset,
- (ulong) ut_dulint_get_low(
- buf_frame_get_newest_modification(
- block->frame)),
- (ulong) ut_dulint_get_low(backup_lsn));
-
- ret = TRUE;
- }
- }
- }
-
- return(ret);
-}
-
-/****************************************************************
Writes the contents of a mini-transaction log, if any, to the database log. */
static
void
@@ -291,7 +118,6 @@ mtr_log_reserve_and_write(
ulint data_size;
ibool success;
byte* first_data;
- ulint n_modified_pages;
ut_ad(mtr);
@@ -322,27 +148,12 @@ mtr_log_reserve_and_write(
if (mtr->log_mode == MTR_LOG_ALL) {
- if (log_get_online_backup_state_low()
- && mtr_first_to_modify_page_after_backup(mtr,
- &n_modified_pages)) {
-
- /* The database is in the online backup state: write
- to the log the full contents of all the pages if this
- mtr is the first to modify any page in the buffer pool
- after online_backup_lsn */
-
- log_close();
- log_release();
-
- mtr_log_write_backup_full_pages(mtr, n_modified_pages);
- } else {
- block = mlog;
+ block = mlog;
- while (block != NULL) {
- log_write_low(dyn_block_get_data(block),
- dyn_block_get_used(block));
- block = dyn_array_get_next_block(mlog, block);
- }
+ while (block != NULL) {
+ log_write_low(dyn_block_get_data(block),
+ dyn_block_get_used(block));
+ block = dyn_array_get_next_block(mlog, block);
}
} else {
ut_ad(mtr->log_mode == MTR_LOG_NONE);
@@ -508,7 +319,6 @@ mtr_read_dulint(
return(mach_read_from_8(ptr));
}
-#ifdef UNIV_DEBUG
/*************************************************************
Prints info of an mtr handle. */
@@ -522,4 +332,3 @@ mtr_print(
(ulong) dyn_array_get_data_size(&(mtr->memo)),
(ulong) dyn_array_get_data_size(&(mtr->log)));
}
-#endif /* UNIV_DEBUG */
diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c
index 5f5060c7464..d5ca8f927c6 100644
--- a/innobase/os/os0file.c
+++ b/innobase/os/os0file.c
@@ -311,14 +311,11 @@ os_file_handle_error(
/*=================*/
/* out: TRUE if we should retry the
operation */
- os_file_t file, /* in: file pointer */
const char* name, /* in: name of a file or NULL */
const char* operation)/* in: operation */
{
ulint err;
- UT_NOT_USED(file);
-
err = os_file_get_last_error(FALSE);
if (err == OS_FILE_DISK_FULL) {
@@ -371,7 +368,7 @@ os_file_handle_error(
#undef USE_FILE_LOCK
#define USE_FILE_LOCK
-#if defined(UNIV_HOTBACKUP) || defined(__WIN__) || defined(__FreeBSD__)
+#if defined(UNIV_HOTBACKUP) || defined(__WIN__) || defined(__FreeBSD__) || defined(__NETWARE__)
/* InnoDB Hot Backup does not lock the data files.
* On Windows, mandatory locking is used.
* On FreeBSD with LinuxThreads, advisory locking does not work properly.
@@ -387,22 +384,19 @@ os_file_lock(
/*=========*/
/* out: 0 on success */
int fd, /* in: file descriptor */
- const char* name, /* in: file name */
- uint lock_type) /* in: lock_type */
+ const char* name) /* in: file name */
{
struct flock lk;
- lk.l_type = lock_type;
+ lk.l_type = F_WRLCK;
lk.l_whence = SEEK_SET;
lk.l_start = lk.l_len = 0;
if (fcntl(fd, F_SETLK, &lk) == -1) {
fprintf(stderr,
- "InnoDB: Unable to lock %s with lock %d, error: %d",
- name, lock_type, errno);
- perror (": fcntl");
+ "InnoDB: Unable to lock %s, error: %d", name, errno);
close(fd);
return(-1);
}
- return 0;
+ return(0);
}
#endif /* USE_FILE_LOCK */
@@ -485,6 +479,25 @@ os_io_init_simple(void)
}
/***************************************************************************
+Creates a temporary file. In case of error, causes abnormal termination. */
+
+FILE*
+os_file_create_tmpfile(void)
+/*========================*/
+ /* out: temporary file handle (never NULL) */
+{
+ FILE* file = tmpfile();
+ if (file == NULL) {
+ ut_print_timestamp(stderr);
+ fputs(" InnoDB: Error: unable to create temporary file\n",
+ stderr);
+ os_file_handle_error(NULL, "tmpfile");
+ ut_error;
+ }
+ return(file);
+}
+
+/***************************************************************************
The os_file_opendir() function opens a directory stream corresponding to the
directory named by the dirname argument. The directory stream is positioned
at the first entry. In both Unix and Windows we automatically skip the '.'
@@ -526,7 +539,7 @@ os_file_opendir(
if (dir == INVALID_HANDLE_VALUE) {
if (error_is_fatal) {
- os_file_handle_error(NULL, dirname, "opendir");
+ os_file_handle_error(dirname, "opendir");
}
return(NULL);
@@ -537,7 +550,7 @@ os_file_opendir(
dir = opendir(dirname);
if (dir == NULL && error_is_fatal) {
- os_file_handle_error(0, dirname, "opendir");
+ os_file_handle_error(dirname, "opendir");
}
return(dir);
@@ -720,7 +733,7 @@ os_file_create_directory(
if (!(rcode != 0 ||
(GetLastError() == ERROR_FILE_EXISTS && !fail_if_exists))) {
/* failure */
- os_file_handle_error(NULL, pathname, "CreateDirectory");
+ os_file_handle_error(pathname, "CreateDirectory");
return(FALSE);
}
@@ -733,7 +746,7 @@ os_file_create_directory(
if (!(rcode == 0 || (errno == EEXIST && !fail_if_exists))) {
/* failure */
- os_file_handle_error(0, pathname, "mkdir");
+ os_file_handle_error(pathname, "mkdir");
return(FALSE);
}
@@ -812,7 +825,7 @@ try_again:
if (file == INVALID_HANDLE_VALUE) {
*success = FALSE;
- retry = os_file_handle_error(file, name,
+ retry = os_file_handle_error(name,
create_mode == OS_FILE_OPEN ?
"open" : "create");
if (retry) {
@@ -862,14 +875,15 @@ try_again:
if (file == -1) {
*success = FALSE;
- retry = os_file_handle_error(file, name,
+ retry = os_file_handle_error(name,
create_mode == OS_FILE_OPEN ?
"open" : "create");
if (retry) {
goto try_again;
}
#ifdef USE_FILE_LOCK
- } else if (os_file_lock(file, name, F_WRLCK)) {
+ } else if (access_type == OS_FILE_READ_WRITE
+ && os_file_lock(file, name)) {
*success = FALSE;
file = -1;
#endif
@@ -980,7 +994,8 @@ os_file_create_simple_no_error_handling(
if (file == -1) {
*success = FALSE;
#ifdef USE_FILE_LOCK
- } else if (os_file_lock(file, name, F_WRLCK)) {
+ } else if (access_type == OS_FILE_READ_WRITE
+ && os_file_lock(file, name)) {
*success = FALSE;
file = -1;
#endif
@@ -1102,7 +1117,7 @@ try_again:
if (file == INVALID_HANDLE_VALUE) {
*success = FALSE;
- retry = os_file_handle_error(file, name,
+ retry = os_file_handle_error(name,
create_mode == OS_FILE_CREATE ?
"create" : "open");
if (retry) {
@@ -1187,14 +1202,15 @@ try_again:
if (file == -1) {
*success = FALSE;
- retry = os_file_handle_error(file, name,
+ retry = os_file_handle_error(name,
create_mode == OS_FILE_CREATE ?
"create" : "open");
if (retry) {
goto try_again;
}
#ifdef USE_FILE_LOCK
- } else if (os_file_lock(file, name, F_WRLCK)) {
+ } else if (create_mode != OS_FILE_OPEN_RAW
+ && os_file_lock(file, name)) {
*success = FALSE;
file = -1;
#endif
@@ -1258,7 +1274,7 @@ loop:
ret = unlink((const char*)name);
if (ret != 0 && errno != ENOENT) {
- os_file_handle_error(0, name, "delete");
+ os_file_handle_error(name, "delete");
return(FALSE);
}
@@ -1320,7 +1336,7 @@ loop:
ret = unlink((const char*)name);
if (ret != 0) {
- os_file_handle_error(0, name, "delete");
+ os_file_handle_error(name, "delete");
return(FALSE);
}
@@ -1350,7 +1366,7 @@ os_file_rename(
return(TRUE);
}
- os_file_handle_error(NULL, oldpath, "rename");
+ os_file_handle_error(oldpath, "rename");
return(FALSE);
#else
@@ -1359,7 +1375,7 @@ os_file_rename(
ret = rename((const char*)oldpath, (const char*)newpath);
if (ret != 0) {
- os_file_handle_error(0, oldpath, "rename");
+ os_file_handle_error(oldpath, "rename");
return(FALSE);
}
@@ -1389,19 +1405,16 @@ os_file_close(
return(TRUE);
}
- os_file_handle_error(file, NULL, "close");
+ os_file_handle_error(NULL, "close");
return(FALSE);
#else
int ret;
-#ifdef USE_FILE_LOCK
- (void) os_file_lock(file, "unknown", F_UNLCK);
-#endif
ret = close(file);
if (ret == -1) {
- os_file_handle_error(file, NULL, "close");
+ os_file_handle_error(NULL, "close");
return(FALSE);
}
@@ -1434,9 +1447,6 @@ os_file_close_no_error_handling(
#else
int ret;
-#ifdef USE_FILE_LOCK
- (void) os_file_lock(file, "unknown", F_UNLCK);
-#endif
ret = close(file);
if (ret == -1) {
@@ -1657,7 +1667,7 @@ os_file_flush(
return(TRUE);
}
- os_file_handle_error(file, NULL, "flush");
+ os_file_handle_error(NULL, "flush");
/* It is a fatal error if a file flush does not succeed, because then
the database can get corrupt on disk */
@@ -1692,7 +1702,7 @@ os_file_flush(
fprintf(stderr,
" InnoDB: Error: the OS said file flush did not succeed\n");
- os_file_handle_error(file, NULL, "flush");
+ os_file_handle_error(NULL, "flush");
/* It is a fatal error if a file flush does not succeed, because then
the database can get corrupt on disk */
@@ -1740,7 +1750,7 @@ os_file_pread(
os_n_file_reads++;
-#ifdef HAVE_PREAD
+#if defined(HAVE_PREAD) && !defined(HAVE_BROKEN_PREAD)
os_mutex_enter(os_file_count_mutex);
os_file_n_pending_preads++;
os_mutex_exit(os_file_count_mutex);
@@ -1815,7 +1825,7 @@ os_file_pwrite(
os_n_file_writes++;
-#ifdef HAVE_PWRITE
+#if defined(HAVE_PWRITE) && !defined(HAVE_BROKEN_PREAD)
os_mutex_enter(os_file_count_mutex);
os_file_n_pending_pwrites++;
os_mutex_exit(os_file_count_mutex);
@@ -1952,7 +1962,7 @@ try_again:
#ifdef __WIN__
error_handling:
#endif
- retry = os_file_handle_error(file, NULL, "read");
+ retry = os_file_handle_error(NULL, "read");
if (retry) {
goto try_again;
@@ -2331,31 +2341,25 @@ os_file_dirname(
pathname */
const char* path) /* in: pathname */
{
- char* dir;
- int i, length, last_slash;
-
- /* find the offset of the last slash */
- length = ut_strlen(path);
- for (i = length - 1; i >= 0 && path[i] != OS_FILE_PATH_SEPARATOR; i++);
- last_slash = i;
+ /* Find the offset of the last slash */
+ const char* last_slash = strrchr(path, OS_FILE_PATH_SEPARATOR);
+ if (!last_slash) {
+ /* No slash in the path, return "." */
- if (last_slash < 0) {
- /* no slash in the path, return "." */
return(mem_strdup("."));
}
- /* ok, there is a slash */
+ /* Ok, there is a slash */
- if (last_slash == 0) {
+ if (last_slash == path) {
/* last slash is the first char of the path */
+
return(mem_strdup("/"));
}
- /* non-trivial directory component */
- dir = mem_strdup(path);
- dir[last_slash] = 0;
+ /* Non-trivial directory component */
- return(dir);
+ return(mem_strdupl(path, last_slash - path));
}
/********************************************************************
@@ -2369,30 +2373,33 @@ os_file_create_subdirs_if_needed(
const char* path) /* in: path name */
{
char* subdir;
- static char rootdir[2] = { OS_FILE_PATH_SEPARATOR, 0 };
ibool success, subdir_exists;
os_file_type_t type;
subdir = os_file_dirname(path);
- if (0 == strcmp(subdir, rootdir) || 0 == strcmp(subdir, ".")) {
+ if (strlen(subdir) == 1
+ && (*subdir == OS_FILE_PATH_SEPARATOR || *subdir == '.')) {
/* subdir is root or cwd, nothing to do */
- ut_free(subdir);
+ mem_free(subdir);
+
return(TRUE);
}
- /* test if subdir exists */
+ /* Test if subdir exists */
success = os_file_status(subdir, &subdir_exists, &type);
if (success && !subdir_exists) {
/* subdir does not exist, create it */
success = os_file_create_subdirs_if_needed(subdir);
if (!success) {
- ut_free(subdir);
+ mem_free(subdir);
+
return(FALSE);
}
success = os_file_create_directory(subdir, FALSE);
}
- ut_free(subdir);
+ mem_free(subdir);
+
return(success);
}
@@ -3172,7 +3179,7 @@ try_again:
os_aio_array_free_slot(array, slot);
- retry = os_file_handle_error(file, name,
+ retry = os_file_handle_error(name,
type == OS_FILE_READ ? "aio read" : "aio write");
if (retry) {
@@ -3272,7 +3279,7 @@ os_aio_windows_handle(
ut_a(TRUE == os_file_flush(slot->file));
}
} else {
- os_file_handle_error(slot->file, slot->name, "Windows aio");
+ os_file_handle_error(slot->name, "Windows aio");
ret_val = FALSE;
}
diff --git a/innobase/os/os0thread.c b/innobase/os/os0thread.c
index 59d0fdbd8c9..12a8abf3069 100644
--- a/innobase/os/os0thread.c
+++ b/innobase/os/os0thread.c
@@ -201,6 +201,15 @@ os_thread_exit(
#endif
}
+#ifdef HAVE_PTHREAD_JOIN
+int
+os_thread_join(
+/*=============*/
+ os_thread_id_t thread_id) /* in: id of the thread to join */
+{
+ return pthread_join(thread_id, NULL);
+}
+#endif
/*********************************************************************
Returns handle to the current thread. */
diff --git a/innobase/page/page0page.c b/innobase/page/page0page.c
index aecc2dc4fd2..b5f411c43fc 100644
--- a/innobase/page/page0page.c
+++ b/innobase/page/page0page.c
@@ -325,7 +325,7 @@ page_create(
tuple = dtuple_create(heap, 1);
field = dtuple_get_nth_field(tuple, 0);
- dfield_set_data(field,(char *) "infimum", strlen("infimum") + 1);
+ dfield_set_data(field, "infimum", sizeof "infimum");
dtype_set(dfield_get_type(field), DATA_VARCHAR, DATA_ENGLISH, 20, 0);
/* Set the corresponding physical record to its place in the page
@@ -347,7 +347,7 @@ page_create(
tuple = dtuple_create(heap, 1);
field = dtuple_get_nth_field(tuple, 0);
- dfield_set_data(field, (char *) "supremum", strlen("supremum") + 1);
+ dfield_set_data(field, "supremum", sizeof "supremum");
dtype_set(dfield_get_type(field), DATA_VARCHAR, DATA_ENGLISH, 20, 0);
supremum_rec = rec_convert_dtuple_to_rec(heap_top, tuple);
diff --git a/innobase/pars/lexyy.c b/innobase/pars/lexyy.c
index 1b8c69ccc7a..0112f618533 100644
--- a/innobase/pars/lexyy.c
+++ b/innobase/pars/lexyy.c
@@ -25,7 +25,6 @@
#ifdef __cplusplus
#include <stdlib.h>
-#include <unistd.h>
/* Use prototypes in function declarations. */
#define YY_USE_PROTOS
@@ -636,9 +635,9 @@ Linux.
#include "mem0mem.h"
#include "os0proc.h"
-#define malloc(A) mem_alloc(A)
-#define free(A) mem_free(A)
-#define realloc(P, A) mem_realloc(P, A, __FILE__, __LINE__)
+#define malloc(A) ut_malloc(A)
+#define free(A) ut_free(A)
+#define realloc(P, A) ut_realloc(P, A)
#define exit(A) ut_error
#define YY_INPUT(buf, result, max_size) pars_get_lex_chars(buf, &result, max_size)
@@ -655,16 +654,16 @@ string_append(
const char* str, /* in: string to be appended */
ulint len) /* in: length of the string */
{
+ if (stringbuf == NULL) {
+ stringbuf = malloc(1);
+ stringbuf_len_alloc = 1;
+ }
+
if (stringbuf_len + len > stringbuf_len_alloc) {
- if (stringbuf_len_alloc == 0) {
- stringbuf_len_alloc++;
- }
while (stringbuf_len + len > stringbuf_len_alloc) {
stringbuf_len_alloc <<= 1;
}
- stringbuf = stringbuf
- ? realloc(stringbuf, stringbuf_len_alloc)
- : malloc(stringbuf_len_alloc);
+ stringbuf = realloc(stringbuf, stringbuf_len_alloc);
}
memcpy(stringbuf + stringbuf_len, str, len);
@@ -934,31 +933,54 @@ case 3:
YY_RULE_SETUP
#line 116 "pars0lex.l"
{
+/* Quoted character string literals are handled in an explicit
+start state 'quoted'. This state is entered and the buffer for
+the scanned string is emptied upon encountering a starting quote.
+
+In the state 'quoted', only two actions are possible (defined below). */
BEGIN(quoted);
stringbuf_len = 0;
}
YY_BREAK
case 4:
YY_RULE_SETUP
-#line 120 "pars0lex.l"
-string_append(yytext, yyleng);
+#line 125 "pars0lex.l"
+{
+ /* Got a sequence of characters other than "'":
+ append to string buffer */
+ string_append(yytext, yyleng);
+}
YY_BREAK
case 5:
YY_RULE_SETUP
-#line 121 "pars0lex.l"
-{ string_append(yytext, yyleng / 2);
+#line 130 "pars0lex.l"
+{
+ /* Got a sequence of "'" characters:
+ append half of them to string buffer,
+ as "''" represents a single "'".
+ We apply truncating division,
+ so that "'''" will result in "'". */
+
+ string_append(yytext, yyleng / 2);
+
+ /* If we got an odd number of quotes, then the
+ last quote we got is the terminating quote.
+ At the end of the string, we return to the
+ initial start state and report the scanned
+ string literal. */
+
if (yyleng % 2) {
BEGIN(INITIAL);
yylval = sym_tab_add_str_lit(
pars_sym_tab_global,
- stringbuf, stringbuf_len);
+ (byte*) stringbuf, stringbuf_len);
return(PARS_STR_LIT);
}
}
YY_BREAK
case 6:
YY_RULE_SETUP
-#line 131 "pars0lex.l"
+#line 154 "pars0lex.l"
{
yylval = sym_tab_add_null_lit(pars_sym_tab_global);
@@ -967,521 +989,521 @@ YY_RULE_SETUP
YY_BREAK
case 7:
YY_RULE_SETUP
-#line 137 "pars0lex.l"
+#line 160 "pars0lex.l"
{
/* Implicit cursor name */
yylval = sym_tab_add_str_lit(pars_sym_tab_global,
- yytext, yyleng);
+ (byte*) yytext, yyleng);
return(PARS_SQL_TOKEN);
}
YY_BREAK
case 8:
YY_RULE_SETUP
-#line 144 "pars0lex.l"
+#line 167 "pars0lex.l"
{
return(PARS_AND_TOKEN);
}
YY_BREAK
case 9:
YY_RULE_SETUP
-#line 148 "pars0lex.l"
+#line 171 "pars0lex.l"
{
return(PARS_OR_TOKEN);
}
YY_BREAK
case 10:
YY_RULE_SETUP
-#line 152 "pars0lex.l"
+#line 175 "pars0lex.l"
{
return(PARS_NOT_TOKEN);
}
YY_BREAK
case 11:
YY_RULE_SETUP
-#line 156 "pars0lex.l"
+#line 179 "pars0lex.l"
{
return(PARS_PROCEDURE_TOKEN);
}
YY_BREAK
case 12:
YY_RULE_SETUP
-#line 160 "pars0lex.l"
+#line 183 "pars0lex.l"
{
return(PARS_IN_TOKEN);
}
YY_BREAK
case 13:
YY_RULE_SETUP
-#line 164 "pars0lex.l"
+#line 187 "pars0lex.l"
{
return(PARS_OUT_TOKEN);
}
YY_BREAK
case 14:
YY_RULE_SETUP
-#line 168 "pars0lex.l"
+#line 191 "pars0lex.l"
{
return(PARS_INT_TOKEN);
}
YY_BREAK
case 15:
YY_RULE_SETUP
-#line 172 "pars0lex.l"
+#line 195 "pars0lex.l"
{
return(PARS_INT_TOKEN);
}
YY_BREAK
case 16:
YY_RULE_SETUP
-#line 176 "pars0lex.l"
+#line 199 "pars0lex.l"
{
return(PARS_FLOAT_TOKEN);
}
YY_BREAK
case 17:
YY_RULE_SETUP
-#line 180 "pars0lex.l"
+#line 203 "pars0lex.l"
{
return(PARS_CHAR_TOKEN);
}
YY_BREAK
case 18:
YY_RULE_SETUP
-#line 184 "pars0lex.l"
+#line 207 "pars0lex.l"
{
return(PARS_IS_TOKEN);
}
YY_BREAK
case 19:
YY_RULE_SETUP
-#line 188 "pars0lex.l"
+#line 211 "pars0lex.l"
{
return(PARS_BEGIN_TOKEN);
}
YY_BREAK
case 20:
YY_RULE_SETUP
-#line 192 "pars0lex.l"
+#line 215 "pars0lex.l"
{
return(PARS_END_TOKEN);
}
YY_BREAK
case 21:
YY_RULE_SETUP
-#line 196 "pars0lex.l"
+#line 219 "pars0lex.l"
{
return(PARS_IF_TOKEN);
}
YY_BREAK
case 22:
YY_RULE_SETUP
-#line 200 "pars0lex.l"
+#line 223 "pars0lex.l"
{
return(PARS_THEN_TOKEN);
}
YY_BREAK
case 23:
YY_RULE_SETUP
-#line 204 "pars0lex.l"
+#line 227 "pars0lex.l"
{
return(PARS_ELSE_TOKEN);
}
YY_BREAK
case 24:
YY_RULE_SETUP
-#line 208 "pars0lex.l"
+#line 231 "pars0lex.l"
{
return(PARS_ELSIF_TOKEN);
}
YY_BREAK
case 25:
YY_RULE_SETUP
-#line 212 "pars0lex.l"
+#line 235 "pars0lex.l"
{
return(PARS_LOOP_TOKEN);
}
YY_BREAK
case 26:
YY_RULE_SETUP
-#line 216 "pars0lex.l"
+#line 239 "pars0lex.l"
{
return(PARS_WHILE_TOKEN);
}
YY_BREAK
case 27:
YY_RULE_SETUP
-#line 220 "pars0lex.l"
+#line 243 "pars0lex.l"
{
return(PARS_RETURN_TOKEN);
}
YY_BREAK
case 28:
YY_RULE_SETUP
-#line 224 "pars0lex.l"
+#line 247 "pars0lex.l"
{
return(PARS_SELECT_TOKEN);
}
YY_BREAK
case 29:
YY_RULE_SETUP
-#line 228 "pars0lex.l"
+#line 251 "pars0lex.l"
{
return(PARS_SUM_TOKEN);
}
YY_BREAK
case 30:
YY_RULE_SETUP
-#line 232 "pars0lex.l"
+#line 255 "pars0lex.l"
{
return(PARS_COUNT_TOKEN);
}
YY_BREAK
case 31:
YY_RULE_SETUP
-#line 236 "pars0lex.l"
+#line 259 "pars0lex.l"
{
return(PARS_DISTINCT_TOKEN);
}
YY_BREAK
case 32:
YY_RULE_SETUP
-#line 240 "pars0lex.l"
+#line 263 "pars0lex.l"
{
return(PARS_FROM_TOKEN);
}
YY_BREAK
case 33:
YY_RULE_SETUP
-#line 244 "pars0lex.l"
+#line 267 "pars0lex.l"
{
return(PARS_WHERE_TOKEN);
}
YY_BREAK
case 34:
YY_RULE_SETUP
-#line 248 "pars0lex.l"
+#line 271 "pars0lex.l"
{
return(PARS_FOR_TOKEN);
}
YY_BREAK
case 35:
YY_RULE_SETUP
-#line 252 "pars0lex.l"
+#line 275 "pars0lex.l"
{
return(PARS_CONSISTENT_TOKEN);
}
YY_BREAK
case 36:
YY_RULE_SETUP
-#line 256 "pars0lex.l"
+#line 279 "pars0lex.l"
{
return(PARS_READ_TOKEN);
}
YY_BREAK
case 37:
YY_RULE_SETUP
-#line 260 "pars0lex.l"
+#line 283 "pars0lex.l"
{
return(PARS_ORDER_TOKEN);
}
YY_BREAK
case 38:
YY_RULE_SETUP
-#line 264 "pars0lex.l"
+#line 287 "pars0lex.l"
{
return(PARS_BY_TOKEN);
}
YY_BREAK
case 39:
YY_RULE_SETUP
-#line 268 "pars0lex.l"
+#line 291 "pars0lex.l"
{
return(PARS_ASC_TOKEN);
}
YY_BREAK
case 40:
YY_RULE_SETUP
-#line 272 "pars0lex.l"
+#line 295 "pars0lex.l"
{
return(PARS_DESC_TOKEN);
}
YY_BREAK
case 41:
YY_RULE_SETUP
-#line 276 "pars0lex.l"
+#line 299 "pars0lex.l"
{
return(PARS_INSERT_TOKEN);
}
YY_BREAK
case 42:
YY_RULE_SETUP
-#line 280 "pars0lex.l"
+#line 303 "pars0lex.l"
{
return(PARS_INTO_TOKEN);
}
YY_BREAK
case 43:
YY_RULE_SETUP
-#line 284 "pars0lex.l"
+#line 307 "pars0lex.l"
{
return(PARS_VALUES_TOKEN);
}
YY_BREAK
case 44:
YY_RULE_SETUP
-#line 288 "pars0lex.l"
+#line 311 "pars0lex.l"
{
return(PARS_UPDATE_TOKEN);
}
YY_BREAK
case 45:
YY_RULE_SETUP
-#line 292 "pars0lex.l"
+#line 315 "pars0lex.l"
{
return(PARS_SET_TOKEN);
}
YY_BREAK
case 46:
YY_RULE_SETUP
-#line 296 "pars0lex.l"
+#line 319 "pars0lex.l"
{
return(PARS_DELETE_TOKEN);
}
YY_BREAK
case 47:
YY_RULE_SETUP
-#line 300 "pars0lex.l"
+#line 323 "pars0lex.l"
{
return(PARS_CURRENT_TOKEN);
}
YY_BREAK
case 48:
YY_RULE_SETUP
-#line 304 "pars0lex.l"
+#line 327 "pars0lex.l"
{
return(PARS_OF_TOKEN);
}
YY_BREAK
case 49:
YY_RULE_SETUP
-#line 308 "pars0lex.l"
+#line 331 "pars0lex.l"
{
return(PARS_CREATE_TOKEN);
}
YY_BREAK
case 50:
YY_RULE_SETUP
-#line 312 "pars0lex.l"
+#line 335 "pars0lex.l"
{
return(PARS_TABLE_TOKEN);
}
YY_BREAK
case 51:
YY_RULE_SETUP
-#line 316 "pars0lex.l"
+#line 339 "pars0lex.l"
{
return(PARS_INDEX_TOKEN);
}
YY_BREAK
case 52:
YY_RULE_SETUP
-#line 320 "pars0lex.l"
+#line 343 "pars0lex.l"
{
return(PARS_UNIQUE_TOKEN);
}
YY_BREAK
case 53:
YY_RULE_SETUP
-#line 324 "pars0lex.l"
+#line 347 "pars0lex.l"
{
return(PARS_CLUSTERED_TOKEN);
}
YY_BREAK
case 54:
YY_RULE_SETUP
-#line 328 "pars0lex.l"
+#line 351 "pars0lex.l"
{
return(PARS_DOES_NOT_FIT_IN_MEM_TOKEN);
}
YY_BREAK
case 55:
YY_RULE_SETUP
-#line 332 "pars0lex.l"
+#line 355 "pars0lex.l"
{
return(PARS_ON_TOKEN);
}
YY_BREAK
case 56:
YY_RULE_SETUP
-#line 336 "pars0lex.l"
+#line 359 "pars0lex.l"
{
return(PARS_DECLARE_TOKEN);
}
YY_BREAK
case 57:
YY_RULE_SETUP
-#line 340 "pars0lex.l"
+#line 363 "pars0lex.l"
{
return(PARS_CURSOR_TOKEN);
}
YY_BREAK
case 58:
YY_RULE_SETUP
-#line 344 "pars0lex.l"
+#line 367 "pars0lex.l"
{
return(PARS_OPEN_TOKEN);
}
YY_BREAK
case 59:
YY_RULE_SETUP
-#line 348 "pars0lex.l"
+#line 371 "pars0lex.l"
{
return(PARS_FETCH_TOKEN);
}
YY_BREAK
case 60:
YY_RULE_SETUP
-#line 352 "pars0lex.l"
+#line 375 "pars0lex.l"
{
return(PARS_CLOSE_TOKEN);
}
YY_BREAK
case 61:
YY_RULE_SETUP
-#line 356 "pars0lex.l"
+#line 379 "pars0lex.l"
{
return(PARS_NOTFOUND_TOKEN);
}
YY_BREAK
case 62:
YY_RULE_SETUP
-#line 360 "pars0lex.l"
+#line 383 "pars0lex.l"
{
return(PARS_TO_CHAR_TOKEN);
}
YY_BREAK
case 63:
YY_RULE_SETUP
-#line 364 "pars0lex.l"
+#line 387 "pars0lex.l"
{
return(PARS_TO_NUMBER_TOKEN);
}
YY_BREAK
case 64:
YY_RULE_SETUP
-#line 368 "pars0lex.l"
+#line 391 "pars0lex.l"
{
return(PARS_TO_BINARY_TOKEN);
}
YY_BREAK
case 65:
YY_RULE_SETUP
-#line 372 "pars0lex.l"
+#line 395 "pars0lex.l"
{
return(PARS_BINARY_TO_NUMBER_TOKEN);
}
YY_BREAK
case 66:
YY_RULE_SETUP
-#line 376 "pars0lex.l"
+#line 399 "pars0lex.l"
{
return(PARS_SUBSTR_TOKEN);
}
YY_BREAK
case 67:
YY_RULE_SETUP
-#line 380 "pars0lex.l"
+#line 403 "pars0lex.l"
{
return(PARS_REPLSTR_TOKEN);
}
YY_BREAK
case 68:
YY_RULE_SETUP
-#line 384 "pars0lex.l"
+#line 407 "pars0lex.l"
{
return(PARS_CONCAT_TOKEN);
}
YY_BREAK
case 69:
YY_RULE_SETUP
-#line 388 "pars0lex.l"
+#line 411 "pars0lex.l"
{
return(PARS_INSTR_TOKEN);
}
YY_BREAK
case 70:
YY_RULE_SETUP
-#line 392 "pars0lex.l"
+#line 415 "pars0lex.l"
{
return(PARS_LENGTH_TOKEN);
}
YY_BREAK
case 71:
YY_RULE_SETUP
-#line 396 "pars0lex.l"
+#line 419 "pars0lex.l"
{
return(PARS_SYSDATE_TOKEN);
}
YY_BREAK
case 72:
YY_RULE_SETUP
-#line 400 "pars0lex.l"
+#line 423 "pars0lex.l"
{
return(PARS_PRINTF_TOKEN);
}
YY_BREAK
case 73:
YY_RULE_SETUP
-#line 404 "pars0lex.l"
+#line 427 "pars0lex.l"
{
return(PARS_ASSERT_TOKEN);
}
YY_BREAK
case 74:
YY_RULE_SETUP
-#line 408 "pars0lex.l"
+#line 431 "pars0lex.l"
{
return(PARS_RND_TOKEN);
}
YY_BREAK
case 75:
YY_RULE_SETUP
-#line 412 "pars0lex.l"
+#line 435 "pars0lex.l"
{
return(PARS_RND_STR_TOKEN);
}
YY_BREAK
case 76:
YY_RULE_SETUP
-#line 416 "pars0lex.l"
+#line 439 "pars0lex.l"
{
return(PARS_ROW_PRINTF_TOKEN);
}
YY_BREAK
case 77:
YY_RULE_SETUP
-#line 420 "pars0lex.l"
+#line 443 "pars0lex.l"
{
return(PARS_COMMIT_TOKEN);
}
YY_BREAK
case 78:
YY_RULE_SETUP
-#line 424 "pars0lex.l"
+#line 447 "pars0lex.l"
{
return(PARS_ROLLBACK_TOKEN);
}
YY_BREAK
case 79:
YY_RULE_SETUP
-#line 428 "pars0lex.l"
+#line 451 "pars0lex.l"
{
return(PARS_WORK_TOKEN);
}
YY_BREAK
case 80:
YY_RULE_SETUP
-#line 432 "pars0lex.l"
+#line 455 "pars0lex.l"
{
yylval = sym_tab_add_id(pars_sym_tab_global,
(byte*)yytext,
@@ -1491,42 +1513,42 @@ YY_RULE_SETUP
YY_BREAK
case 81:
YY_RULE_SETUP
-#line 439 "pars0lex.l"
+#line 462 "pars0lex.l"
{
return(PARS_DDOT_TOKEN);
}
YY_BREAK
case 82:
YY_RULE_SETUP
-#line 443 "pars0lex.l"
+#line 466 "pars0lex.l"
{
return(PARS_ASSIGN_TOKEN);
}
YY_BREAK
case 83:
YY_RULE_SETUP
-#line 447 "pars0lex.l"
+#line 470 "pars0lex.l"
{
return(PARS_LE_TOKEN);
}
YY_BREAK
case 84:
YY_RULE_SETUP
-#line 451 "pars0lex.l"
+#line 474 "pars0lex.l"
{
return(PARS_GE_TOKEN);
}
YY_BREAK
case 85:
YY_RULE_SETUP
-#line 455 "pars0lex.l"
+#line 478 "pars0lex.l"
{
return(PARS_NE_TOKEN);
}
YY_BREAK
case 86:
YY_RULE_SETUP
-#line 459 "pars0lex.l"
+#line 482 "pars0lex.l"
{
return((int)(*yytext));
@@ -1534,7 +1556,7 @@ YY_RULE_SETUP
YY_BREAK
case 87:
YY_RULE_SETUP
-#line 464 "pars0lex.l"
+#line 487 "pars0lex.l"
{
return((int)(*yytext));
@@ -1542,7 +1564,7 @@ YY_RULE_SETUP
YY_BREAK
case 88:
YY_RULE_SETUP
-#line 469 "pars0lex.l"
+#line 492 "pars0lex.l"
{
return((int)(*yytext));
@@ -1550,7 +1572,7 @@ YY_RULE_SETUP
YY_BREAK
case 89:
YY_RULE_SETUP
-#line 474 "pars0lex.l"
+#line 497 "pars0lex.l"
{
return((int)(*yytext));
@@ -1558,7 +1580,7 @@ YY_RULE_SETUP
YY_BREAK
case 90:
YY_RULE_SETUP
-#line 479 "pars0lex.l"
+#line 502 "pars0lex.l"
{
return((int)(*yytext));
@@ -1566,7 +1588,7 @@ YY_RULE_SETUP
YY_BREAK
case 91:
YY_RULE_SETUP
-#line 484 "pars0lex.l"
+#line 507 "pars0lex.l"
{
return((int)(*yytext));
@@ -1574,7 +1596,7 @@ YY_RULE_SETUP
YY_BREAK
case 92:
YY_RULE_SETUP
-#line 489 "pars0lex.l"
+#line 512 "pars0lex.l"
{
return((int)(*yytext));
@@ -1582,7 +1604,7 @@ YY_RULE_SETUP
YY_BREAK
case 93:
YY_RULE_SETUP
-#line 494 "pars0lex.l"
+#line 517 "pars0lex.l"
{
return((int)(*yytext));
@@ -1590,7 +1612,7 @@ YY_RULE_SETUP
YY_BREAK
case 94:
YY_RULE_SETUP
-#line 499 "pars0lex.l"
+#line 522 "pars0lex.l"
{
return((int)(*yytext));
@@ -1598,7 +1620,7 @@ YY_RULE_SETUP
YY_BREAK
case 95:
YY_RULE_SETUP
-#line 504 "pars0lex.l"
+#line 527 "pars0lex.l"
{
return((int)(*yytext));
@@ -1606,7 +1628,7 @@ YY_RULE_SETUP
YY_BREAK
case 96:
YY_RULE_SETUP
-#line 509 "pars0lex.l"
+#line 532 "pars0lex.l"
{
return((int)(*yytext));
@@ -1614,7 +1636,7 @@ YY_RULE_SETUP
YY_BREAK
case 97:
YY_RULE_SETUP
-#line 514 "pars0lex.l"
+#line 537 "pars0lex.l"
{
return((int)(*yytext));
@@ -1622,7 +1644,7 @@ YY_RULE_SETUP
YY_BREAK
case 98:
YY_RULE_SETUP
-#line 519 "pars0lex.l"
+#line 542 "pars0lex.l"
{
return((int)(*yytext));
@@ -1630,7 +1652,7 @@ YY_RULE_SETUP
YY_BREAK
case 99:
YY_RULE_SETUP
-#line 524 "pars0lex.l"
+#line 547 "pars0lex.l"
{
return((int)(*yytext));
@@ -1638,7 +1660,7 @@ YY_RULE_SETUP
YY_BREAK
case 100:
YY_RULE_SETUP
-#line 529 "pars0lex.l"
+#line 552 "pars0lex.l"
{
return((int)(*yytext));
@@ -1646,32 +1668,32 @@ YY_RULE_SETUP
YY_BREAK
case 101:
YY_RULE_SETUP
-#line 534 "pars0lex.l"
+#line 557 "pars0lex.l"
BEGIN(comment); /* eat up comment */
YY_BREAK
case 102:
YY_RULE_SETUP
-#line 536 "pars0lex.l"
+#line 559 "pars0lex.l"
YY_BREAK
case 103:
YY_RULE_SETUP
-#line 537 "pars0lex.l"
+#line 560 "pars0lex.l"
YY_BREAK
case 104:
YY_RULE_SETUP
-#line 538 "pars0lex.l"
+#line 561 "pars0lex.l"
BEGIN(INITIAL);
YY_BREAK
case 105:
YY_RULE_SETUP
-#line 540 "pars0lex.l"
+#line 563 "pars0lex.l"
/* eat up whitespace */
YY_BREAK
case 106:
YY_RULE_SETUP
-#line 543 "pars0lex.l"
+#line 566 "pars0lex.l"
{
fprintf(stderr,"Unrecognized character: %02x\n",
*yytext);
@@ -1683,10 +1705,10 @@ YY_RULE_SETUP
YY_BREAK
case 107:
YY_RULE_SETUP
-#line 552 "pars0lex.l"
+#line 575 "pars0lex.l"
YY_FATAL_ERROR( "flex scanner jammed" );
YY_BREAK
-#line 1687 "lex.yy.c"
+#line 1710 "lex.yy.c"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(comment):
case YY_STATE_EOF(quoted):
@@ -2574,5 +2596,5 @@ int main()
return 0;
}
#endif
-#line 552 "pars0lex.l"
+#line 575 "pars0lex.l"
diff --git a/innobase/pars/pars0lex.l b/innobase/pars/pars0lex.l
index 0b1af554bed..811057d48a1 100644
--- a/innobase/pars/pars0lex.l
+++ b/innobase/pars/pars0lex.l
@@ -58,9 +58,9 @@ Linux.
#include "mem0mem.h"
#include "os0proc.h"
-#define malloc(A) mem_alloc(A)
-#define free(A) mem_free(A)
-#define realloc(P, A) mem_realloc(P, A, __FILE__, __LINE__)
+#define malloc(A) ut_malloc(A)
+#define free(A) ut_free(A)
+#define realloc(P, A) ut_realloc(P, A)
#define exit(A) ut_error
#define YY_INPUT(buf, result, max_size) pars_get_lex_chars(buf, &result, max_size)
@@ -77,16 +77,16 @@ string_append(
const char* str, /* in: string to be appended */
ulint len) /* in: length of the string */
{
+ if (stringbuf == NULL) {
+ stringbuf = malloc(1);
+ stringbuf_len_alloc = 1;
+ }
+
if (stringbuf_len + len > stringbuf_len_alloc) {
- if (stringbuf_len_alloc == 0) {
- stringbuf_len_alloc++;
- }
while (stringbuf_len + len > stringbuf_len_alloc) {
stringbuf_len_alloc <<= 1;
}
- stringbuf = stringbuf
- ? realloc(stringbuf, stringbuf_len_alloc)
- : malloc(stringbuf_len_alloc);
+ stringbuf = realloc(stringbuf, stringbuf_len_alloc);
}
memcpy(stringbuf + stringbuf_len, str, len);
@@ -114,11 +114,34 @@ ID [a-z_A-Z][a-z_A-Z0-9]*
}
"'" {
+/* Quoted character string literals are handled in an explicit
+start state 'quoted'. This state is entered and the buffer for
+the scanned string is emptied upon encountering a starting quote.
+
+In the state 'quoted', only two actions are possible (defined below). */
BEGIN(quoted);
stringbuf_len = 0;
}
-<quoted>[^\']+ string_append(yytext, yyleng);
-<quoted>"'"+ { string_append(yytext, yyleng / 2);
+<quoted>[^\']+ {
+ /* Got a sequence of characters other than "'":
+ append to string buffer */
+ string_append(yytext, yyleng);
+}
+<quoted>"'"+ {
+ /* Got a sequence of "'" characters:
+ append half of them to string buffer,
+ as "''" represents a single "'".
+ We apply truncating division,
+ so that "'''" will result in "'". */
+
+ string_append(yytext, yyleng / 2);
+
+ /* If we got an odd number of quotes, then the
+ last quote we got is the terminating quote.
+ At the end of the string, we return to the
+ initial start state and report the scanned
+ string literal. */
+
if (yyleng % 2) {
BEGIN(INITIAL);
yylval = sym_tab_add_str_lit(
diff --git a/innobase/pars/pars0opt.c b/innobase/pars/pars0opt.c
index 4fb0c937f1e..7ba4af15243 100644
--- a/innobase/pars/pars0opt.c
+++ b/innobase/pars/pars0opt.c
@@ -1190,7 +1190,6 @@ opt_search_plan(
#endif
}
-#ifdef UNIV_SQL_DEBUG
/************************************************************************
Prints info of a query plan. */
@@ -1237,4 +1236,3 @@ opt_print_query_plan(
(unsigned long) UT_LIST_GET_LEN(plan->end_conds));
}
}
-#endif /* UNIV_SQL_DEBUG */
diff --git a/innobase/pars/pars0pars.c b/innobase/pars/pars0pars.c
index 12451b4d94d..e4b388cba82 100644
--- a/innobase/pars/pars0pars.c
+++ b/innobase/pars/pars0pars.c
@@ -530,7 +530,7 @@ pars_retrieve_table_def(
/*====================*/
sym_node_t* sym_node) /* in: table node */
{
- char* table_name;
+ const char* table_name;
ut_a(sym_node);
ut_a(que_node_get_type(sym_node) == QUE_NODE_SYMBOL);
@@ -538,7 +538,7 @@ pars_retrieve_table_def(
sym_node->resolved = TRUE;
sym_node->token_type = SYM_TABLE;
- table_name = (char*) sym_node->name;
+ table_name = (const char*) sym_node->name;
sym_node->table = dict_table_get_low(table_name);
diff --git a/innobase/que/que0que.c b/innobase/que/que0que.c
index 08bf7ce3e59..22878dec27f 100644
--- a/innobase/que/que0que.c
+++ b/innobase/que/que0que.c
@@ -12,6 +12,7 @@ Created 5/27/1996 Heikki Tuuri
#include "que0que.ic"
#endif
+#include "srv0que.h"
#include "usr0sess.h"
#include "trx0trx.h"
#include "trx0roll.h"
@@ -174,15 +175,19 @@ a single worker thread to execute it. This function should be used to end
the wait state of a query thread waiting for a lock or a stored procedure
completion. */
-que_thr_t*
+void
que_thr_end_wait(
/*=============*/
- /* out: next query thread to run;
- NULL if none */
- que_thr_t* thr) /* in: query thread in the
+ que_thr_t* thr, /* in: query thread in the
QUE_THR_LOCK_WAIT,
or QUE_THR_PROCEDURE_WAIT, or
QUE_THR_SIG_REPLY_WAIT state */
+ que_thr_t** next_thr) /* in/out: next query thread to run;
+ if the value which is passed in is
+ a pointer to a NULL pointer, then the
+ calling function can start running
+ a new query thread; if NULL is passed
+ as the parameter, it is ignored */
{
ibool was_active;
@@ -190,8 +195,6 @@ que_thr_end_wait(
ut_ad(mutex_own(&kernel_mutex));
#endif /* UNIV_SYNC_DEBUG */
ut_ad(thr);
- ut_ad(next_thr);
- ut_ad(*next_thr == NULL);
ut_ad((thr->state == QUE_THR_LOCK_WAIT)
|| (thr->state == QUE_THR_PROCEDURE_WAIT)
|| (thr->state == QUE_THR_SIG_REPLY_WAIT));
@@ -203,8 +206,18 @@ que_thr_end_wait(
que_thr_move_to_run_state(thr);
- return(was_active ? NULL : thr);
-}
+ if (was_active) {
+
+ return;
+ }
+
+ if (next_thr && *next_thr == NULL) {
+ *next_thr = thr;
+ } else {
+ ut_a(0);
+ srv_que_task_enqueue_low(thr);
+ }
+}
/**************************************************************************
Same as que_thr_end_wait, but no parameter next_thr available. */
@@ -241,6 +254,8 @@ que_thr_end_wait_no_next_thr(
for the lock to be released: */
srv_release_mysql_thread_if_suspended(thr);
+
+ /* srv_que_task_enqueue_low(thr); */
}
/**************************************************************************
@@ -341,6 +356,49 @@ que_fork_start_command(
return(NULL);
}
+/**************************************************************************
+After signal handling is finished, returns control to a query graph error
+handling routine. (Currently, just returns the control to the root of the
+graph so that the graph can communicate an error message to the client.) */
+
+void
+que_fork_error_handle(
+/*==================*/
+ trx_t* trx __attribute__((unused)), /* in: trx */
+ que_t* fork) /* in: query graph which was run before signal
+ handling started, NULL not allowed */
+{
+ que_thr_t* thr;
+
+#ifdef UNIV_SYNC_DEBUG
+ ut_ad(mutex_own(&kernel_mutex));
+#endif /* UNIV_SYNC_DEBUG */
+ ut_ad(trx->sess->state == SESS_ERROR);
+ ut_ad(UT_LIST_GET_LEN(trx->reply_signals) == 0);
+ ut_ad(UT_LIST_GET_LEN(trx->wait_thrs) == 0);
+
+ thr = UT_LIST_GET_FIRST(fork->thrs);
+
+ while (thr != NULL) {
+ ut_ad(!thr->is_active);
+ ut_ad(thr->state != QUE_THR_SIG_REPLY_WAIT);
+ ut_ad(thr->state != QUE_THR_LOCK_WAIT);
+
+ thr->run_node = thr;
+ thr->prev_node = thr->child;
+ thr->state = QUE_THR_COMPLETED;
+
+ thr = UT_LIST_GET_NEXT(thrs, thr);
+ }
+
+ thr = UT_LIST_GET_FIRST(fork->thrs);
+
+ que_thr_move_to_run_state(thr);
+
+ ut_a(0);
+ srv_que_task_enqueue_low(thr);
+}
+
/********************************************************************
Tests if all the query threads in the same fork have a given state. */
UNIV_INLINE
@@ -709,18 +767,22 @@ this function may only be called from inside que_run_threads or
que_thr_check_if_switch! These restrictions exist to make the rollback code
easier to maintain. */
static
-que_thr_t*
+void
que_thr_dec_refer_count(
/*====================*/
- /* out: next query thread to run */
- que_thr_t* thr) /* in: query thread */
+ que_thr_t* thr, /* in: query thread */
+ que_thr_t** next_thr) /* in/out: next query thread to run;
+ if the value which is passed in is
+ a pointer to a NULL pointer, then the
+ calling function can start running
+ a new query thread */
{
que_fork_t* fork;
trx_t* trx;
sess_t* sess;
ulint fork_type;
- que_thr_t* next_thr = NULL;
-
+ ibool stopped;
+
fork = thr->common.parent;
trx = thr->graph->trx;
sess = trx->sess;
@@ -731,7 +793,9 @@ que_thr_dec_refer_count(
if (thr->state == QUE_THR_RUNNING) {
- if (!que_thr_stop(thr)) {
+ stopped = que_thr_stop(thr);
+
+ if (!stopped) {
/* The reason for the thr suspension or wait was
already canceled before we came here: continue
running the thread */
@@ -739,9 +803,16 @@ que_thr_dec_refer_count(
/* fputs("!!!!!!!! Wait already ended: continue thr\n",
stderr); */
+ if (next_thr && *next_thr == NULL) {
+ *next_thr = thr;
+ } else {
+ ut_a(0);
+ srv_que_task_enqueue_low(thr);
+ }
+
mutex_exit(&kernel_mutex);
- return(thr);
+ return;
}
}
@@ -757,7 +828,7 @@ que_thr_dec_refer_count(
mutex_exit(&kernel_mutex);
- return(next_thr);
+ return;
}
fork_type = fork->fork_type;
@@ -773,7 +844,7 @@ que_thr_dec_refer_count(
ut_ad(UT_LIST_GET_LEN(trx->signals) > 0);
ut_ad(trx->handling_signals == TRUE);
- next_thr = trx_finish_rollback_off_kernel(fork, trx);
+ trx_finish_rollback_off_kernel(fork, trx, next_thr);
} else if (fork_type == QUE_FORK_PURGE) {
@@ -795,7 +866,7 @@ que_thr_dec_refer_count(
zero, then we start processing a signal; from it we may get
a new query thread to run */
- next_thr = trx_sig_start_handle(trx);
+ trx_sig_start_handle(trx, next_thr);
}
if (trx->handling_signals && UT_LIST_GET_LEN(trx->signals) == 0) {
@@ -804,8 +875,6 @@ que_thr_dec_refer_count(
}
mutex_exit(&kernel_mutex);
-
- return(next_thr);
}
/**************************************************************************
@@ -970,10 +1039,9 @@ que_thr_stop_for_mysql_no_error(
trx->n_active_thrs--;
}
-#ifdef UNIV_DEBUG
/**************************************************************************
Prints info of an SQL query graph node. */
-static
+
void
que_node_print_info(
/*================*/
@@ -1030,7 +1098,6 @@ que_node_print_info(
fprintf(stderr, "Node type %lu: %s, address %p\n", (ulong) type, str, node);
}
-#endif /* UNIV_DEBUG */
/**************************************************************************
Performs an execution step on a query thread. */
@@ -1179,7 +1246,6 @@ loop:
/*-------------------------*/
next_thr = que_thr_step(thr);
/*-------------------------*/
- ut_a(next_thr == thr || next_thr == NULL);
/* Test the effect on performance of adding extra mutex
reservations */
@@ -1192,7 +1258,8 @@ loop:
loop_count++;
if (next_thr != thr) {
- next_thr = que_thr_dec_refer_count(thr);
+ ut_a(next_thr == NULL);
+ que_thr_dec_refer_count(thr, &next_thr);
if (next_thr == NULL) {
diff --git a/innobase/rem/rem0cmp.c b/innobase/rem/rem0cmp.c
index 254ebeec8c9..6e8f3d82ef3 100644
--- a/innobase/rem/rem0cmp.c
+++ b/innobase/rem/rem0cmp.c
@@ -33,12 +33,13 @@ At the present, the comparison functions return 0 in the case,
where two records disagree only in the way that one
has more fields than the other. */
+#ifdef UNIV_DEBUG
/*****************************************************************
Used in debug checking of cmp_dtuple_... .
This function is used to compare a data tuple to a physical record. If
dtuple has n fields then rec must have either m >= n fields, or it must
differ from dtuple in some of the m fields rec has. */
-
+static
int
cmp_debug_dtuple_rec_with_match(
/*============================*/
@@ -54,6 +55,7 @@ cmp_debug_dtuple_rec_with_match(
completely matched fields; when function
returns, contains the value for current
comparison */
+#endif /* UNIV_DEBUG */
/*****************************************************************
This function is used to compare two data fields for which the data type
is such that we must use MySQL code to compare them. The prototype here
@@ -962,13 +964,14 @@ order_resolved:
return(ret);
}
+#ifdef UNIV_DEBUG
/*****************************************************************
Used in debug checking of cmp_dtuple_... .
This function is used to compare a data tuple to a physical record. If
dtuple has n fields then rec must have either m >= n fields, or it must
differ from dtuple in some of the m fields rec has. If encounters an
externally stored field, returns 0. */
-
+static
int
cmp_debug_dtuple_rec_with_match(
/*============================*/
@@ -1064,3 +1067,4 @@ order_resolved:
return(ret);
}
+#endif /* UNIV_DEBUG */
diff --git a/innobase/row/row0ins.c b/innobase/row/row0ins.c
index 062f21369a7..7f1852c70f2 100644
--- a/innobase/row/row0ins.c
+++ b/innobase/row/row0ins.c
@@ -80,9 +80,9 @@ ins_node_create(
node->trx_id = ut_dulint_zero;
node->entry_sys_heap = mem_heap_create(128);
-#ifdef UNIV_DEBUG
- node->magic_n = INS_NODE_MAGIC_N;
-#endif /* UNIV_DEBUG */
+
+ node->magic_n = INS_NODE_MAGIC_N;
+
return(node);
}
@@ -194,7 +194,6 @@ ins_node_set_new_row(
ins_node_t* node, /* in: insert node */
dtuple_t* row) /* in: new row (or first row) for the node */
{
- ut_ad(node->magic_n == INS_NODE_MAGIC_N);
node->state = INS_NODE_SET_IX_LOCK;
node->index = NULL;
node->entry = NULL;
@@ -518,7 +517,7 @@ static
void
row_ins_foreign_report_err(
/*=======================*/
- char* errstr, /* in: error string from the viewpoint
+ const char* errstr, /* in: error string from the viewpoint
of the parent table */
que_thr_t* thr, /* in: query thread whose run_node
is an update node */
@@ -652,32 +651,33 @@ row_ins_foreign_check_on_constraint(
ulint err;
ulint i;
char* ptr;
- char table_name_buf[1000];
+ char* table_name_buf;
ut_a(thr && foreign && pcur && mtr);
/* Since we are going to delete or update a row, we have to invalidate
the MySQL query cache for table */
- ut_a(ut_strlen(table->name) < 998);
- strcpy(table_name_buf, table->name);
+ table_name_buf = mem_strdup(table->name);
ptr = strchr(table_name_buf, '/');
ut_a(ptr);
*ptr = '\0';
- /* We call a function in ha_innodb.cc */
#ifndef UNIV_HOTBACKUP
+ /* We call a function in ha_innodb.cc */
innobase_invalidate_query_cache(thr_get_trx(thr), table_name_buf,
- ut_strlen(table->name) + 1);
+ strlen(table->name) + 1);
#endif
+ mem_free(table_name_buf);
+
node = thr->run_node;
if (node->is_delete && 0 == (foreign->type &
(DICT_FOREIGN_ON_DELETE_CASCADE
| DICT_FOREIGN_ON_DELETE_SET_NULL))) {
- row_ins_foreign_report_err((char*)"Trying to delete",
+ row_ins_foreign_report_err("Trying to delete",
thr, foreign,
btr_pcur_get_rec(pcur), entry);
@@ -690,7 +690,7 @@ row_ins_foreign_check_on_constraint(
/* This is an UPDATE */
- row_ins_foreign_report_err((char*)"Trying to update",
+ row_ins_foreign_report_err("Trying to update",
thr, foreign,
btr_pcur_get_rec(pcur), entry);
@@ -751,7 +751,7 @@ row_ins_foreign_check_on_constraint(
err = DB_ROW_IS_REFERENCED;
row_ins_foreign_report_err(
-(char*)"Trying an update, possibly causing a cyclic cascaded update\n"
+"Trying an update, possibly causing a cyclic cascaded update\n"
"in the child table,", thr, foreign, btr_pcur_get_rec(pcur), entry);
goto nonstandard_exit_func;
@@ -876,7 +876,7 @@ row_ins_foreign_check_on_constraint(
err = DB_ROW_IS_REFERENCED;
row_ins_foreign_report_err(
-(char*)"Trying a cascaded update where the updated value in the child\n"
+"Trying a cascaded update where the updated value in the child\n"
"table would not fit in the length of the column, or the value would\n"
"be NULL and the column is declared as not NULL in the child table,",
thr, foreign, btr_pcur_get_rec(pcur), entry);
@@ -1194,7 +1194,7 @@ run_again:
}
} else {
row_ins_foreign_report_err(
- (char*)"Trying to delete or update",
+ "Trying to delete or update",
thr, foreign, rec, entry);
err = DB_ROW_IS_REFERENCED;
@@ -2013,7 +2013,6 @@ row_ins(
ulint err;
ut_ad(node && thr);
- ut_ad(node->magic_n == INS_NODE_MAGIC_N);
if (node->state == INS_NODE_ALLOC_ROW_ID) {
@@ -2078,7 +2077,7 @@ row_ins_step(
trx_start_if_not_started(trx);
node = thr->run_node;
- ut_ad(node->magic_n == INS_NODE_MAGIC_N);
+
ut_ad(que_node_get_type(node) == QUE_NODE_INSERT);
parent = que_node_get_parent(node);
diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c
index 61be3a7248e..c4408de2a85 100644
--- a/innobase/row/row0mysql.c
+++ b/innobase/row/row0mysql.c
@@ -397,6 +397,7 @@ row_create_prebuilt(
prebuilt->clust_pcur = btr_pcur_create_for_mysql();
prebuilt->select_lock_type = LOCK_NONE;
+ prebuilt->stored_select_lock_type = 99999999;
prebuilt->sel_graph = NULL;
@@ -691,7 +692,7 @@ row_lock_table_autoinc_for_mysql(
return(DB_SUCCESS);
}
- trx->op_info = (char *) "setting auto-inc lock";
+ trx->op_info = "setting auto-inc lock";
if (node == NULL) {
row_get_prebuilt_insert_row(prebuilt);
@@ -727,14 +728,14 @@ run_again:
goto run_again;
}
- trx->op_info = (char *) "";
+ trx->op_info = "";
return(err);
}
que_thr_stop_for_mysql_no_error(thr, trx);
- trx->op_info = (char *) "";
+ trx->op_info = "";
return((int) err);
}
@@ -774,7 +775,7 @@ row_lock_table_for_mysql(
ut_ad(trx);
ut_ad(trx->mysql_thread_id == os_thread_get_curr_id());
- trx->op_info = (char *) "setting table lock";
+ trx->op_info = "setting table lock";
if (prebuilt->sel_graph == NULL) {
/* Build a dummy select query graph */
@@ -811,14 +812,14 @@ run_again:
goto run_again;
}
- trx->op_info = (char *) "";
+ trx->op_info = "";
return(err);
}
que_thr_stop_for_mysql_no_error(thr, trx);
- trx->op_info = (char *) "";
+ trx->op_info = "";
return((int) err);
}
@@ -869,7 +870,7 @@ row_insert_for_mysql(
return(DB_ERROR);
}
- trx->op_info = (char *) "inserting";
+ trx->op_info = "inserting";
trx_start_if_not_started(trx);
@@ -910,7 +911,7 @@ run_again:
goto run_again;
}
- trx->op_info = (char *) "";
+ trx->op_info = "";
return(err);
}
@@ -927,7 +928,7 @@ run_again:
}
row_update_statistics_if_needed(prebuilt->table);
- trx->op_info = (char *) "";
+ trx->op_info = "";
return((int) err);
}
@@ -1084,7 +1085,7 @@ row_update_for_mysql(
return(DB_ERROR);
}
- trx->op_info = (char *) "updating or deleting";
+ trx->op_info = "updating or deleting";
trx_start_if_not_started(trx);
@@ -1131,7 +1132,7 @@ run_again:
if (err == DB_RECORD_NOT_FOUND) {
trx->error_state = DB_SUCCESS;
- trx->op_info = (char *) "";
+ trx->op_info = "";
return((int) err);
}
@@ -1142,7 +1143,7 @@ run_again:
goto run_again;
}
- trx->op_info = (char *) "";
+ trx->op_info = "";
return(err);
}
@@ -1161,7 +1162,7 @@ run_again:
row_update_statistics_if_needed(prebuilt->table);
- trx->op_info = (char *) "";
+ trx->op_info = "";
return((int) err);
}
@@ -1413,7 +1414,8 @@ row_create_table_for_mysql(
tab_node_t* node;
mem_heap_t* heap;
que_thr_t* thr;
- ulint namelen;
+ const char* table_name;
+ ulint table_name_len;
ulint err;
ut_ad(trx->mysql_thread_id == os_thread_get_curr_id());
@@ -1437,7 +1439,7 @@ row_create_table_for_mysql(
return(DB_ERROR);
}
- trx->op_info = (char *) "creating table";
+ trx->op_info = "creating table";
if (row_mysql_is_system_table(table->name)) {
@@ -1465,10 +1467,17 @@ row_create_table_for_mysql(
return(row_mysql_recover_tmp_table(table, trx));
}
- namelen = strlen(table->name) + 1;
+ /* The table name is prefixed with the database name and a '/'.
+ Certain table names starting with 'innodb_' have their special
+ meaning regardless of the database name. Thus, we need to
+ ignore the database name prefix in the comparisons. */
+ table_name = strchr(table->name, '/');
+ ut_a(table_name);
+ table_name++;
+ table_name_len = strlen(table_name) + 1;
- if (namelen == sizeof S_innodb_monitor
- && !memcmp(table->name, S_innodb_monitor,
+ if (table_name_len == sizeof S_innodb_monitor
+ && !memcmp(table_name, S_innodb_monitor,
sizeof S_innodb_monitor)) {
/* Table equals "innodb_monitor":
@@ -1480,27 +1489,27 @@ row_create_table_for_mysql(
of InnoDB monitor prints */
os_event_set(srv_lock_timeout_thread_event);
- } else if (namelen == sizeof S_innodb_lock_monitor
- && !memcmp(table->name, S_innodb_lock_monitor,
+ } else if (table_name_len == sizeof S_innodb_lock_monitor
+ && !memcmp(table_name, S_innodb_lock_monitor,
sizeof S_innodb_lock_monitor)) {
srv_print_innodb_monitor = TRUE;
srv_print_innodb_lock_monitor = TRUE;
os_event_set(srv_lock_timeout_thread_event);
- } else if (namelen == sizeof S_innodb_tablespace_monitor
- && !memcmp(table->name, S_innodb_tablespace_monitor,
+ } else if (table_name_len == sizeof S_innodb_tablespace_monitor
+ && !memcmp(table_name, S_innodb_tablespace_monitor,
sizeof S_innodb_tablespace_monitor)) {
srv_print_innodb_tablespace_monitor = TRUE;
os_event_set(srv_lock_timeout_thread_event);
- } else if (namelen == sizeof S_innodb_table_monitor
- && !memcmp(table->name, S_innodb_table_monitor,
+ } else if (table_name_len == sizeof S_innodb_table_monitor
+ && !memcmp(table_name, S_innodb_table_monitor,
sizeof S_innodb_table_monitor)) {
srv_print_innodb_table_monitor = TRUE;
os_event_set(srv_lock_timeout_thread_event);
- } else if (namelen == sizeof S_innodb_mem_validate
- && !memcmp(table->name, S_innodb_mem_validate,
+ } else if (table_name_len == sizeof S_innodb_mem_validate
+ && !memcmp(table_name, S_innodb_mem_validate,
sizeof S_innodb_mem_validate)) {
/* We define here a debugging feature intended for
developers */
@@ -1572,7 +1581,7 @@ row_create_table_for_mysql(
que_graph_free((que_t*) que_node_get_parent(thr));
- trx->op_info = (char *) "";
+ trx->op_info = "";
return((int) err);
}
@@ -1601,7 +1610,7 @@ row_create_index_for_mysql(
#endif /* UNIV_SYNC_DEBUG */
ut_ad(trx->mysql_thread_id == os_thread_get_curr_id());
- trx->op_info = (char *) "creating index";
+ trx->op_info = "creating index";
/* Check that the same column does not appear twice in the index.
Starting from 4.0.14, InnoDB should be able to cope with that, but
@@ -1669,7 +1678,7 @@ error_handling:
trx->error_state = DB_SUCCESS;
}
- trx->op_info = (char *) "";
+ trx->op_info = "";
return((int) err);
}
@@ -1705,7 +1714,7 @@ row_table_add_foreign_constraints(
#endif /* UNIV_SYNC_DEBUG */
ut_a(sql_string);
- trx->op_info = (char *) "adding foreign keys";
+ trx->op_info = "adding foreign keys";
trx_start_if_not_started(trx);
@@ -1749,8 +1758,8 @@ static
int
row_drop_table_for_mysql_in_background(
/*===================================*/
- /* out: error code or DB_SUCCESS */
- char* name) /* in: table name */
+ /* out: error code or DB_SUCCESS */
+ const char* name) /* in: table name */
{
ulint error;
trx_t* trx;
@@ -1951,11 +1960,41 @@ row_discard_tablespace_for_mysql(
que_t* graph = NULL;
ibool success;
ulint err;
- char buf[2 * OS_FILE_MAX_PATH];
+ char* buf;
+
+ static const char discard_tablespace_proc1[] =
+ "PROCEDURE DISCARD_TABLESPACE_PROC () IS\n"
+ "old_id CHAR;\n"
+ "new_id CHAR;\n"
+ "new_id_low INT;\n"
+ "new_id_high INT;\n"
+ "table_name CHAR;\n"
+ "BEGIN\n"
+ "table_name := ";
+ static const char discard_tablespace_proc2[] =
+ ";\n"
+ "new_id_high := %lu;\n"
+ "new_id_low := %lu;\n"
+ "new_id := CONCAT(TO_BINARY(new_id_high, 4), TO_BINARY(new_id_low, 4));\n"
+ "SELECT ID INTO old_id\n"
+ "FROM SYS_TABLES\n"
+ "WHERE NAME = table_name;\n"
+ "IF (SQL %% NOTFOUND) THEN\n"
+ " COMMIT WORK;\n"
+ " RETURN;\n"
+ "END IF;\n"
+ "UPDATE SYS_TABLES SET ID = new_id\n"
+ "WHERE ID = old_id;\n"
+ "UPDATE SYS_COLUMNS SET TABLE_ID = new_id\n"
+ "WHERE TABLE_ID = old_id;\n"
+ "UPDATE SYS_INDEXES SET TABLE_ID = new_id\n"
+ "WHERE TABLE_ID = old_id;\n"
+ "COMMIT WORK;\n"
+ "END;\n";
ut_ad(trx->mysql_thread_id == os_thread_get_curr_id());
- trx->op_info = (char *) "discarding tablespace";
+ trx->op_info = "discarding tablespace";
trx_start_if_not_started(trx);
/* Serialize data dictionary operations with dictionary mutex:
@@ -1973,9 +2012,10 @@ row_discard_tablespace_for_mysql(
if (table->space == 0) {
ut_print_timestamp(stderr);
- fprintf(stderr,
-" InnoDB: Error: table %s\n"
-"InnoDB: is in the system tablespace 0 which cannot be discarded\n", name);
+ fputs(" InnoDB: Error: table ", stderr);
+ ut_print_name(stderr, name);
+ fputs("\n"
+"InnoDB: is in the system tablespace 0 which cannot be discarded\n", stderr);
err = DB_ERROR;
goto funct_exit;
@@ -1983,36 +2023,16 @@ row_discard_tablespace_for_mysql(
new_id = dict_hdr_get_new_id(DICT_HDR_TABLE_ID);
- sprintf(buf,
- "PROCEDURE DISCARD_TABLESPACE_PROC () IS\n"
- "old_id CHAR;\n"
- "new_id CHAR;\n"
- "new_id_low INT;\n"
- "new_id_high INT;\n"
- "table_name CHAR;\n"
- "BEGIN\n"
- "table_name :='%s';\n"
- "new_id_high := %lu;\n"
- "new_id_low := %lu;\n"
- "new_id := CONCAT(TO_BINARY(new_id_high, 4), TO_BINARY(new_id_low, 4));\n"
- "SELECT ID INTO old_id\n"
- "FROM SYS_TABLES\n"
- "WHERE NAME = table_name;\n"
- "IF (SQL %% NOTFOUND) THEN\n"
- " COMMIT WORK;\n"
- " RETURN;\n"
- "END IF;\n"
- "UPDATE SYS_TABLES SET ID = new_id\n"
- "WHERE ID = old_id;\n"
- "UPDATE SYS_COLUMNS SET TABLE_ID = new_id\n"
- "WHERE TABLE_ID = old_id;\n"
- "UPDATE SYS_INDEXES SET TABLE_ID = new_id\n"
- "WHERE TABLE_ID = old_id;\n"
- "COMMIT WORK;\n"
- "END;\n", name, (ulong) ut_dulint_get_high(new_id),
- (ulong) ut_dulint_get_low(new_id));
+ buf = mem_alloc((sizeof discard_tablespace_proc1) +
+ (sizeof discard_tablespace_proc2) +
+ 20 + ut_strlenq(name, '\''));
- ut_a(strlen(buf) < 2 * OS_FILE_MAX_PATH);
+ memcpy(buf, discard_tablespace_proc1, sizeof discard_tablespace_proc1);
+ sprintf(ut_strcpyq(buf + (sizeof discard_tablespace_proc1 - 1),
+ '\'', name),
+ discard_tablespace_proc2,
+ (ulong) ut_dulint_get_high(new_id),
+ (ulong) ut_dulint_get_low(new_id));
graph = pars_sql(buf);
@@ -2060,7 +2080,7 @@ funct_exit:
trx_commit_for_mysql(trx);
- trx->op_info = (char *) "";
+ trx->op_info = "";
return((int) err);
}
@@ -2085,7 +2105,7 @@ row_import_tablespace_for_mysql(
trx_start_if_not_started(trx);
- trx->op_info = (char*) "importing tablespace";
+ trx->op_info = "importing tablespace";
current_lsn = log_get_lsn();
@@ -2126,9 +2146,10 @@ row_import_tablespace_for_mysql(
if (table->space == 0) {
ut_print_timestamp(stderr);
- fprintf(stderr,
-" InnoDB: Error: table %s\n"
-"InnoDB: is in the system tablespace 0 which cannot be imported\n", name);
+ fputs(" InnoDB: Error: table ", stderr);
+ ut_print_name(stderr, name);
+ fputs("\n"
+"InnoDB: is in the system tablespace 0 which cannot be imported\n", stderr);
err = DB_ERROR;
goto funct_exit;
@@ -2136,10 +2157,12 @@ row_import_tablespace_for_mysql(
if (!table->tablespace_discarded) {
ut_print_timestamp(stderr);
- fprintf(stderr,
+ fputs(
" InnoDB: Error: you are trying to IMPORT a tablespace\n"
-"InnoDB: %s, though you have not called DISCARD on it yet\n"
-"InnoDB: during the lifetime of the mysqld process!\n", name);
+"InnoDB: ", stderr);
+ ut_print_name(stderr, name);
+ fputs(", though you have not called DISCARD on it yet\n"
+"InnoDB: during the lifetime of the mysqld process!\n", stderr);
err = DB_ERROR;
@@ -2165,7 +2188,7 @@ funct_exit:
trx_commit_for_mysql(trx);
- trx->op_info = (char *) "";
+ trx->op_info = "";
return((int) err);
}
@@ -2189,6 +2212,7 @@ row_drop_table_for_mysql(
que_thr_t* thr;
que_t* graph;
ulint err;
+ const char* table_name;
ulint namelen;
ibool success;
ibool locked_dictionary = FALSE;
@@ -2274,14 +2298,21 @@ row_drop_table_for_mysql(
return(DB_ERROR);
}
- trx->op_info = (char *) "dropping table";
+ trx->op_info = "dropping table";
trx_start_if_not_started(trx);
- namelen = strlen(name) + 1;
+ /* The table name is prefixed with the database name and a '/'.
+ Certain table names starting with 'innodb_' have their special
+ meaning regardless of the database name. Thus, we need to
+ ignore the database name prefix in the comparisons. */
+ table_name = strchr(name, '/');
+ ut_a(table_name);
+ table_name++;
+ namelen = strlen(table_name) + 1;
if (namelen == sizeof S_innodb_monitor
- && !memcmp(name, S_innodb_monitor,
+ && !memcmp(table_name, S_innodb_monitor,
sizeof S_innodb_monitor)) {
/* Table name equals "innodb_monitor":
@@ -2290,17 +2321,17 @@ row_drop_table_for_mysql(
srv_print_innodb_monitor = FALSE;
srv_print_innodb_lock_monitor = FALSE;
} else if (namelen == sizeof S_innodb_lock_monitor
- && !memcmp(name, S_innodb_lock_monitor,
+ && !memcmp(table_name, S_innodb_lock_monitor,
sizeof S_innodb_lock_monitor)) {
srv_print_innodb_monitor = FALSE;
srv_print_innodb_lock_monitor = FALSE;
} else if (namelen == sizeof S_innodb_tablespace_monitor
- && !memcmp(name, S_innodb_tablespace_monitor,
+ && !memcmp(table_name, S_innodb_tablespace_monitor,
sizeof S_innodb_tablespace_monitor)) {
srv_print_innodb_tablespace_monitor = FALSE;
} else if (namelen == sizeof S_innodb_table_monitor
- && !memcmp(name, S_innodb_table_monitor,
+ && !memcmp(table_name, S_innodb_table_monitor,
sizeof S_innodb_table_monitor)) {
srv_print_innodb_table_monitor = FALSE;
@@ -2469,7 +2500,7 @@ row_drop_table_for_mysql(
if (dict_load_table(name) != NULL) {
ut_print_timestamp(stderr);
fputs(" InnoDB: Error: not able to remove table ",
- stderr);
+ stderr);
ut_print_name(stderr, name);
fputs(" from the dictionary cache!\n", stderr);
err = DB_ERROR;
@@ -2491,8 +2522,10 @@ row_drop_table_for_mysql(
if (!success) {
ut_print_timestamp(stderr);
fprintf(stderr,
-" InnoDB: Error: not able to delete tablespace %lu of table %s!\n",
- (ulong) space_id, name);
+" InnoDB: Error: not able to delete tablespace %lu of table ",
+ (ulong) space_id);
+ ut_print_name(stderr, name);
+ fputs("!\n", stderr);
err = DB_ERROR;
}
}
@@ -2507,7 +2540,7 @@ funct_exit:
trx_commit_for_mysql(trx);
- trx->op_info = (char *) "";
+ trx->op_info = "";
srv_wake_master_thread();
@@ -2533,7 +2566,7 @@ row_drop_database_for_mysql(
ut_a(name != NULL);
ut_a(name[namelen - 1] == '/');
- trx->op_info = (char *) "dropping database";
+ trx->op_info = "dropping database";
trx_start_if_not_started(trx);
loop:
@@ -2587,7 +2620,7 @@ loop:
trx_commit_for_mysql(trx);
- trx->op_info = (char *) "";
+ trx->op_info = "";
return(err);
}
@@ -2738,7 +2771,7 @@ row_rename_table_for_mysql(
return(DB_ERROR);
}
- trx->op_info = (char *) "renaming table";
+ trx->op_info = "renaming table";
trx_start_if_not_started(trx);
if (row_mysql_is_recovered_tmp_table(new_name)) {
@@ -2757,15 +2790,14 @@ row_rename_table_for_mysql(
err = DB_TABLE_NOT_FOUND;
ut_print_timestamp(stderr);
- fprintf(stderr,
- " InnoDB: Error: table %s\n"
- "InnoDB: does not exist in the InnoDB internal\n"
+ fputs(" InnoDB: Error: table ", stderr);
+ ut_print_name(stderr, old_name);
+ fputs(" does not exist in the InnoDB internal\n"
"InnoDB: data dictionary though MySQL is trying to rename the table.\n"
"InnoDB: Have you copied the .frm file of the table to the\n"
"InnoDB: MySQL database directory from another database?\n"
"InnoDB: You can look for further help from section 15.1 of\n"
- "InnoDB: http://www.innodb.com/ibman.html\n",
- old_name);
+ "InnoDB: http://www.innodb.com/ibman.php\n", stderr);
goto funct_exit;
}
@@ -2773,12 +2805,12 @@ row_rename_table_for_mysql(
err = DB_TABLE_NOT_FOUND;
ut_print_timestamp(stderr);
- fprintf(stderr,
- " InnoDB: Error: table %s\n"
- "InnoDB: does not have an .ibd file in the database directory.\n"
+ fputs(" InnoDB: Error: table ", stderr);
+ ut_print_name(stderr, old_name);
+ fputs(
+ " does not have an .ibd file in the database directory.\n"
"InnoDB: You can look for further help from section 15.1 of\n"
- "InnoDB: http://www.innodb.com/ibman.html\n",
- old_name);
+ "InnoDB: http://www.innodb.com/ibman.php\n", stderr);
goto funct_exit;
}
@@ -2905,23 +2937,25 @@ row_rename_table_for_mysql(
if (err != DB_SUCCESS) {
if (err == DB_DUPLICATE_KEY) {
ut_print_timestamp(stderr);
- fprintf(stderr,
- " InnoDB: Error: table %s exists in the InnoDB internal data\n"
- "InnoDB: dictionary though MySQL is trying rename table %s to it.\n"
+ fputs(" InnoDB: Error: table ", stderr);
+ ut_print_name(stderr, new_name);
+ fputs(" exists in the InnoDB internal data\n"
+ "InnoDB: dictionary though MySQL is trying rename table ", stderr);
+ ut_print_name(stderr, old_name);
+ fputs(" to it.\n"
"InnoDB: Have you deleted the .frm file and not used DROP TABLE?\n"
"InnoDB: You can look for further help from section 15.1 of\n"
- "InnoDB: http://www.innodb.com/ibman.html\n",
- new_name, old_name);
- fprintf(stderr,
- "InnoDB: If table %s is a temporary table #sql..., then it can be that\n"
+ "InnoDB: http://www.innodb.com/ibman.php\n"
+ "InnoDB: If table ", stderr);
+ ut_print_name(stderr, new_name);
+ fputs(" is a temporary table #sql..., then it can be that\n"
"InnoDB: there are still queries running on the table, and it will be\n"
- "InnoDB: dropped automatically when the queries end.\n", new_name);
- fprintf(stderr,
+ "InnoDB: dropped automatically when the queries end.\n"
"InnoDB: You can drop the orphaned table inside InnoDB by\n"
"InnoDB: creating an InnoDB table with the same name in another\n"
"InnoDB: database and moving the .frm file to the current database.\n"
"InnoDB: Then MySQL thinks the table exists, and DROP TABLE will\n"
- "InnoDB: succeed.\n");
+ "InnoDB: succeed.\n", stderr);
}
trx->error_state = DB_SUCCESS;
trx_general_rollback_for_mysql(trx, FALSE, NULL);
@@ -2937,9 +2971,12 @@ row_rename_table_for_mysql(
trx_general_rollback_for_mysql(trx, FALSE, NULL);
trx->error_state = DB_SUCCESS;
ut_print_timestamp(stderr);
- fprintf(stderr,
-" InnoDB: Error in table rename, cannot rename %s to %s\n", old_name,
- new_name);
+ fputs(" InnoDB: Error in table rename, cannot rename ",
+ stderr);
+ ut_print_name(stderr, old_name);
+ fputs(" to ", stderr);
+ ut_print_name(stderr, new_name);
+ putc('\n', stderr);
err = DB_ERROR;
goto funct_exit;
@@ -2958,11 +2995,14 @@ row_rename_table_for_mysql(
if (err != DB_SUCCESS) {
ut_print_timestamp(stderr);
- fprintf(stderr,
- " InnoDB: Error: in ALTER TABLE table %s\n"
- "InnoDB: has or is referenced in foreign key constraints\n"
- "InnoDB: which are not compatible with the new table definition.\n",
- new_name);
+ fputs(" InnoDB: Error: in ALTER TABLE ",
+ stderr);
+ ut_print_name(stderr, new_name);
+ fputs("\n"
+ "InnoDB: has or is referenced in foreign key constraints\n"
+ "InnoDB: which are not compatible with the new table definition.\n",
+ stderr);
+
ut_a(dict_table_rename_in_cache(table,
old_name, FALSE));
trx->error_state = DB_SUCCESS;
@@ -2987,7 +3027,7 @@ funct_exit:
trx_commit_for_mysql(trx);
- trx->op_info = (char *) "";
+ trx->op_info = "";
return((int) err);
}
@@ -3125,7 +3165,7 @@ row_check_table_for_mysql(
ulint ret = DB_SUCCESS;
ulint old_isolation_level;
- prebuilt->trx->op_info = (char *) "checking table";
+ prebuilt->trx->op_info = "checking table";
old_isolation_level = prebuilt->trx->isolation_level;
@@ -3160,9 +3200,11 @@ row_check_table_for_mysql(
ret = DB_ERROR;
+ fputs("Error: ", stderr);
+ dict_index_name_print(stderr, index);
fprintf(stderr,
- "Error: index %s contains %lu entries, should be %lu\n",
- index->name, (ulong) n_rows,
+ " contains %lu entries, should be %lu\n",
+ (ulong) n_rows,
(ulong) n_rows_in_table);
}
}
@@ -3181,7 +3223,7 @@ row_check_table_for_mysql(
ret = DB_ERROR;
}
- prebuilt->trx->op_info = (char *) "";
+ prebuilt->trx->op_info = "";
return(ret);
}
diff --git a/innobase/row/row0sel.c b/innobase/row/row0sel.c
index 48796c8a455..9e8e9b82f2d 100644
--- a/innobase/row/row0sel.c
+++ b/innobase/row/row0sel.c
@@ -2831,7 +2831,7 @@ row_search_for_mysql(
/* PHASE 1: Try to pop the row from the prefetch cache */
if (direction == 0) {
- trx->op_info = (char *) "starting index read";
+ trx->op_info = "starting index read";
prebuilt->n_rows_fetched = 0;
prebuilt->n_fetch_cached = 0;
@@ -2842,7 +2842,7 @@ row_search_for_mysql(
row_prebuild_sel_graph(prebuilt);
}
} else {
- trx->op_info = (char *) "fetching rows";
+ trx->op_info = "fetching rows";
if (prebuilt->n_rows_fetched == 0) {
prebuilt->fetch_direction = direction;
@@ -2867,7 +2867,7 @@ row_search_for_mysql(
prebuilt->n_rows_fetched++;
srv_n_rows_read++;
- trx->op_info = (char *) "";
+ trx->op_info = "";
return(DB_SUCCESS);
}
@@ -2879,7 +2879,7 @@ row_search_for_mysql(
cache, but the cache was not full at the time of the
popping: no more rows can exist in the result set */
- trx->op_info = (char *) "";
+ trx->op_info = "";
return(DB_RECORD_NOT_FOUND);
}
@@ -2924,7 +2924,7 @@ row_search_for_mysql(
if (direction != 0 && !prebuilt->used_in_HANDLER) {
- trx->op_info = (char *) "";
+ trx->op_info = "";
return(DB_RECORD_NOT_FOUND);
}
}
@@ -3005,7 +3005,7 @@ row_search_for_mysql(
trx->has_search_latch = FALSE;
}
- trx->op_info = (char *) "";
+ trx->op_info = "";
/* NOTE that we do NOT store the cursor
position */
@@ -3028,7 +3028,7 @@ row_search_for_mysql(
trx->has_search_latch = FALSE;
}
- trx->op_info = (char *) "";
+ trx->op_info = "";
/* NOTE that we do NOT store the cursor
position */
@@ -3575,7 +3575,7 @@ lock_wait_or_error:
/* fputs("Using ", stderr);
dict_index_name_print(stderr, index);
fprintf(stderr, " cnt %lu ret value %lu err\n", cnt, err); */
- trx->op_info = (char *) "";
+ trx->op_info = "";
return(err);
@@ -3598,7 +3598,7 @@ normal_return:
srv_n_rows_read++;
}
- trx->op_info = (char *) "";
+ trx->op_info = "";
return(ret);
}
diff --git a/innobase/row/row0upd.c b/innobase/row/row0upd.c
index 724e7bf91e7..d35ae0a3e38 100644
--- a/innobase/row/row0upd.c
+++ b/innobase/row/row0upd.c
@@ -287,9 +287,7 @@ upd_node_create(
node->select = NULL;
node->heap = mem_heap_create(128);
-#ifdef UNIV_DEBUG
- node->magic_n = UPD_NODE_MAGIC_N;
-#endif /* UNIV_DEBUG */
+ node->magic_n = UPD_NODE_MAGIC_N;
node->cmpl_info = 0;
@@ -1806,7 +1804,6 @@ row_upd_step(
trx_start_if_not_started(trx);
node = thr->run_node;
- ut_ad(node->magic_n == UPD_NODE_MAGIC_N);
sel_node = node->select;
@@ -1926,7 +1923,6 @@ row_upd_in_place_in_select(
node = que_node_get_parent(sel_node);
- ut_ad(node->magic_n == UPD_NODE_MAGIC_N);
ut_ad(que_node_get_type(node) == QUE_NODE_UPDATE);
pcur = node->pcur;
diff --git a/innobase/srv/Makefile.am b/innobase/srv/Makefile.am
index 37fd73a4bf0..752683b82b8 100644
--- a/innobase/srv/Makefile.am
+++ b/innobase/srv/Makefile.am
@@ -19,6 +19,6 @@ include ../include/Makefile.i
noinst_LIBRARIES = libsrv.a
-libsrv_a_SOURCES = srv0srv.c srv0start.c
+libsrv_a_SOURCES = srv0srv.c srv0que.c srv0start.c
EXTRA_PROGRAMS =
diff --git a/innobase/srv/srv0que.c b/innobase/srv/srv0que.c
new file mode 100644
index 00000000000..9dc9ae453d9
--- /dev/null
+++ b/innobase/srv/srv0que.c
@@ -0,0 +1,113 @@
+/******************************************************
+Server query execution
+
+(c) 1996 Innobase Oy
+
+Created 6/5/1996 Heikki Tuuri
+*******************************************************/
+
+#include "srv0que.h"
+
+#include "srv0srv.h"
+#include "sync0sync.h"
+#include "os0thread.h"
+#include "usr0sess.h"
+#include "que0que.h"
+
+/**************************************************************************
+Checks if there is work to do in the server task queue. If there is, the
+thread starts processing a task. Before leaving, it again checks the task
+queue and picks a new task if any exists. This is called by a SRV_WORKER
+thread. */
+
+void
+srv_que_task_queue_check(void)
+/*==========================*/
+{
+ que_thr_t* thr;
+
+ for (;;) {
+ mutex_enter(&kernel_mutex);
+
+ thr = UT_LIST_GET_FIRST(srv_sys->tasks);
+
+ if (thr == NULL) {
+ mutex_exit(&kernel_mutex);
+
+ return;
+ }
+
+ UT_LIST_REMOVE(queue, srv_sys->tasks, thr);
+
+ mutex_exit(&kernel_mutex);
+
+ que_run_threads(thr);
+ }
+}
+
+/**************************************************************************
+Performs round-robin on the server tasks. This is called by a SRV_WORKER
+thread every second or so. */
+
+que_thr_t*
+srv_que_round_robin(
+/*================*/
+ /* out: the new (may be == thr) query thread
+ to run */
+ que_thr_t* thr) /* in: query thread */
+{
+ que_thr_t* new_thr;
+
+ ut_ad(thr);
+ ut_ad(thr->state == QUE_THR_RUNNING);
+
+ mutex_enter(&kernel_mutex);
+
+ UT_LIST_ADD_LAST(queue, srv_sys->tasks, thr);
+
+ new_thr = UT_LIST_GET_FIRST(srv_sys->tasks);
+
+ mutex_exit(&kernel_mutex);
+
+ return(new_thr);
+}
+
+/**************************************************************************
+Enqueues a task to server task queue and releases a worker thread, if there
+is a suspended one. */
+
+void
+srv_que_task_enqueue_low(
+/*=====================*/
+ que_thr_t* thr) /* in: query thread */
+{
+ ut_ad(thr);
+
+#ifdef UNIV_SYNC_DEBUG
+ ut_ad(mutex_own(&kernel_mutex));
+#endif /* UNIV_SYNC_DEBUG */
+
+ UT_LIST_ADD_LAST(queue, srv_sys->tasks, thr);
+
+ srv_release_threads(SRV_WORKER, 1);
+}
+
+/**************************************************************************
+Enqueues a task to server task queue and releases a worker thread, if there
+is a suspended one. */
+
+void
+srv_que_task_enqueue(
+/*=================*/
+ que_thr_t* thr) /* in: query thread */
+{
+ ut_ad(thr);
+
+ ut_a(0); /* Under MySQL this is never called */
+
+ mutex_enter(&kernel_mutex);
+
+ srv_que_task_enqueue_low(thr);
+
+ mutex_exit(&kernel_mutex);
+}
diff --git a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
index 33adcaa14b8..fc46c95a8a6 100644
--- a/innobase/srv/srv0srv.c
+++ b/innobase/srv/srv0srv.c
@@ -34,6 +34,7 @@ Created 10/8/1995 Heikki Tuuri
#include "sync0sync.h"
#include "thr0loc.h"
#include "que0que.h"
+#include "srv0que.h"
#include "log0recv.h"
#include "pars0pars.h"
#include "usr0sess.h"
@@ -57,7 +58,7 @@ ulint srv_activity_count = 0;
ibool srv_lock_timeout_and_monitor_active = FALSE;
ibool srv_error_monitor_active = FALSE;
-char* srv_main_thread_op_info = (char*) "";
+const char* srv_main_thread_op_info = "";
/* Server parameters which are read from the initfile */
@@ -65,7 +66,9 @@ char* srv_main_thread_op_info = (char*) "";
names, where the file name itself may also contain a path */
char* srv_data_home = NULL;
+#ifdef UNIV_LOG_ARCHIVE
char* srv_arch_dir = NULL;
+#endif /* UNIV_LOG_ARCHIVE */
ibool srv_file_per_table = FALSE; /* store to its own file each table
created by an user; data dictionary
@@ -94,7 +97,6 @@ char** srv_log_group_home_dirs = NULL;
ulint srv_n_log_groups = ULINT_MAX;
ulint srv_n_log_files = ULINT_MAX;
ulint srv_log_file_size = ULINT_MAX; /* size in database pages */
-ibool srv_log_archive_on = FALSE;
ulint srv_log_buffer_size = ULINT_MAX; /* size in database pages */
ulint srv_flush_log_at_trx_commit = 1;
@@ -149,8 +151,11 @@ ulint srv_lock_table_size = ULINT_MAX;
ulint srv_n_file_io_threads = ULINT_MAX;
+#ifdef UNIV_LOG_ARCHIVE
+ibool srv_log_archive_on = FALSE;
ibool srv_archive_recovery = 0;
dulint srv_archive_recovery_limit_lsn;
+#endif /* UNIV_LOG_ARCHIVE */
ulint srv_lock_wait_timeout = 1024 * 1024 * 1024;
@@ -921,11 +926,11 @@ retry:
os_fast_mutex_unlock(&srv_conc_mutex);
- trx->op_info = (char*)"sleeping before joining InnoDB queue";
+ trx->op_info = "sleeping before joining InnoDB queue";
os_thread_sleep(50000);
- trx->op_info = (char*)"";
+ trx->op_info = "";
os_fast_mutex_lock(&srv_conc_mutex);
@@ -978,11 +983,11 @@ retry:
/* Go to wait for the event; when a thread leaves InnoDB it will
release this thread */
- trx->op_info = (char*)"waiting in InnoDB queue";
+ trx->op_info = "waiting in InnoDB queue";
os_event_wait(slot->event);
- trx->op_info = (char*)"";
+ trx->op_info = "";
os_fast_mutex_lock(&srv_conc_mutex);
@@ -1946,7 +1951,7 @@ loop:
/* ---- When there is database activity by users, we cycle in this
loop */
- srv_main_thread_op_info = (char*) "reserving kernel mutex";
+ srv_main_thread_op_info = "reserving kernel mutex";
n_ios_very_old = log_sys->n_log_ios + buf_pool->n_pages_read
+ buf_pool->n_pages_written;
@@ -1970,7 +1975,7 @@ loop:
for (i = 0; i < 10; i++) {
n_ios_old = log_sys->n_log_ios + buf_pool->n_pages_read
+ buf_pool->n_pages_written;
- srv_main_thread_op_info = (char*)"sleeping";
+ srv_main_thread_op_info = "sleeping";
if (!skip_sleep) {
@@ -1983,12 +1988,11 @@ loop:
can drop tables lazily after there no longer are SELECT
queries to them. */
- srv_main_thread_op_info =
- (char*)"doing background drop tables";
+ srv_main_thread_op_info = "doing background drop tables";
row_drop_tables_for_mysql_in_background();
- srv_main_thread_op_info = (char*)"";
+ srv_main_thread_op_info = "";
if (srv_fast_shutdown && srv_shutdown_state > 0) {
@@ -1999,10 +2003,10 @@ loop:
is issued or the we have specified in my.cnf no flush
at transaction commit */
- srv_main_thread_op_info = (char*)"flushing log";
+ srv_main_thread_op_info = "flushing log";
log_buffer_flush_to_disk();
- srv_main_thread_op_info = (char*)"making checkpoint";
+ srv_main_thread_op_info = "making checkpoint";
log_free_check();
/* If there were less than 5 i/os during the
@@ -2015,11 +2019,10 @@ loop:
n_ios = log_sys->n_log_ios + buf_pool->n_pages_read
+ buf_pool->n_pages_written;
if (n_pend_ios < 3 && (n_ios - n_ios_old < 5)) {
- srv_main_thread_op_info =
- (char*)"doing insert buffer merge";
+ srv_main_thread_op_info = "doing insert buffer merge";
ibuf_contract_for_n_pages(TRUE, 5);
- srv_main_thread_op_info = (char*)"flushing log";
+ srv_main_thread_op_info = "flushing log";
log_buffer_flush_to_disk();
}
@@ -2067,20 +2070,20 @@ loop:
+ buf_pool->n_pages_written;
if (n_pend_ios < 3 && (n_ios - n_ios_very_old < 200)) {
- srv_main_thread_op_info = (char*) "flushing buffer pool pages";
+ srv_main_thread_op_info = "flushing buffer pool pages";
buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max);
- srv_main_thread_op_info = (char*) "flushing log";
+ srv_main_thread_op_info = "flushing log";
log_buffer_flush_to_disk();
}
/* We run a batch of insert buffer merge every 10 seconds,
even if the server were active */
- srv_main_thread_op_info = (char*)"doing insert buffer merge";
+ srv_main_thread_op_info = "doing insert buffer merge";
ibuf_contract_for_n_pages(TRUE, 5);
- srv_main_thread_op_info = (char*)"flushing log";
+ srv_main_thread_op_info = "flushing log";
log_buffer_flush_to_disk();
/* We run a full purge every 10 seconds, even if the server
@@ -2097,20 +2100,20 @@ loop:
goto background_loop;
}
- srv_main_thread_op_info = (char*)"purging";
+ srv_main_thread_op_info = "purging";
n_pages_purged = trx_purge();
current_time = time(NULL);
if (difftime(current_time, last_flush_time) > 1) {
- srv_main_thread_op_info = (char*) "flushing log";
+ srv_main_thread_op_info = "flushing log";
log_buffer_flush_to_disk();
last_flush_time = current_time;
}
}
- srv_main_thread_op_info = (char*)"flushing buffer pool pages";
+ srv_main_thread_op_info = "flushing buffer pool pages";
/* Flush a few oldest pages to make a new checkpoint younger */
@@ -2131,13 +2134,13 @@ loop:
ut_dulint_max);
}
- srv_main_thread_op_info = (char*)"making checkpoint";
+ srv_main_thread_op_info = "making checkpoint";
/* Make a new checkpoint about once in 10 seconds */
log_checkpoint(TRUE, FALSE);
- srv_main_thread_op_info = (char*)"reserving kernel mutex";
+ srv_main_thread_op_info = "reserving kernel mutex";
mutex_enter(&kernel_mutex);
@@ -2161,7 +2164,7 @@ background_loop:
/* The server has been quiet for a while: start running background
operations */
- srv_main_thread_op_info = (char*)"doing background drop tables";
+ srv_main_thread_op_info = "doing background drop tables";
n_tables_to_drop = row_drop_tables_for_mysql_in_background();
@@ -2174,7 +2177,7 @@ background_loop:
os_thread_sleep(100000);
}
- srv_main_thread_op_info = (char*)"purging";
+ srv_main_thread_op_info = "purging";
/* Run a full purge */
@@ -2188,20 +2191,20 @@ background_loop:
break;
}
- srv_main_thread_op_info = (char*)"purging";
+ srv_main_thread_op_info = "purging";
n_pages_purged = trx_purge();
current_time = time(NULL);
if (difftime(current_time, last_flush_time) > 1) {
- srv_main_thread_op_info = (char*) "flushing log";
+ srv_main_thread_op_info = "flushing log";
log_buffer_flush_to_disk();
last_flush_time = current_time;
}
}
- srv_main_thread_op_info = (char*)"reserving kernel mutex";
+ srv_main_thread_op_info = "reserving kernel mutex";
mutex_enter(&kernel_mutex);
if (srv_activity_count != old_activity_count) {
@@ -2210,7 +2213,7 @@ background_loop:
}
mutex_exit(&kernel_mutex);
- srv_main_thread_op_info = (char*)"doing insert buffer merge";
+ srv_main_thread_op_info = "doing insert buffer merge";
if (srv_fast_shutdown && srv_shutdown_state > 0) {
n_bytes_merged = 0;
@@ -2218,7 +2221,7 @@ background_loop:
n_bytes_merged = ibuf_contract_for_n_pages(TRUE, 20);
}
- srv_main_thread_op_info = (char*)"reserving kernel mutex";
+ srv_main_thread_op_info = "reserving kernel mutex";
mutex_enter(&kernel_mutex);
if (srv_activity_count != old_activity_count) {
@@ -2228,10 +2231,10 @@ background_loop:
mutex_exit(&kernel_mutex);
flush_loop:
- srv_main_thread_op_info = (char*)"flushing buffer pool pages";
+ srv_main_thread_op_info = "flushing buffer pool pages";
n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max);
- srv_main_thread_op_info = (char*)"reserving kernel mutex";
+ srv_main_thread_op_info = "reserving kernel mutex";
mutex_enter(&kernel_mutex);
if (srv_activity_count != old_activity_count) {
@@ -2240,15 +2243,14 @@ flush_loop:
}
mutex_exit(&kernel_mutex);
- srv_main_thread_op_info =
- (char*) "waiting for buffer pool flush to end";
+ srv_main_thread_op_info = "waiting for buffer pool flush to end";
buf_flush_wait_batch_end(BUF_FLUSH_LIST);
- srv_main_thread_op_info = (char*) "flushing log";
+ srv_main_thread_op_info = "flushing log";
log_buffer_flush_to_disk();
- srv_main_thread_op_info = (char*)"making checkpoint";
+ srv_main_thread_op_info = "making checkpoint";
log_checkpoint(TRUE, FALSE);
@@ -2260,7 +2262,7 @@ flush_loop:
goto flush_loop;
}
- srv_main_thread_op_info = (char*)"reserving kernel mutex";
+ srv_main_thread_op_info = "reserving kernel mutex";
mutex_enter(&kernel_mutex);
if (srv_activity_count != old_activity_count) {
@@ -2269,8 +2271,7 @@ flush_loop:
}
mutex_exit(&kernel_mutex);
/*
- srv_main_thread_op_info =
- (char*)"archiving log (if log archive is on)";
+ srv_main_thread_op_info = "archiving log (if log archive is on)";
log_archive_do(FALSE, &n_bytes_archived);
*/
@@ -2301,7 +2302,7 @@ flush_loop:
master thread to wait for more server activity */
suspend_thread:
- srv_main_thread_op_info = (char*)"suspending";
+ srv_main_thread_op_info = "suspending";
mutex_enter(&kernel_mutex);
@@ -2315,7 +2316,7 @@ suspend_thread:
mutex_exit(&kernel_mutex);
- srv_main_thread_op_info = (char*)"waiting for server activity";
+ srv_main_thread_op_info = "waiting for server activity";
os_event_wait(event);
diff --git a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c
index 68fcb82c6d8..dd38eddb20b 100644
--- a/innobase/srv/srv0start.c
+++ b/innobase/srv/srv0start.c
@@ -628,7 +628,7 @@ open_or_create_log_file(
fil_node_create(name, srv_log_file_size,
2 * k + SRV_LOG_SPACE_FIRST_ID, FALSE);
-#ifdef notdefined
+#ifdef UNIV_LOG_ARCHIVE
/* If this is the first log group, create the file space object
for archived logs.
Under MySQL, no archiving ever done. */
@@ -636,12 +636,11 @@ open_or_create_log_file(
if (k == 0 && i == 0) {
arch_space_id = 2 * k + 1 + SRV_LOG_SPACE_FIRST_ID;
- fil_space_create((char*) "arch_log_space", arch_space_id,
- FIL_LOG);
+ fil_space_create("arch_log_space", arch_space_id, FIL_LOG);
} else {
arch_space_id = ULINT_UNDEFINED;
}
-#endif
+#endif /* UNIV_LOG_ARCHIVE */
if (i == 0) {
log_group_init(k, srv_n_log_files,
srv_log_file_size * UNIV_PAGE_SIZE,
@@ -662,12 +661,14 @@ open_or_create_data_files(
/* out: DB_SUCCESS or error code */
ibool* create_new_db, /* out: TRUE if new database should be
created */
- dulint* min_flushed_lsn,/* out: min of flushed lsn values in data
- files */
+#ifdef UNIV_LOG_ARCHIVE
ulint* min_arch_log_no,/* out: min of archived log numbers in data
files */
- dulint* max_flushed_lsn,/* out: */
ulint* max_arch_log_no,/* out: */
+#endif /* UNIV_LOG_ARCHIVE */
+ dulint* min_flushed_lsn,/* out: min of flushed lsn values in data
+ files */
+ dulint* max_flushed_lsn,/* out: */
ulint* sum_of_new_sizes)/* out: sum of sizes of the new files added */
{
ibool ret;
@@ -820,8 +821,10 @@ open_or_create_data_files(
skip_size_check:
fil_read_flushed_lsn_and_arch_log_no(files[i],
one_opened,
- min_flushed_lsn, min_arch_log_no,
- max_flushed_lsn, max_arch_log_no);
+#ifdef UNIV_LOG_ARCHIVE
+ min_arch_log_no, max_arch_log_no,
+#endif /* UNIV_LOG_ARCHIVE */
+ min_flushed_lsn, max_flushed_lsn);
one_opened = TRUE;
} else {
/* We created the data file and now write it full of
@@ -908,8 +911,10 @@ innobase_start_or_create_for_mysql(void)
ibool log_opened = FALSE;
dulint min_flushed_lsn;
dulint max_flushed_lsn;
+#ifdef UNIV_LOG_ARCHIVE
ulint min_arch_log_no;
ulint max_arch_log_no;
+#endif /* UNIV_LOG_ARCHIVE */
ulint sum_of_new_sizes;
ulint sum_of_data_file_sizes;
ulint tablespace_size_in_header;
@@ -1017,28 +1022,22 @@ innobase_start_or_create_for_mysql(void)
srv_win_file_flush_method = SRV_WIN_IO_UNBUFFERED;
#ifndef __WIN__
- } else if (0 == ut_strcmp(srv_file_flush_method_str,
- (char*)"fdatasync")) {
+ } else if (0 == ut_strcmp(srv_file_flush_method_str, "fdatasync")) {
srv_unix_file_flush_method = SRV_UNIX_FDATASYNC;
- } else if (0 == ut_strcmp(srv_file_flush_method_str,
- (char*)"O_DSYNC")) {
+ } else if (0 == ut_strcmp(srv_file_flush_method_str, "O_DSYNC")) {
srv_unix_file_flush_method = SRV_UNIX_O_DSYNC;
- } else if (0 == ut_strcmp(srv_file_flush_method_str,
- (char*)"O_DIRECT")) {
+ } else if (0 == ut_strcmp(srv_file_flush_method_str, "O_DIRECT")) {
srv_unix_file_flush_method = SRV_UNIX_O_DIRECT;
- } else if (0 == ut_strcmp(srv_file_flush_method_str,
- (char*)"littlesync")) {
+ } else if (0 == ut_strcmp(srv_file_flush_method_str, "littlesync")) {
srv_unix_file_flush_method = SRV_UNIX_LITTLESYNC;
- } else if (0 == ut_strcmp(srv_file_flush_method_str,
- (char*)"nosync")) {
+ } else if (0 == ut_strcmp(srv_file_flush_method_str, "nosync")) {
srv_unix_file_flush_method = SRV_UNIX_NOSYNC;
#else
- } else if (0 == ut_strcmp(srv_file_flush_method_str,
- (char*)"normal")) {
+ } else if (0 == ut_strcmp(srv_file_flush_method_str, "normal")) {
srv_win_file_flush_method = SRV_WIN_IO_NORMAL;
os_aio_use_native_aio = FALSE;
@@ -1181,6 +1180,7 @@ NetWare. */
os_thread_create(io_handler_thread, n + i, thread_ids + i);
}
+#ifdef UNIV_LOG_ARCHIVE
if (0 != ut_strcmp(srv_log_group_home_dirs[0], srv_arch_dir)) {
fprintf(stderr,
"InnoDB: Error: you must set the log group home dir in my.cnf the\n"
@@ -1188,6 +1188,7 @@ NetWare. */
return(DB_ERROR);
}
+#endif /* UNIV_LOG_ARCHIVE */
if (srv_n_log_files * srv_log_file_size >= 262144) {
fprintf(stderr,
@@ -1219,8 +1220,10 @@ NetWare. */
}
err = open_or_create_data_files(&create_new_db,
- &min_flushed_lsn, &min_arch_log_no,
- &max_flushed_lsn, &max_arch_log_no,
+#ifdef UNIV_LOG_ARCHIVE
+ &min_arch_log_no, &max_arch_log_no,
+#endif /* UNIV_LOG_ARCHIVE */
+ &min_flushed_lsn, &max_flushed_lsn,
&sum_of_new_sizes);
if (err != DB_SUCCESS) {
fprintf(stderr,
@@ -1235,8 +1238,10 @@ NetWare. */
return((int) err);
}
+#ifdef UNIV_LOG_ARCHIVE
srv_normalize_path_for_win(srv_arch_dir);
srv_arch_dir = srv_add_path_separator_if_needed(srv_arch_dir);
+#endif /* UNIV_LOG_ARCHIVE */
for (i = 0; i < srv_n_log_files; i++) {
err = open_or_create_log_file(create_new_db, &log_file_created,
@@ -1270,9 +1275,16 @@ NetWare. */
fil_open_log_and_system_tablespace_files();
- if (log_created && !create_new_db && !srv_archive_recovery) {
+ if (log_created && !create_new_db
+#ifdef UNIV_LOG_ARCHIVE
+ && !srv_archive_recovery
+#endif /* UNIV_LOG_ARCHIVE */
+ ) {
if (ut_dulint_cmp(max_flushed_lsn, min_flushed_lsn) != 0
- || max_arch_log_no != min_arch_log_no) {
+#ifdef UNIV_LOG_ARCHIVE
+ || max_arch_log_no != min_arch_log_no
+#endif /* UNIV_LOG_ARCHIVE */
+ ) {
fprintf(stderr,
"InnoDB: Cannot initialize created log files because\n"
"InnoDB: data files were not in sync with each other\n"
@@ -1295,10 +1307,14 @@ NetWare. */
mutex_enter(&(log_sys->mutex));
+#ifdef UNIV_LOG_ARCHIVE
/* Do not + 1 arch_log_no because we do not use log
archiving */
recv_reset_logs(max_flushed_lsn, max_arch_log_no, TRUE);
-
+#else
+ recv_reset_logs(max_flushed_lsn, TRUE);
+#endif /* UNIV_LOG_ARCHIVE */
+
mutex_exit(&(log_sys->mutex));
}
@@ -1313,6 +1329,7 @@ NetWare. */
dict_create();
srv_startup_is_before_trx_rollback_phase = FALSE;
+#ifdef UNIV_LOG_ARCHIVE
} else if (srv_archive_recovery) {
fprintf(stderr,
"InnoDB: Starting archive recovery from a backup...\n");
@@ -1336,6 +1353,7 @@ NetWare. */
fsp_header_get_free_limit(0);
recv_recovery_from_archive_finish();
+#endif /* UNIV_LOG_ARCHIVE */
} else {
/* We always try to do a recovery, even if the database had
been shut down normally: this is the normal startup path */
@@ -1384,7 +1402,7 @@ NetWare. */
log_make_checkpoint_at(ut_dulint_max, TRUE);
-#ifdef notdefined
+#ifdef UNIV_LOG_ARCHIVE
/* Archiving is always off under MySQL */
if (!srv_log_archive_on) {
ut_a(DB_SUCCESS == log_archive_noarchivelog());
@@ -1403,7 +1421,7 @@ NetWare. */
ut_a(DB_SUCCESS == log_archive_archivelog());
}
}
-#endif
+#endif /* UNIV_LOG_ARCHIVE */
if (!create_new_db && srv_force_recovery == 0) {
/* After a crash recovery we only check that the info in data
dictionary is consistent with what we already know about space
@@ -1460,9 +1478,7 @@ NetWare. */
os_thread_create(&srv_master_thread, NULL, thread_ids + 1 +
SRV_MAX_N_IO_THREADS);
-#ifdef UNIV_DEBUG
/* buf_debug_prints = TRUE; */
-#endif /* UNIV_DEBUG */
sum_of_data_file_sizes = 0;
diff --git a/innobase/sync/sync0rw.c b/innobase/sync/sync0rw.c
index 769eb326ce2..77757685208 100644
--- a/innobase/sync/sync0rw.c
+++ b/innobase/sync/sync0rw.c
@@ -119,8 +119,8 @@ rw_lock_create_func(
lock->cfile_name = cfile_name;
lock->cline = cline;
- lock->last_s_file_name = (char *) "not yet reserved";
- lock->last_x_file_name = (char *) "not yet reserved";
+ lock->last_s_file_name = "not yet reserved";
+ lock->last_x_file_name = "not yet reserved";
lock->last_s_line = 0;
lock->last_x_line = 0;
@@ -171,7 +171,6 @@ rw_lock_free(
mutex_exit(&rw_lock_list_mutex);
}
-#ifdef UNIV_DEBUG
/**********************************************************************
Checks that the rw-lock has been initialized and that there are no
simultaneous shared and exclusive locks. */
@@ -199,7 +198,6 @@ rw_lock_validate(
return(TRUE);
}
-#endif /* UNIV_DEBUG */
/**********************************************************************
Lock an rw-lock in shared mode for the current thread. If the rw-lock is
@@ -593,7 +591,7 @@ rw_lock_add_debug_info(
rw_lock_t* lock, /* in: rw-lock */
ulint pass, /* in: pass value */
ulint lock_type, /* in: lock type */
- char* file_name, /* in: file where requested */
+ const char* file_name, /* in: file where requested */
ulint line) /* in: line where requested */
{
rw_lock_debug_t* info;
diff --git a/innobase/sync/sync0sync.c b/innobase/sync/sync0sync.c
index 31f287b6341..86306e49cac 100644
--- a/innobase/sync/sync0sync.c
+++ b/innobase/sync/sync0sync.c
@@ -214,7 +214,7 @@ mutex_create_func(
mutex->magic_n = MUTEX_MAGIC_N;
#ifdef UNIV_SYNC_DEBUG
mutex->line = 0;
- mutex->file_name = (char *) "not yet reserved";
+ mutex->file_name = "not yet reserved";
#endif /* UNIV_SYNC_DEBUG */
mutex->level = SYNC_LEVEL_NONE;
mutex->cfile_name = cfile_name;
@@ -314,7 +314,6 @@ mutex_enter_nowait(
return(1);
}
-#ifdef UNIV_DEBUG
/**********************************************************************
Checks that the mutex has been initialized. */
@@ -328,7 +327,6 @@ mutex_validate(
return(TRUE);
}
-#endif /* UNIV_DEBUG */
/**********************************************************************
Sets the waiters field in a mutex. */
@@ -512,7 +510,7 @@ void
mutex_set_debug_info(
/*=================*/
mutex_t* mutex, /* in: mutex */
- char* file_name, /* in: file where requested */
+ const char* file_name, /* in: file where requested */
ulint line) /* in: line where requested */
{
ut_ad(mutex);
@@ -1077,12 +1075,8 @@ sync_thread_add_level(
} else if (level == SYNC_DICT_HEADER) {
ut_a(sync_thread_levels_g(array, SYNC_DICT_HEADER));
} else if (level == SYNC_DICT) {
-#ifdef UNIV_DEBUG
- ut_a(buf_debug_prints ||
- sync_thread_levels_g(array, SYNC_DICT));
-#else /* UNIV_DEBUG */
- ut_a(sync_thread_levels_g(array, SYNC_DICT));
-#endif /* UNIV_DEBUG */
+ ut_a(buf_debug_prints
+ || sync_thread_levels_g(array, SYNC_DICT));
} else {
ut_error;
}
diff --git a/innobase/thr/thr0loc.c b/innobase/thr/thr0loc.c
index a17d09fcca6..033bb22807f 100644
--- a/innobase/thr/thr0loc.c
+++ b/innobase/thr/thr0loc.c
@@ -46,12 +46,11 @@ struct thr_local_struct{
ibool in_ibuf;/* TRUE if the the thread is doing an ibuf
operation */
hash_node_t hash; /* hash chain node */
-#ifdef UNIV_DEBUG
ulint magic_n;
-#define THR_LOCAL_MAGIC_N 1231234
-#endif /* UNIV_DEBUG */
};
+#define THR_LOCAL_MAGIC_N 1231234
+
/***********************************************************************
Returns the local storage struct for a thread. */
static
@@ -170,9 +169,8 @@ thr_local_create(void)
local->id = os_thread_get_curr_id();
local->handle = os_thread_get_curr();
-#ifdef UNIV_DEBUG
local->magic_n = THR_LOCAL_MAGIC_N;
-#endif /* UNIV_DEBUG */
+
local->in_ibuf = FALSE;
mutex_enter(&thr_local_mutex);
@@ -211,7 +209,7 @@ thr_local_free(
mutex_exit(&thr_local_mutex);
- ut_ad(local->magic_n == THR_LOCAL_MAGIC_N);
+ ut_a(local->magic_n == THR_LOCAL_MAGIC_N);
mem_free(local);
}
diff --git a/innobase/trx/trx0purge.c b/innobase/trx/trx0purge.c
index 002775eaac1..3d5f0d3f03a 100644
--- a/innobase/trx/trx0purge.c
+++ b/innobase/trx/trx0purge.c
@@ -23,6 +23,7 @@ Created 3/26/1996 Heikki Tuuri
#include "row0purge.h"
#include "row0upd.h"
#include "trx0rec.h"
+#include "srv0que.h"
#include "os0thread.h"
/* The global data structure coordinating a purge */
@@ -1059,6 +1060,8 @@ trx_purge(void)
mutex_exit(&kernel_mutex);
+/* srv_que_task_enqueue(thr2); */
+
if (srv_print_thread_releases) {
fputs("Starting purge\n", stderr);
diff --git a/innobase/trx/trx0roll.c b/innobase/trx/trx0roll.c
index 4343249764e..e65755a0f73 100644
--- a/innobase/trx/trx0roll.c
+++ b/innobase/trx/trx0roll.c
@@ -20,6 +20,7 @@ Created 3/26/1996 Heikki Tuuri
#include "trx0rec.h"
#include "que0que.h"
#include "usr0sess.h"
+#include "srv0que.h"
#include "srv0start.h"
#include "row0undo.h"
#include "row0mysql.h"
@@ -116,11 +117,11 @@ trx_rollback_for_mysql(
return(DB_SUCCESS);
}
- trx->op_info = (char *) "rollback";
+ trx->op_info = "rollback";
err = trx_general_rollback_for_mysql(trx, FALSE, NULL);
- trx->op_info = (char *) "";
+ trx->op_info = "";
return(err);
}
@@ -141,14 +142,14 @@ trx_rollback_last_sql_stat_for_mysql(
return(DB_SUCCESS);
}
- trx->op_info = (char *) "rollback of SQL statement";
+ trx->op_info = "rollback of SQL statement";
err = trx_general_rollback_for_mysql(trx, TRUE,
&(trx->last_sql_stat_start));
/* The following call should not be needed, but we play safe: */
trx_mark_sql_stat_end(trx);
- trx->op_info = (char *) "";
+ trx->op_info = "";
return(err);
}
@@ -239,7 +240,7 @@ trx_rollback_to_savepoint_for_mysql(
*mysql_binlog_cache_pos = savep->mysql_binlog_cache_pos;
- trx->op_info = (char *) "rollback to a savepoint";
+ trx->op_info = "rollback to a savepoint";
err = trx_general_rollback_for_mysql(trx, TRUE, &(savep->savept));
@@ -248,7 +249,7 @@ trx_rollback_to_savepoint_for_mysql(
trx_mark_sql_stat_end(trx);
- trx->op_info = (char *) "";
+ trx->op_info = "";
return(err);
}
@@ -343,7 +344,7 @@ trx_rollback_or_clean_all_without_sess(void)
trx_t* trx;
dict_table_t* table;
ib_longlong rows_to_undo;
- char* unit = (char*)"";
+ const char* unit = "";
int err;
mutex_enter(&kernel_mutex);
@@ -421,7 +422,7 @@ loop:
rows_to_undo = trx_roll_max_undo_no;
if (rows_to_undo > 1000000000) {
rows_to_undo = rows_to_undo / 1000000;
- unit = (char*)"M";
+ unit = "M";
}
fprintf(stderr,
@@ -931,15 +932,21 @@ trx_undo_rec_release(
/*************************************************************************
Starts a rollback operation. */
-que_thr_t*
+void
trx_rollback(
/*=========*/
- /* out: next query thread to run */
trx_t* trx, /* in: transaction */
- trx_sig_t* sig) /* in: signal starting the rollback */
+ trx_sig_t* sig, /* in: signal starting the rollback */
+ que_thr_t** next_thr)/* in/out: next query thread to run;
+ if the value which is passed in is
+ a pointer to a NULL pointer, then the
+ calling function can start running
+ a new query thread; if the passed value is
+ NULL, the parameter is ignored */
{
que_t* roll_graph;
que_thr_t* thr;
+/* que_thr_t* thr2; */
#ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&kernel_mutex));
@@ -981,7 +988,18 @@ trx_rollback(
thr = que_fork_start_command(roll_graph);
ut_ad(thr);
- return(thr);
+
+/* thr2 = que_fork_start_command(roll_graph);
+
+ ut_ad(thr2); */
+
+ if (next_thr && (*next_thr == NULL)) {
+ *next_thr = thr;
+/* srv_que_task_enqueue_low(thr2); */
+ } else {
+ srv_que_task_enqueue_low(thr);
+/* srv_que_task_enqueue_low(thr2); */
+ }
}
/********************************************************************
@@ -1053,14 +1071,17 @@ trx_finish_error_processing(
/*************************************************************************
Finishes a partial rollback operation. */
static
-que_thr_t*
+void
trx_finish_partial_rollback_off_kernel(
/*===================================*/
- /* out: next query thread to run */
- trx_t* trx) /* in: transaction */
+ trx_t* trx, /* in: transaction */
+ que_thr_t** next_thr)/* in/out: next query thread to run;
+ if the value which is passed in is a pointer
+ to a NULL pointer, then the calling function
+ can start running a new query thread; if this
+ parameter is NULL, it is ignored */
{
trx_sig_t* sig;
- que_thr_t* next_thr;
#ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&kernel_mutex));
@@ -1071,26 +1092,29 @@ trx_finish_partial_rollback_off_kernel(
/* Remove the signal from the signal queue and send reply message
to it */
- next_thr = trx_sig_reply(sig);
+ trx_sig_reply(sig, next_thr);
trx_sig_remove(trx, sig);
trx->que_state = TRX_QUE_RUNNING;
- return(next_thr);
}
/********************************************************************
Finishes a transaction rollback. */
-que_thr_t*
+void
trx_finish_rollback_off_kernel(
/*===========================*/
- /* out: next query thread to run */
que_t* graph, /* in: undo graph which can now be freed */
- trx_t* trx) /* in: transaction */
+ trx_t* trx, /* in: transaction */
+ que_thr_t** next_thr)/* in/out: next query thread to run;
+ if the value which is passed in is
+ a pointer to a NULL pointer, then the
+ calling function can start running
+ a new query thread; if this parameter is
+ NULL, it is ignored */
{
trx_sig_t* sig;
trx_sig_t* next_sig;
- que_thr_t* next_thr;
#ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&kernel_mutex));
@@ -1105,21 +1129,21 @@ trx_finish_rollback_off_kernel(
if (sig->type == TRX_SIG_ROLLBACK_TO_SAVEPT) {
- return(trx_finish_partial_rollback_off_kernel(trx));
+ trx_finish_partial_rollback_off_kernel(trx, next_thr);
+
+ return;
} else if (sig->type == TRX_SIG_ERROR_OCCURRED) {
trx_finish_error_processing(trx);
- return(NULL);
+ return;
}
-#ifdef UNIV_DEBUG
if (lock_print_waits) {
fprintf(stderr, "Trx %lu rollback finished\n",
(ulong) ut_dulint_get_low(trx->id));
}
-#endif /* UNIV_DEBUG */
trx_commit_off_kernel(trx);
@@ -1127,23 +1151,19 @@ trx_finish_rollback_off_kernel(
send reply messages to them */
trx->que_state = TRX_QUE_RUNNING;
-
- next_thr = NULL;
+
while (sig != NULL) {
next_sig = UT_LIST_GET_NEXT(signals, sig);
if (sig->type == TRX_SIG_TOTAL_ROLLBACK) {
- ut_a(next_thr == NULL);
- next_thr = trx_sig_reply(sig);
+ trx_sig_reply(sig, next_thr);
trx_sig_remove(trx, sig);
}
sig = next_sig;
}
-
- return(next_thr);
}
/*************************************************************************
@@ -1176,6 +1196,7 @@ trx_rollback_step(
que_thr_t* thr) /* in: query thread */
{
roll_node_t* node;
+ ibool success;
ulint sig_no;
trx_savept_t* savept;
@@ -1202,13 +1223,19 @@ trx_rollback_step(
/* Send a rollback signal to the transaction */
- trx_sig_send(thr_get_trx(thr), sig_no, TRX_SIG_SELF,
- thr, savept);
+ success = trx_sig_send(thr_get_trx(thr),
+ sig_no, TRX_SIG_SELF,
+ thr, savept, NULL);
thr->state = QUE_THR_SIG_REPLY_WAIT;
mutex_exit(&kernel_mutex);
+ if (!success) {
+ /* Error in delivering the rollback signal */
+ que_thr_handle_error(thr, DB_ERROR, NULL, 0);
+ }
+
return(NULL);
}
diff --git a/innobase/trx/trx0sys.c b/innobase/trx/trx0sys.c
index 7e35e34f014..54bd5be01a1 100644
--- a/innobase/trx/trx0sys.c
+++ b/innobase/trx/trx0sys.c
@@ -45,6 +45,15 @@ or there was no master log position info inside InnoDB. */
char trx_sys_mysql_master_log_name[TRX_SYS_MYSQL_LOG_NAME_LEN];
ib_longlong trx_sys_mysql_master_log_pos = -1;
+/* If this MySQL server uses binary logging, after InnoDB has been inited
+and if it has done a crash recovery, we store the binlog file name and position
+here. If .._pos is -1, it means there was no binlog position info inside
+InnoDB. */
+
+char trx_sys_mysql_bin_log_name[TRX_SYS_MYSQL_LOG_NAME_LEN];
+ib_longlong trx_sys_mysql_bin_log_pos = -1;
+
+
/********************************************************************
Determines if a page number is located inside the doublewrite buffer. */
@@ -619,7 +628,6 @@ trx_sys_update_mysql_binlog_offset(
MLOG_4BYTES, mtr);
}
-#ifdef UNIV_HOTBACKUP
/*********************************************************************
Prints to stderr the MySQL binlog info in the system header if the
magic number shows it valid. */
@@ -647,11 +655,10 @@ trx_sys_print_mysql_binlog_offset_from_page(
sys_header + TRX_SYS_MYSQL_LOG_INFO + TRX_SYS_MYSQL_LOG_NAME);
}
}
-#endif /* UNIV_HOTBACKUP */
/*********************************************************************
-Prints to stderr the MySQL binlog offset info in the trx system header if
-the magic number shows it valid. */
+Stores the MySQL binlog offset info in the trx system header if
+the magic number shows it valid, and print the info to stderr */
void
trx_sys_print_mysql_binlog_offset(void)
@@ -659,7 +666,8 @@ trx_sys_print_mysql_binlog_offset(void)
{
trx_sysf_t* sys_header;
mtr_t mtr;
-
+ ulong trx_sys_mysql_bin_log_pos_high, trx_sys_mysql_bin_log_pos_low;
+
mtr_start(&mtr);
sys_header = trx_sysf_get(&mtr);
@@ -673,14 +681,22 @@ trx_sys_print_mysql_binlog_offset(void)
return;
}
- fprintf(stderr,
- "InnoDB: Last MySQL binlog file position %lu %lu, file name %s\n",
- (ulong) mach_read_from_4(sys_header + TRX_SYS_MYSQL_LOG_INFO
- + TRX_SYS_MYSQL_LOG_OFFSET_HIGH),
- (ulong) mach_read_from_4(sys_header + TRX_SYS_MYSQL_LOG_INFO
- + TRX_SYS_MYSQL_LOG_OFFSET_LOW),
- sys_header + TRX_SYS_MYSQL_LOG_INFO + TRX_SYS_MYSQL_LOG_NAME);
+ trx_sys_mysql_bin_log_pos_high = mach_read_from_4(sys_header + TRX_SYS_MYSQL_LOG_INFO
+ + TRX_SYS_MYSQL_LOG_OFFSET_HIGH);
+ trx_sys_mysql_bin_log_pos_low = mach_read_from_4(sys_header + TRX_SYS_MYSQL_LOG_INFO
+ + TRX_SYS_MYSQL_LOG_OFFSET_LOW);
+
+ trx_sys_mysql_bin_log_pos = (((ib_longlong)trx_sys_mysql_bin_log_pos_high) << 32) +
+ (ib_longlong)trx_sys_mysql_bin_log_pos_low;
+
+ ut_memcpy(trx_sys_mysql_bin_log_name, sys_header + TRX_SYS_MYSQL_LOG_INFO +
+ TRX_SYS_MYSQL_LOG_NAME, TRX_SYS_MYSQL_LOG_NAME_LEN);
+ fprintf(stderr,
+ "InnoDB: Last MySQL binlog file position %lu %lu, file name %s\n",
+ trx_sys_mysql_bin_log_pos_high, trx_sys_mysql_bin_log_pos_low,
+ trx_sys_mysql_bin_log_name);
+
mtr_commit(&mtr);
}
@@ -832,7 +848,7 @@ trx_sys_init_at_db_start(void)
{
trx_sysf_t* sys_header;
ib_longlong rows_to_undo = 0;
- char* unit = (char*)"";
+ const char* unit = "";
trx_t* trx;
mtr_t mtr;
@@ -881,7 +897,7 @@ trx_sys_init_at_db_start(void)
}
if (rows_to_undo > 1000000000) {
- unit = (char*)"M";
+ unit = "M";
rows_to_undo = rows_to_undo / 1000000;
}
diff --git a/innobase/trx/trx0trx.c b/innobase/trx/trx0trx.c
index 862229ef032..a9aae48dae6 100644
--- a/innobase/trx/trx0trx.c
+++ b/innobase/trx/trx0trx.c
@@ -81,7 +81,7 @@ trx_create(
trx->magic_n = TRX_MAGIC_N;
- trx->op_info = (char *) "";
+ trx->op_info = "";
trx->type = TRX_USER;
trx->conc_state = TRX_NOT_STARTED;
@@ -107,7 +107,7 @@ trx_create(
trx->mysql_log_file_name = NULL;
trx->mysql_log_offset = 0;
- trx->mysql_master_log_file_name = (char*)"";
+ trx->mysql_master_log_file_name = "";
trx->mysql_master_log_pos = 0;
mutex_create(&(trx->undo_mutex));
@@ -897,15 +897,18 @@ trx_assign_read_view(
/********************************************************************
Commits a transaction. NOTE that the kernel mutex is temporarily released. */
static
-que_thr_t*
+void
trx_handle_commit_sig_off_kernel(
/*=============================*/
- /* out: next query thread to run */
- trx_t* trx) /* in: transaction */
+ trx_t* trx, /* in: transaction */
+ que_thr_t** next_thr) /* in/out: next query thread to run;
+ if the value which is passed in is
+ a pointer to a NULL pointer, then the
+ calling function can start running
+ a new query thread */
{
trx_sig_t* sig;
trx_sig_t* next_sig;
- que_thr_t* next_thr = NULL;
#ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&kernel_mutex));
@@ -927,8 +930,7 @@ trx_handle_commit_sig_off_kernel(
if (sig->type == TRX_SIG_COMMIT) {
- ut_a(next_thr == NULL);
- next_thr = trx_sig_reply(sig);
+ trx_sig_reply(sig, next_thr);
trx_sig_remove(trx, sig);
}
@@ -936,8 +938,6 @@ trx_handle_commit_sig_off_kernel(
}
trx->que_state = TRX_QUE_RUNNING;
-
- return(next_thr);
}
/***************************************************************
@@ -999,6 +999,39 @@ trx_lock_wait_to_suspended(
trx->que_state = TRX_QUE_RUNNING;
}
+/***************************************************************
+Moves the query threads in the sig reply wait list of trx to the SUSPENDED
+state. */
+static
+void
+trx_sig_reply_wait_to_suspended(
+/*============================*/
+ trx_t* trx) /* in: transaction */
+{
+ trx_sig_t* sig;
+ que_thr_t* thr;
+
+#ifdef UNIV_SYNC_DEBUG
+ ut_ad(mutex_own(&kernel_mutex));
+#endif /* UNIV_SYNC_DEBUG */
+
+ sig = UT_LIST_GET_FIRST(trx->reply_signals);
+
+ while (sig != NULL) {
+ thr = sig->receiver;
+
+ ut_ad(thr->state == QUE_THR_SIG_REPLY_WAIT);
+
+ thr->state = QUE_THR_SUSPENDED;
+
+ sig->receiver = NULL;
+
+ UT_LIST_REMOVE(reply_signals, trx->reply_signals, sig);
+
+ sig = UT_LIST_GET_FIRST(trx->reply_signals);
+ }
+}
+
/*********************************************************************
Checks the compatibility of a new signal with the other signals in the
queue. */
@@ -1078,10 +1111,11 @@ trx_sig_is_compatible(
/********************************************************************
Sends a signal to a trx object. */
-que_thr_t*
+ibool
trx_sig_send(
/*=========*/
- /* out: next query thread to run */
+ /* out: TRUE if the signal was
+ successfully delivered */
trx_t* trx, /* in: trx handle */
ulint type, /* in: signal type */
ulint sender, /* in: TRX_SIG_SELF or
@@ -1089,8 +1123,14 @@ trx_sig_send(
que_thr_t* receiver_thr, /* in: query thread which wants the
reply, or NULL; if type is
TRX_SIG_END_WAIT, this must be NULL */
- trx_savept_t* savept) /* in: possible rollback savepoint, or
+ trx_savept_t* savept, /* in: possible rollback savepoint, or
NULL */
+ que_thr_t** next_thr) /* in/out: next query thread to run;
+ if the value which is passed in is
+ a pointer to a NULL pointer, then the
+ calling function can start running
+ a new query thread; if the parameter
+ is NULL, it is ignored */
{
trx_sig_t* sig;
trx_t* receiver_trx;
@@ -1100,7 +1140,14 @@ trx_sig_send(
ut_ad(mutex_own(&kernel_mutex));
#endif /* UNIV_SYNC_DEBUG */
- ut_a(trx_sig_is_compatible(trx, type, sender));
+ if (!trx_sig_is_compatible(trx, type, sender)) {
+ /* The signal is not compatible with the other signals in
+ the queue: do nothing */
+
+ ut_error;
+
+ return(FALSE);
+ }
/* Queue the signal object */
@@ -1134,6 +1181,11 @@ trx_sig_send(
sig);
}
+ if (trx->sess->state == SESS_ERROR) {
+
+ trx_sig_reply_wait_to_suspended(trx);
+ }
+
if ((sender != TRX_SIG_SELF) || (type == TRX_SIG_BREAK_EXECUTION)) {
/* The following call will add a TRX_SIG_ERROR_OCCURRED
@@ -1148,10 +1200,10 @@ trx_sig_send(
if (UT_LIST_GET_FIRST(trx->signals) == sig) {
- return(trx_sig_start_handle(trx));
+ trx_sig_start_handle(trx, next_thr);
}
- return(NULL);
+ return(TRUE);
}
/********************************************************************
@@ -1173,18 +1225,27 @@ trx_end_signal_handling(
trx->handling_signals = FALSE;
trx->graph = trx->graph_before_signal_handling;
+
+ if (trx->graph && (trx->sess->state == SESS_ERROR)) {
+
+ que_fork_error_handle(trx, trx->graph);
+ }
}
/********************************************************************
Starts handling of a trx signal. */
-que_thr_t*
+void
trx_sig_start_handle(
/*=================*/
- /* out: next query thread to run, or NULL */
- trx_t* trx) /* in: trx handle */
+ trx_t* trx, /* in: trx handle */
+ que_thr_t** next_thr) /* in/out: next query thread to run;
+ if the value which is passed in is
+ a pointer to a NULL pointer, then the
+ calling function can start running
+ a new query thread; if the parameter
+ is NULL, it is ignored */
{
- que_thr_t* next_thr = NULL;
trx_sig_t* sig;
ulint type;
loop:
@@ -1200,7 +1261,7 @@ loop:
trx_end_signal_handling(trx);
- return(next_thr);
+ return;
}
if (trx->conc_state == TRX_NOT_STARTED) {
@@ -1216,13 +1277,23 @@ loop:
trx_lock_wait_to_suspended(trx);
}
+ /* If the session is in the error state and this trx has threads
+ waiting for reply from signals, moves these threads to the suspended
+ state, canceling wait reservations; note that if the transaction has
+ sent a commit or rollback signal to itself, and its session is not in
+ the error state, then nothing is done here. */
+
+ if (trx->sess->state == SESS_ERROR) {
+ trx_sig_reply_wait_to_suspended(trx);
+ }
+
/* If there are no running query threads, we can start processing of a
signal, otherwise we have to wait until all query threads of this
transaction are aware of the arrival of the signal. */
if (trx->n_active_thrs > 0) {
- return(NULL);
+ return;
}
if (trx->handling_signals == FALSE) {
@@ -1236,19 +1307,30 @@ loop:
if (type == TRX_SIG_COMMIT) {
- next_thr = trx_handle_commit_sig_off_kernel(trx);
+ trx_handle_commit_sig_off_kernel(trx, next_thr);
} else if ((type == TRX_SIG_TOTAL_ROLLBACK)
- || (type == TRX_SIG_ROLLBACK_TO_SAVEPT)
- || (type == TRX_SIG_ERROR_OCCURRED)) {
+ || (type == TRX_SIG_ROLLBACK_TO_SAVEPT)) {
+
+ trx_rollback(trx, sig, next_thr);
+
+ /* No further signals can be handled until the rollback
+ completes, therefore we return */
+
+ return;
+
+ } else if (type == TRX_SIG_ERROR_OCCURRED) {
+
+ trx_rollback(trx, sig, next_thr);
+
/* No further signals can be handled until the rollback
completes, therefore we return */
- return(trx_rollback(trx, sig));
+ return;
} else if (type == TRX_SIG_BREAK_EXECUTION) {
- next_thr = trx_sig_reply(sig);
+ trx_sig_reply(sig, next_thr);
trx_sig_remove(trx, sig);
} else {
ut_error;
@@ -1261,14 +1343,17 @@ loop:
Send the reply message when a signal in the queue of the trx has been
handled. */
-que_thr_t*
+void
trx_sig_reply(
/*==========*/
- /* out: next query thread to run */
- trx_sig_t* sig) /* in: signal */
+ trx_sig_t* sig, /* in: signal */
+ que_thr_t** next_thr) /* in/out: next query thread to run;
+ if the value which is passed in is
+ a pointer to a NULL pointer, then the
+ calling function can start running
+ a new query thread */
{
- trx_t* receiver_trx;
- que_thr_t* next_thr = NULL;
+ trx_t* receiver_trx;
ut_ad(sig);
#ifdef UNIV_SYNC_DEBUG
@@ -1282,13 +1367,13 @@ trx_sig_reply(
UT_LIST_REMOVE(reply_signals, receiver_trx->reply_signals,
sig);
- next_thr = que_thr_end_wait(sig->receiver);
+ ut_ad(receiver_trx->sess->state != SESS_ERROR);
+
+ que_thr_end_wait(sig->receiver, next_thr);
sig->receiver = NULL;
}
-
- return(next_thr);
}
/********************************************************************
@@ -1344,6 +1429,7 @@ trx_commit_step(
{
commit_node_t* node;
que_thr_t* next_thr;
+ ibool success;
node = thr->run_node;
@@ -1358,15 +1444,22 @@ trx_commit_step(
node->state = COMMIT_NODE_WAIT;
+ next_thr = NULL;
+
thr->state = QUE_THR_SIG_REPLY_WAIT;
/* Send the commit signal to the transaction */
- next_thr = trx_sig_send(thr_get_trx(thr), TRX_SIG_COMMIT,
- TRX_SIG_SELF, thr, NULL);
-
+ success = trx_sig_send(thr_get_trx(thr), TRX_SIG_COMMIT,
+ TRX_SIG_SELF, thr, NULL, &next_thr);
+
mutex_exit(&kernel_mutex);
+ if (!success) {
+ /* Error in delivering the commit signal */
+ que_thr_handle_error(thr, DB_ERROR, NULL, 0);
+ }
+
return(next_thr);
}
@@ -1394,7 +1487,7 @@ trx_commit_for_mysql(
ut_a(trx);
- trx->op_info = (char *) "committing";
+ trx->op_info = "committing";
trx_start_if_not_started(trx);
@@ -1404,7 +1497,7 @@ trx_commit_for_mysql(
mutex_exit(&kernel_mutex);
- trx->op_info = (char *) "";
+ trx->op_info = "";
return(0);
}
@@ -1423,7 +1516,7 @@ trx_commit_complete_for_mysql(
ut_a(trx);
- trx->op_info = (char*)"flushing log";
+ trx->op_info = "flushing log";
if (srv_flush_log_at_trx_commit == 0) {
/* Do nothing */
@@ -1447,7 +1540,7 @@ trx_commit_complete_for_mysql(
ut_error;
}
- trx->op_info = (char*)"";
+ trx->op_info = "";
return(0);
}
diff --git a/innobase/usr/usr0sess.c b/innobase/usr/usr0sess.c
index cc016f2b823..359c1552421 100644
--- a/innobase/usr/usr0sess.c
+++ b/innobase/usr/usr0sess.c
@@ -37,6 +37,8 @@ sess_open(void)
#endif /* UNIV_SYNC_DEBUG */
sess = mem_alloc(sizeof(sess_t));
+ sess->state = SESS_ACTIVE;
+
sess->trx = trx_create(sess);
UT_LIST_INIT(sess->graphs);
diff --git a/innobase/ut/ut0mem.c b/innobase/ut/ut0mem.c
index 47b612d757e..9a591df9f77 100644
--- a/innobase/ut/ut0mem.c
+++ b/innobase/ut/ut0mem.c
@@ -203,6 +203,81 @@ ut_free(
}
/**************************************************************************
+Implements realloc. This is needed by /pars/lexyy.c. Otherwise, you should not
+use this function because the allocation functions in mem0mem.h are the
+recommended ones in InnoDB.
+
+man realloc in Linux, 2004:
+
+ realloc() changes the size of the memory block pointed to
+ by ptr to size bytes. The contents will be unchanged to
+ the minimum of the old and new sizes; newly allocated mem­
+ ory will be uninitialized. If ptr is NULL, the call is
+ equivalent to malloc(size); if size is equal to zero, the
+ call is equivalent to free(ptr). Unless ptr is NULL, it
+ must have been returned by an earlier call to malloc(),
+ calloc() or realloc().
+
+RETURN VALUE
+ realloc() returns a pointer to the newly allocated memory,
+ which is suitably aligned for any kind of variable and may
+ be different from ptr, or NULL if the request fails. If
+ size was equal to 0, either NULL or a pointer suitable to
+ be passed to free() is returned. If realloc() fails the
+ original block is left untouched - it is not freed or
+ moved. */
+
+void*
+ut_realloc(
+/*=======*/
+ /* out, own: pointer to new mem block or NULL */
+ void* ptr, /* in: pointer to old block or NULL */
+ ulint size) /* in: desired size */
+{
+ ut_mem_block_t* block;
+ ulint old_size;
+ ulint min_size;
+ void* new_ptr;
+
+ if (ptr == NULL) {
+
+ return(ut_malloc(size));
+ }
+
+ if (size == 0) {
+ ut_free(ptr);
+
+ return(NULL);
+ }
+
+ block = (ut_mem_block_t*)((byte*)ptr - sizeof(ut_mem_block_t));
+
+ ut_a(block->magic_n == UT_MEM_MAGIC_N);
+
+ old_size = block->size - sizeof(ut_mem_block_t);
+
+ if (size < old_size) {
+ min_size = size;
+ } else {
+ min_size = old_size;
+ }
+
+ new_ptr = ut_malloc(size);
+
+ if (new_ptr == NULL) {
+
+ return(NULL);
+ }
+
+ /* Copy the old data from ptr */
+ ut_memcpy(new_ptr, ptr, min_size);
+
+ ut_free(ptr);
+
+ return(new_ptr);
+}
+
+/**************************************************************************
Frees in shutdown all allocated memory not freed yet. */
void