mirror of
https://github.com/MariaDB/server.git
synced 2025-01-18 04:53:01 +01:00
945625ebaa
BitKeeper/etc/logging_ok: auto-union BitKeeper/deleted/.del-mytest-old.c~5237697b30cf59e4: Auto merged Build-tools/Bootstrap: Auto merged Build-tools/mysql-copyright: Auto merged configure.in: Auto merged BitKeeper/deleted/.del-mysql_fix_privilege_tables.sql: Auto merged VC++Files/innobase/innobase.dsp: Auto merged client/mysql.cc: Auto merged include/my_global.h: Auto merged innobase/dict/dict0crea.c: Auto merged innobase/dict/dict0dict.c: Auto merged innobase/include/mtr0log.h: Auto merged innobase/include/mtr0log.ic: Auto merged innobase/include/srv0srv.h: Auto merged innobase/include/ut0dbg.h: Auto merged innobase/lock/lock0lock.c: Auto merged innobase/os/os0file.c: Auto merged innobase/row/row0mysql.c: Auto merged innobase/row/row0sel.c: Auto merged innobase/srv/srv0srv.c: Auto merged innobase/ut/ut0dbg.c: Auto merged innobase/ut/ut0mem.c: Auto merged libmysql/Makefile.am: Auto merged libmysql/Makefile.shared: Auto merged libmysql/conf_to_src.c: Auto merged libmysql/dll.c: Auto merged libmysql/errmsg.c: Auto merged libmysql/manager.c: Auto merged libmysql_r/Makefile.am: Auto merged myisam/mi_key.c: Auto merged mysql-test/Makefile.am: Auto merged mysql-test/mysql-test-run.sh: Auto merged mysql-test/r/having.result: Auto merged mysql-test/r/heap.result: Auto merged mysql-test/r/type_date.result: Auto merged mysql-test/r/type_float.result: Auto merged mysql-test/t/having.test: Auto merged mysql-test/t/heap.test: Auto merged mysql-test/t/type_date.test: Auto merged mysql-test/t/type_float.test: Auto merged mysql-test/t/type_uint.test: Auto merged scripts/make_binary_distribution.sh: Auto merged scripts/make_win_src_distribution.sh: Auto merged sql/Makefile.am: Auto merged sql/field.h: Auto merged sql/ha_heap.cc: Auto merged sql/item_func.cc: Auto merged sql/item_func.h: Auto merged sql/item_sum.h: Auto merged sql/lock.cc: Auto merged sql/log.cc: Auto merged sql/protocol.cc: Auto merged sql/repl_failsafe.cc: Auto merged sql/sql_acl.cc: Auto merged sql/sql_analyse.cc: Auto merged sql/sql_class.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_parse.cc: Auto merged sql/share/czech/errmsg.txt: Auto merged sql/share/danish/errmsg.txt: Auto merged sql/share/dutch/errmsg.txt: Auto merged sql/share/english/errmsg.txt: Auto merged sql/share/estonian/errmsg.txt: Auto merged sql/share/french/errmsg.txt: Auto merged sql/sql_select.cc: Auto merged sql/sql_table.cc: Auto merged sql/share/greek/errmsg.txt: Auto merged sql/share/hungarian/errmsg.txt: Auto merged sql/share/japanese/errmsg.txt: Auto merged sql/share/korean/errmsg.txt: Auto merged sql/share/norwegian-ny/errmsg.txt: Auto merged sql/share/norwegian/errmsg.txt: Auto merged sql/share/polish/errmsg.txt: Auto merged sql/share/portuguese/errmsg.txt: Auto merged sql/share/romanian/errmsg.txt: Auto merged sql/share/russian/errmsg.txt: Auto merged sql/share/slovak/errmsg.txt: Auto merged sql/share/spanish/errmsg.txt: Auto merged sql/share/swedish/errmsg.txt: Auto merged sql/share/ukrainian/errmsg.txt: Auto merged
219 lines
5 KiB
Text
219 lines
5 KiB
Text
/******************************************************
|
|
Mini-transaction logging routines
|
|
|
|
(c) 1995 Innobase Oy
|
|
|
|
Created 12/7/1995 Heikki Tuuri
|
|
*******************************************************/
|
|
|
|
#include "mach0data.h"
|
|
#include "ut0lst.h"
|
|
#include "buf0buf.h"
|
|
|
|
/************************************************************
|
|
Opens a buffer to mlog. It must be closed with mlog_close. */
|
|
UNIV_INLINE
|
|
byte*
|
|
mlog_open(
|
|
/*======*/
|
|
/* out: buffer, NULL if log mode MTR_LOG_NONE */
|
|
mtr_t* mtr, /* in: mtr */
|
|
ulint size) /* in: buffer size in bytes; MUST be
|
|
smaller than DYN_ARRAY_DATA_SIZE! */
|
|
{
|
|
dyn_array_t* mlog;
|
|
|
|
mtr->modifications = TRUE;
|
|
|
|
if (mtr_get_log_mode(mtr) == MTR_LOG_NONE) {
|
|
|
|
return(NULL);
|
|
}
|
|
|
|
mlog = &(mtr->log);
|
|
|
|
return(dyn_array_open(mlog, size));
|
|
}
|
|
|
|
/************************************************************
|
|
Closes a buffer opened to mlog. */
|
|
UNIV_INLINE
|
|
void
|
|
mlog_close(
|
|
/*=======*/
|
|
mtr_t* mtr, /* in: mtr */
|
|
byte* ptr) /* in: buffer space from ptr up was not used */
|
|
{
|
|
dyn_array_t* mlog;
|
|
|
|
ut_ad(mtr_get_log_mode(mtr) != MTR_LOG_NONE);
|
|
|
|
mlog = &(mtr->log);
|
|
|
|
dyn_array_close(mlog, ptr);
|
|
}
|
|
|
|
/************************************************************
|
|
Catenates 1 - 4 bytes to the mtr log. The value is not compressed. */
|
|
UNIV_INLINE
|
|
void
|
|
mlog_catenate_ulint(
|
|
/*================*/
|
|
mtr_t* mtr, /* in: mtr */
|
|
ulint val, /* in: value to write */
|
|
ulint type) /* in: MLOG_1BYTE, MLOG_2BYTES, MLOG_4BYTES */
|
|
{
|
|
dyn_array_t* mlog;
|
|
byte* ptr;
|
|
|
|
if (mtr_get_log_mode(mtr) == MTR_LOG_NONE) {
|
|
|
|
return;
|
|
}
|
|
|
|
mlog = &(mtr->log);
|
|
|
|
ut_ad(MLOG_1BYTE == 1);
|
|
ut_ad(MLOG_2BYTES == 2);
|
|
ut_ad(MLOG_4BYTES == 4);
|
|
|
|
ptr = dyn_array_push(mlog, type);
|
|
|
|
if (type == MLOG_4BYTES) {
|
|
mach_write_to_4(ptr, val);
|
|
} else if (type == MLOG_2BYTES) {
|
|
mach_write_to_2(ptr, val);
|
|
} else {
|
|
ut_ad(type == MLOG_1BYTE);
|
|
mach_write_to_1(ptr, val);
|
|
}
|
|
}
|
|
|
|
/************************************************************
|
|
Catenates a compressed ulint to mlog. */
|
|
UNIV_INLINE
|
|
void
|
|
mlog_catenate_ulint_compressed(
|
|
/*===========================*/
|
|
mtr_t* mtr, /* in: mtr */
|
|
ulint val) /* in: value to write */
|
|
{
|
|
byte* log_ptr;
|
|
|
|
log_ptr = mlog_open(mtr, 10);
|
|
|
|
/* If no logging is requested, we may return now */
|
|
if (log_ptr == NULL) {
|
|
|
|
return;
|
|
}
|
|
|
|
log_ptr += mach_write_compressed(log_ptr, val);
|
|
|
|
mlog_close(mtr, log_ptr);
|
|
}
|
|
|
|
/************************************************************
|
|
Catenates a compressed dulint to mlog. */
|
|
UNIV_INLINE
|
|
void
|
|
mlog_catenate_dulint_compressed(
|
|
/*============================*/
|
|
mtr_t* mtr, /* in: mtr */
|
|
dulint val) /* in: value to write */
|
|
{
|
|
byte* log_ptr;
|
|
|
|
log_ptr = mlog_open(mtr, 15);
|
|
|
|
/* If no logging is requested, we may return now */
|
|
if (log_ptr == NULL) {
|
|
|
|
return;
|
|
}
|
|
|
|
log_ptr += mach_dulint_write_compressed(log_ptr, val);
|
|
|
|
mlog_close(mtr, log_ptr);
|
|
}
|
|
|
|
/************************************************************
|
|
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(
|
|
/*===============================*/
|
|
/* out: new value of log_ptr */
|
|
byte* ptr, /* in: pointer to (inside) a buffer frame holding the
|
|
file page where modification is made */
|
|
byte type, /* in: log item type: MLOG_1BYTE, ... */
|
|
byte* log_ptr,/* in: pointer to mtr log which has been opened */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
buf_block_t* block;
|
|
ulint space;
|
|
ulint offset;
|
|
|
|
ut_ad(mtr_memo_contains(mtr, buf_block_align(ptr),
|
|
MTR_MEMO_PAGE_X_FIX));
|
|
ut_ad(type <= MLOG_BIGGEST_TYPE);
|
|
ut_ad(ptr && log_ptr);
|
|
|
|
block = buf_block_align(ptr);
|
|
|
|
space = buf_block_get_space(block);
|
|
offset = buf_block_get_page_no(block);
|
|
|
|
mach_write_to_1(log_ptr, type);
|
|
log_ptr++;
|
|
log_ptr += mach_write_compressed(log_ptr, space);
|
|
log_ptr += mach_write_compressed(log_ptr, offset);
|
|
|
|
mtr->n_log_recs++;
|
|
|
|
#ifdef UNIV_LOG_DEBUG
|
|
/* fprintf(stderr,
|
|
"Adding to mtr log record type %lu space %lu page no %lu\n",
|
|
type, space, offset); */
|
|
#endif
|
|
|
|
#ifdef UNIV_DEBUG
|
|
/* We now assume that all x-latched pages have been modified! */
|
|
|
|
if (!mtr_memo_contains(mtr, block, MTR_MEMO_MODIFY)) {
|
|
|
|
mtr_memo_push(mtr, block, MTR_MEMO_MODIFY);
|
|
}
|
|
#endif
|
|
return(log_ptr);
|
|
}
|
|
|
|
/************************************************************
|
|
Writes a log record about an .ibd file create/delete/rename. */
|
|
UNIV_INLINE
|
|
byte*
|
|
mlog_write_initial_log_record_for_file_op(
|
|
/*======================================*/
|
|
/* out: new value of log_ptr */
|
|
ulint type, /* in: MLOG_FILE_CREATE, MLOG_FILE_DELETE, or
|
|
MLOG_FILE_RENAME */
|
|
ulint space_id,/* in: space id, if applicable */
|
|
ulint page_no,/* in: page number (not relevant currently) */
|
|
byte* log_ptr,/* in: pointer to mtr log which has been opened */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
ut_ad(log_ptr);
|
|
|
|
mach_write_to_1(log_ptr, type);
|
|
log_ptr++;
|
|
|
|
/* We write dummy space id and page number */
|
|
log_ptr += mach_write_compressed(log_ptr, space_id);
|
|
log_ptr += mach_write_compressed(log_ptr, page_no);
|
|
|
|
mtr->n_log_recs++;
|
|
|
|
return(log_ptr);
|
|
}
|