Commit d12dbe77 authored by Jan Lindström's avatar Jan Lindström

MDEV-6246: Merge 10.0.10-FusionIO to 10.1.

parents 9d399c9f 972a14b5
# Copyright (C) 2014, SkySQL Ab. All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
MACRO (MYSQL_CHECK_LZ4)
CHECK_INCLUDE_FILES(lz4.h HAVE_LZ4_H)
CHECK_LIBRARY_EXISTS(lz4 LZ4_compress_limitedOutput "" HAVE_LZ4_SHARED_LIB)
IF (HAVE_LZ4_SHARED_LIB AND HAVE_LZ4_H)
ADD_DEFINITIONS(-DHAVE_LZ4=1)
LINK_LIBRARIES(lz4)
ENDIF()
ENDMACRO()
MACRO (MYSQL_CHECK_LZ4_STATIC)
CHECK_INCLUDE_FILES(lz4.h HAVE_LZ4_H)
CHECK_LIBRARY_EXISTS(liblz4.a LZ4_compress_limitedOutput "" HAVE_LZ4_LIB)
IF(HAVE_LZ4_LIB AND HAVE_LZ4_H)
ADD_DEFINITIONS(-DHAVE_LZ4=1)
LINK_LIBRARIES(liblz4.a)
ENDIF()
ENDMACRO()
\ No newline at end of file
# Copyright (C) 2014, SkySQL Ab. All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
MACRO (MYSQL_CHECK_LZO_STATIC)
CHECK_INCLUDE_FILES(lzo/lzo1x.h HAVE_LZO_H)
CHECK_LIBRARY_EXISTS(liblzo2.a lzo1x_1_compress "" HAVE_LZO_LIB)
IF(HAVE_LZO_LIB AND HAVE_LZO_H)
ADD_DEFINITIONS(-DHAVE_LZO=1)
LINK_LIBRARIES(liblzo2.a)
ENDIF()
ENDMACRO()
MACRO (MYSQL_CHECK_LZO)
CHECK_INCLUDE_FILES(lzo/lzo1x.h HAVE_LZO_H)
CHECK_LIBRARY_EXISTS(lzo2 lzo1x_1_compress "" HAVE_LZO_LIB)
IF(HAVE_LZO_LIB AND HAVE_LZO_H)
ADD_DEFINITIONS(-DHAVE_LZO=1)
LINK_LIBRARIES(lzo2)
ENDIF()
ENDMACRO()
......@@ -72,10 +72,24 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
ENDIF()
ENDIF()
IF(WITH_INNOBASE_STORAGE_ENGINE)
# Add path to the InnoDB headers
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/storage/innobase/include)
# We use the InnoDB code directly in case the code changes.
ADD_DEFINITIONS("-DUNIV_INNOCHECKSUM")
SET(INNOBASE_SOURCES
../storage/innobase/buf/buf0checksum.cc
../storage/innobase/ut/ut0crc32.cc
../storage/innobase/ut/ut0ut.cc
)
MYSQL_ADD_EXECUTABLE(innochecksum innochecksum.cc ${INNOBASE_SOURCES})
TARGET_LINK_LIBRARIES(innochecksum mysys mysys_ssl)
ENDIF()
MYSQL_ADD_EXECUTABLE(replace replace.c COMPONENT Server)
TARGET_LINK_LIBRARIES(replace mysys)
IF(UNIX)
MYSQL_ADD_EXECUTABLE(innochecksum innochecksum.c)
MYSQL_ADD_EXECUTABLE(resolve_stack_dump resolve_stack_dump.c)
TARGET_LINK_LIBRARIES(resolve_stack_dump mysys)
......
/*
Copyright (c) 2005, 2011, Oracle and/or its affiliates
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
InnoDB offline file checksum utility. 85% of the code in this file
was taken wholesale fron the InnoDB codebase.
The final 15% was originally written by Mark Smith of Danga
Interactive, Inc. <junior@danga.com>
Published with a permission.
*/
#include <my_global.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
/* all of these ripped from InnoDB code from MySQL 4.0.22 */
#define UT_HASH_RANDOM_MASK 1463735687
#define UT_HASH_RANDOM_MASK2 1653893711
#define FIL_PAGE_LSN 16
#define FIL_PAGE_FILE_FLUSH_LSN 26
#define FIL_PAGE_OFFSET 4
#define FIL_PAGE_DATA 38
#define FIL_PAGE_END_LSN_OLD_CHKSUM 8
#define FIL_PAGE_SPACE_OR_CHKSUM 0
#define UNIV_PAGE_SIZE (2 * 8192)
/* command line argument to do page checks (that's it) */
/* another argument to specify page ranges... seek to right spot and go from there */
typedef unsigned long int ulint;
/* innodb function in name; modified slightly to not have the ASM version (lots of #ifs that didn't apply) */
ulint mach_read_from_4(uchar *b)
{
return( ((ulint)(b[0]) << 24)
+ ((ulint)(b[1]) << 16)
+ ((ulint)(b[2]) << 8)
+ (ulint)(b[3])
);
}
ulint
ut_fold_ulint_pair(
/*===============*/
/* out: folded value */
ulint n1, /* in: ulint */
ulint n2) /* in: ulint */
{
return(((((n1 ^ n2 ^ UT_HASH_RANDOM_MASK2) << 8) + n1)
^ UT_HASH_RANDOM_MASK) + n2);
}
ulint
ut_fold_binary(
/*===========*/
/* out: folded value */
uchar* str, /* in: string of bytes */
ulint len) /* in: length */
{
ulint i;
ulint fold= 0;
for (i= 0; i < len; i++)
{
fold= ut_fold_ulint_pair(fold, (ulint)(*str));
str++;
}
return(fold);
}
ulint
buf_calc_page_new_checksum(
/*=======================*/
/* out: checksum */
uchar* page) /* in: buffer page */
{
ulint checksum;
/* Since the fields FIL_PAGE_FILE_FLUSH_LSN and ..._ARCH_LOG_NO
are written outside the buffer pool to the first pages of data
files, we have to skip them in the page checksum calculation.
We must also skip the field FIL_PAGE_SPACE_OR_CHKSUM where the
checksum is stored, and also the last 8 bytes of page because
there we store the old formula checksum. */
checksum= ut_fold_binary(page + FIL_PAGE_OFFSET,
FIL_PAGE_FILE_FLUSH_LSN - FIL_PAGE_OFFSET)
+ ut_fold_binary(page + FIL_PAGE_DATA,
UNIV_PAGE_SIZE - FIL_PAGE_DATA
- FIL_PAGE_END_LSN_OLD_CHKSUM);
checksum= checksum & 0xFFFFFFFF;
return(checksum);
}
ulint
buf_calc_page_old_checksum(
/*=======================*/
/* out: checksum */
uchar* page) /* in: buffer page */
{
ulint checksum;
checksum= ut_fold_binary(page, FIL_PAGE_FILE_FLUSH_LSN);
checksum= checksum & 0xFFFFFFFF;
return(checksum);
}
int main(int argc, char **argv)
{
FILE *f; /* our input file */
uchar *p; /* storage of pages read */
int bytes; /* bytes read count */
ulint ct; /* current page number (0 based) */
int now; /* current time */
int lastt; /* last time */
ulint oldcsum, oldcsumfield, csum, csumfield, logseq, logseqfield; /* ulints for checksum storage */
struct stat st; /* for stat, if you couldn't guess */
unsigned long long int size; /* size of file (has to be 64 bits) */
ulint pages; /* number of pages in file */
ulint start_page= 0, end_page= 0, use_end_page= 0; /* for starting and ending at certain pages */
off_t offset= 0;
int just_count= 0; /* if true, just print page count */
int verbose= 0;
int debug= 0;
int c;
int fd;
/* remove arguments */
while ((c= getopt(argc, argv, "cvds:e:p:")) != -1)
{
switch (c)
{
case 'v':
verbose= 1;
break;
case 'c':
just_count= 1;
break;
case 's':
start_page= atoi(optarg);
break;
case 'e':
end_page= atoi(optarg);
use_end_page= 1;
break;
case 'p':
start_page= atoi(optarg);
end_page= atoi(optarg);
use_end_page= 1;
break;
case 'd':
debug= 1;
break;
case ':':
fprintf(stderr, "option -%c requires an argument\n", optopt);
return 1;
break;
case '?':
fprintf(stderr, "unrecognized option: -%c\n", optopt);
return 1;
break;
}
}
/* debug implies verbose... */
if (debug) verbose= 1;
/* make sure we have the right arguments */
if (optind >= argc)
{
printf("InnoDB offline file checksum utility.\n");
printf("usage: %s [-c] [-s <start page>] [-e <end page>] [-p <page>] [-v] [-d] <filename>\n", argv[0]);
printf("\t-c\tprint the count of pages in the file\n");
printf("\t-s n\tstart on this page number (0 based)\n");
printf("\t-e n\tend at this page number (0 based)\n");
printf("\t-p n\tcheck only this page (0 based)\n");
printf("\t-v\tverbose (prints progress every 5 seconds)\n");
printf("\t-d\tdebug mode (prints checksums for each page)\n");
return 1;
}
/* stat the file to get size and page count */
if (stat(argv[optind], &st))
{
perror("error statting file");
return 1;
}
size= st.st_size;
pages= size / UNIV_PAGE_SIZE;
if (just_count)
{
printf("%lu\n", pages);
return 0;
}
else if (verbose)
{
printf("file %s = %llu bytes (%lu pages)...\n", argv[optind], size, pages);
printf("checking pages in range %lu to %lu\n", start_page, use_end_page ? end_page : (pages - 1));
}
/* open the file for reading */
f= fopen(argv[optind], "r");
if (!f)
{
perror("error opening file");
return 1;
}
/* seek to the necessary position */
if (start_page)
{
fd= fileno(f);
if (!fd)
{
perror("unable to obtain file descriptor number");
return 1;
}
offset= (off_t)start_page * (off_t)UNIV_PAGE_SIZE;
if (lseek(fd, offset, SEEK_SET) != offset)
{
perror("unable to seek to necessary offset");
return 1;
}
}
/* allocate buffer for reading (so we don't realloc every time) */
p= (uchar *)malloc(UNIV_PAGE_SIZE);
/* main checksumming loop */
ct= start_page;
lastt= 0;
while (!feof(f))
{
bytes= fread(p, 1, UNIV_PAGE_SIZE, f);
if (!bytes && feof(f)) return 0;
if (bytes != UNIV_PAGE_SIZE)
{
fprintf(stderr, "bytes read (%d) doesn't match universal page size (%d)\n", bytes, UNIV_PAGE_SIZE);
return 1;
}
/* check the "stored log sequence numbers" */
logseq= mach_read_from_4(p + FIL_PAGE_LSN + 4);
logseqfield= mach_read_from_4(p + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM + 4);
if (debug)
printf("page %lu: log sequence number: first = %lu; second = %lu\n", ct, logseq, logseqfield);
if (logseq != logseqfield)
{
fprintf(stderr, "page %lu invalid (fails log sequence number check)\n", ct);
return 1;
}
/* check old method of checksumming */
oldcsum= buf_calc_page_old_checksum(p);
oldcsumfield= mach_read_from_4(p + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM);
if (debug)
printf("page %lu: old style: calculated = %lu; recorded = %lu\n", ct, oldcsum, oldcsumfield);
if (oldcsumfield != mach_read_from_4(p + FIL_PAGE_LSN) && oldcsumfield != oldcsum)
{
fprintf(stderr, "page %lu invalid (fails old style checksum)\n", ct);
return 1;
}
/* now check the new method */
csum= buf_calc_page_new_checksum(p);
csumfield= mach_read_from_4(p + FIL_PAGE_SPACE_OR_CHKSUM);
if (debug)
printf("page %lu: new style: calculated = %lu; recorded = %lu\n", ct, csum, csumfield);
if (csumfield != 0 && csum != csumfield)
{
fprintf(stderr, "page %lu invalid (fails new style checksum)\n", ct);
return 1;
}
/* end if this was the last page we were supposed to check */
if (use_end_page && (ct >= end_page))
return 0;
/* do counter increase and progress printing */
ct++;
if (verbose)
{
if (ct % 64 == 0)
{
now= time(0);
if (!lastt) lastt= now;
if (now - lastt >= 1)
{
printf("page %lu okay: %.3f%% done\n", (ct - 1), (float) ct / pages * 100);
lastt= now;
}
}
}
}
return 0;
}
This diff is collapsed.
......@@ -20,3 +20,5 @@ mysql_embedded : Bug#12561297 2011-05-14 Anitha Dependent on PB2 chang
ssl_crl_clients_valid : broken upstream
ssl_crl : broken upstream
ssl_crl_clrpath : broken upstream
innodb-wl5522-debug-zip : broken upstream
innodb_bug12902967 : broken upstream
\ No newline at end of file
......@@ -37,6 +37,8 @@ buffer_pool_bytes_dirty disabled
buffer_pool_pages_free disabled
buffer_pages_created disabled
buffer_pages_written disabled
buffer_index_pages_written disabled
buffer_non_index_pages_written disabled
buffer_pages_read disabled
buffer_data_reads disabled
buffer_data_written disabled
......@@ -160,6 +162,14 @@ compress_pages_compressed disabled
compress_pages_decompressed disabled
compression_pad_increments disabled
compression_pad_decrements disabled
compress_saved disabled
compress_trim_sect512 disabled
compress_trim_sect4096 disabled
compress_pages_page_compressed disabled
compress_page_compressed_trim_op disabled
compress_page_compressed_trim_op_saved disabled
compress_pages_page_decompressed disabled
compress_pages_page_compression_error disabled
index_page_splits disabled
index_page_merge_attempts disabled
index_page_merge_successful disabled
......
......@@ -37,6 +37,8 @@ buffer_pool_bytes_dirty disabled
buffer_pool_pages_free disabled
buffer_pages_created disabled
buffer_pages_written disabled
buffer_index_pages_written disabled
buffer_non_index_pages_written disabled
buffer_pages_read disabled
buffer_data_reads disabled
buffer_data_written disabled
......@@ -160,6 +162,14 @@ compress_pages_compressed disabled
compress_pages_decompressed disabled
compression_pad_increments disabled
compression_pad_decrements disabled
compress_saved disabled
compress_trim_sect512 disabled
compress_trim_sect4096 disabled
compress_pages_page_compressed disabled
compress_page_compressed_trim_op disabled
compress_page_compressed_trim_op_saved disabled
compress_pages_page_decompressed disabled
compress_pages_page_compression_error disabled
index_page_splits disabled
index_page_merge_attempts disabled
index_page_merge_successful disabled
......
......@@ -37,6 +37,8 @@ buffer_pool_bytes_dirty disabled
buffer_pool_pages_free disabled
buffer_pages_created disabled
buffer_pages_written disabled
buffer_index_pages_written disabled
buffer_non_index_pages_written disabled
buffer_pages_read disabled
buffer_data_reads disabled
buffer_data_written disabled
......@@ -160,6 +162,14 @@ compress_pages_compressed disabled
compress_pages_decompressed disabled
compression_pad_increments disabled
compression_pad_decrements disabled
compress_saved disabled
compress_trim_sect512 disabled
compress_trim_sect4096 disabled
compress_pages_page_compressed disabled
compress_page_compressed_trim_op disabled
compress_page_compressed_trim_op_saved disabled
compress_pages_page_decompressed disabled
compress_pages_page_compression_error disabled
index_page_splits disabled
index_page_merge_attempts disabled
index_page_merge_successful disabled
......
......@@ -37,6 +37,8 @@ buffer_pool_bytes_dirty disabled
buffer_pool_pages_free disabled
buffer_pages_created disabled
buffer_pages_written disabled
buffer_index_pages_written disabled
buffer_non_index_pages_written disabled
buffer_pages_read disabled
buffer_data_reads disabled
buffer_data_written disabled
......@@ -160,6 +162,14 @@ compress_pages_compressed disabled
compress_pages_decompressed disabled
compression_pad_increments disabled
compression_pad_decrements disabled
compress_saved disabled
compress_trim_sect512 disabled
compress_trim_sect4096 disabled
compress_pages_page_compressed disabled
compress_page_compressed_trim_op disabled
compress_page_compressed_trim_op_saved disabled
compress_pages_page_decompressed disabled
compress_pages_page_compression_error disabled
index_page_splits disabled
index_page_merge_attempts disabled
index_page_merge_successful disabled
......
select @@global.innodb_mtflush_threads;
@@global.innodb_mtflush_threads
8
select @@session.innodb_mtflush_threads;
ERROR HY000: Variable 'innodb_mtflush_threads' is a GLOBAL variable
show global variables like 'innodb_mtflush_threads';
Variable_name Value
innodb_mtflush_threads 8
show session variables like 'innodb_mtflush_threads';
Variable_name Value
innodb_mtflush_threads 8
select * from information_schema.global_variables where variable_name='innodb_mtflush_threads';
VARIABLE_NAME VARIABLE_VALUE
INNODB_MTFLUSH_THREADS 8
select * from information_schema.session_variables where variable_name='innodb_mtflush_threads';
VARIABLE_NAME VARIABLE_VALUE
INNODB_MTFLUSH_THREADS 8
set global innodb_mtflush_threads=1;
ERROR HY000: Variable 'innodb_mtflush_threads' is a read only variable
set session innodb_mtflush_threads=1;
ERROR HY000: Variable 'innodb_mtflush_threads' is a read only variable
select @@global.innodb_use_fallocate;
@@global.innodb_use_fallocate
0
select @@global.innodb_use_mtflush;
@@global.innodb_use_mtflush
0
select @@session.innodb_use_mtflush;
ERROR HY000: Variable 'innodb_use_mtflush' is a GLOBAL variable
show global variables like 'innodb_use_mtflush';
Variable_name Value
innodb_use_mtflush OFF
show session variables like 'innodb_use_mtflush';
Variable_name Value
innodb_use_mtflush OFF
select * from information_schema.global_variables where variable_name='innodb_use_mtflush';
VARIABLE_NAME VARIABLE_VALUE
INNODB_USE_MTFLUSH OFF
select * from information_schema.session_variables where variable_name='innodb_use_mtflush';
VARIABLE_NAME VARIABLE_VALUE
INNODB_USE_MTFLUSH OFF
set global innodb_use_mtflush=1;
ERROR HY000: Variable 'innodb_use_mtflush' is a read only variable
set session innodb_use_mtflush=1;
ERROR HY000: Variable 'innodb_use_mtflush' is a read only variable
SET @start_use_trim = @@global.innodb_use_trim;
SELECT @start_use_trim;
@start_use_trim
0
SELECT COUNT(@@GLOBAL.innodb_use_trim);
COUNT(@@GLOBAL.innodb_use_trim)
1
1 Expected
SET @@GLOBAL.innodb_use_trim=1;
SELECT COUNT(@@GLOBAL.innodb_use_trim);
COUNT(@@GLOBAL.innodb_use_trim)
1
1 Expected
SELECT IF(@@GLOBAL.innodb_use_trim, 'ON', 'OFF') = VARIABLE_VALUE
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
WHERE VARIABLE_NAME='innodb_use_trim';
IF(@@GLOBAL.innodb_use_trim, 'ON', 'OFF') = VARIABLE_VALUE
1
1 Expected
SELECT COUNT(@@GLOBAL.innodb_use_trim);
COUNT(@@GLOBAL.innodb_use_trim)
1
1 Expected
SELECT COUNT(VARIABLE_VALUE)
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
WHERE VARIABLE_NAME='innodb_use_trim';
COUNT(VARIABLE_VALUE)
1
1 Expected
SET @@global.innodb_use_trim = @start_use_trim;
SELECT @@global.innodb_use_trim;
@@global.innodb_use_trim
0
--source include/have_innodb.inc
# bool readonly
#
# show values;
#
select @@global.innodb_mtflush_threads;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
select @@session.innodb_mtflush_threads;
show global variables like 'innodb_mtflush_threads';
show session variables like 'innodb_mtflush_threads';
select * from information_schema.global_variables where variable_name='innodb_mtflush_threads';
select * from information_schema.session_variables where variable_name='innodb_mtflush_threads';
#
# show that it's read-only
#
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set global innodb_mtflush_threads=1;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set session innodb_mtflush_threads=1;
--source include/have_innodb.inc
# bool readonly
# not on all compilations
select @@global.innodb_use_fallocate;
--source include/have_innodb.inc
# bool readonly
#
# show values;
#
select @@global.innodb_use_mtflush;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
select @@session.innodb_use_mtflush;
show global variables like 'innodb_use_mtflush';
show session variables like 'innodb_use_mtflush';
select * from information_schema.global_variables where variable_name='innodb_use_mtflush';
select * from information_schema.session_variables where variable_name='innodb_use_mtflush';
#
# show that it's read-only
#
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set global innodb_use_mtflush=1;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set session innodb_use_mtflush=1;
--source include/have_innodb.inc
SET @start_use_trim = @@global.innodb_use_trim;
SELECT @start_use_trim;
SELECT COUNT(@@GLOBAL.innodb_use_trim);
--echo 1 Expected
####################################################################
# Check if Value can set #
####################################################################
SET @@GLOBAL.innodb_use_trim=1;
SELECT COUNT(@@GLOBAL.innodb_use_trim);
--echo 1 Expected
#################################################################
# Check if the value in GLOBAL Table matches value in variable #
#################################################################
SELECT IF(@@GLOBAL.innodb_use_trim, 'ON', 'OFF') = VARIABLE_VALUE
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
WHERE VARIABLE_NAME='innodb_use_trim';
--echo 1 Expected
SELECT COUNT(@@GLOBAL.innodb_use_trim);
--echo 1 Expected
SELECT COUNT(VARIABLE_VALUE)
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
WHERE VARIABLE_NAME='innodb_use_trim';
--echo 1 Expected
SET @@global.innodb_use_trim = @start_use_trim;
SELECT @@global.innodb_use_trim;
\ No newline at end of file
......@@ -18,6 +18,11 @@
INCLUDE(CheckFunctionExists)
INCLUDE(CheckCSourceCompiles)
INCLUDE(CheckCSourceRuns)
INCLUDE(lz4)
INCLUDE(lzo)
MYSQL_CHECK_LZ4()
MYSQL_CHECK_LZO()
# OS tests
IF(UNIX)
......@@ -284,6 +289,7 @@ SET(INNOBASE_SOURCES
buf/buf0flu.cc
buf/buf0lru.cc
buf/buf0rea.cc
buf/buf0mtflu.cc
data/data0data.cc
data/data0type.cc
dict/dict0boot.cc
......@@ -297,6 +303,7 @@ SET(INNOBASE_SOURCES
eval/eval0eval.cc
eval/eval0proc.cc
fil/fil0fil.cc
fil/fil0pagecompress.cc
fsp/fsp0fsp.cc
fut/fut0fut.cc
fut/fut0lst.cc
......
......@@ -2031,7 +2031,7 @@ btr_parse_page_reorganize(
buf_block_t* block, /*!< in: page to be reorganized, or NULL */
mtr_t* mtr) /*!< in: mtr or NULL */
{
ulint level;
ulint level = page_zip_level;
ut_ad(ptr && end_ptr);
......
......@@ -1860,9 +1860,14 @@ btr_cur_update_alloc_zip_func(
false=update-in-place */
mtr_t* mtr) /*!< in/out: mini-transaction */
{
/* Have a local copy of the variables as these can change
dynamically. */
ulint compression_level = page_zip_level;
const page_t* page = page_cur_get_page(cursor);
ut_ad(page_zip == page_cur_get_page_zip(cursor));
ut_ad(page_zip);
ut_ad(!dict_index_is_ibuf(index));
ut_ad(rec_offs_validate(page_cur_get_rec(cursor), index, offsets));
......
......@@ -2,6 +2,7 @@
Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Copyright (c) 2013, SkySQL Ab. All Rights Reserved.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
......@@ -3350,6 +3351,7 @@ buf_page_init_low(
bpage->access_time = 0;
bpage->newest_modification = 0;
bpage->oldest_modification = 0;
bpage->write_size = 0;
HASH_INVALIDATE(bpage, hash);
#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
bpage->file_page_was_freed = FALSE;
......
/*****************************************************************************
Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 2014, SkySQL Ab. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -381,7 +382,8 @@ buf_dblwr_init_or_load_pages(
buffer */
fil_io(OS_FILE_READ, true, TRX_SYS_SPACE, 0, TRX_SYS_PAGE_NO, 0,
UNIV_PAGE_SIZE, read_buf, NULL);
UNIV_PAGE_SIZE, read_buf, NULL, 0);
doublewrite = read_buf + TRX_SYS_DOUBLEWRITE;
if (mach_read_from_4(doublewrite + TRX_SYS_DOUBLEWRITE_MAGIC)
......@@ -417,11 +419,12 @@ buf_dblwr_init_or_load_pages(
fil_io(OS_FILE_READ, true, TRX_SYS_SPACE, 0, block1, 0,
TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE,
buf, NULL);
buf, NULL, 0);
fil_io(OS_FILE_READ, true, TRX_SYS_SPACE, 0, block2, 0,
TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE,
buf + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE,
NULL);
NULL, 0);
/* Check if any of these pages is half-written in data files, in the
intended position */
......@@ -448,7 +451,7 @@ buf_dblwr_init_or_load_pages(
}
fil_io(OS_FILE_WRITE, true, space_id, 0, source_page_no, 0,
UNIV_PAGE_SIZE, page, NULL);
UNIV_PAGE_SIZE, page, NULL, 0);
} else if (load_corrupt_pages) {
......@@ -510,7 +513,7 @@ buf_dblwr_process()
fil_io(OS_FILE_READ, true, space_id, zip_size,
page_no, 0,
zip_size ? zip_size : UNIV_PAGE_SIZE,
read_buf, NULL);
read_buf, NULL, 0);
/* Check if the page is corrupt */
......@@ -562,7 +565,7 @@ buf_dblwr_process()
fil_io(OS_FILE_WRITE, true, space_id,
zip_size, page_no, 0,
zip_size ? zip_size : UNIV_PAGE_SIZE,
page, NULL);
page, NULL, 0);
ib_logf(IB_LOG_LEVEL_INFO,
"Recovered the page from"
......@@ -778,7 +781,7 @@ buf_dblwr_write_block_to_datafile(
buf_page_get_page_no(bpage), 0,
buf_page_get_zip_size(bpage),
(void*) bpage->zip.data,
(void*) bpage);
(void*) bpage, 0);
return;
}
......@@ -790,8 +793,7 @@ buf_dblwr_write_block_to_datafile(
fil_io(flags, sync, buf_block_get_space(block), 0,
buf_block_get_page_no(block), 0, UNIV_PAGE_SIZE,
(void*) block->frame, (void*) block);
(void*) block->frame, (void*) block, (ulint *)&bpage->write_size);
}
/********************************************************************//**
......@@ -885,7 +887,7 @@ try_again:
fil_io(OS_FILE_WRITE, true, TRX_SYS_SPACE, 0,
buf_dblwr->block1, 0, len,
(void*) write_buf, NULL);
(void*) write_buf, NULL, 0);
if (buf_dblwr->first_free <= TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) {
/* No unwritten pages in the second block. */
......@@ -901,7 +903,7 @@ try_again:
fil_io(OS_FILE_WRITE, true, TRX_SYS_SPACE, 0,
buf_dblwr->block2, 0, len,
(void*) write_buf, NULL);
(void*) write_buf, NULL, 0);
flush:
/* increment the doublewrite flushed pages counter */
......@@ -1130,14 +1132,14 @@ retry:
fil_io(OS_FILE_WRITE, true, TRX_SYS_SPACE, 0,
offset, 0, UNIV_PAGE_SIZE,
(void*) (buf_dblwr->write_buf
+ UNIV_PAGE_SIZE * i), NULL);
+ UNIV_PAGE_SIZE * i), NULL, 0);
} else {
/* It is a regular page. Write it directly to the
doublewrite buffer */
fil_io(OS_FILE_WRITE, true, TRX_SYS_SPACE, 0,
offset, 0, UNIV_PAGE_SIZE,
(void*) ((buf_block_t*) bpage)->frame,
NULL);
NULL, 0);
}
/* Now flush the doublewrite buffer data to disk */
......
/*****************************************************************************
Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 2014, SkySQL Ab. All Rights Reserved.
Copyright (c) 2013, 2014, Fusion-io. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -30,6 +32,7 @@ Created 11/11/1995 Heikki Tuuri
#endif
#include "buf0buf.h"
#include "buf0mtflu.h"
#include "buf0checksum.h"
#include "srv0start.h"
#include "srv0srv.h"
......@@ -44,10 +47,12 @@ Created 11/11/1995 Heikki Tuuri
#include "ibuf0ibuf.h"
#include "log0log.h"
#include "os0file.h"
#include "os0sync.h"
#include "trx0sys.h"
#include "srv0mon.h"
#include "mysql/plugin.h"
#include "mysql/service_thd_wait.h"
#include "fil0pagecompress.h"
/** Number of pages flushed through non flush_list flushes. */
static ulint buf_lru_flush_page_count = 0;
......@@ -723,8 +728,10 @@ buf_flush_write_complete(
flush_type = buf_page_get_flush_type(bpage);
buf_pool->n_flush[flush_type]--;
#ifdef UNIV_DEBUG
/* fprintf(stderr, "n pending flush %lu\n",
buf_pool->n_flush[flush_type]); */
#endif
if (buf_pool->n_flush[flush_type] == 0
&& buf_pool->init_flush[flush_type] == FALSE) {
......@@ -880,6 +887,8 @@ buf_flush_write_block_low(
{
ulint zip_size = buf_page_get_zip_size(bpage);
page_t* frame = NULL;
ulint space_id = buf_page_get_space(bpage);
atomic_writes_t awrites = fil_space_get_atomic_writes(space_id);
#ifdef UNIV_DEBUG
buf_pool_t* buf_pool = buf_pool_from_bpage(bpage);
......@@ -956,13 +965,29 @@ buf_flush_write_block_low(
sync, buf_page_get_space(bpage), zip_size,
buf_page_get_page_no(bpage), 0,
zip_size ? zip_size : UNIV_PAGE_SIZE,
frame, bpage);
frame, bpage, &bpage->write_size);
} else {
/* InnoDB uses doublewrite buffer and doublewrite buffer
is initialized. User can define do we use atomic writes
on a file space (table) or not. If atomic writes are
not used we should use doublewrite buffer and if
atomic writes should be used, no doublewrite buffer
is used. */
if (awrites == ATOMIC_WRITES_ON) {
fil_io(OS_FILE_WRITE | OS_AIO_SIMULATED_WAKE_LATER,
FALSE, buf_page_get_space(bpage), zip_size,
buf_page_get_page_no(bpage), 0,
zip_size ? zip_size : UNIV_PAGE_SIZE,
frame, bpage, &bpage->write_size);
} else if (flush_type == BUF_FLUSH_SINGLE_PAGE) {
buf_dblwr_write_single_page(bpage, sync);
} else {
ut_ad(!sync);
buf_dblwr_add_to_batch(bpage);
}
}
/* When doing single page flushing the IO is done synchronously
and we flush the changes to disk only for the tablespace we
......@@ -1221,7 +1246,9 @@ buf_flush_try_neighbors(
}
}
#ifdef UNIV_DEBUG
/* fprintf(stderr, "Flush area: low %lu high %lu\n", low, high); */
#endif
if (high > fil_space_get_size(space)) {
high = fil_space_get_size(space);
......@@ -1664,7 +1691,6 @@ pages: to avoid deadlocks, this function must be written so that it cannot
end up waiting for these latches! NOTE 2: in the case of a flush list flush,
the calling thread is not allowed to own any latches on pages!
@return number of blocks for which the write request was queued */
static
ulint
buf_flush_batch(
/*============*/
......@@ -1721,7 +1747,6 @@ buf_flush_batch(
/******************************************************************//**
Gather the aggregated stats for both flush list and LRU list flushing */
static
void
buf_flush_common(
/*=============*/
......@@ -1746,7 +1771,6 @@ buf_flush_common(
/******************************************************************//**
Start a buffer flush batch for LRU or flush list */
static
ibool
buf_flush_start(
/*============*/
......@@ -1775,7 +1799,6 @@ buf_flush_start(
/******************************************************************//**
End a buffer flush batch for LRU or flush list */
static
void
buf_flush_end(
/*==========*/
......@@ -1899,6 +1922,10 @@ buf_flush_list(
ulint i;
bool success = true;
if (buf_mtflu_init_done()) {
return(buf_mtflu_flush_list(min_n, lsn_limit, n_processed));
}
if (n_processed) {
*n_processed = 0;
}
......@@ -2069,6 +2096,11 @@ buf_flush_LRU_tail(void)
{
ulint total_flushed = 0;
if(buf_mtflu_init_done())
{
return(buf_mtflu_flush_LRU_tail());
}
for (ulint i = 0; i < srv_buf_pool_instances; i++) {
buf_pool_t* buf_pool = buf_pool_from_array(i);
......@@ -2374,6 +2406,8 @@ page_cleaner_sleep_if_needed(
}
}
/******************************************************************//**
page_cleaner thread tasked with flushing dirty pages from the buffer
pools. As of now we'll have only one instance of this thread.
......@@ -2400,7 +2434,6 @@ DECLARE_THREAD(buf_flush_page_cleaner_thread)(
fprintf(stderr, "InnoDB: page_cleaner thread running, id %lu\n",
os_thread_pf(os_thread_get_curr_id()));
#endif /* UNIV_DEBUG_THREAD_CREATION */
buf_page_cleaner_is_active = TRUE;
while (srv_shutdown_state == SRV_SHUTDOWN_NONE) {
......@@ -2424,6 +2457,7 @@ DECLARE_THREAD(buf_flush_page_cleaner_thread)(
/* Flush pages from flush_list if required */
n_flushed += page_cleaner_flush_pages_if_needed();
} else {
n_flushed = page_cleaner_do_flush_batch(
PCT_IO(100),
......@@ -2440,6 +2474,7 @@ DECLARE_THREAD(buf_flush_page_cleaner_thread)(
}
ut_ad(srv_shutdown_state > 0);
if (srv_fast_shutdown == 2) {
/* In very fast shutdown we simulate a crash of
buffer pool. We are not required to do any flushing */
......@@ -2605,9 +2640,11 @@ buf_flush_validate(
return(ret);
}
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
#endif /* !UNIV_HOTBACKUP */
#ifdef UNIV_DEBUG
/******************************************************************//**
Check if there are any dirty pages that belong to a space id in the flush
......
This diff is collapsed.
/*****************************************************************************
Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 2014, SkySQL Ab. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -184,14 +185,14 @@ buf_read_page_low(
*err = fil_io(OS_FILE_READ | wake_later
| ignore_nonexistent_pages,
sync, space, zip_size, offset, 0, zip_size,
bpage->zip.data, bpage);
bpage->zip.data, bpage, &bpage->write_size);
} else {
ut_a(buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE);
*err = fil_io(OS_FILE_READ | wake_later
| ignore_nonexistent_pages,
sync, space, 0, offset, 0, UNIV_PAGE_SIZE,
((buf_block_t*) bpage)->frame, bpage);
((buf_block_t*) bpage)->frame, bpage, 0);
}
if (sync) {
......
......@@ -2,6 +2,7 @@
Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
Copyright (c) 2013, SkySQL Ab. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*****************************************************************************
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, SkySQL Ab. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -56,6 +57,22 @@ typedef struct st_innobase_share {
/** Prebuilt structures in an InnoDB table handle used within MySQL */
struct row_prebuilt_t;
/** Engine specific table options are definined using this struct */
struct ha_table_option_struct
{
bool page_compressed; /*!< Table is using page compression
if this option is true. */
int page_compression_level; /*!< Table page compression level
or UNIV_UNSPECIFIED. */
uint atomic_writes; /*!< Use atomic writes for this
table if this options is ON or
in DEFAULT if
srv_use_atomic_writes=1.
Atomic writes are not used if
value OFF.*/
};
/** The class defining a handle to an Innodb table */
class ha_innobase: public handler
{
......@@ -182,6 +199,8 @@ class ha_innobase: public handler
char* norm_name,
char* temp_path,
char* remote_path);
const char* check_table_options(THD *thd, TABLE* table,
HA_CREATE_INFO* create_info, const bool use_tablespace, const ulint file_format);
int create(const char *name, register TABLE *form,
HA_CREATE_INFO *create_info);
int truncate();
......
/*****************************************************************************
Copyright (c) 2005, 2013, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 2014, SkySQL Ab. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -259,6 +260,22 @@ ha_innobase::check_if_supported_inplace_alter(
update_thd();
trx_search_latch_release_if_reserved(prebuilt->trx);
/* Change on engine specific table options require rebuild of the
table */
if (ha_alter_info->handler_flags
== Alter_inplace_info::CHANGE_CREATE_OPTION) {
ha_table_option_struct *new_options= ha_alter_info->create_info->option_struct;
ha_table_option_struct *old_options= table->s->option_struct;
if (new_options->page_compressed != old_options->page_compressed ||
new_options->page_compression_level != old_options->page_compression_level ||
new_options->atomic_writes != old_options->atomic_writes) {
ha_alter_info->unsupported_reason = innobase_get_err_msg(
ER_ALTER_OPERATION_NOT_SUPPORTED_REASON);
DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
}
}
if (ha_alter_info->handler_flags
& ~(INNOBASE_INPLACE_IGNORE
| INNOBASE_ALTER_NOREBUILD
......@@ -3382,6 +3399,17 @@ ha_innobase::prepare_inplace_alter_table(
if (ha_alter_info->handler_flags
& Alter_inplace_info::CHANGE_CREATE_OPTION) {
/* Check engine specific table options */
if (const char* invalid_tbopt = check_table_options(
user_thd, altered_table,
ha_alter_info->create_info,
prebuilt->table->space != 0,
srv_file_format)) {
my_error(ER_ILLEGAL_HA_CREATE_OPTION, MYF(0),
table_type(), invalid_tbopt);
goto err_exit_no_heap;
}
if (const char* invalid_opt = create_options_are_invalid(
user_thd, altered_table,
ha_alter_info->create_info,
......
/*****************************************************************************
Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 2014, SkySQL Ab. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -1489,6 +1490,11 @@ struct buf_page_t{
state == BUF_BLOCK_ZIP_PAGE and
zip.data == NULL means an active
buf_pool->watch */
ulint write_size; /* Write size is set when this
page is first time written and then
if written again we check is TRIM
operation needed. */
#ifndef UNIV_HOTBACKUP
buf_page_t* hash; /*!< node used in chaining to
buf_pool->page_hash or
......
/*****************************************************************************
Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2014, 2014, SkySQL Ab.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -279,6 +280,55 @@ buf_flush_get_dirty_pages_count(
#endif /* !UNIV_HOTBACKUP */
/******************************************************************//**
Start a buffer flush batch for LRU or flush list */
ibool
buf_flush_start(
/*============*/
buf_pool_t* buf_pool, /*!< buffer pool instance */
buf_flush_t flush_type); /*!< in: BUF_FLUSH_LRU
or BUF_FLUSH_LIST */
/******************************************************************//**
End a buffer flush batch for LRU or flush list */
void
buf_flush_end(
/*==========*/
buf_pool_t* buf_pool, /*!< buffer pool instance */
buf_flush_t flush_type); /*!< in: BUF_FLUSH_LRU
or BUF_FLUSH_LIST */
/******************************************************************//**
Gather the aggregated stats for both flush list and LRU list flushing */
void
buf_flush_common(
/*=============*/
buf_flush_t flush_type, /*!< in: type of flush */
ulint page_count); /*!< in: number of pages flushed */
/*******************************************************************//**
This utility flushes dirty blocks from the end of the LRU list or flush_list.
NOTE 1: in the case of an LRU flush the calling thread may own latches to
pages: to avoid deadlocks, this function must be written so that it cannot
end up waiting for these latches! NOTE 2: in the case of a flush list flush,
the calling thread is not allowed to own any latches on pages!
@return number of blocks for which the write request was queued */
ulint
buf_flush_batch(
/*============*/
buf_pool_t* buf_pool, /*!< in: buffer pool instance */
buf_flush_t flush_type, /*!< in: BUF_FLUSH_LRU or
BUF_FLUSH_LIST; if BUF_FLUSH_LIST,
then the caller must not own any
latches on pages */
ulint min_n, /*!< in: wished minimum mumber of blocks
flushed (it is not guaranteed that the
actual number is that big, though) */
lsn_t lsn_limit); /*!< in: in the case of BUF_FLUSH_LIST
all blocks whose oldest_modification is
smaller than this should be flushed
(if their number does not exceed
min_n), otherwise ignored */
#ifndef UNIV_NONINL
#include "buf0flu.ic"
#endif
......
/*****************************************************************************
Copyright (C) 2014 SkySQL Ab. All Rights Reserved.
Copyright (C) 2014 Fusion-io. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*****************************************************************************/
/******************************************************************//**
@file include/buf0mtflu.h
Multi-threadef flush method interface function prototypes
Created 06/02/2014 Jan Lindström jan.lindstrom@skysql.com
Dhananjoy Das DDas@fusionio.com
***********************************************************************/
#ifndef buf0mtflu_h
#define buf0mtflu_h
/******************************************************************//**
Add exit work item to work queue to signal multi-threded flush
threads that they should exit.
*/
void
buf_mtflu_io_thread_exit(void);
/*===========================*/
/******************************************************************//**
Initialize multi-threaded flush thread syncronization data.
@return Initialized multi-threaded flush thread syncroniztion data. */
void*
buf_mtflu_handler_init(
/*===================*/
ulint n_threads, /*!< in: Number of threads to create */
ulint wrk_cnt); /*!< in: Number of work items */
/******************************************************************//**
Return true if multi-threaded flush is initialized
@return true if initialized, false if not */
bool
buf_mtflu_init_done(void);
/*======================*/
/*********************************************************************//**
Clears up tail of the LRU lists:
* Put replaceable pages at the tail of LRU to the free list
* Flush dirty pages at the tail of LRU to the disk
The depth to which we scan each buffer pool is controlled by dynamic
config parameter innodb_LRU_scan_depth.
@return total pages flushed */
UNIV_INTERN
ulint
buf_mtflu_flush_LRU_tail(void);
/*===========================*/
/*******************************************************************//**
Multi-threaded version of buf_flush_list
*/
bool
buf_mtflu_flush_list(
/*=================*/
ulint min_n, /*!< in: wished minimum mumber of blocks
flushed (it is not guaranteed that the
actual number is that big, though) */
lsn_t lsn_limit, /*!< in the case BUF_FLUSH_LIST all
blocks whose oldest_modification is
smaller than this should be flushed
(if their number does not exceed
min_n), otherwise ignored */
ulint* n_processed); /*!< out: the number of pages
which were processed is passed
back to caller. Ignored if NULL */
/*********************************************************************//**
Set correct thread identifiers to io thread array based on
information we have. */
void
buf_mtflu_set_thread_ids(
/*=====================*/
ulint n_threads, /*!<in: Number of threads to fill */
void* ctx, /*!<in: thread context */
os_thread_id_t* thread_ids); /*!<in: thread id array */
#endif
......@@ -2,6 +2,7 @@
Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
Copyright (c) 2013, SkySQL Ab. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -42,6 +43,8 @@ Created 1/8/1996 Heikki Tuuri
#include "ut0byte.h"
#include "trx0types.h"
#include "row0types.h"
#include "fsp0fsp.h"
#include "dict0pagecompress.h"
#ifndef UNIV_HOTBACKUP
# include "sync0sync.h"
......@@ -904,7 +907,14 @@ dict_tf_set(
ulint* flags, /*!< in/out: table */
rec_format_t format, /*!< in: file format */
ulint zip_ssize, /*!< in: zip shift size */
bool remote_path) /*!< in: table uses DATA DIRECTORY */
bool remote_path, /*!< in: table uses DATA DIRECTORY
*/
bool page_compressed,/*!< in: table uses page compressed
pages */
ulint page_compression_level, /*!< in: table page compression
level */
ulint atomic_writes) /*!< in: table atomic
writes option value*/
__attribute__((nonnull));
/********************************************************************//**
Convert a 32 bit integer table flags to the 32 bit integer that is
......@@ -932,6 +942,7 @@ dict_tf_get_zip_size(
/*=================*/
ulint flags) /*!< in: flags */
__attribute__((const));
/********************************************************************//**
Check whether the table uses the compressed compact page format.
@return compressed page size, or 0 if not compressed */
......@@ -1812,6 +1823,7 @@ dict_table_get_index_on_first_col(
#endif /* !UNIV_HOTBACKUP */
#ifndef UNIV_NONINL
#include "dict0dict.ic"
#endif
......
This diff is collapsed.
......@@ -2,6 +2,7 @@
Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
Copyright (c) 2013, SkySQL Ab. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -120,11 +121,26 @@ This flag prevents older engines from attempting to open the table and
allows InnoDB to update_create_info() accordingly. */
#define DICT_TF_WIDTH_DATA_DIR 1
/**
Width of the page compression flag
*/
#define DICT_TF_WIDTH_PAGE_COMPRESSION 1
#define DICT_TF_WIDTH_PAGE_COMPRESSION_LEVEL 4
/**
Width of atomic writes flag
DEFAULT=0, ON = 1, OFF = 2
*/
#define DICT_TF_WIDTH_ATOMIC_WRITES 2
/** Width of all the currently known table flags */
#define DICT_TF_BITS (DICT_TF_WIDTH_COMPACT \
+ DICT_TF_WIDTH_ZIP_SSIZE \
+ DICT_TF_WIDTH_ATOMIC_BLOBS \
+ DICT_TF_WIDTH_DATA_DIR)
+ DICT_TF_WIDTH_DATA_DIR \
+ DICT_TF_WIDTH_PAGE_COMPRESSION \
+ DICT_TF_WIDTH_PAGE_COMPRESSION_LEVEL \
+ DICT_TF_WIDTH_ATOMIC_WRITES)
/** A mask of all the known/used bits in table flags */
#define DICT_TF_BIT_MASK (~(~0 << DICT_TF_BITS))
......@@ -140,9 +156,19 @@ allows InnoDB to update_create_info() accordingly. */
/** Zero relative shift position of the DATA_DIR field */
#define DICT_TF_POS_DATA_DIR (DICT_TF_POS_ATOMIC_BLOBS \
+ DICT_TF_WIDTH_ATOMIC_BLOBS)
/** Zero relative shift position of the start of the UNUSED bits */
#define DICT_TF_POS_UNUSED (DICT_TF_POS_DATA_DIR \
/** Zero relative shift position of the PAGE_COMPRESSION field */
#define DICT_TF_POS_PAGE_COMPRESSION (DICT_TF_POS_DATA_DIR \
+ DICT_TF_WIDTH_DATA_DIR)
/** Zero relative shift position of the PAGE_COMPRESSION_LEVEL field */
#define DICT_TF_POS_PAGE_COMPRESSION_LEVEL (DICT_TF_POS_PAGE_COMPRESSION \
+ DICT_TF_WIDTH_PAGE_COMPRESSION)
/** Zero relative shift position of the ATOMIC_WRITES field */
#define DICT_TF_POS_ATOMIC_WRITES (DICT_TF_POS_PAGE_COMPRESSION_LEVEL \
+ DICT_TF_WIDTH_PAGE_COMPRESSION_LEVEL)
/** Zero relative shift position of the start of the UNUSED bits */
#define DICT_TF_POS_UNUSED (DICT_TF_POS_ATOMIC_WRITES \
+ DICT_TF_WIDTH_ATOMIC_WRITES)
/** Bit mask of the COMPACT field */
#define DICT_TF_MASK_COMPACT \
......@@ -160,6 +186,18 @@ allows InnoDB to update_create_info() accordingly. */
#define DICT_TF_MASK_DATA_DIR \
((~(~0 << DICT_TF_WIDTH_DATA_DIR)) \
<< DICT_TF_POS_DATA_DIR)
/** Bit mask of the PAGE_COMPRESSION field */
#define DICT_TF_MASK_PAGE_COMPRESSION \
((~(~0 << DICT_TF_WIDTH_PAGE_COMPRESSION)) \
<< DICT_TF_POS_PAGE_COMPRESSION)
/** Bit mask of the PAGE_COMPRESSION_LEVEL field */
#define DICT_TF_MASK_PAGE_COMPRESSION_LEVEL \
((~(~0 << DICT_TF_WIDTH_PAGE_COMPRESSION_LEVEL)) \
<< DICT_TF_POS_PAGE_COMPRESSION_LEVEL)
/** Bit mask of the ATOMIC_WRITES field */
#define DICT_TF_MASK_ATOMIC_WRITES \
((~(~0 << DICT_TF_WIDTH_ATOMIC_WRITES)) \
<< DICT_TF_POS_ATOMIC_WRITES)
/** Return the value of the COMPACT field */
#define DICT_TF_GET_COMPACT(flags) \
......@@ -177,6 +215,19 @@ allows InnoDB to update_create_info() accordingly. */
#define DICT_TF_HAS_DATA_DIR(flags) \
((flags & DICT_TF_MASK_DATA_DIR) \
>> DICT_TF_POS_DATA_DIR)
/** Return the value of the PAGE_COMPRESSION field */
#define DICT_TF_GET_PAGE_COMPRESSION(flags) \
((flags & DICT_TF_MASK_PAGE_COMPRESSION) \
>> DICT_TF_POS_PAGE_COMPRESSION)
/** Return the value of the PAGE_COMPRESSION_LEVEL field */
#define DICT_TF_GET_PAGE_COMPRESSION_LEVEL(flags) \
((flags & DICT_TF_MASK_PAGE_COMPRESSION_LEVEL) \
>> DICT_TF_POS_PAGE_COMPRESSION_LEVEL)
/** Return the value of the ATOMIC_WRITES field */
#define DICT_TF_GET_ATOMIC_WRITES(flags) \
((flags & DICT_TF_MASK_ATOMIC_WRITES) \
>> DICT_TF_POS_ATOMIC_WRITES)
/** Return the contents of the UNUSED bits */
#define DICT_TF_GET_UNUSED(flags) \
(flags >> DICT_TF_POS_UNUSED)
......
/*****************************************************************************
Copyright (C) 2013 SkySQL Ab. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*****************************************************************************/
/******************************************************************//**
@file include/dict0pagecompress.h
Helper functions for extracting/storing page compression information
to dictionary.
Created 11/12/2013 Jan Lindström jan.lindstrom@skysql.com
***********************************************************************/
#ifndef dict0pagecompress_h
#define dict0pagecompress_h
/********************************************************************//**
Extract the page compression level from table flags.
@return page compression level, or 0 if not compressed */
UNIV_INLINE
ulint
dict_tf_get_page_compression_level(
/*===============================*/
ulint flags) /*!< in: flags */
__attribute__((const));
/********************************************************************//**
Extract the page compression flag from table flags
@return page compression flag, or false if not compressed */
UNIV_INLINE
ibool
dict_tf_get_page_compression(
/*==========================*/
ulint flags) /*!< in: flags */
__attribute__((const));
/********************************************************************//**
Check whether the table uses the page compressed page format.
@return page compression level, or 0 if not compressed */
UNIV_INLINE
ulint
dict_table_page_compression_level(
/*==============================*/
const dict_table_t* table) /*!< in: table */
__attribute__((const));
/********************************************************************//**
Verify that dictionary flags match tablespace flags
@return true if flags match, false if not */
UNIV_INLINE
ibool
dict_tf_verify_flags(
/*=================*/
ulint table_flags, /*!< in: dict_table_t::flags */
ulint fsp_flags) /*!< in: fil_space_t::flags */
__attribute__((const));
/********************************************************************//**
Extract the atomic writes flag from table flags.
@return true if atomic writes are used, false if not used */
UNIV_INLINE
atomic_writes_t
dict_tf_get_atomic_writes(
/*======================*/
ulint flags) /*!< in: flags */
__attribute__((const));
/********************************************************************//**
Check whether the table uses the atomic writes.
@return true if atomic writes is used, false if not */
UNIV_INLINE
atomic_writes_t
dict_table_get_atomic_writes(
/*=========================*/
const dict_table_t* table); /*!< in: table */
#ifndef UNIV_NONINL
#include "dict0pagecompress.ic"
#endif
#endif
/*****************************************************************************
Copyright (C) 2013 SkySQL Ab. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*****************************************************************************/
/******************************************************************//**
@file include/dict0pagecompress.ic
Inline implementation for helper functions for extracting/storing
page compression and atomic writes information to dictionary.
Created 11/12/2013 Jan Lindström jan.lindstrom@skysql.com
***********************************************************************/
/********************************************************************//**
Verify that dictionary flags match tablespace flags
@return true if flags match, false if not */
UNIV_INLINE
ibool
dict_tf_verify_flags(
/*=================*/
ulint table_flags, /*!< in: dict_table_t::flags */
ulint fsp_flags) /*!< in: fil_space_t::flags */
{
ulint table_unused = DICT_TF_GET_UNUSED(table_flags);
ulint compact = DICT_TF_GET_COMPACT(table_flags);
ulint ssize = DICT_TF_GET_ZIP_SSIZE(table_flags);
ulint atomic_blobs = DICT_TF_HAS_ATOMIC_BLOBS(table_flags);
ulint data_dir = DICT_TF_HAS_DATA_DIR(table_flags);
ulint page_compression = DICT_TF_GET_PAGE_COMPRESSION(table_flags);
ulint page_compression_level = DICT_TF_GET_PAGE_COMPRESSION_LEVEL(table_flags);
ulint atomic_writes = DICT_TF_GET_ATOMIC_WRITES(table_flags);
ulint post_antelope = FSP_FLAGS_GET_POST_ANTELOPE(fsp_flags);
ulint zip_ssize = FSP_FLAGS_GET_ZIP_SSIZE(fsp_flags);
ulint fsp_atomic_blobs = FSP_FLAGS_HAS_ATOMIC_BLOBS(fsp_flags);
ulint page_ssize = FSP_FLAGS_GET_PAGE_SSIZE(fsp_flags);
ulint fsp_unused = FSP_FLAGS_GET_UNUSED(fsp_flags);
ulint fsp_page_compression = FSP_FLAGS_GET_PAGE_COMPRESSION(fsp_flags);
ulint fsp_page_compression_level = FSP_FLAGS_GET_PAGE_COMPRESSION_LEVEL(fsp_flags);
ulint fsp_atomic_writes = FSP_FLAGS_GET_ATOMIC_WRITES(fsp_flags);
DBUG_EXECUTE_IF("dict_tf_verify_flags_failure",
return(ULINT_UNDEFINED););
ut_a(!table_unused);
ut_a(!fsp_unused);
ut_a(page_ssize == 0 || page_ssize != 0); /* silence compiler */
ut_a(compact == 0 || compact == 1); /* silence compiler */
ut_a(data_dir == 0 || data_dir == 1); /* silence compiler */
ut_a(post_antelope == 0 || post_antelope == 1); /* silence compiler */
if (ssize != zip_ssize) {
fprintf(stderr,
"InnoDB: Error: table flags has zip_ssize %ld"
" in the data dictionary\n"
"InnoDB: but the flags in file has zip_ssize %ld\n",
ssize, zip_ssize);
return (FALSE);
}
if (atomic_blobs != fsp_atomic_blobs) {
fprintf(stderr,
"InnoDB: Error: table flags has atomic_blobs %ld"
" in the data dictionary\n"
"InnoDB: but the flags in file has atomic_blobs %ld\n",
atomic_blobs, fsp_atomic_blobs);
return (FALSE);
}
if (page_compression != fsp_page_compression) {
fprintf(stderr,
"InnoDB: Error: table flags has page_compression %ld"
" in the data dictionary\n"
"InnoDB: but the flags in file ahas page_compression %ld\n",
page_compression, fsp_page_compression);
return (FALSE);
}
if (page_compression_level != fsp_page_compression_level) {
fprintf(stderr,
"InnoDB: Error: table flags has page_compression_level %ld"
" in the data dictionary\n"
"InnoDB: but the flags in file has page_compression_level %ld\n",
page_compression_level, fsp_page_compression_level);
return (FALSE);
}
if (atomic_writes != fsp_atomic_writes) {
fprintf(stderr,
"InnoDB: Error: table flags has atomic writes %ld"
" in the data dictionary\n"
"InnoDB: but the flags in file has atomic_writes %ld\n",
atomic_writes, fsp_atomic_writes);
return (FALSE);
}
return(TRUE);
}
/********************************************************************//**
Extract the page compression level from dict_table_t::flags.
These flags are in memory, so assert that they are valid.
@return page compression level, or 0 if not compressed */
UNIV_INLINE
ulint
dict_tf_get_page_compression_level(
/*===============================*/
ulint flags) /*!< in: flags */
{
ulint page_compression_level = DICT_TF_GET_PAGE_COMPRESSION_LEVEL(flags);
ut_ad(page_compression_level >= 0 && page_compression_level <= 9);
return(page_compression_level);
}
/********************************************************************//**
Check whether the table uses the page compression page format.
@return page compression level, or 0 if not compressed */
UNIV_INLINE
ulint
dict_table_page_compression_level(
/*==============================*/
const dict_table_t* table) /*!< in: table */
{
ut_ad(table);
ut_ad(dict_tf_get_page_compression(table->flags));
return(dict_tf_get_page_compression_level(table->flags));
}
/********************************************************************//**
Check whether the table uses the page compression page format.
@return true if page compressed, false if not */
UNIV_INLINE
ibool
dict_tf_get_page_compression(
/*=========================*/
ulint flags) /*!< in: flags */
{
return(DICT_TF_GET_PAGE_COMPRESSION(flags));
}
/********************************************************************//**
Check whether the table uses the page compression page format.
@return true if page compressed, false if not */
UNIV_INLINE
ibool
dict_table_is_page_compressed(
/*==========================*/
const dict_table_t* table) /*!< in: table */
{
return (dict_tf_get_page_compression(table->flags));
}
/********************************************************************//**
Extract the atomic writes flag from table flags.
@return enumerated value of atomic writes */
UNIV_INLINE
atomic_writes_t
dict_tf_get_atomic_writes(
/*======================*/
ulint flags) /*!< in: flags */
{
return((atomic_writes_t)DICT_TF_GET_ATOMIC_WRITES(flags));
}
/********************************************************************//**
Check whether the table uses the atomic writes.
@return enumerated value of atomic writes */
UNIV_INLINE
atomic_writes_t
dict_table_get_atomic_writes(
/*=========================*/
const dict_table_t* table) /*!< in: table */
{
return ((atomic_writes_t)dict_tf_get_atomic_writes(table->flags));
}
/*****************************************************************************
Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 2014, SkySQL Ab. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -75,6 +76,13 @@ enum ib_quiesce_t {
QUIESCE_COMPLETE /*!< All done */
};
/** Enum values for atomic_writes table option */
typedef enum {
ATOMIC_WRITES_DEFAULT = 0,
ATOMIC_WRITES_ON = 1,
ATOMIC_WRITES_OFF = 2
} atomic_writes_t;
/** Prefix for tmp tables, adopted from sql/table.h */
#define tmp_file_prefix "#sql"
#define tmp_file_prefix_length 4
......
/*****************************************************************************
Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 2014, SkySQL Ab. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -130,6 +131,10 @@ extern fil_addr_t fil_addr_null;
#define FIL_PAGE_SPACE_ID FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID
#define FIL_PAGE_DATA 38 /*!< start of the data on the page */
/* Following are used when page compression is used */
#define FIL_PAGE_COMPRESSED_SIZE 2 /*!< Number of bytes used to store
actual payload data size on
compressed pages. */
/* @} */
/** File page trailer @{ */
#define FIL_PAGE_END_LSN_OLD_CHKSUM 8 /*!< the low 4 bytes of this are used
......@@ -142,6 +147,7 @@ extern fil_addr_t fil_addr_null;
#ifndef UNIV_INNOCHECKSUM
/** File page types (values of FIL_PAGE_TYPE) @{ */
#define FIL_PAGE_PAGE_COMPRESSED 34354 /*!< page compressed page */
#define FIL_PAGE_INDEX 17855 /*!< B-tree node */
#define FIL_PAGE_UNDO_LOG 2 /*!< Undo log page */
#define FIL_PAGE_INODE 3 /*!< Index node */
......@@ -204,6 +210,7 @@ ulint
fil_space_get_type(
/*===============*/
ulint id); /*!< in: space id */
#endif /* !UNIV_HOTBACKUP */
/*******************************************************************//**
Appends a new file to the chain of files of a space. File must be closed.
......@@ -747,8 +754,13 @@ fil_io(
void* buf, /*!< in/out: buffer where to store read data
or from where to write; in aio this must be
appropriately aligned */
void* message) /*!< in: message for aio handler if non-sync
void* message, /*!< in: message for aio handler if non-sync
aio used, else ignored */
ulint* write_size) /*!< in/out: Actual write size initialized
after fist successfull trim
operation for this page and if
initialized we do not trim again if
actual page size does not decrease. */
__attribute__((nonnull(8)));
/**********************************************************************//**
Waits for an aio operation to complete. This function is used to write the
......@@ -988,4 +1000,30 @@ fil_mtr_rename_log(
__attribute__((nonnull));
#endif /* !UNIV_INNOCHECKSUM */
/****************************************************************//**
Acquire fil_system mutex */
void
fil_system_enter(void);
/*==================*/
/****************************************************************//**
Release fil_system mutex */
void
fil_system_exit(void);
/*==================*/
#ifndef UNIV_INNOCHECKSUM
/*******************************************************************//**
Returns the table space by a given id, NULL if not found. */
fil_space_t*
fil_space_get_by_id(
/*================*/
ulint id); /*!< in: space id */
/*******************************************************************//**
Return space name */
char*
fil_space_name(
/*===========*/
fil_space_t* space); /*!< in: space */
#endif
#endif /* fil0fil_h */
/*****************************************************************************
Copyright (C) 2013, 2014 SkySQL Ab. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*****************************************************************************/
#ifndef fil0pagecompress_h
#define fil0pagecompress_h
#include "fsp0fsp.h"
#include "fsp0pagecompress.h"
/******************************************************************//**
@file include/fil0pagecompress.h
Helper functions for extracting/storing page compression and
atomic writes information to table space.
Created 11/12/2013 Jan Lindström jan.lindstrom@skysql.com
***********************************************************************/
/*******************************************************************//**
Returns the page compression level flag of the space, or 0 if the space
is not compressed. The tablespace must be cached in the memory cache.
@return page compression level if page compressed, ULINT_UNDEFINED if space not found */
ulint
fil_space_get_page_compression_level(
/*=================================*/
ulint id); /*!< in: space id */
/*******************************************************************//**
Returns the page compression flag of the space, or false if the space
is not compressed. The tablespace must be cached in the memory cache.
@return true if page compressed, false if not or space not found */
ibool
fil_space_is_page_compressed(
/*=========================*/
ulint id); /*!< in: space id */
/*******************************************************************//**
Returns the atomic writes flag of the space, or false if the space
is not using atomic writes. The tablespace must be cached in the memory cache.
@return atomic write table option value */
atomic_writes_t
fil_space_get_atomic_writes(
/*=========================*/
ulint id); /*!< in: space id */
/*******************************************************************//**
Find out wheather the page is index page or not
@return true if page type index page, false if not */
ibool
fil_page_is_index_page(
/*===================*/
byte *buf); /*!< in: page */
/****************************************************************//**
Get the name of the compression algorithm used for page
compression.
@return compression algorithm name or "UNKNOWN" if not known*/
const char*
fil_get_compression_alg_name(
/*=========================*/
ulint comp_alg); /*!<in: compression algorithm number */
/****************************************************************//**
For page compressed pages compress the page before actual write
operation.
@return compressed page to be written*/
byte*
fil_compress_page(
/*==============*/
ulint space_id, /*!< in: tablespace id of the
table. */
byte* buf, /*!< in: buffer from which to write; in aio
this must be appropriately aligned */
byte* out_buf, /*!< out: compressed buffer */
ulint len, /*!< in: length of input buffer.*/
ulint compression_level, /*!< in: compression level */
ulint* out_len, /*!< out: actual length of compressed
page */
byte* lzo_mem); /*!< in: temporal memory used by LZO */
/****************************************************************//**
For page compressed pages decompress the page after actual read
operation.
@return uncompressed page */
void
fil_decompress_page(
/*================*/
byte* page_buf, /*!< in: preallocated buffer or NULL */
byte* buf, /*!< out: buffer from which to read; in aio
this must be appropriately aligned */
ulint len, /*!< in: length of output buffer.*/
ulint* write_size); /*!< in/out: Actual payload size of
the compressed data. */
/****************************************************************//**
Get space id from fil node
@return space id*/
ulint
fil_node_get_space_id(
/*==================*/
fil_node_t* node); /*!< in: Node where to get space id*/
/*******************************************************************//**
Find out wheather the page is page compressed
@return true if page is page compressed*/
ibool
fil_page_is_compressed(
/*===================*/
byte *buf); /*!< in: page */
#endif
/*****************************************************************************
Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, SkySQL Ab. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -53,12 +54,21 @@ to the two Barracuda row formats COMPRESSED and DYNAMIC. */
/** Width of the DATA_DIR flag. This flag indicates that the tablespace
is found in a remote location, not the default data directory. */
#define FSP_FLAGS_WIDTH_DATA_DIR 1
/** Number of flag bits used to indicate the page compression and compression level */
#define FSP_FLAGS_WIDTH_PAGE_COMPRESSION 1
#define FSP_FLAGS_WIDTH_PAGE_COMPRESSION_LEVEL 4
/** Number of flag bits used to indicate atomic writes for this tablespace */
#define FSP_FLAGS_WIDTH_ATOMIC_WRITES 2
/** Width of all the currently known tablespace flags */
#define FSP_FLAGS_WIDTH (FSP_FLAGS_WIDTH_POST_ANTELOPE \
+ FSP_FLAGS_WIDTH_ZIP_SSIZE \
+ FSP_FLAGS_WIDTH_ATOMIC_BLOBS \
+ FSP_FLAGS_WIDTH_PAGE_SSIZE \
+ FSP_FLAGS_WIDTH_DATA_DIR)
+ FSP_FLAGS_WIDTH_DATA_DIR \
+ FSP_FLAGS_WIDTH_PAGE_COMPRESSION \
+ FSP_FLAGS_WIDTH_PAGE_COMPRESSION_LEVEL \
+ FSP_FLAGS_WIDTH_ATOMIC_WRITES)
/** A mask of all the known/used bits in tablespace flags */
#define FSP_FLAGS_MASK (~(~0 << FSP_FLAGS_WIDTH))
......@@ -71,9 +81,20 @@ is found in a remote location, not the default data directory. */
/** Zero relative shift position of the ATOMIC_BLOBS field */
#define FSP_FLAGS_POS_ATOMIC_BLOBS (FSP_FLAGS_POS_ZIP_SSIZE \
+ FSP_FLAGS_WIDTH_ZIP_SSIZE)
/** Zero relative shift position of the PAGE_SSIZE field */
#define FSP_FLAGS_POS_PAGE_SSIZE (FSP_FLAGS_POS_ATOMIC_BLOBS \
/** Note that these need to be before the page size to be compatible with
dictionary */
/** Zero relative shift position of the PAGE_COMPRESSION field */
#define FSP_FLAGS_POS_PAGE_COMPRESSION (FSP_FLAGS_POS_ATOMIC_BLOBS \
+ FSP_FLAGS_WIDTH_ATOMIC_BLOBS)
/** Zero relative shift position of the PAGE_COMPRESSION_LEVEL field */
#define FSP_FLAGS_POS_PAGE_COMPRESSION_LEVEL (FSP_FLAGS_POS_PAGE_COMPRESSION \
+ FSP_FLAGS_WIDTH_PAGE_COMPRESSION)
/** Zero relative shift position of the ATOMIC_WRITES field */
#define FSP_FLAGS_POS_ATOMIC_WRITES (FSP_FLAGS_POS_PAGE_COMPRESSION_LEVEL \
+ FSP_FLAGS_WIDTH_PAGE_COMPRESSION_LEVEL)
/** Zero relative shift position of the PAGE_SSIZE field */
#define FSP_FLAGS_POS_PAGE_SSIZE (FSP_FLAGS_POS_ATOMIC_WRITES \
+ FSP_FLAGS_WIDTH_ATOMIC_WRITES)
/** Zero relative shift position of the start of the UNUSED bits */
#define FSP_FLAGS_POS_DATA_DIR (FSP_FLAGS_POS_PAGE_SSIZE \
+ FSP_FLAGS_WIDTH_PAGE_SSIZE)
......@@ -101,6 +122,18 @@ is found in a remote location, not the default data directory. */
#define FSP_FLAGS_MASK_DATA_DIR \
((~(~0 << FSP_FLAGS_WIDTH_DATA_DIR)) \
<< FSP_FLAGS_POS_DATA_DIR)
/** Bit mask of the PAGE_COMPRESSION field */
#define FSP_FLAGS_MASK_PAGE_COMPRESSION \
((~(~0 << FSP_FLAGS_WIDTH_PAGE_COMPRESSION)) \
<< FSP_FLAGS_POS_PAGE_COMPRESSION)
/** Bit mask of the PAGE_COMPRESSION_LEVEL field */
#define FSP_FLAGS_MASK_PAGE_COMPRESSION_LEVEL \
((~(~0 << FSP_FLAGS_WIDTH_PAGE_COMPRESSION_LEVEL)) \
<< FSP_FLAGS_POS_PAGE_COMPRESSION_LEVEL)
/** Bit mask of the ATOMIC_WRITES field */
#define FSP_FLAGS_MASK_ATOMIC_WRITES \
((~(~0 << FSP_FLAGS_WIDTH_ATOMIC_WRITES)) \
<< FSP_FLAGS_POS_ATOMIC_WRITES)
/** Return the value of the POST_ANTELOPE field */
#define FSP_FLAGS_GET_POST_ANTELOPE(flags) \
......@@ -126,11 +159,38 @@ is found in a remote location, not the default data directory. */
#define FSP_FLAGS_GET_UNUSED(flags) \
(flags >> FSP_FLAGS_POS_UNUSED)
/** Return the value of the PAGE_COMPRESSION field */
#define FSP_FLAGS_GET_PAGE_COMPRESSION(flags) \
((flags & FSP_FLAGS_MASK_PAGE_COMPRESSION) \
>> FSP_FLAGS_POS_PAGE_COMPRESSION)
/** Return the value of the PAGE_COMPRESSION_LEVEL field */
#define FSP_FLAGS_GET_PAGE_COMPRESSION_LEVEL(flags) \
((flags & FSP_FLAGS_MASK_PAGE_COMPRESSION_LEVEL) \
>> FSP_FLAGS_POS_PAGE_COMPRESSION_LEVEL)
/** Return the value of the ATOMIC_WRITES field */
#define FSP_FLAGS_GET_ATOMIC_WRITES(flags) \
((flags & FSP_FLAGS_MASK_ATOMIC_WRITES) \
>> FSP_FLAGS_POS_ATOMIC_WRITES)
/** Set a PAGE_SSIZE into the correct bits in a given
tablespace flags. */
#define FSP_FLAGS_SET_PAGE_SSIZE(flags, ssize) \
(flags | (ssize << FSP_FLAGS_POS_PAGE_SSIZE))
/** Set a PAGE_COMPRESSION into the correct bits in a given
tablespace flags. */
#define FSP_FLAGS_SET_PAGE_COMPRESSION(flags, compression) \
(flags | (compression << FSP_FLAGS_POS_PAGE_COMPRESSION))
/** Set a PAGE_COMPRESSION_LEVEL into the correct bits in a given
tablespace flags. */
#define FSP_FLAGS_SET_PAGE_COMPRESSION_LEVEL(flags, level) \
(flags | (level << FSP_FLAGS_POS_PAGE_COMPRESSION_LEVEL))
/** Set a ATOMIC_WRITES into the correct bits in a given
tablespace flags. */
#define FSP_FLAGS_SET_ATOMIC_WRITES(flags, atomics) \
(flags | (atomics << FSP_FLAGS_POS_ATOMIC_WRITES))
/* @} */
/* @defgroup Tablespace Header Constants (moved from fsp0fsp.c) @{ */
......
/*****************************************************************************
Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, SkySQL Ab. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -63,12 +64,17 @@ fsp_flags_is_valid(
ulint atomic_blobs = FSP_FLAGS_HAS_ATOMIC_BLOBS(flags);
ulint page_ssize = FSP_FLAGS_GET_PAGE_SSIZE(flags);
ulint unused = FSP_FLAGS_GET_UNUSED(flags);
ulint page_compression = FSP_FLAGS_GET_PAGE_COMPRESSION(flags);
ulint page_compression_level = FSP_FLAGS_GET_PAGE_COMPRESSION_LEVEL(flags);
ulint atomic_writes = FSP_FLAGS_GET_ATOMIC_WRITES(flags);
DBUG_EXECUTE_IF("fsp_flags_is_valid_failure", return(false););
/* fsp_flags is zero unless atomic_blobs is set. */
/* Make sure there are no bits that we do not know about. */
if (unused != 0 || flags == 1) {
fprintf(stderr, "InnoDB: Error: Tablespace flags %lu corrupted unused %lu\n",
flags, unused);
return(false);
} else if (post_antelope) {
/* The Antelope row formats REDUNDANT and COMPACT did
......@@ -76,6 +82,8 @@ fsp_flags_is_valid(
4-byte field is zero for Antelope row formats. */
if (!atomic_blobs) {
fprintf(stderr, "InnoDB: Error: Tablespace flags %lu corrupted atomic_blobs %lu\n",
flags, atomic_blobs);
return(false);
}
}
......@@ -87,10 +95,14 @@ fsp_flags_is_valid(
externally stored parts. */
if (post_antelope || zip_ssize != 0) {
fprintf(stderr, "InnoDB: Error: Tablespace flags %lu corrupted zip_ssize %lu atomic_blobs %lu\n",
flags, zip_ssize, atomic_blobs);
return(false);
}
} else if (!post_antelope || zip_ssize > PAGE_ZIP_SSIZE_MAX) {
fprintf(stderr, "InnoDB: Error: Tablespace flags %lu corrupted zip_ssize %lu max %d\n",
flags, zip_ssize, PAGE_ZIP_SSIZE_MAX);
return(false);
} else if (page_ssize > UNIV_PAGE_SSIZE_MAX) {
......@@ -98,12 +110,33 @@ fsp_flags_is_valid(
be zero for an original 16k page size.
Validate the page shift size is within allowed range. */
fprintf(stderr, "InnoDB: Error: Tablespace flags %lu corrupted page_ssize %lu max %lu\n",
flags, page_ssize, UNIV_PAGE_SSIZE_MAX);
return(false);
} else if (UNIV_PAGE_SIZE != UNIV_PAGE_SIZE_ORIG && !page_ssize) {
fprintf(stderr, "InnoDB: Error: Tablespace flags %lu corrupted page_ssize %lu max %lu:%d\n",
flags, page_ssize, UNIV_PAGE_SIZE, UNIV_PAGE_SIZE_ORIG);
return(false);
}
/* Page compression level requires page compression and atomic blobs
to be set */
if (page_compression_level || page_compression) {
if (!page_compression || !atomic_blobs) {
fprintf(stderr, "InnoDB: Error: Tablespace flags %lu corrupted page_compression %lu\n"
"InnoDB: Error: page_compression_level %lu atomic_blobs %lu\n",
flags, page_compression, page_compression_level, atomic_blobs);
return(false);
}
}
if (atomic_writes < 0 || atomic_writes > ATOMIC_WRITES_OFF) {
fprintf(stderr, "InnoDB: Error: Tablespace flags %lu corrupted atomic_writes %lu\n",
flags, atomic_writes);
return (false);
}
#if UNIV_FORMAT_MAX != UNIV_FORMAT_B
# error "UNIV_FORMAT_MAX != UNIV_FORMAT_B, Add more validations."
#endif
......@@ -312,3 +345,4 @@ xdes_calc_descriptor_page(
}
#endif /* !UNIV_INNOCHECKSUM */
/*****************************************************************************
Copyright (C) 2013, 2014 SkySQL Ab. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*****************************************************************************/
/******************************************************************//**
@file include/fsp0pagecompress.h
Helper functions for extracting/storing page compression and
atomic writes information to file space.
Created 11/12/2013 Jan Lindström jan.lindstrom@skysql.com
***********************************************************************/
#ifndef fsp0pagecompress_h
#define fsp0pagecompress_h
#define PAGE_UNCOMPRESSED 0
#define PAGE_ZLIB_ALGORITHM 1
#define PAGE_LZ4_ALGORITHM 2
#define PAGE_LZO_ALGORITHM 3
#define PAGE_ALGORITHM_LAST PAGE_LZO_ALGORITHM
/**********************************************************************//**
Reads the page compression level from the first page of a tablespace.
@return page compression level, or 0 if uncompressed */
UNIV_INTERN
ulint
fsp_header_get_compression_level(
/*=============================*/
const page_t* page); /*!< in: first page of a tablespace */
/********************************************************************//**
Determine if the tablespace is page compressed from dict_table_t::flags.
@return TRUE if page compressed, FALSE if not compressed */
UNIV_INLINE
ibool
fsp_flags_is_page_compressed(
/*=========================*/
ulint flags); /*!< in: tablespace flags */
/********************************************************************//**
Extract the page compression level from tablespace flags.
A tablespace has only one physical page compression level
whether that page is compressed or not.
@return page compression level of the file-per-table tablespace,
or zero if the table is not compressed. */
UNIV_INLINE
ulint
fsp_flags_get_page_compression_level(
/*=================================*/
ulint flags); /*!< in: tablespace flags */
/********************************************************************//**
Determine the tablespace is using atomic writes from dict_table_t::flags.
@return true if atomic writes is used, false if not */
UNIV_INLINE
atomic_writes_t
fsp_flags_get_atomic_writes(
/*========================*/
ulint flags); /*!< in: tablespace flags */
#ifndef UNIV_NONINL
#include "fsp0pagecompress.ic"
#endif
#endif
/*****************************************************************************
Copyright (C) 2013,2014 SkySQL Ab. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*****************************************************************************/
/******************************************************************//**
@file include/fsp0pagecompress.ic
Implementation for helper functions for extracting/storing page
compression and atomic writes information to file space.
Created 11/12/2013 Jan Lindström jan.lindstrom@skysql.com
***********************************************************************/
/********************************************************************//**
Determine if the tablespace is page compressed from dict_table_t::flags.
@return TRUE if page compressed, FALSE if not page compressed */
UNIV_INLINE
ibool
fsp_flags_is_page_compressed(
/*=========================*/
ulint flags) /*!< in: tablespace flags */
{
return(FSP_FLAGS_GET_PAGE_COMPRESSION(flags));
}
/********************************************************************//**
Determine the tablespace is page compression level from dict_table_t::flags.
@return page compression level or 0 if not compressed*/
UNIV_INLINE
ulint
fsp_flags_get_page_compression_level(
/*=================================*/
ulint flags) /*!< in: tablespace flags */
{
return(FSP_FLAGS_GET_PAGE_COMPRESSION_LEVEL(flags));
}
/********************************************************************//**
Determine the tablespace is using atomic writes from dict_table_t::flags.
@return true if atomic writes is used, false if not */
UNIV_INLINE
atomic_writes_t
fsp_flags_get_atomic_writes(
/*========================*/
ulint flags) /*!< in: tablespace flags */
{
return((atomic_writes_t)FSP_FLAGS_GET_ATOMIC_WRITES(flags));
}
/*******************************************************************//**
Find out wheather the page is index page or not
@return true if page type index page, false if not */
UNIV_INLINE
ibool
fil_page_is_index_page(
/*===================*/
byte *buf) /*!< in: page */
{
return(mach_read_from_2(buf+FIL_PAGE_TYPE) == FIL_PAGE_INDEX);
}
/*******************************************************************//**
Find out wheather the page is page compressed
@return true if page is page compressed, false if not */
UNIV_INLINE
ibool
fil_page_is_compressed(
/*===================*/
byte *buf) /*!< in: page */
{
return(mach_read_from_2(buf+FIL_PAGE_TYPE) == FIL_PAGE_PAGE_COMPRESSED);
}
/*******************************************************************//**
Returns the page compression level of the space, or 0 if the space
is not compressed. The tablespace must be cached in the memory cache.
@return page compression level, ULINT_UNDEFINED if space not found */
UNIV_INLINE
ulint
fil_space_get_page_compression_level(
/*=================================*/
ulint id) /*!< in: space id */
{
ulint flags;
flags = fil_space_get_flags(id);
if (flags && flags != ULINT_UNDEFINED) {
return(fsp_flags_get_page_compression_level(flags));
}
return(flags);
}
/*******************************************************************//**
Extract the page compression from space.
@return true if space is page compressed, false if space is not found
or space is not page compressed. */
UNIV_INLINE
ibool
fil_space_is_page_compressed(
/*=========================*/
ulint id) /*!< in: space id */
{
ulint flags;
flags = fil_space_get_flags(id);
if (flags && flags != ULINT_UNDEFINED) {
return(fsp_flags_is_page_compressed(flags));
}
return(flags);
}
/****************************************************************//**
Get the name of the compression algorithm used for page
compression.
@return compression algorithm name or "UNKNOWN" if not known*/
UNIV_INLINE
const char*
fil_get_compression_alg_name(
/*=========================*/
ulint comp_alg) /*!<in: compression algorithm number */
{
switch(comp_alg) {
case PAGE_UNCOMPRESSED:
return ("uncompressed");
break;
case PAGE_ZLIB_ALGORITHM:
return ("ZLIB");
break;
case PAGE_LZ4_ALGORITHM:
return ("LZ4");
break;
case PAGE_LZO_ALGORITHM:
return ("LZO");
break;
default:
return("UNKNOWN");
ut_error;
break;
}
}
/*******************************************************************//**
Returns the atomic writes flag of the space, or false if the space
is not using atomic writes. The tablespace must be cached in the memory cache.
@return atomic writes table option value */
UNIV_INLINE
atomic_writes_t
fil_space_get_atomic_writes(
/*========================*/
ulint id) /*!< in: space id */
{
ulint flags;
flags = fil_space_get_flags(id);
if (flags && flags != ULINT_UNDEFINED) {
return((atomic_writes_t)fsp_flags_get_atomic_writes(flags));
}
return((atomic_writes_t)0);
}
......@@ -29,6 +29,7 @@ Created May 26, 2009 Vasil Dimov
#include "univ.i"
#include "fil0fil.h" /* for FIL_PAGE_DATA */
#include "ut0byte.h"
/** @name Flags for inserting records in order
If records are inserted in order, there are the following
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment