Skip to content

Commit 98909ce

Browse files
Sunny BainsSunny Bains
Sunny Bains
authored and
Sunny Bains
committed
WL#7696 - Backport code from mysql-trunk to mysql-5.7
1 parent c104981 commit 98909ce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+11000
-5726
lines changed

extra/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License as published by
@@ -86,6 +86,9 @@ MYSQL_ADD_EXECUTABLE(replace replace.c)
8686
TARGET_LINK_LIBRARIES(replace mysys)
8787

8888
IF(WITH_INNOBASE_STORAGE_ENGINE)
89+
90+
INCLUDE(${CMAKE_SOURCE_DIR}/storage/innobase/lz4.cmake)
91+
8992
# Add path to the InnoDB headers
9093
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/storage/innobase/include ${CMAKE_SOURCE_DIR}/sql)
9194
# We use the InnoDB code directly in case the code changes.
@@ -96,6 +99,7 @@ IF(WITH_INNOBASE_STORAGE_ENGINE)
9699
../storage/innobase/ut/ut0ut.cc
97100
../storage/innobase/buf/buf0buf.cc
98101
../storage/innobase/page/page0zip.cc
102+
../storage/innobase/os/os0file.cc
99103
)
100104

101105
MYSQL_ADD_EXECUTABLE(innochecksum innochecksum.cc ${INNOBASE_SOURCES})

extra/innochecksum.cc

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ The parts not included are excluded by #ifndef UNIV_INNOCHECKSUM. */
5050
#include "fut0lst.h" /* FLST_NODE_SIZE */
5151
#include "buf0checksum.h" /* buf_calc_page_*() */
5252
#include "fil0fil.h" /* FIL_* */
53+
#include "os0file.h"
5354
#include "fsp0fsp.h" /* fsp_flags_get_page_size() &
5455
fsp_flags_get_zip_size() */
5556
#include "mach0data.h" /* mach_read_from_4() */
@@ -176,6 +177,25 @@ get_page_size(
176177
return(page_size_t(flags));
177178
}
178179

180+
/** Decompress a page
181+
@param[in,out] buf Page read from disk, uncompressed data will
182+
also be copied to this page
183+
@param[in, out] scratch Page to use for temporary decompress
184+
@param[in] page_size scratch physical size
185+
@return true if decompress succeeded */
186+
static
187+
bool page_decompress(
188+
byte* buf,
189+
byte* scratch,
190+
page_size_t page_size)
191+
{
192+
dberr_t err;
193+
194+
err = os_file_decompress_page(buf, scratch, page_size.physical());
195+
196+
return(err == DB_SUCCESS);
197+
}
198+
179199
#ifdef _WIN32
180200
/***********************************************//*
181201
@param [in] error error no. from the getLastError().
@@ -1335,6 +1355,8 @@ int main(
13351355
"======================================\n");
13361356
}
13371357

1358+
byte* tbuf = (byte*) malloc(UNIV_PAGE_SIZE_MAX);
1359+
13381360
/* main checksumming loop */
13391361
cur_page_num = start_page;
13401362
lastt = 0;
@@ -1354,13 +1376,16 @@ int main(
13541376
page_size.physical());
13551377
perror(" ");
13561378

1379+
free(tbuf);
1380+
13571381
DBUG_RETURN(1);
13581382
}
13591383

13601384
if (bytes != page_size.physical()) {
13611385
fprintf(stderr, "Error: bytes read (%lu) "
13621386
"doesn't match page size (%lu)\n",
13631387
bytes, page_size.physical());
1388+
free(tbuf);
13641389
DBUG_RETURN(1);
13651390
}
13661391

@@ -1369,6 +1394,15 @@ int main(
13691394
skip_page = is_page_doublewritebuffer(buf);
13701395
} else {
13711396
skip_page = false;
1397+
1398+
if (!page_decompress(buf, tbuf, page_size)) {
1399+
1400+
fprintf(stderr,
1401+
"Page decompress failed");
1402+
1403+
free(tbuf);
1404+
DBUG_RETURN(1);
1405+
}
13721406
}
13731407

13741408
/* If no-check is enabled, skip the
@@ -1394,6 +1428,7 @@ int main(
13941428
"count::%" PRIuMAX "\n",
13951429
allow_mismatches);
13961430

1431+
free(tbuf);
13971432
DBUG_RETURN(1);
13981433
}
13991434
}
@@ -1406,6 +1441,7 @@ int main(
14061441
page_size.is_compressed(), &pos,
14071442
static_cast<ulong>(page_size.physical()))) {
14081443

1444+
free(tbuf);
14091445
DBUG_RETURN(1);
14101446
}
14111447

@@ -1438,6 +1474,8 @@ int main(
14381474
}
14391475
}
14401476

1477+
free(tbuf);
1478+
14411479
if (!read_from_stdin) {
14421480
/* flcose() will flush the data and release the lock if
14431481
any acquired. */

