Skip to content

Commit c8fcaf8

Browse files
committed
Merge branch 'merge-innodb-5.6' into 10.0
2 parents d520d35 + 220e70f commit c8fcaf8

22 files changed

+705
-158
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#
2+
# Bug #19183565 CREATE DYNAMIC INNODB_TMPDIR VARIABLE TO CONTROL
3+
# WHERE INNODB WRITES TEMP FILES
4+
#
5+
# If innodb_tmpdir is NULL or "", temporary file will be created in
6+
# server configuration variable location(--tmpdir)
7+
create table t1(a int primary key)engine=innodb;
8+
show session variables like 'innodb_tmpdir';
9+
Variable_name Value
10+
innodb_tmpdir
11+
alter table t1 add column b int not null;
12+
set global innodb_tmpdir=NULL;
13+
# Connection con1
14+
show session variables like 'innodb_tmpdir';
15+
Variable_name Value
16+
innodb_tmpdir
17+
alter table t1 add key(b);
18+
drop table t1;
19+
# innodb_tmpdir with invalid path.
20+
create table t1(a int primary key)engine=innodb;
21+
set global innodb_tmpdir='wrong_value';
22+
ERROR 42000: Variable 'innodb_tmpdir' can't be set to the value of 'wrong_value'
23+
show warnings;
24+
Level Code Message
25+
Warning 1210 InnoDB: Path doesn't exist.
26+
Error 1231 Variable 'innodb_tmpdir' can't be set to the value of 'wrong_value'
27+
drop table t1;
28+
# innodb_tmpdir with mysql data directory path.
29+
create table t1(a text, b text, fulltext(a,b))engine=innodb;
30+
insert into t1 values('test1', 'test2');
31+
insert into t1 values('text1', 'text2');
32+
set global innodb_tmpdir = @@global.datadir;
33+
ERROR 42000: Variable 'innodb_tmpdir' can't be set to the value of 'MYSQL_DATADIR'
34+
show warnings;
35+
Level Code Message
36+
Warning 1210 InnoDB: Path Location should not be same as mysql data directory location.
37+
Error 1231 DATADIR/data/'
38+
drop table t1;
39+
# innodb_tmpdir with valid location.
40+
create table t1(a text, b text, fulltext(a,b))engine=innodb;
41+
insert into t1 values('test1', 'test2');
42+
insert into t1 values('text1', 'text2');
43+
set @tmpdir = @@global.tmpdir;
44+
set global innodb_tmpdir = @tmpdir;
45+
show session variables like 'innodb_tmpdir';
46+
Variable_name Value
47+
innodb_tmpdir
48+
# Connection con3
49+
alter table t1 add fulltext(b);
50+
set global innodb_tmpdir=NULL;
51+
drop table t1;

