summaryrefslogtreecommitdiff
path: root/innobase/include
diff options
context:
space:
mode:
Diffstat (limited to 'innobase/include')
-rw-r--r--innobase/include/btr0btr.h10
-rw-r--r--innobase/include/btr0cur.h3
-rw-r--r--innobase/include/btr0sea.h3
-rw-r--r--innobase/include/buf0buf.h21
-rw-r--r--innobase/include/buf0buf.ic4
-rw-r--r--innobase/include/buf0rea.h2
-rw-r--r--innobase/include/data0data.h10
-rw-r--r--innobase/include/data0data.ic24
-rw-r--r--innobase/include/ha0ha.h2
-rw-r--r--innobase/include/ibuf0ibuf.h6
-rw-r--r--innobase/include/lock0lock.h10
-rw-r--r--innobase/include/log0log.h56
-rw-r--r--innobase/include/log0log.ic29
-rw-r--r--innobase/include/os0file.h18
-rw-r--r--innobase/include/os0thread.h6
-rw-r--r--innobase/include/page0page.h2
-rw-r--r--innobase/include/page0page.ic42
-rw-r--r--innobase/include/rem0rec.ic2
-rw-r--r--innobase/include/row0mysql.h13
-rw-r--r--innobase/include/srv0srv.h8
-rw-r--r--innobase/include/sync0arr.h2
-rw-r--r--innobase/include/sync0sync.h12
-rw-r--r--innobase/include/trx0roll.h8
-rw-r--r--innobase/include/trx0sys.h52
-rw-r--r--innobase/include/trx0trx.h28
-rw-r--r--innobase/include/univ.i41
-rw-r--r--innobase/include/ut0ut.h9
-rw-r--r--innobase/include/ut0ut.ic22
28 files changed, 277 insertions, 168 deletions
diff --git a/innobase/include/btr0btr.h b/innobase/include/btr0btr.h
index d22f9d79c1c..bf433c0c264 100644
--- a/innobase/include/btr0btr.h
+++ b/innobase/include/btr0btr.h
@@ -204,16 +204,6 @@ btr_page_reorganize(
page_t* page, /* in: page to be reorganized */
mtr_t* mtr); /* in: mtr */
/*****************************************************************
-Reorganizes an index page. */
-
-void
-btr_page_reorganize_low(
-/*====================*/
- ibool low, /* in: TRUE if locks should not be updated, i.e.,
- there cannot exist locks on the page */
- page_t* page, /* in: page to be reorganized */
- mtr_t* mtr); /* in: mtr */
-/*****************************************************************
Decides if the page should be split at the convergence point of
inserts converging to left. */
diff --git a/innobase/include/btr0cur.h b/innobase/include/btr0cur.h
index bce1f0685cc..b01cbd9a875 100644
--- a/innobase/include/btr0cur.h
+++ b/innobase/include/btr0cur.h
@@ -709,6 +709,9 @@ allowed to free an inherited external field. */
#define BTR_EXTERN_INHERITED_FLAG 64
extern ulint btr_cur_n_non_sea;
+extern ulint btr_cur_n_sea;
+extern ulint btr_cur_n_non_sea_old;
+extern ulint btr_cur_n_sea_old;
#ifndef UNIV_NONINL
#include "btr0cur.ic"
diff --git a/innobase/include/btr0sea.h b/innobase/include/btr0sea.h
index fdf5cf375a3..14feca5d5c5 100644
--- a/innobase/include/btr0sea.h
+++ b/innobase/include/btr0sea.h
@@ -176,6 +176,7 @@ btr_search_validate(void);
/* The search info struct in an index */
struct btr_search_struct{
+ ulint magic_n; /* magic number */
/* The following 4 fields are currently not used: */
rec_t* last_search; /* pointer to the lower limit record of the
previous search; NULL if not known */
@@ -220,6 +221,8 @@ struct btr_search_struct{
ulint n_searches; /* number of searches */
};
+#define BTR_SEARCH_MAGIC_N 1112765
+
/* The hash index system */
typedef struct btr_search_sys_struct btr_search_sys_t;
diff --git a/innobase/include/buf0buf.h b/innobase/include/buf0buf.h
index 5ddbf39335a..b80ed96f54c 100644
--- a/innobase/include/buf0buf.h
+++ b/innobase/include/buf0buf.h
@@ -219,6 +219,16 @@ buf_page_create(
a page */
mtr_t* mtr); /* in: mini-transaction handle */
/************************************************************************
+Inits a page to the buffer buf_pool, for use in ibbackup --restore. */
+
+void
+buf_page_init_for_backup_restore(
+/*=============================*/
+ ulint space, /* in: space id */
+ ulint offset, /* in: offset of the page within space
+ in units of a page */
+ buf_block_t* block); /* in: block to init */
+/************************************************************************
Decrements the bufferfix count of a buffer control block and releases
a latch, if specified. */
UNIV_INLINE
@@ -438,7 +448,7 @@ Prints info of the buffer pool data structure. */
void
buf_print(void);
-/*===========*/
+/*============*/
/*************************************************************************
Returns the number of pending buf pool ios. */
@@ -449,8 +459,10 @@ buf_get_n_pending_ios(void);
Prints info of the buffer i/o. */
void
-buf_print_io(void);
-/*==============*/
+buf_print_io(
+/*=========*/
+ char* buf, /* in/out: buffer where to print */
+ char* buf_end);/* in: buffer end */
/*************************************************************************
Checks that all file pages in the buffer are in a replaceable state. */
@@ -605,6 +617,7 @@ struct buf_block_struct{
/* 1. General fields */
+ ulint magic_n; /* magic number to check */
ulint state; /* state of the control block:
BUF_BLOCK_NOT_USED, ... */
byte* frame; /* pointer to buffer frame which
@@ -729,6 +742,8 @@ struct buf_block_struct{
frees a page in buffer pool */
};
+#define BUF_BLOCK_MAGIC_N 41526563
+
/* The buffer pool structure. NOTE! The definition appears here only for
other modules of this directory (buf) to see it. Do not use from outside! */
diff --git a/innobase/include/buf0buf.ic b/innobase/include/buf0buf.ic
index 52bee0eb282..e5a2c480922 100644
--- a/innobase/include/buf0buf.ic
+++ b/innobase/include/buf0buf.ic
@@ -209,7 +209,7 @@ buf_block_align(
ut_ad((ulint)ptr >= (ulint)frame_zero);
- block = buf_pool_get_nth_block(buf_pool, (ptr - frame_zero)
+ block = buf_pool_get_nth_block(buf_pool, ((ulint)(ptr - frame_zero))
>> UNIV_PAGE_SIZE_SHIFT);
ut_a(block >= buf_pool->blocks);
ut_a(block < buf_pool->blocks + buf_pool->max_size);
@@ -236,7 +236,7 @@ buf_block_align_low(
ut_ad((ulint)ptr >= (ulint)frame_zero);
- block = buf_pool_get_nth_block(buf_pool, (ptr - frame_zero)
+ block = buf_pool_get_nth_block(buf_pool, ((ulint)(ptr - frame_zero))
>> UNIV_PAGE_SIZE_SHIFT);
ut_a(block >= buf_pool->blocks);
ut_a(block < buf_pool->blocks + buf_pool->max_size);
diff --git a/innobase/include/buf0rea.h b/innobase/include/buf0rea.h
index 1efe67369ab..aed965a6b21 100644
--- a/innobase/include/buf0rea.h
+++ b/innobase/include/buf0rea.h
@@ -89,7 +89,7 @@ buf_read_recv_pages(
/* The size in pages of the area which the read-ahead algorithms read if
invoked */
-#define BUF_READ_AHEAD_AREA ut_min(32, buf_pool->curr_size / 16)
+#define BUF_READ_AHEAD_AREA ut_min(64, ut_2_power_up(buf_pool->curr_size / 32))
/* Modes used in read-ahead */
#define BUF_READ_IBUF_PAGES_ONLY 131
diff --git a/innobase/include/data0data.h b/innobase/include/data0data.h
index c19d7ea5552..e0fb06e5018 100644
--- a/innobase/include/data0data.h
+++ b/innobase/include/data0data.h
@@ -123,7 +123,7 @@ dfield_datas_are_binary_equal(
dfield_t* field2);/* in: field */
/*************************************************************************
Tests if dfield data length and content is equal to the given. */
-UNIV_INLINE
+
ibool
dfield_data_is_binary_equal(
/*========================*/
@@ -279,6 +279,14 @@ dtuple_check_typed(
/* out: TRUE if ok */
dtuple_t* tuple); /* in: tuple */
/**************************************************************
+Checks that a data tuple is typed. */
+
+ibool
+dtuple_check_typed_no_assert(
+/*=========================*/
+ /* out: TRUE if ok */
+ dtuple_t* tuple); /* in: tuple */
+/**************************************************************
Validates the consistency of a tuple which must be complete, i.e,
all fields must have been set. */
diff --git a/innobase/include/data0data.ic b/innobase/include/data0data.ic
index 0750a3894d1..d356664df21 100644
--- a/innobase/include/data0data.ic
+++ b/innobase/include/data0data.ic
@@ -154,30 +154,6 @@ dfield_datas_are_binary_equal(
}
/*************************************************************************
-Tests if dfield data length and content is equal to the given. */
-UNIV_INLINE
-ibool
-dfield_data_is_binary_equal(
-/*========================*/
- /* out: TRUE if equal */
- dfield_t* field, /* in: field */
- ulint len, /* in: data length or UNIV_SQL_NULL */
- byte* data) /* in: data */
-{
- if (len != field->len) {
-
- return(FALSE);
- }
-
- if (len != UNIV_SQL_NULL && 0 != ut_memcmp(field->data, data, len)) {
-
- return(FALSE);
- }
-
- return(TRUE);
-}
-
-/*************************************************************************
Gets info bits in a data tuple. */
UNIV_INLINE
ulint
diff --git a/innobase/include/ha0ha.h b/innobase/include/ha0ha.h
index aeed7c32eff..945b1198a41 100644
--- a/innobase/include/ha0ha.h
+++ b/innobase/include/ha0ha.h
@@ -127,6 +127,8 @@ Prints info of a hash table. */
void
ha_print_info(
/*==========*/
+ char* buf, /* in/out: buffer where to print */
+ char* buf_end,/* in: buffer end */
hash_table_t* table); /* in: hash table */
diff --git a/innobase/include/ibuf0ibuf.h b/innobase/include/ibuf0ibuf.h
index fac28461be4..a290e90e4db 100644
--- a/innobase/include/ibuf0ibuf.h
+++ b/innobase/include/ibuf0ibuf.h
@@ -269,8 +269,10 @@ ibuf_count_get(
Prints info of ibuf. */
void
-ibuf_print(void);
-/*============*/
+ibuf_print(
+/*=======*/
+ char* buf, /* in/out: buffer where to print */
+ char* buf_end);/* in: buffer end */
#define IBUF_HEADER_PAGE_NO FSP_IBUF_HEADER_PAGE_NO
#define IBUF_TREE_ROOT_PAGE_NO FSP_IBUF_TREE_ROOT_PAGE_NO
diff --git a/innobase/include/lock0lock.h b/innobase/include/lock0lock.h
index 5a15b78b869..80afba97416 100644
--- a/innobase/include/lock0lock.h
+++ b/innobase/include/lock0lock.h
@@ -460,6 +460,8 @@ Prints info of a table lock. */
void
lock_table_print(
/*=============*/
+ char* buf, /* in/out: buffer where to print, must be at least
+ 500 bytes */
lock_t* lock); /* in: table type lock */
/*************************************************************************
Prints info of a record lock. */
@@ -467,13 +469,17 @@ Prints info of a record lock. */
void
lock_rec_print(
/*===========*/
+ char* buf, /* in/out: buffer where to print, must be at least
+ 500 bytes */
lock_t* lock); /* in: record type lock */
/*************************************************************************
Prints info of locks for all transactions. */
void
-lock_print_info(void);
-/*=================*/
+lock_print_info(
+/*============*/
+ char* buf, /* in/out: buffer where to print */
+ char* buf_end);/* in: buffer end */
/*************************************************************************
Validates the lock queue on a table. */
diff --git a/innobase/include/log0log.h b/innobase/include/log0log.h
index eeb4f2e45f1..5d848b85658 100644
--- a/innobase/include/log0log.h
+++ b/innobase/include/log0log.h
@@ -157,6 +157,14 @@ log_io_complete(
/*============*/
log_group_t* group); /* in: log group */
/**********************************************************
+Flushes the log files to the disk, using, for example, the Unix fsync.
+This function does the flush even if the user has set
+srv_flush_log_at_trx_commit = FALSE. */
+
+void
+log_flush_to_disk(void);
+/*===================*/
+/**********************************************************
This function is called, e.g., when a transaction wants to commit. It checks
that the log has been flushed to disk up to the last log entry written by the
transaction. If there is a flush running, it waits and checks if the flush
@@ -260,7 +268,9 @@ log_reset_first_header_and_checkpoint(
/*==================================*/
byte* hdr_buf,/* in: buffer which will be written to the start
of the first log file */
- dulint lsn); /* in: lsn of the start of the first log file */
+ dulint start); /* in: lsn of the start of the first log file;
+ we pretend that there is a checkpoint at
+ start + LOG_BLOCK_HDR_SIZE */
/************************************************************************
Starts an archiving operation. */
@@ -463,6 +473,15 @@ log_block_init(
byte* log_block, /* in: pointer to the log buffer */
dulint lsn); /* in: lsn within the log block */
/****************************************************************
+Initializes a log block in the log buffer in the old, < 3.23.52 format, where
+there was no checksum yet. */
+UNIV_INLINE
+void
+log_block_init_in_old_format(
+/*=========================*/
+ byte* log_block, /* in: pointer to the log buffer */
+ dulint lsn); /* in: lsn within the log block */
+/****************************************************************
Converts a lsn to a log block number. */
UNIV_INLINE
ulint
@@ -474,8 +493,10 @@ log_block_convert_lsn_to_no(
Prints info of the log. */
void
-log_print(void);
-/*===========*/
+log_print(
+/*======*/
+ char* buf, /* in/out: buffer where to print */
+ char* buf_end);/* in: buffer end */
extern log_t* log_sys;
@@ -523,7 +544,10 @@ extern log_t* log_sys;
bytes */
/* Offsets of a log block trailer from the end of the block */
-#define LOG_BLOCK_TRL_NO 4 /* log block number */
+#define LOG_BLOCK_TRL_CHECKSUM 4 /* 1 byte checksum of the log block
+ contents */
+#define LOG_BLOCK_TRL_NO 3 /* 3 lowest bytes of the log block
+ number */
#define LOG_BLOCK_TRL_SIZE 4 /* trailer size in bytes */
/* Offsets for a checkpoint field */
@@ -558,11 +582,22 @@ extern log_t* log_sys;
#define LOG_GROUP_ID 0 /* log group number */
#define LOG_FILE_START_LSN 4 /* lsn of the start of data in this
log file */
-#define LOG_FILE_NO 12 /* 4-byte archived log file number */
+#define LOG_FILE_NO 12 /* 4-byte archived log file number;
+ this field is only defined in an
+ archived log file */
+#define LOG_FILE_WAS_CREATED_BY_HOT_BACKUP 16
+ /* a 32-byte field which contains
+ the string 'ibbackup' and the
+ creation time if the log file was
+ created by ibbackup --restore;
+ when mysqld is first time started
+ on the restored database, it can
+ print helpful info for the user */
#define LOG_FILE_ARCH_COMPLETED OS_FILE_LOG_BLOCK_SIZE
/* this 4-byte field is TRUE when
the writing of an archived log file
- has been completed */
+ has been completed; this field is
+ only defined in an archived log file */
#define LOG_FILE_END_LSN (OS_FILE_LOG_BLOCK_SIZE + 4)
/* lsn where the archived log file
at least extends: actually the
@@ -572,7 +607,14 @@ extern log_t* log_sys;
is defined only when an archived log
file has been completely written */
#define LOG_CHECKPOINT_1 OS_FILE_LOG_BLOCK_SIZE
+ /* first checkpoint field in the log
+ header; we write alternately to the
+ checkpoint fields when we make new
+ checkpoints; this field is only defined
+ in the first log file of a log group */
#define LOG_CHECKPOINT_2 (3 * OS_FILE_LOG_BLOCK_SIZE)
+ /* second checkpoint field in the log
+ header */
#define LOG_FILE_HDR_SIZE (4 * OS_FILE_LOG_BLOCK_SIZE)
#define LOG_GROUP_OK 301
@@ -678,7 +720,7 @@ struct log_struct{
write i/o has been completed for all
log groups */
dulint flush_lsn; /* end lsn for the current flush */
- ulint flush_end_offset;/* the data in buffer ha been flushed
+ ulint flush_end_offset;/* the data in buffer has been flushed
up to this offset when the current
flush ends: this field will then
be copied to buf_next_to_write */
diff --git a/innobase/include/log0log.ic b/innobase/include/log0log.ic
index e5c313d129b..36e65239374 100644
--- a/innobase/include/log0log.ic
+++ b/innobase/include/log0log.ic
@@ -179,7 +179,7 @@ log_block_get_trl_no(
trailer */
byte* log_block) /* in: log block */
{
- return(mach_read_from_4(log_block + OS_FILE_LOG_BLOCK_SIZE
+ return(mach_read_from_3(log_block + OS_FILE_LOG_BLOCK_SIZE
- LOG_BLOCK_TRL_NO));
}
@@ -192,8 +192,8 @@ log_block_set_trl_no(
byte* log_block, /* in: log block */
ulint n) /* in: log block number */
{
- mach_write_to_4(log_block + OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_TRL_NO,
- n);
+ mach_write_to_3(log_block + OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_TRL_NO,
+ n & 0xFFFFFF);
}
/****************************************************************
@@ -237,6 +237,29 @@ log_block_init(
log_block_set_data_len(log_block, LOG_BLOCK_HDR_SIZE);
log_block_set_first_rec_group(log_block, 0);
}
+
+/****************************************************************
+Initializes a log block in the log buffer in the old format, where there
+was no checksum yet. */
+UNIV_INLINE
+void
+log_block_init_in_old_format(
+/*=========================*/
+ byte* log_block, /* in: pointer to the log buffer */
+ dulint lsn) /* in: lsn within the log block */
+{
+ ulint no;
+
+ ut_ad(mutex_own(&(log_sys->mutex)));
+
+ no = log_block_convert_lsn_to_no(lsn);
+
+ log_block_set_hdr_no(log_block, no);
+ mach_write_to_4(log_block + OS_FILE_LOG_BLOCK_SIZE
+ - LOG_BLOCK_TRL_NO - 1, no);
+ log_block_set_data_len(log_block, LOG_BLOCK_HDR_SIZE);
+ log_block_set_first_rec_group(log_block, 0);
+}
/****************************************************************
Writes to the log the string given. The log must be released with
diff --git a/innobase/include/os0file.h b/innobase/include/os0file.h
index 01fa12955ff..b7911c5014a 100644
--- a/innobase/include/os0file.h
+++ b/innobase/include/os0file.h
@@ -16,6 +16,7 @@ Created 10/21/1995 Heikki Tuuri
os_file_write */
extern ibool os_do_not_call_flush_at_each_write;
extern ibool os_has_said_disk_full;
+extern ibool os_aio_print_debug;
#ifdef __WIN__
@@ -33,6 +34,8 @@ extern ibool os_has_said_disk_full;
typedef int os_file_t;
#endif
+extern ulint os_innodb_umask;
+
/* If this flag is TRUE, then we will use the native aio of the
OS (provided we compiled Innobase with it in), otherwise we will
use simulated aio we build below with threads */
@@ -309,6 +312,15 @@ Wakes up simulated aio i/o-handler threads if they have something to do. */
void
os_aio_simulated_wake_handler_threads(void);
/*=======================================*/
+/**************************************************************************
+This function can be called if one wants to post a batch of reads and
+prefers an i/o-handler thread to handle them all at once later. You must
+call os_aio_simulated_wake_handler_threads later to ensure the threads
+are not left sleeping! */
+
+void
+os_aio_simulated_put_read_threads_to_sleep(void);
+/*============================================*/
#ifdef WIN_ASYNC_IO
/**************************************************************************
@@ -391,8 +403,10 @@ os_aio_validate(void);
Prints info of the aio arrays. */
void
-os_aio_print(void);
-/*==============*/
+os_aio_print(
+/*=========*/
+ char* buf, /* in/out: buffer where to print */
+ char* buf_end);/* in: buffer end */
/**************************************************************************
Checks that all slots in the system have been freed, that is, there are
no pending io operations. */
diff --git a/innobase/include/os0thread.h b/innobase/include/os0thread.h
index 2e4b6f0f6ee..0d6fa5a8f37 100644
--- a/innobase/include/os0thread.h
+++ b/innobase/include/os0thread.h
@@ -12,8 +12,10 @@ Created 9/8/1995 Heikki Tuuri
#include "univ.i"
-/* Maximum number of threads which can be created in the program */
-#define OS_THREAD_MAX_N 1000
+/* Maximum number of threads which can be created in the program;
+this is also the size of the wait slot array for MySQL threads which
+can wait inside InnoDB */
+#define OS_THREAD_MAX_N 10000
/* Possible fixed priorities for threads */
#define OS_THREAD_PRIORITY_NONE 100
diff --git a/innobase/include/page0page.h b/innobase/include/page0page.h
index 8e68381b868..2f77127466f 100644
--- a/innobase/include/page0page.h
+++ b/innobase/include/page0page.h
@@ -328,7 +328,7 @@ page_dir_calc_reserved_space(
ulint n_recs); /* in: number of records */
/*******************************************************************
Looks for the directory slot which owns the given record. */
-UNIV_INLINE
+
ulint
page_dir_find_owner_slot(
/*=====================*/
diff --git a/innobase/include/page0page.ic b/innobase/include/page0page.ic
index f84fe5a5606..e7c0f8ee07c 100644
--- a/innobase/include/page0page.ic
+++ b/innobase/include/page0page.ic
@@ -479,6 +479,8 @@ page_rec_get_next(
offs = rec_get_next_offs(rec);
+ ut_a(offs < UNIV_PAGE_SIZE);
+
if (offs == 0) {
return(NULL);
@@ -487,40 +489,6 @@ page_rec_get_next(
return(page + offs);
}
-/*******************************************************************
-Looks for the directory slot which owns the given record. */
-UNIV_INLINE
-ulint
-page_dir_find_owner_slot(
-/*=====================*/
- /* out: the directory slot number */
- rec_t* rec) /* in: the physical record */
-{
- ulint i;
- page_t* page;
- page_dir_slot_t* slot;
-
- ut_ad(page_rec_check(rec));
-
- while (rec_get_n_owned(rec) == 0) {
- rec = page_rec_get_next(rec);
- }
-
- page = buf_frame_align(rec);
-
- i = page_dir_get_n_slots(page) - 1;
- slot = page_dir_get_nth_slot(page, i);
-
- while (page_dir_slot_get_rec(slot) != rec) {
- ut_a(i > 0);
-
- i--;
- slot = page_dir_get_nth_slot(page, i);
- }
-
- return(i);
-}
-
/****************************************************************
Sets the pointer to the next record on the page. */
UNIV_INLINE
@@ -534,7 +502,7 @@ page_rec_set_next(
page_t* page;
ut_ad(page_rec_check(rec));
- ut_ad((next == NULL)
+ ut_a((next == NULL)
|| (buf_frame_align(rec) == buf_frame_align(next)));
page = buf_frame_align(rec);
@@ -573,7 +541,7 @@ page_rec_get_prev(
slot_no = page_dir_find_owner_slot(rec);
- ut_ad(slot_no != 0);
+ ut_a(slot_no != 0);
slot = page_dir_get_nth_slot(page, slot_no - 1);
@@ -584,7 +552,7 @@ page_rec_get_prev(
rec2 = page_rec_get_next(rec2);
}
- ut_ad(prev_rec);
+ ut_a(prev_rec);
return(prev_rec);
}
diff --git a/innobase/include/rem0rec.ic b/innobase/include/rem0rec.ic
index 6b96e3056fa..aaa3c58a003 100644
--- a/innobase/include/rem0rec.ic
+++ b/innobase/include/rem0rec.ic
@@ -970,8 +970,6 @@ rec_fold(
ut_ad(n_fields <= rec_get_n_fields(rec));
ut_ad((n_fields < rec_get_n_fields(rec)) || (n_bytes == 0));
ut_ad(n_fields + n_bytes > 0);
- /* Only the page supremum and infimum records have 1 field: */
- ut_ad(rec_get_n_fields(rec) > 1);
n_fields_rec = rec_get_n_fields(rec);
diff --git a/innobase/include/row0mysql.h b/innobase/include/row0mysql.h
index 13b3dffd874..8152c534f48 100644
--- a/innobase/include/row0mysql.h
+++ b/innobase/include/row0mysql.h
@@ -230,6 +230,19 @@ row_update_cascade_for_mysql(
or set null operation */
dict_table_t* table); /* in: table where we do the operation */
/*************************************************************************
+Locks the data dictionary exclusively for performing a table create
+operation. */
+
+void
+row_mysql_lock_data_dictionary(void);
+/*================================*/
+/*************************************************************************
+Unlocks the data dictionary exclusively lock. */
+
+void
+row_mysql_unlock_data_dictionary(void);
+/*==================================*/
+/*************************************************************************
Does a table creation operation for MySQL. If the name of the created
table ends to characters INNODB_MONITOR, then this also starts
printing of monitor output by the master thread. */
diff --git a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
index 6777a24e7db..178c7b6971f 100644
--- a/innobase/include/srv0srv.h
+++ b/innobase/include/srv0srv.h
@@ -357,6 +357,14 @@ srv_error_monitor_thread(
/* out: a dummy parameter */
void* arg); /* in: a dummy parameter required by
os_thread_create */
+/**********************************************************************
+Sprintfs to a buffer the output of the InnoDB Monitor. */
+
+void
+srv_sprintf_innodb_monitor(
+/*=======================*/
+ char* buf, /* in/out: buffer which must be at least 4 kB */
+ ulint len); /* in: length of the buffer */
/* Types for the threads existing in the system. Threads of types 4 - 9
diff --git a/innobase/include/sync0arr.h b/innobase/include/sync0arr.h
index f0134894997..765ad33afea 100644
--- a/innobase/include/sync0arr.h
+++ b/innobase/include/sync0arr.h
@@ -114,6 +114,8 @@ Prints info of the wait array. */
void
sync_array_print_info(
/*==================*/
+ char* buf, /* in/out: buffer where to print */
+ char* buf_end,/* in: buffer end */
sync_array_t* arr); /* in: wait array */
diff --git a/innobase/include/sync0sync.h b/innobase/include/sync0sync.h
index 4f55709a5d7..5bfa0bc2d48 100644
--- a/innobase/include/sync0sync.h
+++ b/innobase/include/sync0sync.h
@@ -117,14 +117,18 @@ FUNCTION PROTOTYPES FOR DEBUGGING */
Prints wait info of the sync system. */
void
-sync_print_wait_info(void);
-/*======================*/
+sync_print_wait_info(
+/*=================*/
+ char* buf, /* in/out: buffer where to print */
+ char* buf_end); /* in: buffer end */
/***********************************************************************
Prints info of the sync system. */
void
-sync_print(void);
-/*============*/
+sync_print(
+/*=======*/
+ char* buf, /* in/out: buffer where to print */
+ char* buf_end); /* in: buffer end */
/**********************************************************************
Checks that the mutex has been initialized. */
diff --git a/innobase/include/trx0roll.h b/innobase/include/trx0roll.h
index c456768e820..820af4cd014 100644
--- a/innobase/include/trx0roll.h
+++ b/innobase/include/trx0roll.h
@@ -102,11 +102,13 @@ trx_rollback(
calling function can start running
a new query thread */
/***********************************************************************
-Rollback uncommitted transactions which have no user session. */
+Rollback or clean up transactions which have no user session. If the
+transaction already was committed, then we clean up a possible insert
+undo log. If the transaction was not yet committed, then we roll it back. */
void
-trx_rollback_all_without_sess(void);
-/*===============================*/
+trx_rollback_or_clean_all_without_sess(void);
+/*========================================*/
/********************************************************************
Finishes a transaction rollback. */
diff --git a/innobase/include/trx0sys.h b/innobase/include/trx0sys.h
index 60d5adb72d1..b08df7f6901 100644
--- a/innobase/include/trx0sys.h
+++ b/innobase/include/trx0sys.h
@@ -24,6 +24,14 @@ Created 3/26/1996 Heikki Tuuri
#include "fsp0fsp.h"
#include "read0types.h"
+/* In a MySQL replication slave, in crash recovery we store the master log
+file name and position here. We have successfully got the updates to InnoDB
+up to this position. If .._pos is -1, it means no crash recovery was needed,
+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;
+
/* The transaction system */
extern trx_sys_t* trx_sys;
@@ -229,13 +237,18 @@ trx_in_trx_list(
trx_t* in_trx);/* in: trx */
/*********************************************************************
Updates the offset information about the end of the MySQL binlog entry
-which corresponds to the transaction just being committed. */
+which corresponds to the transaction just being committed. In a MySQL
+replication slave updates the latest master binlog position up to which
+replication has proceeded. */
void
trx_sys_update_mysql_binlog_offset(
/*===============================*/
- trx_t* trx, /* in: transaction being committed */
- mtr_t* mtr); /* in: mtr */
+ char* file_name,/* in: MySQL log file name */
+ ib_longlong offset, /* in: position in that log file */
+ ulint field, /* in: offset of the MySQL log info field in
+ the trx sys header */
+ mtr_t* mtr); /* in: mtr */
/*********************************************************************
Prints to stderr the MySQL binlog offset info in the trx system header if
the magic number shows it valid. */
@@ -243,15 +256,17 @@ the magic number shows it valid. */
void
trx_sys_print_mysql_binlog_offset(void);
/*===================================*/
+/*********************************************************************
+Prints to stderr the MySQL master log offset info in the trx system header if
+the magic number shows it valid. */
+
+void
+trx_sys_print_mysql_master_log_pos(void);
+/*====================================*/
/* The automatically created system rollback segment has this id */
#define TRX_SYS_SYSTEM_RSEG_ID 0
-/* Max number of rollback segments: the number of segment specification slots
-in the transaction system array; rollback segment id must fit in one byte,
-therefore 256 */
-#define TRX_SYS_N_RSEGS 256
-
/* Space id and page no where the trx system file copy resides */
#define TRX_SYS_SPACE 0 /* the SYSTEM tablespace */
#define TRX_SYS_PAGE_NO FSP_TRX_SYS_PAGE_NO
@@ -277,22 +292,29 @@ therefore 256 */
segment specification slots */
/*-------------------------------------------------------------*/
-#define TRX_SYS_MYSQL_LOG_NAME_LEN 32
+/* Max number of rollback segments: the number of segment specification slots
+in the transaction system array; rollback segment id must fit in one byte,
+therefore 256; each slot is currently 8 bytes in size */
+#define TRX_SYS_N_RSEGS 256
+
+#define TRX_SYS_MYSQL_LOG_NAME_LEN 512
#define TRX_SYS_MYSQL_LOG_MAGIC_N 873422344
+/* The offset of the MySQL replication info on the trx system header page;
+this contains the same fields as TRX_SYS_MYSQL_LOG_INFO below */
+#define TRX_SYS_MYSQL_MASTER_LOG_INFO (UNIV_PAGE_SIZE - 2000)
+
/* The offset of the MySQL binlog offset info on the trx system header page */
-#define TRX_SYS_MYSQL_LOG_INFO (UNIV_PAGE_SIZE - 300)
+#define TRX_SYS_MYSQL_LOG_INFO (UNIV_PAGE_SIZE - 1000)
#define TRX_SYS_MYSQL_LOG_MAGIC_N_FLD 0 /* magic number which shows
if we have valid data in the
MySQL binlog info; the value
is ..._MAGIC_N if yes */
-#define TRX_SYS_MYSQL_LOG_NAME 4 /* MySQL log file name */
-#define TRX_SYS_MYSQL_LOG_OFFSET_HIGH (4 + TRX_SYS_MYSQL_LOG_NAME_LEN)
- /* high 4 bytes of the offset
+#define TRX_SYS_MYSQL_LOG_OFFSET_HIGH 4 /* high 4 bytes of the offset
within that file */
-#define TRX_SYS_MYSQL_LOG_OFFSET_LOW (8 + TRX_SYS_MYSQL_LOG_NAME_LEN)
- /* low 4 bytes of the offset
+#define TRX_SYS_MYSQL_LOG_OFFSET_LOW 8 /* low 4 bytes of the offset
within that file */
+#define TRX_SYS_MYSQL_LOG_NAME 12 /* MySQL log file name */
/* The offset of the doublewrite buffer header on the trx system header page */
#define TRX_SYS_DOUBLEWRITE (UNIV_PAGE_SIZE - 200)
diff --git a/innobase/include/trx0trx.h b/innobase/include/trx0trx.h
index 261f33d3dc3..83789966514 100644
--- a/innobase/include/trx0trx.h
+++ b/innobase/include/trx0trx.h
@@ -124,6 +124,15 @@ void
trx_commit_off_kernel(
/*==================*/
trx_t* trx); /* in: transaction */
+/********************************************************************
+Cleans up a transaction at database startup. The cleanup is needed if
+the transaction already got to the middle of a commit when the database
+crashed, andf we cannot roll it back. */
+
+void
+trx_cleanup_at_db_startup(
+/*======================*/
+ trx_t* trx); /* in: transaction */
/**************************************************************************
Does the transaction commit for MySQL. */
@@ -252,7 +261,9 @@ own the kernel mutex. */
void
trx_print(
/*======*/
- trx_t* trx); /* in: transaction */
+ char* buf, /* in/out: buffer where to print, must be at least
+ 500 bytes */
+ trx_t* trx); /* in: transaction */
/* Signal to a transaction */
@@ -322,13 +333,24 @@ struct trx_struct{
void* mysql_thd; /* MySQL thread handle corresponding
to this trx, or NULL */
char* mysql_log_file_name;
- /* If MySQL binlog is used, this field
+ /* if MySQL binlog is used, this field
contains a pointer to the latest file
name; this is NULL if binlog is not
used */
- ib_longlong mysql_log_offset;/* If MySQL binlog is used, this field
+ ib_longlong mysql_log_offset;/* if MySQL binlog is used, this field
contains the end offset of the binlog
entry */
+ char* mysql_master_log_file_name;
+ /* if the database server is a MySQL
+ replication slave, we have here the
+ master binlog name up to which
+ replication has processed; otherwise
+ this is a pointer to a null character */
+ ib_longlong mysql_master_log_pos;
+ /* if the database server is a MySQL
+ replication slave, this is the
+ position in the log file up to which
+ replication has processed */
os_thread_id_t mysql_thread_id;/* id of the MySQL thread associated
with this transaction object */
/*------------------------------*/
diff --git a/innobase/include/univ.i b/innobase/include/univ.i
index 160a435319a..c852741d5ac 100644
--- a/innobase/include/univ.i
+++ b/innobase/include/univ.i
@@ -9,41 +9,26 @@ Created 1/20/1994 Heikki Tuuri
#ifndef univ_i
#define univ_i
-#if (defined(_WIN32) || defined(_WIN64)) && !defined(MYSQL_SERVER)
+#if (defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)) && !defined(MYSQL_SERVER)
#define __WIN__
#include <windows.h>
-/* When compiling for Itanium IA64, undefine the flag below to prevent use
-of 32-bit assembler */
-
-#ifndef WIN64
+#if !defined(WIN64) && !defined(_WIN64)
#define UNIV_CAN_USE_X86_ASSEMBLER
#endif
-/* If you want to check for errors with compiler level -W4,
-comment out the above include of windows.h and let the following defines
-be defined:
-#define HANDLE void*
-#define CRITICAL_SECTION ulint
-*/
-
#ifdef _NT_
#define __NT__
#endif
#else
-/* The Unix version */
-
-/* Most C compilers other than gcc do not know 'extern inline' */
-#if !defined(__GNUC__) && !defined(__WIN__)
-#undef UNIV_MUST_NOT_INLINE
-#define UNIV_MUST_NOT_INLINE
-#endif
+/* The defines used with MySQL */
/* Include two header files from MySQL to make the Unix flavor used
-in compiling more Posix-compatible. We assume that 'innobase' is a
-subdirectory of 'mysql'. */
+in compiling more Posix-compatible. These headers also define __WIN__
+if we are compiling on Windows. */
+
#include <my_global.h>
#include <my_pthread.h>
@@ -60,6 +45,20 @@ subdirectory of 'mysql'. */
#include <sched.h>
#endif
+/* When compiling for Itanium IA64, undefine the flag below to prevent use
+of the 32-bit x86 assembler in mutex operations. */
+
+#if defined(__WIN__) && !defined(WIN64) && !defined(_WIN64)
+#define UNIV_CAN_USE_X86_ASSEMBLER
+#endif
+
+/* We only try to do explicit inlining of functions with gcc and
+Microsoft Visual C++ */
+
+#if !defined(__GNUC__) && !defined(__WIN__)
+#define UNIV_MUST_NOT_INLINE
+#endif
+
#ifdef HAVE_PREAD
#define HAVE_PWRITE
#endif
diff --git a/innobase/include/ut0ut.h b/innobase/include/ut0ut.h
index 338460d7de9..408788016c1 100644
--- a/innobase/include/ut0ut.h
+++ b/innobase/include/ut0ut.h
@@ -114,7 +114,7 @@ ut_2_exp(
ulint n); /* in: number */
/*****************************************************************
Calculates fast the number rounded up to the nearest power of 2. */
-UNIV_INLINE
+
ulint
ut_2_power_up(
/*==========*/
@@ -155,6 +155,13 @@ ut_print_timestamp(
/*===============*/
FILE* file); /* in: file where to print */
/**************************************************************
+Sprintfs a timestamp to a buffer. */
+
+void
+ut_sprintf_timestamp(
+/*=================*/
+ char* buf); /* in: buffer where to sprintf */
+/**************************************************************
Returns current year, month, day. */
void
diff --git a/innobase/include/ut0ut.ic b/innobase/include/ut0ut.ic
index 90f25d2b382..9d7dd283f29 100644
--- a/innobase/include/ut0ut.ic
+++ b/innobase/include/ut0ut.ic
@@ -172,25 +172,3 @@ ut_2_exp(
{
return(1 << n);
}
-
-/*****************************************************************
-Calculates fast the number rounded up to the nearest power of 2. */
-UNIV_INLINE
-ulint
-ut_2_power_up(
-/*==========*/
- /* out: first power of 2 which is >= n */
- ulint n) /* in: number != 0 */
-{
- ulint res;
-
- res = 1;
-
- ut_ad(n > 0);
-
- while (res < n) {
- res = res * 2;
- }
-
- return(res);
-}