mysql-test/include/innodb-util.inc

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ sub ib_normalize_path {
1212
my ($path) = @_;
1313
}
1414

15-
sub ib_backup_tablespace {
15+
sub ib_backup_ibd_file {
1616
my ($db, $table) = @_;
1717
my $datadir = $ENV{'MYSQLD_DATADIR'};
18-
my $cfg_file = sprintf("%s.cfg", $table);
1918
my $ibd_file = sprintf("%s.ibd", $table);
2019
my $tmpd = $ENV{'MYSQLTEST_VARDIR'} . "/tmp";
2120

@@ -24,12 +23,28 @@ sub ib_backup_tablespace {
2423

2524
copy(@args) or die "copy @args failed: $!";
2625

26+
copy(@args) or die "copy @args failed: $!";
27+
}
28+
29+
sub ib_backup_cfg_file {
30+
my ($db, $table) = @_;
31+
my $datadir = $ENV{'MYSQLD_DATADIR'};
32+
my $cfg_file = sprintf("%s.cfg", $table);
33+
my $tmpd = $ENV{'MYSQLTEST_VARDIR'} . "/tmp";
34+
2735
my @args = (File::Spec->catfile($datadir, $db, $cfg_file),
2836
File::Spec->catfile($tmpd, $cfg_file));
2937

3038
copy(@args) or die "copy @args failed: $!";
3139
}
3240

41+
sub ib_backup_tablespace {
42+
my ($db, $table) = @_;
43+
44+
ib_backup_ibd_file($db, $table);
45+
ib_backup_cfg_file($db, $table);
46+
}
47+
3348
sub ib_cleanup {
3449
my ($db, $table) = @_;
3550
my $datadir = $ENV{'MYSQLD_DATADIR'};
@@ -125,4 +140,5 @@ sub ib_restore_ibd_files {
125140
ib_restore_ibd_file($tmpd, $datadir, $db, $table);
126141
}
127142
}
143+
128144
EOF

mysql-test/suite/innodb/r/innodb-wl6045-1.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ call mtr.add_suppression("\\[ERROR\\] InnoDB: Database page corruption on disk o
44
SET GLOBAL innodb_file_per_table=on;
55
[1]: Test is to corrupt the ibd file, & do repair for (innodb|crc32|none) checksum through innochecksum tool
66
# Create and populate the table to be corrupted
7-
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB;
7+
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) COMPRESSION="none", ENGINE=InnoDB;
88
INSERT INTO t1 (b) VALUES ('corrupt me');
99
INSERT INTO t1 (b) VALUES ('corrupt me');
1010
# Shutdown the server
@@ -38,7 +38,7 @@ select count(*) from t1;
3838
select * from t1;
3939
DROP TABLE t1;
4040
[19]: Test Completed
41-
CREATE TABLE tab1(c1 INT PRIMARY KEY,c2 VARCHAR(20)) ENGINE=InnoDB;
41+
CREATE TABLE tab1(c1 INT PRIMARY KEY,c2 VARCHAR(20)) COMPRESSION="none", ENGINE=InnoDB;
4242
CREATE INDEX idx1 ON tab1(c2(10));
4343
INSERT INTO tab1 VALUES(1, 'Innochecksum InnoDB1');
4444
# shutdown the server

mysql-test/suite/innodb/r/innodb-wl6045-linux.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ SET GLOBAL innodb_file_per_table=on;
22
SHOW variables like '%innodb_checksum_algorithm%';
33
Variable_name Value
44
innodb_checksum_algorithm innodb
5-
CREATE TABLE t1(c1 INT PRIMARY KEY,c2 VARCHAR(20)) ENGINE=InnoDB;
5+
CREATE TABLE t1(c1 INT PRIMARY KEY,c2 VARCHAR(20)) COMPRESSION="none", ENGINE=InnoDB;
66
INSERT INTO t1 VALUES(1, 'Innochecksum InnoDB');
77
INSERT INTO t1 VALUES(2, 'Innochecksum CRC32');
88
# Shutdown the Server

mysql-test/suite/innodb/r/innodb_bug14147491.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Create and populate the table to be corrupted
2-
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB;
2+
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) COMPRESSION="none", ENGINE=InnoDB;
33
INSERT INTO t1 (b) VALUES ('corrupt me');
44
INSERT INTO t1 (b) VALUES ('corrupt me');
55
# Backup the t1.ibd before corrupting
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
DROP TABLE IF EXISTS t1;
2+
SET GLOBAL innodb_file_per_table = 1;
3+
SELECT @@innodb_file_per_table;
4+
@@innodb_file_per_table
5+
1
6+
CREATE TABLE t1(c1 INT PRIMARY KEY) COMPRESSION = "ZLIB" ENGINE = InnoDB;
7+
SHOW CREATE TABLE t1;
8+
Table Create Table
9+
t1 CREATE TABLE `t1` (
10+
`c1` int(11) NOT NULL,
11+
PRIMARY KEY (`c1`)
12+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMPRESS='ZLIB'
13+
INSERT INTO t1 VALUES(1),(2),(3),(4);
14+
FLUSH TABLES t1 WITH READ LOCK;
15+
UNLOCK TABLES;
16+
SELECT * FROM t1;
17+
c1
18+
1
19+
2
20+
3
21+
4
22+
ALTER TABLE t1 COMPRESSION = "";
23+
OPTIMIZE TABLE t1;
24+
Table Op Msg_type Msg_text
25+
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
26+
test.t1 optimize status OK
27+
SHOW CREATE TABLE t1;
28+
Table Create Table
29+
t1 CREATE TABLE `t1` (
30+
`c1` int(11) NOT NULL,
31+
PRIMARY KEY (`c1`)
32+
) ENGINE=InnoDB DEFAULT CHARSET=latin1
33+
SELECT * FROM t1;
34+
c1
35+
1
36+
2
37+
3
38+
4
39+
ALTER TABLE t1 COMPRESSION = "ZLIB";
40+
OPTIMIZE TABLE t1;
41+
Table Op Msg_type Msg_text
42+
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
43+
test.t1 optimize status OK
44+
SHOW CREATE TABLE t1;
45+
Table Create Table
46+
t1 CREATE TABLE `t1` (
47+
`c1` int(11) NOT NULL,
48+
PRIMARY KEY (`c1`)
49+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMPRESS='ZLIB'
50+
SELECT NAME, COMPRESSION
51+
FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES WHERE NAME LIKE '%t1';
52+
NAME COMPRESSION
53+
test/t1 Zlib
54+
SELECT * FROM t1;
55+
c1
56+
1
57+
2
58+
3
59+
4
60+
ALTER TABLE t1 COMPRESSION = "BLAH";
61+
ERROR HY000: Table storage engine 'InnoDB' does not support the create option 'COMPRESSION'
62+
SHOW WARNINGS;
63+
Level Code Message
64+
Warning 1112 InnoDB: Unsupported compression algorithm 'BLAH'
65+
Error 1478 Table storage engine 'InnoDB' does not support the create option 'COMPRESSION'
66+
SHOW CREATE TABLE t1;
67+
Table Create Table
68+
t1 CREATE TABLE `t1` (
69+
`c1` int(11) NOT NULL,
70+
PRIMARY KEY (`c1`)
71+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMPRESS='ZLIB'
72+
ALTER TABLE t1 COMPRESSION = "NONE";
73+
OPTIMIZE TABLE t1;
74+
Table Op Msg_type Msg_text
75+
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
76+
test.t1 optimize status OK
77+
SHOW CREATE TABLE t1;
78+
Table Create Table
79+
t1 CREATE TABLE `t1` (
80+
`c1` int(11) NOT NULL,
81+
PRIMARY KEY (`c1`)
82+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMPRESS='NONE'
83+
SELECT NAME, COMPRESSION
84+
FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES
85+
WHERE NAME LIKE '%t1';
86+
NAME COMPRESSION
87+
test/t1 None
88+
SELECT * FROM t1;
89+
c1
90+
1
91+
2
92+
3
93+
4
94+
DROP TABLE t1;
95+
CREATE TABLE t1(c1 INT PRIMARY KEY) COMPRESSION = "zlibX" ENGINE = InnoDB;
96+
ERROR HY000: Table storage engine for 't1' doesn't have this option
97+
SHOW WARNINGS;
98+
Level Code Message
99+
Warning 1112 InnoDB: Unsupported compression algorithm 'zlibX'
100+
Error 1031 Table storage engine for 't1' doesn't have this option
101+
SHOW CREATE TABLE t1;
102+
ERROR 42S02: Table 'test.t1' doesn't exist
103+
SET @long_str = REPEAT('ZLIB', 32768);
104+
SET @s = CONCAT('CREATE TABLE t1(c1 INT) ENGINE=InnoDB, COMPRESSION = "', @long_str, '"');
105+
PREPARE stmt from @s;
106+
EXECUTE stmt;
107+
ERROR HY000: String 'ZLIBZLIBZLIBZLIBZLIBZLIBZLIBZLIBZLIBZLIBZLIBZLIBZLIBZLIBZLIBZLIBZLIBZL' is too long for COMPRESS (should be no longer than 2048)
108+
DEALLOCATE PREPARE stmt;
109+
SHOW CREATE TABLE t1;
110+
ERROR 42S02: Table 'test.t1' doesn't exist
111+
SET SESSION innodb_strict_mode = on;
112+
CREATE TABLE t1(c1 INT PRIMARY KEY) COMPRESSION = "zlibX" ENGINE = InnoDB;
113+
ERROR HY000: Table storage engine for 't1' doesn't have this option
114+
SHOW WARNINGS;
115+
Level Code Message
116+
Warning 1112 InnoDB: Unsupported compression algorithm 'zlibX'
117+
Error 1031 Table storage engine for 't1' doesn't have this option
118+
SHOW CREATE TABLE t1;
119+
ERROR 42S02: Table 'test.t1' doesn't exist
120+
CREATE TABLE t1(c1 INT PRIMARY KEY) ENGINE = InnoDB;
121+
SHOW CREATE TABLE t1;
122+
Table Create Table
123+
t1 CREATE TABLE `t1` (
124+
`c1` int(11) NOT NULL,
125+
PRIMARY KEY (`c1`)
126+
) ENGINE=InnoDB DEFAULT CHARSET=latin1
127+
ALTER TABLE t1 COMPRESSION = "BLAH";
128+
ERROR HY000: Table storage engine 'InnoDB' does not support the create option 'COMPRESSION'
129+
SHOW CREATE TABLE t1;
130+
Table Create Table
131+
t1 CREATE TABLE `t1` (
132+
`c1` int(11) NOT NULL,
133+
PRIMARY KEY (`c1`)
134+
) ENGINE=InnoDB DEFAULT CHARSET=latin1
135+
DROP TABLE t1;
136+
SET SESSION innodb_strict_mode = off;
137+
CREATE TABLE t1(C1 INT) ENGINE=InnoDB;
138+
ALTER TABLE t1 COMPRESSION = 'abcdefghijklmnopqrstuvwxyz';
139+
Warnings:
140+
Warning 138 InnoDB: Unsupported compression algorithm 'abcdefghijklmnopqrstuvwxyz'
141+
SELECT TABLE_NAME, CREATE_OPTIONS
142+
FROM INFORMATION_SCHEMA.TABLES
143+
WHERE TABLE_SCHEMA='test' AND TABLE_NAME = 't1';
144+
TABLE_NAME CREATE_OPTIONS
145+
t1 COMPRESS="abcdefg"
146+
SELECT NAME, COMPRESSION
147+
FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES
148+
WHERE NAME LIKE '%t1';
149+
NAME COMPRESSION
150+
test/t1 None
151+
DROP TABLE t1;
152+
SET GLOBAL INNODB_FILE_PER_TABLE = 0;
153+
CREATE TABLE t1(C1 INT) ENGINE=InnoDB COMPRESSION="zlib";
154+
ERROR 42000: Table 't1' uses an extension that doesn't exist in this MySQL version
155+
SHOW WARNINGS;
156+
Level Code Message
157+
Warning 138 InnoDB: Compression not supported for shared tablespaces
158+
Error 1112 Table 't1' uses an extension that doesn't exist in this MySQL version
159+
CREATE TABLE t1(C1 INT) ENGINE=InnoDB COMPRESSION="blah";
160+
ERROR 42000: Table 't1' uses an extension that doesn't exist in this MySQL version
161+
SHOW WARNINGS;
162+
Level Code Message
163+
Warning 138 InnoDB: Unsupported compression algorithm 'blah'
164+
Warning 138 InnoDB: Compression not supported for shared tablespaces
165+
Error 1112 Table 't1' uses an extension that doesn't exist in this MySQL version
166+
SHOW CREATE TABLE t1;
167+
ERROR 42S02: Table 'test.t1' doesn't exist
168+
CREATE TEMPORARY TABLE t1(C1 INT) ENGINE=InnoDB COMPRESSION="zlib";
169+
ERROR 42000: Table 't1' uses an extension that doesn't exist in this MySQL version
170+
SHOW WARNINGS;
171+
Level Code Message
172+
Warning 138 InnoDB: Cannot compress pages of shared tablespaces
173+
Warning 138 InnoDB: Compression not supported for temporary tables
174+
Error 1112 Table 't1' uses an extension that doesn't exist in this MySQL version
175+
CREATE TEMPORARY TABLE t1(C1 INT) ENGINE=InnoDB COMPRESSION="blah";
176+
ERROR 42000: Table 't1' uses an extension that doesn't exist in this MySQL version
177+
SHOW WARNINGS;
178+
Level Code Message
179+
Warning 138 InnoDB: Cannot compress pages of shared tablespaces
180+
Warning 138 InnoDB: Unsupported compression algorithm 'blah'
181+
Warning 138 InnoDB: Compression not supported for temporary tables
182+
Error 1112 Table 't1' uses an extension that doesn't exist in this MySQL version
183+
SHOW CREATE TABLE t1;
184+
ERROR 42S02: Table 'test.t1' doesn't exist
185+
SET GLOBAL INNODB_FILE_PER_TABLE=1;

0 commit comments

Comments
 (0)