mysql-test/suite/innodb/t/tmpdir.test

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
--source include/have_innodb.inc
2+
--source include/count_sessions.inc
3+
4+
if (`select plugin_auth_version <= "5.6.26-MariaDB-76.0" from information_schema.plugins where plugin_name='innodb'`)
5+
{
6+
--skip Not fixed in XtraDB as of 5.6.26-MariaDB-76.0 or earlier
7+
}
8+
9+
--echo #
10+
--echo # Bug #19183565 CREATE DYNAMIC INNODB_TMPDIR VARIABLE TO CONTROL
11+
--echo # WHERE INNODB WRITES TEMP FILES
12+
--echo #
13+
14+
--echo # If innodb_tmpdir is NULL or "", temporary file will be created in
15+
--echo # server configuration variable location(--tmpdir)
16+
17+
create table t1(a int primary key)engine=innodb;
18+
show session variables like 'innodb_tmpdir';
19+
alter table t1 add column b int not null;
20+
set global innodb_tmpdir=NULL;
21+
--echo # Connection con1
22+
connect (con1,localhost,root);
23+
show session variables like 'innodb_tmpdir';
24+
alter table t1 add key(b);
25+
connection default;
26+
disconnect con1;
27+
drop table t1;
28+
29+
--echo # innodb_tmpdir with invalid path.
30+
31+
create table t1(a int primary key)engine=innodb;
32+
--error ER_WRONG_VALUE_FOR_VAR
33+
set global innodb_tmpdir='wrong_value';
34+
show warnings;
35+
drop table t1;
36+
37+
38+
--echo # innodb_tmpdir with mysql data directory path.
39+
40+
let $MYSQLD_DATADIR= `select @@datadir`;
41+
create table t1(a text, b text, fulltext(a,b))engine=innodb;
42+
insert into t1 values('test1', 'test2');
43+
insert into t1 values('text1', 'text2');
44+
--replace_result $MYSQLD_DATADIR MYSQL_DATADIR
45+
--error ER_WRONG_VALUE_FOR_VAR
46+
set global innodb_tmpdir = @@global.datadir;
47+
--replace_regex /.*mysqld.1/DATADIR/
48+
show warnings;
49+
drop table t1;
50+
51+
--echo # innodb_tmpdir with valid location.
52+
let $MYSQL_TMP_DIR= `select @@tmpdir`;
53+
create table t1(a text, b text, fulltext(a,b))engine=innodb;
54+
insert into t1 values('test1', 'test2');
55+
insert into t1 values('text1', 'text2');
56+
set @tmpdir = @@global.tmpdir;
57+
set global innodb_tmpdir = @tmpdir;
58+
show session variables like 'innodb_tmpdir';
59+
--echo # Connection con3
60+
connect (con3,localhost,root);
61+
# Following alter using innodb_tmpdir as a path to create temporary files
62+
alter table t1 add fulltext(b);
63+
disconnect con3;
64+
connection default;
65+
set global innodb_tmpdir=NULL;
66+
drop table t1;
67+
68+
--source include/wait_until_count_sessions.inc
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
SET @start_global_value = @@global.innodb_tmpdir;
2+
SELECT @start_global_value;
3+
@start_global_value
4+
NULL
5+
select @@session.innodb_tmpdir;
6+
@@session.innodb_tmpdir
7+
NULL
8+
show global variables like 'innodb_tmpdir';
9+
Variable_name Value
10+
innodb_tmpdir
11+
show session variables like 'innodb_tmpdir';
12+
Variable_name Value
13+
innodb_tmpdir
14+
select * from information_schema.global_variables where variable_name='innodb_tmpdir';
15+
VARIABLE_NAME VARIABLE_VALUE
16+
INNODB_TMPDIR
17+
select * from information_schema.session_variables where variable_name='innodb_tmpdir';
18+
VARIABLE_NAME VARIABLE_VALUE
19+
INNODB_TMPDIR
20+
set global innodb_tmpdir=@@global.tmpdir;
21+
set session innodb_tmpdir=@@global.tmpdir;
22+
set global innodb_tmpdir=1.1;
23+
ERROR 42000: Incorrect argument type to variable 'innodb_tmpdir'
24+
set global innodb_tmpdir=1e1;
25+
ERROR 42000: Incorrect argument type to variable 'innodb_tmpdir'
26+
set global innodb_tmpdir=repeat('a',1000);
27+
ERROR 42000: Variable 'innodb_tmpdir' can't be set to the value of 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
28+
show warnings;
29+
Level Code Message
30+
Warning 1210 Path length should not exceed 512 bytes
31+
Error 1231 Variable 'innodb_tmpdir' can't be set to the value of 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
32+
SET @@global.innodb_tmpdir = @start_global_value;
33+
SELECT @@global.innodb_tmpdir;
34+
@@global.innodb_tmpdir
35+
NULL
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
--source include/have_innodb.inc
2+
3+
if (`select plugin_auth_version <= "5.6.26-MariaDB-76.0" from information_schema.plugins where plugin_name='innodb'`)
4+
{
5+
--skip Not fixed in XtraDB as of 5.6.26-MariaDB-76.0 or earlier
6+
}
7+
8+
SET @start_global_value = @@global.innodb_tmpdir;
9+
SELECT @start_global_value;
10+
11+
#
12+
# exists as global and session
13+
#
14+
select @@session.innodb_tmpdir;
15+
16+
show global variables like 'innodb_tmpdir';
17+
show session variables like 'innodb_tmpdir';
18+
19+
select * from information_schema.global_variables where variable_name='innodb_tmpdir';
20+
select * from information_schema.session_variables where variable_name='innodb_tmpdir';
21+
#
22+
# Show that it is writable
23+
#
24+
25+
set global innodb_tmpdir=@@global.tmpdir;
26+
set session innodb_tmpdir=@@global.tmpdir;
27+
28+
#
29+
# incorrect types
30+
#
31+
--error ER_WRONG_TYPE_FOR_VAR
32+
set global innodb_tmpdir=1.1;
33+
--error ER_WRONG_TYPE_FOR_VAR
34+
set global innodb_tmpdir=1e1;
35+
36+
#
37+
# path len more than 512
38+
#
39+
--error ER_WRONG_VALUE_FOR_VAR
40+
set global innodb_tmpdir=repeat('a',1000);
41+
show warnings;
42+
43+
#
44+
# Cleanup
45+
#
46+
47+
SET @@global.innodb_tmpdir = @start_global_value;
48+
SELECT @@global.innodb_tmpdir;

storage/innobase/buf/buf0dump.cc

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
3-
Copyright (c) 2011, 2012, Oracle and/or its affiliates. All Rights Reserved.
3+
Copyright (c) 2011, 2015, Oracle and/or its affiliates. All Rights Reserved.
44
55
This program is free software; you can redistribute it and/or modify it under
66
the terms of the GNU General Public License as published by the Free Software
@@ -167,6 +167,25 @@ buf_load_status(
167167
va_end(ap);
168168
}
169169

170+
/** Returns the directory path where the buffer pool dump file will be created.
171+
@return directory path */
172+
static
173+
const char*
174+
get_buf_dump_dir()
175+
{
176+
const char* dump_dir;
177+
178+
/* The dump file should be created in the default data directory if
179+
innodb_data_home_dir is set as an empty string. */
180+
if (strcmp(srv_data_home, "") == 0) {
181+
dump_dir = fil_path_to_mysql_datadir;
182+
} else {
183+
dump_dir = srv_data_home;
184+
}
185+
186+
return(dump_dir);
187+
}
188+
170189
/*****************************************************************//**
171190
Perform a buffer pool dump into the file specified by
172191
innodb_buffer_pool_filename. If any errors occur then the value of
@@ -190,7 +209,7 @@ buf_dump(
190209
int ret;
191210

192211
ut_snprintf(full_filename, sizeof(full_filename),
193-
"%s%c%s", srv_data_home, SRV_PATH_SEPARATOR,
212+
"%s%c%s", get_buf_dump_dir(), SRV_PATH_SEPARATOR,
194213
srv_buf_dump_filename);
195214

196215
ut_snprintf(tmp_filename, sizeof(tmp_filename),
@@ -463,7 +482,7 @@ buf_load()
463482
buf_load_abort_flag = FALSE;
464483

465484
ut_snprintf(full_filename, sizeof(full_filename),
466-
"%s%c%s", srv_data_home, SRV_PATH_SEPARATOR,
485+
"%s%c%s", get_buf_dump_dir(), SRV_PATH_SEPARATOR,
467486
srv_buf_dump_filename);
468487

469488
buf_load_status(STATUS_NOTICE,

storage/innobase/dict/dict0dict.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,7 @@ dict_init(void)
11071107
&dict_operation_lock, SYNC_DICT_OPERATION);
11081108

11091109
if (!srv_read_only_mode) {
1110-
dict_foreign_err_file = os_file_create_tmpfile();
1110+
dict_foreign_err_file = os_file_create_tmpfile(NULL);
11111111
ut_a(dict_foreign_err_file);
11121112

11131113
mutex_create(dict_foreign_err_mutex_key,

storage/innobase/dict/dict0stats.cc

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
3-
Copyright (c) 2009, 2014, Oracle and/or its affiliates. All Rights Reserved.
3+
Copyright (c) 2009, 2015, Oracle and/or its affiliates. All Rights Reserved.
44
55
This program is free software; you can redistribute it and/or modify it under
66
the terms of the GNU General Public License as published by the Free Software
@@ -1436,16 +1436,14 @@ on the leaf page.
14361436
when comparing records
14371437
@param[out] n_diff number of distinct records
14381438
@param[out] n_external_pages number of external pages
1439-
@param[in,out] mtr mini-transaction
14401439
@return number of distinct records on the leaf page */
14411440
static
14421441
void
14431442
dict_stats_analyze_index_below_cur(
14441443
const btr_cur_t* cur,
14451444
ulint n_prefix,
14461445
ib_uint64_t* n_diff,
1447-
ib_uint64_t* n_external_pages,
1448-
mtr_t* mtr)
1446+
ib_uint64_t* n_external_pages)
14491447
{
14501448
dict_index_t* index;
14511449
ulint space;
@@ -1459,6 +1457,7 @@ dict_stats_analyze_index_below_cur(
14591457
ulint* offsets2;
14601458
ulint* offsets_rec;
14611459
ulint size;
1460+
mtr_t mtr;
14621461

14631462
index = btr_cur_get_index(cur);
14641463

@@ -1497,12 +1496,14 @@ dict_stats_analyze_index_below_cur(
14971496
function without analyzing any leaf pages */
14981497
*n_external_pages = 0;
14991498

1499+
mtr_start(&mtr);
1500+
15001501
/* descend to the leaf level on the B-tree */
15011502
for (;;) {
15021503

15031504
block = buf_page_get_gen(space, zip_size, page_no, RW_S_LATCH,
15041505
NULL /* no guessed block */,
1505-
BUF_GET, __FILE__, __LINE__, mtr);
1506+
BUF_GET, __FILE__, __LINE__, &mtr);
15061507

15071508
page = buf_block_get_frame(block);
15081509

@@ -1524,6 +1525,8 @@ dict_stats_analyze_index_below_cur(
15241525
ut_a(*n_diff > 0);
15251526

15261527
if (*n_diff == 1) {
1528+
mtr_commit(&mtr);
1529+
15271530
/* page has all keys equal and the end of the page
15281531
was reached by dict_stats_scan_page(), no need to
15291532
descend to the leaf level */
@@ -1548,7 +1551,7 @@ dict_stats_analyze_index_below_cur(
15481551
}
15491552

15501553
/* make sure we got a leaf page as a result from the above loop */
1551-
ut_ad(btr_page_get_level(page, mtr) == 0);
1554+
ut_ad(btr_page_get_level(page, &mtr) == 0);
15521555

15531556
/* scan the leaf page and find the number of distinct keys,
15541557
when looking only at the first n_prefix columns; also estimate
@@ -1565,6 +1568,7 @@ dict_stats_analyze_index_below_cur(
15651568
__func__, page_no, n_diff);
15661569
#endif
15671570

1571+
mtr_commit(&mtr);
15681572
mem_heap_free(heap);
15691573
}
15701574

@@ -1774,8 +1778,7 @@ dict_stats_analyze_index_for_n_prefix(
17741778
dict_stats_analyze_index_below_cur(btr_pcur_get_btr_cur(&pcur),
17751779
n_prefix,
17761780
&n_diff_on_leaf_page,
1777-
&n_external_pages,
1778-
mtr);
1781+
&n_external_pages);
17791782

17801783
/* We adjust n_diff_on_leaf_page here to avoid counting
17811784
one record twice - once as the last on some page and once

storage/innobase/fts/fts0opt.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ fts_zip_read_word(
580580
#ifdef UNIV_DEBUG
581581
ulint i;
582582
#endif
583-
byte len = 0;
583+
short len = 0;
584584
void* null = NULL;
585585
byte* ptr = word->f_str;
586586
int flush = Z_NO_FLUSH;
@@ -590,7 +590,7 @@ fts_zip_read_word(
590590
return(NULL);
591591
}
592592

593-
zip->zp->next_out = &len;
593+
zip->zp->next_out = reinterpret_cast<byte*>(&len);
594594
zip->zp->avail_out = sizeof(len);
595595

596596
while (zip->status == Z_OK && zip->zp->avail_out > 0) {
@@ -688,11 +688,12 @@ fts_fetch_index_words(
688688
fts_zip_t* zip = static_cast<fts_zip_t*>(user_arg);
689689
que_node_t* exp = sel_node->select_list;
690690
dfield_t* dfield = que_node_get_val(exp);
691-
byte len = (byte) dfield_get_len(dfield);
691+
short len = static_cast<short>(dfield_get_len(dfield));
692692
void* data = dfield_get_data(dfield);
693693

694694
/* Skip the duplicate words. */
695-
if (zip->word.f_len == len && !memcmp(zip->word.f_str, data, len)) {
695+
if (zip->word.f_len == static_cast<ulint>(len)
696+
&& !memcmp(zip->word.f_str, data, len)) {
696697

697698
return(TRUE);
698699
}
@@ -706,7 +707,7 @@ fts_fetch_index_words(
706707
ut_a(zip->zp->next_in == NULL);
707708

708709
/* The string is prefixed by len. */
709-
zip->zp->next_in = &len;
710+
zip->zp->next_in = reinterpret_cast<byte*>(&len);
710711
zip->zp->avail_in = sizeof(len);
711712

712713
/* Compress the word, create output blocks as necessary. */

0 commit comments

Comments
 (0)