summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-08-13 18:18:25 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2020-08-13 18:18:25 +0300
commit4bd56a697ff2d2edc230a82dbfcf4412ef0996df (patch)
tree77a6e74518875d83ecaf6447b5f5b8801ef50b2f
parent863e28ff3ed0a5859561c397cbfb492170989ddd (diff)
parent3e617b8bef50a81b10b8152d800a1b8b38859913 (diff)
downloadmariadb-git-4bd56a697ff2d2edc230a82dbfcf4412ef0996df.tar.gz
Merge 10.2 into 10.3
-rw-r--r--extra/mariabackup/backup_copy.cc2
-rw-r--r--include/ilist.h9
-rw-r--r--mysql-test/main/type_datetime.result4
-rw-r--r--mysql-test/main/type_datetime.test5
-rw-r--r--mysql-test/suite/galera/r/mdev-22543.result17
-rw-r--r--mysql-test/suite/galera/t/mdev-22543.test58
-rw-r--r--mysql-test/suite/innodb/include/alter_table_pk_no_sort.inc7
-rw-r--r--mysql-test/suite/innodb/r/alter_table.result7
-rw-r--r--mysql-test/suite/innodb/r/innodb-64k.result7
-rw-r--r--mysql-test/suite/innodb/r/innodb-index-debug.result5
-rw-r--r--mysql-test/suite/innodb/r/innodb-index.result5
-rw-r--r--mysql-test/suite/innodb/t/alter_table.test9
-rw-r--r--mysql-test/suite/innodb/t/innodb-64k.test9
-rw-r--r--mysql-test/suite/sys_vars/r/sysvars_innodb.result2
-rw-r--r--plugin/server_audit/server_audit.c60
-rw-r--r--scripts/mysqld_multi.sh14
-rw-r--r--scripts/wsrep_sst_mariabackup.sh25
-rw-r--r--scripts/wsrep_sst_rsync.sh8
-rw-r--r--sql/item.cc2
-rw-r--r--sql/item_geofunc.cc17
-rw-r--r--sql/mdl.cc25
-rw-r--r--sql/mysqld.cc54
-rw-r--r--sql/sql_time.cc2
-rw-r--r--sql/threadpool_generic.cc11
-rw-r--r--sql/wsrep_sst.cc13
-rw-r--r--sql/wsrep_sst.h2
-rw-r--r--storage/innobase/btr/btr0cur.cc16
-rw-r--r--storage/innobase/buf/buf0rea.cc17
-rw-r--r--storage/innobase/fil/fil0crypt.cc33
-rw-r--r--storage/innobase/fil/fil0pagecompress.cc15
-rw-r--r--storage/innobase/fts/fts0que.cc2
-rw-r--r--storage/innobase/handler/ha_innodb.cc2
-rw-r--r--storage/innobase/handler/handler0alter.cc18
-rw-r--r--storage/innobase/include/fil0fil.h10
-rw-r--r--storage/innobase/include/page0page.h14
-rw-r--r--storage/innobase/page/page0cur.cc46
-rw-r--r--storage/innobase/page/page0page.cc37
-rw-r--r--storage/maria/ma_create.c3
-rw-r--r--storage/maria/ma_loghandler.c3
-rw-r--r--storage/myisam/mi_create.c3
-rw-r--r--strings/ctype-ucs2.c2
41 files changed, 374 insertions, 226 deletions
diff --git a/extra/mariabackup/backup_copy.cc b/extra/mariabackup/backup_copy.cc
index 929319927e5..d821ea23748 100644
--- a/extra/mariabackup/backup_copy.cc
+++ b/extra/mariabackup/backup_copy.cc
@@ -1783,7 +1783,7 @@ apply_log_finish()
bool
copy_back()
{
- bool ret;
+ bool ret = false;
datadir_iter_t *it = NULL;
datadir_node_t node;
char *dst_dir;
diff --git a/include/ilist.h b/include/ilist.h
index 74cb472cd4e..f0d15054ab8 100644
--- a/include/ilist.h
+++ b/include/ilist.h
@@ -18,6 +18,8 @@
#pragma once
+#include "my_dbug.h"
+
#include <cstddef>
#include <iterator>
@@ -26,8 +28,7 @@ template <class Tag= void> struct ilist_node
{
ilist_node()
#ifndef DBUG_OFF
- :
- next(NULL), prev(NULL)
+ : next(NULL), prev(NULL)
#endif
{
}
@@ -70,11 +71,12 @@ public:
typedef T *pointer;
typedef T &reference;
- Iterator(ListNode *node) : node_(node) {}
+ Iterator(ListNode *node) : node_(node) { DBUG_ASSERT(node_ != NULL); }
Iterator &operator++()
{
node_= node_->next;
+ DBUG_ASSERT(node_ != NULL);
return *this;
}
Iterator operator++(int)
@@ -87,6 +89,7 @@ public:
Iterator &operator--()
{
node_= node_->prev;
+ DBUG_ASSERT(node_);
return *this;
}
Iterator operator--(int)
diff --git a/mysql-test/main/type_datetime.result b/mysql-test/main/type_datetime.result
index ea4816b72df..a9de6172c30 100644
--- a/mysql-test/main/type_datetime.result
+++ b/mysql-test/main/type_datetime.result
@@ -57,6 +57,7 @@ select * from t1;
t
0000-00-00 00:00:00
drop table t1;
+SET TIMESTAMP=UNIX_TIMESTAMP('2020-08-11 00:00:01');
CREATE TABLE t1 (a timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, b date, c time, d datetime);
insert into t1 (b,c,d) values(now(),curtime(),now());
Warnings:
@@ -65,6 +66,7 @@ select date_format(a,"%Y-%m-%d")=b,right(a+0,6)=c+0,a=d+0 from t1;
date_format(a,"%Y-%m-%d")=b right(a+0,6)=c+0 a=d+0
1 1 1
drop table t1;
+SET TIMESTAMP=DEFAULT;
CREATE TABLE t1 (a datetime not null);
insert into t1 values (0);
select * from t1 where a is null;
@@ -298,8 +300,10 @@ f2 f3
select f2 from t1 where DATE(f2) between "2001-4-15" AND "01-4-15";
f2
2001-04-15 00:00:00
+SET timestamp=UNIX_TIMESTAMP('2001-01-01 00:00:01');
SELECT 1 from dual where NOW() BETWEEN CURRENT_DATE() - INTERVAL 1 DAY AND CURRENT_DATE();
1
+SET timestamp=DEFAULT;
drop table t1;
create table t1 (f1 date);
insert into t1 values('01-01-01'),('01-01-02'),('01-01-03');
diff --git a/mysql-test/main/type_datetime.test b/mysql-test/main/type_datetime.test
index 41913638474..240a96a6208 100644
--- a/mysql-test/main/type_datetime.test
+++ b/mysql-test/main/type_datetime.test
@@ -32,10 +32,12 @@ drop table t1;
# Test insert of now() and curtime()
#
+SET TIMESTAMP=UNIX_TIMESTAMP('2020-08-11 00:00:01');
CREATE TABLE t1 (a timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, b date, c time, d datetime);
insert into t1 (b,c,d) values(now(),curtime(),now());
select date_format(a,"%Y-%m-%d")=b,right(a+0,6)=c+0,a=d+0 from t1;
drop table t1;
+SET TIMESTAMP=DEFAULT;
#
# Test of datetime and not null
@@ -201,6 +203,7 @@ drop table t1;
#
# Bug#16377: Wrong DATE/DATETIME comparison in BETWEEN function.
#
+
create table t1 (f1 date, f2 datetime, f3 timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP);
insert into t1 values('2001-01-01','2001-01-01 01:01:01','2001-01-01 01:01:01');
insert into t1 values('2001-02-05','2001-02-05 00:00:00','2001-02-05 01:01:01');
@@ -214,7 +217,9 @@ select f1, f2, f3 from t1 where cast(f1 as datetime) between f2 and
select f2 from t1 where '2001-04-10 12:34:56' between f2 and '01-05-01';
select f2, f3 from t1 where '01-03-10' between f2 and f3;
select f2 from t1 where DATE(f2) between "2001-4-15" AND "01-4-15";
+SET timestamp=UNIX_TIMESTAMP('2001-01-01 00:00:01');
SELECT 1 from dual where NOW() BETWEEN CURRENT_DATE() - INTERVAL 1 DAY AND CURRENT_DATE();
+SET timestamp=DEFAULT;
drop table t1;
#
diff --git a/mysql-test/suite/galera/r/mdev-22543.result b/mysql-test/suite/galera/r/mdev-22543.result
new file mode 100644
index 00000000000..02f2b632b32
--- /dev/null
+++ b/mysql-test/suite/galera/r/mdev-22543.result
@@ -0,0 +1,17 @@
+connection node_1;
+connection node_2;
+connection node_1;
+CREATE TABLE t1 (f1 INT PRIMARY KEY, f2 INT);
+INSERT INTO t1 VALUES (1, 1);
+SET DEBUG_SYNC = "before_lock_tables_takes_lock SIGNAL sync_point_reached WAIT_FOR sync_point_continue";
+UPDATE t1 SET f2 = 2 WHERE f1 = 1;
+connection node_1_ctrl;
+SET DEBUG_SYNC = "now WAIT_FOR sync_point_reached";
+connection node_2;
+connection node_1_ctrl;
+SET DEBUG_SYNC = "now SIGNAL sync_point_continue";
+connection node_1;
+SET DEBUG_SYNC = "RESET";
+connection node_2;
+connection node_1;
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/t/mdev-22543.test b/mysql-test/suite/galera/t/mdev-22543.test
new file mode 100644
index 00000000000..53662e36942
--- /dev/null
+++ b/mysql-test/suite/galera/t/mdev-22543.test
@@ -0,0 +1,58 @@
+# The test verifies that the FLUSH TABLES WITH READ LOCK does not
+# time out if it needs to wait for another MDL lock for short duration
+# during SST donation.
+
+--source include/galera_cluster.inc
+--source include/have_debug.inc
+--source include/have_debug_sync.inc
+
+--let $node_1 = node_1
+--let $node_2 = node_2
+--source include/auto_increment_offset_save.inc
+
+--let $galera_connection_name = node_1_ctrl
+--let $galera_server_number = 1
+--source include/galera_connect.inc
+
+#
+# Run UPDATE on node_1 and make it block before table locks are taken.
+# This should block FTWRL.
+#
+--connection node_1
+CREATE TABLE t1 (f1 INT PRIMARY KEY, f2 INT);
+INSERT INTO t1 VALUES (1, 1);
+SET DEBUG_SYNC = "before_lock_tables_takes_lock SIGNAL sync_point_reached WAIT_FOR sync_point_continue";
+--send UPDATE t1 SET f2 = 2 WHERE f1 = 1
+
+--connection node_1_ctrl
+SET DEBUG_SYNC = "now WAIT_FOR sync_point_reached";
+
+#
+# Restart node_2, force SST.
+#
+--connection node_2
+--source include/shutdown_mysqld.inc
+--remove_file $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat
+# Restart without waiting. The UPDATE should block FTWRL on node_1,
+# so the SST cannot be completed and node_2 cannot join before
+# UPDATE connection is signalled to continue.
+--exec echo "restart:$start_mysqld_params" > $_expect_file_name
+# If the bug is present, FTWRL times out on node_1 in couple of
+# seconds and node_2 fails to join.
+--sleep 10
+
+--connection node_1_ctrl
+SET DEBUG_SYNC = "now SIGNAL sync_point_continue";
+
+--connection node_1
+--reap
+SET DEBUG_SYNC = "RESET";
+
+--connection node_2
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+
+--connection node_1
+DROP TABLE t1;
+
+--source include/auto_increment_offset_restore.inc
diff --git a/mysql-test/suite/innodb/include/alter_table_pk_no_sort.inc b/mysql-test/suite/innodb/include/alter_table_pk_no_sort.inc
index 6a2fcd15be0..61e304a7626 100644
--- a/mysql-test/suite/innodb/include/alter_table_pk_no_sort.inc
+++ b/mysql-test/suite/innodb/include/alter_table_pk_no_sort.inc
@@ -263,3 +263,10 @@ create table t1(o1 int, o2 int, o3 int, primary key(o1,o2,o3)) engine = innodb;
insert into t1 values(1,1,2),(2,2,1);
alter table t1 drop primary key, add primary key(o1), lock=none;
drop table t1;
+
+# pk(o1,o2) to pk(o1,o2,autoinc) must not sort
+create table t1(o1 int, o2 int, primary key(o1,o2)) engine = innodb;
+insert into t1 values(1,1),(2,1);
+alter table t1 drop primary key, add column a int unique auto_increment,
+add primary key(o1,o2,a), algorithm=inplace;
+drop table t1;
diff --git a/mysql-test/suite/innodb/r/alter_table.result b/mysql-test/suite/innodb/r/alter_table.result
index e47bfb90152..94262ac29c3 100644
--- a/mysql-test/suite/innodb/r/alter_table.result
+++ b/mysql-test/suite/innodb/r/alter_table.result
@@ -53,3 +53,10 @@ ALTER TABLE t1 DROP a;
ERROR HY000: Cannot drop index 'a': needed in a foreign key constraint
ALTER TABLE t1 ADD c INT;
DROP TABLE t1, tx;
+#
+# MDEV-14119 Assertion cmp_rec_rec() on ALTER TABLE
+#
+CREATE TABLE t1(a INT NOT NULL UNIQUE) ENGINE=InnoDB;
+INSERT INTO t1 SELECT * FROM seq_1_to_128;
+ALTER TABLE t1 ADD b TINYINT AUTO_INCREMENT PRIMARY KEY, DROP KEY a;
+DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/r/innodb-64k.result b/mysql-test/suite/innodb/r/innodb-64k.result
index 379235c510c..92d2a03d8da 100644
--- a/mysql-test/suite/innodb/r/innodb-64k.result
+++ b/mysql-test/suite/innodb/r/innodb-64k.result
@@ -1080,3 +1080,10 @@ update t2 set col145=@b;
COMMIT;
drop table t2;
DROP TABLE t1;
+#
+# MDEV-19526 heap number overflow
+#
+CREATE TABLE t1(a SMALLINT NOT NULL UNIQUE AUTO_INCREMENT, KEY(a))
+ENGINE=InnoDB;
+INSERT INTO t1 (a) SELECT seq FROM seq_1_to_8191;
+DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/r/innodb-index-debug.result b/mysql-test/suite/innodb/r/innodb-index-debug.result
index 5d161e5e6ca..daef31d2caa 100644
--- a/mysql-test/suite/innodb/r/innodb-index-debug.result
+++ b/mysql-test/suite/innodb/r/innodb-index-debug.result
@@ -323,4 +323,9 @@ create table t1(o1 int, o2 int, o3 int, primary key(o1,o2,o3)) engine = innodb;
insert into t1 values(1,1,2),(2,2,1);
alter table t1 drop primary key, add primary key(o1), lock=none;
drop table t1;
+create table t1(o1 int, o2 int, primary key(o1,o2)) engine = innodb;
+insert into t1 values(1,1),(2,1);
+alter table t1 drop primary key, add column a int unique auto_increment,
+add primary key(o1,o2,a), algorithm=inplace;
+drop table t1;
SET DEBUG_DBUG = @saved_debug_dbug;
diff --git a/mysql-test/suite/innodb/r/innodb-index.result b/mysql-test/suite/innodb/r/innodb-index.result
index bdc16ad7692..5e91efb7062 100644
--- a/mysql-test/suite/innodb/r/innodb-index.result
+++ b/mysql-test/suite/innodb/r/innodb-index.result
@@ -1903,6 +1903,11 @@ create table t1(o1 int, o2 int, o3 int, primary key(o1,o2,o3)) engine = innodb;
insert into t1 values(1,1,2),(2,2,1);
alter table t1 drop primary key, add primary key(o1), lock=none;
drop table t1;
+create table t1(o1 int, o2 int, primary key(o1,o2)) engine = innodb;
+insert into t1 values(1,1),(2,1);
+alter table t1 drop primary key, add column a int unique auto_increment,
+add primary key(o1,o2,a), algorithm=inplace;
+drop table t1;
#
# MDEV-15325 Incomplete validation of missing tablespace during recovery
#
diff --git a/mysql-test/suite/innodb/t/alter_table.test b/mysql-test/suite/innodb/t/alter_table.test
index d0943e7d407..6bc30d2e8ee 100644
--- a/mysql-test/suite/innodb/t/alter_table.test
+++ b/mysql-test/suite/innodb/t/alter_table.test
@@ -1,4 +1,5 @@
--source include/have_innodb.inc
+--source include/have_sequence.inc
#
# MDEV-11995 ALTER TABLE proceeds despite reporting ER_TOO_LONG_KEY error
#
@@ -59,3 +60,11 @@ ALTER TABLE t1 ADD b INT;
ALTER TABLE t1 DROP a;
ALTER TABLE t1 ADD c INT;
DROP TABLE t1, tx;
+
+--echo #
+--echo # MDEV-14119 Assertion cmp_rec_rec() on ALTER TABLE
+--echo #
+CREATE TABLE t1(a INT NOT NULL UNIQUE) ENGINE=InnoDB;
+INSERT INTO t1 SELECT * FROM seq_1_to_128;
+ALTER TABLE t1 ADD b TINYINT AUTO_INCREMENT PRIMARY KEY, DROP KEY a;
+DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/t/innodb-64k.test b/mysql-test/suite/innodb/t/innodb-64k.test
index b091eee6d57..62d7b929ba1 100644
--- a/mysql-test/suite/innodb/t/innodb-64k.test
+++ b/mysql-test/suite/innodb/t/innodb-64k.test
@@ -2,6 +2,7 @@
# Tests for setting innodb-page-size=64k;
--source include/have_innodb.inc
--source include/have_innodb_64k.inc
+--source include/have_sequence.inc
call mtr.add_suppression('InnoDB: Cannot add field.*because after adding it, the row size is');
@@ -638,3 +639,11 @@ COMMIT;
drop table t2;
DROP TABLE t1;
+
+--echo #
+--echo # MDEV-19526 heap number overflow
+--echo #
+CREATE TABLE t1(a SMALLINT NOT NULL UNIQUE AUTO_INCREMENT, KEY(a))
+ENGINE=InnoDB;
+INSERT INTO t1 (a) SELECT seq FROM seq_1_to_8191;
+DROP TABLE t1;
diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb.result b/mysql-test/suite/sys_vars/r/sysvars_innodb.result
index de2df4b3232..c34c4748493 100644
--- a/mysql-test/suite/sys_vars/r/sysvars_innodb.result
+++ b/mysql-test/suite/sys_vars/r/sysvars_innodb.result
@@ -410,7 +410,7 @@ SESSION_VALUE NULL
DEFAULT_VALUE zlib
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE ENUM
-VARIABLE_COMMENT Compression algorithm used on page compression. One of: none, zlib, lz4, lzo, lzma, or bzip2
+VARIABLE_COMMENT Compression algorithm used on page compression. One of: none, zlib, lz4, lzo, lzma, bzip2, or snappy
NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL
diff --git a/plugin/server_audit/server_audit.c b/plugin/server_audit/server_audit.c
index 460c038dfd0..4e45b36ec3e 100644
--- a/plugin/server_audit/server_audit.c
+++ b/plugin/server_audit/server_audit.c
@@ -1430,7 +1430,6 @@ static size_t escape_string_hide_passwords(const char *str, unsigned int len,
const char *res_start= result;
const char *res_end= result + result_len - 2;
size_t d_len;
- char b_char;
while (len)
{
@@ -1468,27 +1467,28 @@ static size_t escape_string_hide_passwords(const char *str, unsigned int len,
if (*next_s)
{
- memmove(result + d_len, "*****", 5);
+ const char b_char= *next_s++;
+ memset(result + d_len, '*', 5);
result+= d_len + 5;
- b_char= *(next_s++);
- }
- else
- result+= d_len;
- while (*next_s)
- {
- if (*next_s == b_char)
- {
- ++next_s;
- break;
- }
- if (*next_s == '\\')
+ while (*next_s)
{
- if (next_s[1])
- next_s++;
+ if (*next_s == b_char)
+ {
+ ++next_s;
+ break;
+ }
+ if (*next_s == '\\')
+ {
+ if (next_s[1])
+ next_s++;
+ }
+ next_s++;
}
- next_s++;
}
+ else
+ result+= d_len;
+
len-= (uint)(next_s - str);
str= next_s;
continue;
@@ -1496,19 +1496,23 @@ static size_t escape_string_hide_passwords(const char *str, unsigned int len,
no_password:
if (result >= res_end)
break;
- if ((b_char= escaped_char(*str)))
+ else
{
- if (result+1 >= res_end)
- break;
- *(result++)= '\\';
- *(result++)= b_char;
+ const char b_char= escaped_char(*str);
+ if (b_char)
+ {
+ if (result+1 >= res_end)
+ break;
+ *(result++)= '\\';
+ *(result++)= b_char;
+ }
+ else if (is_space(*str))
+ *(result++)= ' ';
+ else
+ *(result++)= *str;
+ str++;
+ len--;
}
- else if (is_space(*str))
- *(result++)= ' ';
- else
- *(result++)= *str;
- str++;
- len--;
}
*result= 0;
return result - res_start;
diff --git a/scripts/mysqld_multi.sh b/scripts/mysqld_multi.sh
index 2c3578834eb..0b33f61710e 100644
--- a/scripts/mysqld_multi.sh
+++ b/scripts/mysqld_multi.sh
@@ -308,9 +308,7 @@ sub report_mysqlds
sub start_mysqlds()
{
- my (@groups, $com, $tmp, $i, @options, $j, $mysqld_found, $suffix_found, $info_sent);
-
- $suffix_found= 0;
+ my (@groups, $com, $tmp, $i, @options, $j, $mysqld_found, $info_sent);
if (!$opt_no_log)
{
@@ -349,10 +347,6 @@ sub start_mysqlds()
$options[$j]= quote_shell_word($options[$j]);
$tmp.= " $options[$j]";
}
- elsif ("--defaults-group-suffix=" eq substr($options[$j], 0, 24))
- {
- $suffix_found= 1;
- }
else
{
$options[$j]= quote_shell_word($options[$j]);
@@ -369,12 +363,6 @@ sub start_mysqlds()
$info_sent= 1;
}
- if (!$suffix_found)
- {
- $com.= " --defaults-group-suffix=";
- $com.= substr($groups[$i],6);
- }
-
$com.= $tmp;
if ($opt_wsrep_new_cluster) {
diff --git a/scripts/wsrep_sst_mariabackup.sh b/scripts/wsrep_sst_mariabackup.sh
index 9aadcc0bc9b..48db55b8f18 100644
--- a/scripts/wsrep_sst_mariabackup.sh
+++ b/scripts/wsrep_sst_mariabackup.sh
@@ -715,7 +715,8 @@ INNODB_DATA_HOME_DIR=${INNODB_DATA_HOME_DIR:-""}
if [ ! -z "$INNODB_DATA_HOME_DIR_ARG" ]; then
INNODB_DATA_HOME_DIR=$INNODB_DATA_HOME_DIR_ARG
fi
-# if INNODB_DATA_HOME_DIR env. variable is not set, try to get it from my.cnf
+# if no command line arg and INNODB_DATA_HOME_DIR environment variable
+# is not set, try to get it from my.cnf:
if [ -z "$INNODB_DATA_HOME_DIR" ]; then
INNODB_DATA_HOME_DIR=$(parse_cnf mysqld$WSREP_SST_OPT_SUFFIX_VALUE innodb-data-home-dir '')
fi
@@ -963,17 +964,25 @@ then
ib_home_dir=$INNODB_DATA_HOME_DIR
- # Try to set ib_log_dir from the command line:
- ib_log_dir=$INNODB_LOG_GROUP_HOME_ARG
- if [ -z "$ib_log_dir" ]; then
- ib_log_dir=$(parse_cnf mysqld$WSREP_SST_OPT_SUFFIX_VALUE innodb-log-group-home-dir "")
+ WSREP_LOG_DIR=${WSREP_LOG_DIR:-""}
+ # Try to set WSREP_LOG_DIR from the command line:
+ if [ ! -z "$INNODB_LOG_GROUP_HOME_ARG" ]; then
+ WSREP_LOG_DIR=$INNODB_LOG_GROUP_HOME_ARG
fi
- if [ -z "$ib_log_dir" ]; then
- ib_log_dir=$(parse_cnf --mysqld innodb-log-group-home-dir "")
+ # if no command line arg and WSREP_LOG_DIR is not set,
+ # try to get it from my.cnf:
+ if [ -z "$WSREP_LOG_DIR" ]; then
+ WSREP_LOG_DIR=$(parse_cnf mysqld$WSREP_SST_OPT_SUFFIX_VALUE innodb-log-group-home-dir '')
fi
+ if [ -z "$WSREP_LOG_DIR" ]; then
+ WSREP_LOG_DIR=$(parse_cnf --mysqld innodb-log-group-home-dir '')
+ fi
+
+ ib_log_dir=$WSREP_LOG_DIR
# Try to set ib_undo_dir from the command line:
- ib_undo_dir=$INNODB_UNDO_DIR_ARG
+ ib_undo_dir=${INNODB_UNDO_DIR_ARG:-""}
+ # if no command line arg then try to get it from my.cnf:
if [ -z "$ib_undo_dir" ]; then
ib_undo_dir=$(parse_cnf mysqld$WSREP_SST_OPT_SUFFIX_VALUE innodb-undo-directory "")
fi
diff --git a/scripts/wsrep_sst_rsync.sh b/scripts/wsrep_sst_rsync.sh
index a8fe122139b..7638627c1ce 100644
--- a/scripts/wsrep_sst_rsync.sh
+++ b/scripts/wsrep_sst_rsync.sh
@@ -151,10 +151,11 @@ fi
WSREP_LOG_DIR=${WSREP_LOG_DIR:-""}
# Try to set WSREP_LOG_DIR from the command line:
-if [ -z "$WSREP_LOG_DIR" ]; then
+if [ ! -z "$INNODB_LOG_GROUP_HOME_ARG" ]; then
WSREP_LOG_DIR=$INNODB_LOG_GROUP_HOME_ARG
fi
-# if WSREP_LOG_DIR env. variable is not set, try to get it from my.cnf
+# if no command line arg and WSREP_LOG_DIR is not set,
+# try to get it from my.cnf:
if [ -z "$WSREP_LOG_DIR" ]; then
WSREP_LOG_DIR=$(parse_cnf mysqld$WSREP_SST_OPT_SUFFIX_VALUE innodb-log-group-home-dir '')
fi
@@ -175,7 +176,8 @@ INNODB_DATA_HOME_DIR=${INNODB_DATA_HOME_DIR:-""}
if [ ! -z "$INNODB_DATA_HOME_DIR_ARG" ]; then
INNODB_DATA_HOME_DIR=$INNODB_DATA_HOME_DIR_ARG
fi
-# if INNODB_DATA_HOME_DIR env. variable is not set, try to get it from my.cnf
+# if no command line arg and INNODB_DATA_HOME_DIR environment variable
+# is not set, try to get it from my.cnf:
if [ -z "$INNODB_DATA_HOME_DIR" ]; then
INNODB_DATA_HOME_DIR=$(parse_cnf mysqld$WSREP_SST_OPT_SUFFIX_VALUE innodb-data-home-dir '')
fi
diff --git a/sql/item.cc b/sql/item.cc
index 6c7a6943bdf..ff1a0cbd917 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -7616,7 +7616,6 @@ Item *find_producing_item(Item *item, st_select_lex *sel)
DBUG_ASSERT(item->type() == Item::FIELD_ITEM ||
(item->type() == Item::REF_ITEM &&
((Item_ref *) item)->ref_type() == Item_ref::VIEW_REF));
- Item *producing_item;
Item_field *field_item= NULL;
Item_equal *item_equal= item->get_item_equal();
table_map tab_map= sel->master_unit()->derived->table->map;
@@ -7638,6 +7637,7 @@ Item *find_producing_item(Item *item, st_select_lex *sel)
List_iterator_fast<Item> li(sel->item_list);
if (field_item)
{
+ Item *producing_item= NULL;
uint field_no= field_item->field->field_index;
for (uint i= 0; i <= field_no; i++)
producing_item= li++;
diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc
index b58a82733a4..0744523592c 100644
--- a/sql/item_geofunc.cc
+++ b/sql/item_geofunc.cc
@@ -2380,12 +2380,15 @@ double Item_func_distance::val_real()
MBR mbr1, mbr2;
const char *c_end;
-
- if ((null_value= (args[0]->null_value || args[1]->null_value ||
- !(g1= Geometry::construct(&buffer1, res1->ptr(), res1->length())) ||
- !(g2= Geometry::construct(&buffer2, res2->ptr(), res2->length())) ||
- g1->get_mbr(&mbr1, &c_end) ||
- g2->get_mbr(&mbr2, &c_end))))
+ if (args[0]->null_value || args[1]->null_value)
+ goto mem_error;
+ g1= Geometry::construct(&buffer1, res1->ptr(), res1->length());
+ if (!g1)
+ goto mem_error;
+ g2= Geometry::construct(&buffer2, res2->ptr(), res2->length());
+ if (!g2)
+ goto mem_error;
+ if (g1->get_mbr(&mbr1, &c_end) || g2->get_mbr(&mbr2, &c_end))
goto mem_error;
mbr1.add_mbr(&mbr2);
@@ -2534,7 +2537,7 @@ String *Item_func_pointonsurface::val_str(String *str)
Geometry *g;
MBR mbr;
const char *c_end;
- double UNINIT_VAR(px), UNINIT_VAR(py), x0, y0;
+ double UNINIT_VAR(px), UNINIT_VAR(py), x0, UNINIT_VAR(y0);
String *result= 0;
const Gcalc_scan_iterator::point *pprev= NULL;
uint32 srid;
diff --git a/sql/mdl.cc b/sql/mdl.cc
index 8d6780671d1..da502053336 100644
--- a/sql/mdl.cc
+++ b/sql/mdl.cc
@@ -26,6 +26,7 @@
#include <mysql/psi/mysql_stage.h>
#include "wsrep_mysqld.h"
#include "wsrep_thd.h"
+#include "wsrep_sst.h"
#ifdef HAVE_PSI_INTERFACE
static PSI_mutex_key key_MDL_wait_LOCK_wait_status;
@@ -2147,18 +2148,26 @@ MDL_context::acquire_lock(MDL_request *mdl_request, double lock_wait_timeout)
wait_status= m_wait.timed_wait(m_owner, &abs_shortwait, FALSE,
mdl_request->key.get_wait_state_name());
+ THD* thd= m_owner->get_thd();
+
if (wait_status != MDL_wait::EMPTY)
break;
/* Check if the client is gone while we were waiting. */
- if (! thd_is_connected(m_owner->get_thd()))
+ if (! thd_is_connected(thd))
{
- /*
- * The client is disconnected. Don't wait forever:
- * assume it's the same as a wait timeout, this
- * ensures all error handling is correct.
- */
- wait_status= MDL_wait::TIMEOUT;
- break;
+#if defined(WITH_WSREP) && !defined(EMBEDDED_LIBRARY)
+ // During SST client might not be connected
+ if (!wsrep_is_sst_progress())
+#endif
+ {
+ /*
+ * The client is disconnected. Don't wait forever:
+ * assume it's the same as a wait timeout, this
+ * ensures all error handling is correct.
+ */
+ wait_status= MDL_wait::TIMEOUT;
+ break;
+ }
}
mysql_prlock_wrlock(&lock->m_rwlock);
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 34d9145ea3d..3a509fb8beb 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -6711,13 +6711,11 @@ void handle_connections_sockets()
MYSQL_SOCKET sock= mysql_socket_invalid();
MYSQL_SOCKET new_sock= mysql_socket_invalid();
uint error_count=0;
- CONNECT *connect;
struct sockaddr_storage cAddr;
int ip_flags __attribute__((unused))=0;
int socket_flags __attribute__((unused))= 0;
int extra_ip_flags __attribute__((unused))=0;
int flags=0,retval;
- bool is_unix_sock;
#ifdef HAVE_POLL
int socket_count= 0;
struct pollfd fds[3]; // for ip_sock, unix_sock and extra_ip_sock
@@ -6917,41 +6915,37 @@ void handle_connections_sockets()
DBUG_PRINT("info", ("Creating CONNECT for new connection"));
- if ((connect= new CONNECT()))
+ if (CONNECT *connect= new CONNECT())
{
- is_unix_sock= (mysql_socket_getfd(sock) ==
- mysql_socket_getfd(unix_sock));
+ const bool is_unix_sock= (mysql_socket_getfd(sock) ==
+ mysql_socket_getfd(unix_sock));
- if (!(connect->vio=
- mysql_socket_vio_new(new_sock,
- is_unix_sock ? VIO_TYPE_SOCKET :
- VIO_TYPE_TCPIP,
- is_unix_sock ? VIO_LOCALHOST: 0)))
+ if ((connect->vio=
+ mysql_socket_vio_new(new_sock,
+ is_unix_sock ? VIO_TYPE_SOCKET :
+ VIO_TYPE_TCPIP,
+ is_unix_sock ? VIO_LOCALHOST: 0)))
{
- delete connect;
- connect= 0; // Error handling below
+ if (is_unix_sock)
+ connect->host= my_localhost;
+
+ if (mysql_socket_getfd(sock) == mysql_socket_getfd(extra_ip_sock))
+ {
+ connect->extra_port= 1;
+ connect->scheduler= extra_thread_scheduler;
+ }
+ create_new_thread(connect);
+ continue;
}
- }
- if (!connect)
- {
- /* Connect failure */
- (void) mysql_socket_shutdown(new_sock, SHUT_RDWR);
- (void) mysql_socket_close(new_sock);
- statistic_increment(aborted_connects,&LOCK_status);
- statistic_increment(connection_errors_internal, &LOCK_status);
- continue;
+ delete connect;
}
- if (is_unix_sock)
- connect->host= my_localhost;
-
- if (mysql_socket_getfd(sock) == mysql_socket_getfd(extra_ip_sock))
- {
- connect->extra_port= 1;
- connect->scheduler= extra_thread_scheduler;
- }
- create_new_thread(connect);
+ /* Connect failure */
+ (void) mysql_socket_shutdown(new_sock, SHUT_RDWR);
+ (void) mysql_socket_close(new_sock);
+ statistic_increment(aborted_connects,&LOCK_status);
+ statistic_increment(connection_errors_internal, &LOCK_status);
}
sd_notify(0, "STOPPING=1\n"
"STATUS=Shutdown in progress\n");
diff --git a/sql/sql_time.cc b/sql/sql_time.cc
index a629e006c04..cb09daff6f5 100644
--- a/sql/sql_time.cc
+++ b/sql/sql_time.cc
@@ -432,7 +432,7 @@ static bool number_to_time_with_warn(bool neg, ulonglong nr, ulong sec_part,
int was_cut;
longlong res;
enum_mysql_timestamp_type ts_type;
- bool have_warnings;
+ bool have_warnings= false;
if (fuzzydate & TIME_TIME_ONLY)
{
diff --git a/sql/threadpool_generic.cc b/sql/threadpool_generic.cc
index 2433369dbbb..8b424591ba6 100644
--- a/sql/threadpool_generic.cc
+++ b/sql/threadpool_generic.cc
@@ -1078,7 +1078,10 @@ void thread_group_destroy(thread_group_t *thread_group)
#endif
if (my_atomic_add32(&shutdown_group_count, -1) == 1)
+ {
my_free(all_groups);
+ all_groups= 0;
+ }
}
/**
@@ -1671,6 +1674,14 @@ TP_pool_generic::~TP_pool_generic()
{
thread_group_close(&all_groups[i]);
}
+
+ /*
+ Wait until memory occupied by all_groups is freed.
+ */
+ int timeout_ms=5000;
+ while(all_groups && timeout_ms--)
+ my_sleep(1000);
+
threadpool_started= false;
DBUG_VOID_RETURN;
}
diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc
index 714df35de8b..a225fbd5a65 100644
--- a/sql/wsrep_sst.cc
+++ b/sql/wsrep_sst.cc
@@ -186,6 +186,7 @@ bool wsrep_before_SE()
static bool sst_complete = false;
static bool sst_needed = false;
+static bool sst_in_progress = false;
#define WSREP_EXTEND_TIMEOUT_INTERVAL 30
#define WSREP_TIMEDWAIT_SECONDS 10
@@ -1545,7 +1546,10 @@ static void* sst_donor_thread (void* a)
char out_buf[out_len];
wsrep_uuid_t ret_uuid= WSREP_UUID_UNDEFINED;
- wsrep_seqno_t ret_seqno= WSREP_SEQNO_UNDEFINED; // seqno of complete SST
+ // seqno of complete SST
+ wsrep_seqno_t ret_seqno= WSREP_SEQNO_UNDEFINED;
+ // SST is now in progress
+ sst_in_progress= true;
wsp::thd thd(FALSE); // we turn off wsrep_on for this THD so that it can
// operate with wsrep_ready == OFF
@@ -1647,6 +1651,8 @@ wait_signal:
wsrep->sst_sent (wsrep, &state_id, -err);
proc.wait();
+ sst_in_progress= false;
+
return NULL;
}
@@ -1821,3 +1827,8 @@ void wsrep_SE_initialized()
{
SE_initialized = true;
}
+
+bool wsrep_is_sst_progress()
+{
+ return (sst_in_progress);
+}
diff --git a/sql/wsrep_sst.h b/sql/wsrep_sst.h
index 38706fa4671..e41a1b46297 100644
--- a/sql/wsrep_sst.h
+++ b/sql/wsrep_sst.h
@@ -77,12 +77,14 @@ extern void wsrep_SE_init_grab(); /*! grab init critical section */
extern void wsrep_SE_init_wait(); /*! wait for SE init to complete */
extern void wsrep_SE_init_done(); /*! signal that SE init is complte */
extern void wsrep_SE_initialized(); /*! mark SE initialization complete */
+extern bool wsrep_is_sst_progress();
#else
#define wsrep_SE_initialized() do { } while(0)
#define wsrep_SE_init_grab() do { } while(0)
#define wsrep_SE_init_done() do { } while(0)
#define wsrep_sst_continue() (0)
+#define wsrep_is_sst_progress() (0)
#endif /* WITH_WSREP */
#endif /* WSREP_SST_H */
diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc
index 957fa48a938..fffa36475e6 100644
--- a/storage/innobase/btr/btr0cur.cc
+++ b/storage/innobase/btr/btr0cur.cc
@@ -3373,17 +3373,23 @@ fail_err:
}
ulint max_size = page_get_max_insert_size_after_reorganize(page, 1);
+ if (max_size < rec_size) {
+ goto fail;
+ }
+
+ const ulint n_recs = page_get_n_recs(page);
+ if (UNIV_UNLIKELY(n_recs >= 8189)) {
+ ut_ad(srv_page_size == 65536);
+ goto fail;
+ }
if (page_has_garbage(page)) {
- if ((max_size < rec_size
- || max_size < BTR_CUR_PAGE_REORGANIZE_LIMIT)
- && page_get_n_recs(page) > 1
+ if (max_size < BTR_CUR_PAGE_REORGANIZE_LIMIT
+ && n_recs > 1
&& page_get_max_insert_size(page, 1) < rec_size) {
goto fail;
}
- } else if (max_size < rec_size) {
- goto fail;
}
/* If there have been many consecutive inserts to the
diff --git a/storage/innobase/buf/buf0rea.cc b/storage/innobase/buf/buf0rea.cc
index e6004ada302..9e3daa5e40e 100644
--- a/storage/innobase/buf/buf0rea.cc
+++ b/storage/innobase/buf/buf0rea.cc
@@ -280,23 +280,6 @@ buf_read_ahead_random(
* buf_read_ahead_random_area;
if (fil_space_t* space = fil_space_acquire(page_id.space())) {
-#ifdef UNIV_DEBUG
- if (srv_file_per_table) {
- ulint size = 0;
-
- for (const fil_node_t* node =
- UT_LIST_GET_FIRST(space->chain);
- node != NULL;
- node = UT_LIST_GET_NEXT(chain, node)) {
-
- size += ulint(os_file_get_size(node->handle)
- / page_size.physical());
- }
-
- ut_ad(size == space->size);
- }
-#endif /* UNIV_DEBUG */
-
high = space->max_page_number_for_io(high);
space->release();
} else {
diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc
index be8db200852..4f80b7e409f 100644
--- a/storage/innobase/fil/fil0crypt.cc
+++ b/storage/innobase/fil/fil0crypt.cc
@@ -1390,28 +1390,31 @@ inline fil_space_t *fil_system_t::keyrotate_next(fil_space_t *space,
ut_ad(mutex_own(&mutex));
sized_ilist<fil_space_t, rotation_list_tag_t>::iterator it=
- space ? space : rotation_list.begin();
+ space && space->is_in_rotation_list ? space : rotation_list.begin();
const sized_ilist<fil_space_t, rotation_list_tag_t>::iterator end=
rotation_list.end();
if (space)
{
- while (++it != end && (!UT_LIST_GET_LEN(it->chain) || it->is_stopping()));
+ const bool released= !space->release();
- /* If one of the encryption threads already started the encryption
- of the table then don't remove the unencrypted spaces from rotation list
-
- If there is a change in innodb_encrypt_tables variables value then
- don't remove the last processed tablespace from the rotation list. */
- space->release();
-
- if (!space->referenced() &&
- (!recheck || space->crypt_data) && !encrypt == !srv_encrypt_tables &&
- space->is_in_rotation_list)
+ if (space->is_in_rotation_list)
{
- ut_a(!rotation_list.empty());
- rotation_list.remove(*space);
- space->is_in_rotation_list= false;
+ while (++it != end &&
+ (!UT_LIST_GET_LEN(it->chain) || it->is_stopping()));
+
+ /* If one of the encryption threads already started the encryption
+ of the table then don't remove the unencrypted spaces from rotation list
+
+ If there is a change in innodb_encrypt_tables variables value then
+ don't remove the last processed tablespace from the rotation list. */
+ if (released && (!recheck || space->crypt_data) &&
+ !encrypt == !srv_encrypt_tables)
+ {
+ ut_a(!rotation_list.empty());
+ rotation_list.remove(*space);
+ space->is_in_rotation_list= false;
+ }
}
}
diff --git a/storage/innobase/fil/fil0pagecompress.cc b/storage/innobase/fil/fil0pagecompress.cc
index 7ded1a226f3..7d034a194c9 100644
--- a/storage/innobase/fil/fil0pagecompress.cc
+++ b/storage/innobase/fil/fil0pagecompress.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (C) 2013, 2018, MariaDB Corporation.
+Copyright (C) 2013, 2020, MariaDB Corporation.
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
@@ -235,25 +235,12 @@ success:
/* Set up the actual payload lenght */
mach_write_to_2(out_buf+FIL_PAGE_DATA, write_size);
-#ifdef UNIV_DEBUG
- /* Verify */
ut_ad(fil_page_is_compressed(out_buf) || fil_page_is_compressed_encrypted(out_buf));
ut_ad(mach_read_from_4(out_buf+FIL_PAGE_SPACE_OR_CHKSUM) == BUF_NO_CHECKSUM_MAGIC);
ut_ad(mach_read_from_2(out_buf+FIL_PAGE_DATA) == write_size);
ut_ad(mach_read_from_8(out_buf+FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION) == (ulint)comp_method ||
mach_read_from_2(out_buf+FIL_PAGE_DATA+FIL_PAGE_COMPRESSED_SIZE) == (ulint)comp_method);
- /* Verify that page can be decompressed */
- {
- page_t tmp_buf[UNIV_PAGE_SIZE_MAX];
- page_t page[UNIV_PAGE_SIZE_MAX];
- memcpy(page, out_buf, srv_page_size);
- ut_ad(fil_page_decompress(tmp_buf, page));
- ut_ad(!buf_page_is_corrupted(false, page, univ_page_size,
- NULL));
- }
-#endif /* UNIV_DEBUG */
-
write_size+=header_len;
if (block_size <= 0) {
diff --git a/storage/innobase/fts/fts0que.cc b/storage/innobase/fts/fts0que.cc
index dfa23d3a425..e03988e3ebc 100644
--- a/storage/innobase/fts/fts0que.cc
+++ b/storage/innobase/fts/fts0que.cc
@@ -2742,7 +2742,7 @@ fts_query_phrase_search(
/* Ignore empty strings. */
if (num_token > 0) {
- fts_string_t* token;
+ fts_string_t* token = NULL;
fts_fetch_t fetch;
trx_t* trx = query->trx;
fts_ast_oper_t oper = query->oper;
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 139fd56ab61..c87e396b0de 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -20123,7 +20123,7 @@ static TYPELIB page_compression_algorithms_typelib=
};
static MYSQL_SYSVAR_ENUM(compression_algorithm, innodb_compression_algorithm,
PLUGIN_VAR_OPCMDARG,
- "Compression algorithm used on page compression. One of: none, zlib, lz4, lzo, lzma, or bzip2",
+ "Compression algorithm used on page compression. One of: none, zlib, lz4, lzo, lzma, bzip2, or snappy",
innodb_compression_algorithm_validate, NULL,
/* We use here the largest number of supported compression method to
enable all those methods that are available. Availability of compression
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index c5693afe50b..98d68250029 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -3732,7 +3732,11 @@ innobase_pk_order_preserved(
if (old_pk_column) {
new_field_order = lint(old_field);
} else if (innobase_pk_col_is_existing(new_col_no, col_map,
- old_n_cols)) {
+ old_n_cols)
+ || new_clust_index->table->persistent_autoinc
+ == new_field + 1) {
+ /* Adding an existing column or an AUTO_INCREMENT
+ column may change the existing ordering. */
new_field_order = lint(old_n_uniq
+ existing_field_count++);
} else {
@@ -5684,12 +5688,6 @@ error_handling_drop_uncached_1:
user_table);
dict_index_t* new_clust_index = dict_table_get_first_index(
ctx->new_table);
- ctx->skip_pk_sort = innobase_pk_order_preserved(
- ctx->col_map, clust_index, new_clust_index);
-
- DBUG_EXECUTE_IF("innodb_alter_table_pk_assert_no_sort",
- DBUG_ASSERT(ctx->skip_pk_sort););
-
ut_ad(!new_clust_index->is_instant());
/* row_merge_build_index() depends on the correct value */
ut_ad(new_clust_index->n_core_null_bytes
@@ -5713,6 +5711,12 @@ error_handling_drop_uncached_1:
}
}
+ ctx->skip_pk_sort = innobase_pk_order_preserved(
+ ctx->col_map, clust_index, new_clust_index);
+
+ DBUG_EXECUTE_IF("innodb_alter_table_pk_assert_no_sort",
+ DBUG_ASSERT(ctx->skip_pk_sort););
+
if (ctx->online) {
/* Allocate a log for online table rebuild. */
rw_lock_x_lock(&clust_index->lock);
diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h
index fa2db4dfa47..0a1d78230c7 100644
--- a/storage/innobase/include/fil0fil.h
+++ b/storage/innobase/include/fil0fil.h
@@ -269,11 +269,13 @@ struct fil_space_t : ilist_node<unflushed_spaces_tag_t>,
/** Acquire a tablespace reference. */
void acquire() { my_atomic_addlint(&n_pending_ops, 1); }
- /** Release a tablespace reference. */
- void release()
+ /** Release a tablespace reference.
+ @return whether this was the last reference */
+ bool release()
{
- ut_ad(referenced());
- my_atomic_addlint(&n_pending_ops, ulint(-1));
+ ulint n = my_atomic_addlint(&n_pending_ops, ulint(-1));
+ ut_ad(n);
+ return n == 1;
}
/** @return whether references are being held */
bool referenced() { return my_atomic_loadlint(&n_pending_ops); }
diff --git a/storage/innobase/include/page0page.h b/storage/innobase/include/page0page.h
index 22f4bd5d8c4..78cf3e26d4d 100644
--- a/storage/innobase/include/page0page.h
+++ b/storage/innobase/include/page0page.h
@@ -955,20 +955,6 @@ page_mem_alloc_free(
free record list */
ulint need); /*!< in: number of bytes allocated */
/************************************************************//**
-Allocates a block of memory from the heap of an index page.
-@return pointer to start of allocated buffer, or NULL if allocation fails */
-byte*
-page_mem_alloc_heap(
-/*================*/
- page_t* page, /*!< in/out: index page */
- page_zip_des_t* page_zip,/*!< in/out: compressed page with enough
- space available for inserting the record,
- or NULL */
- ulint need, /*!< in: total number of bytes needed */
- ulint* heap_no);/*!< out: this contains the heap number
- of the allocated record
- if allocation succeeds */
-/************************************************************//**
Puts a record to free list. */
UNIV_INLINE
void
diff --git a/storage/innobase/page/page0cur.cc b/storage/innobase/page/page0cur.cc
index 149f3be83d9..cf3ffe671ed 100644
--- a/storage/innobase/page/page0cur.cc
+++ b/storage/innobase/page/page0cur.cc
@@ -1207,6 +1207,52 @@ page_direction_increment(
1U + page_header_get_field(page, PAGE_N_DIRECTION));
}
+/************************************************************//**
+Allocates a block of memory from the heap of an index page.
+@return pointer to start of allocated buffer, or NULL if allocation fails */
+static
+byte*
+page_mem_alloc_heap(
+/*================*/
+ page_t* page, /*!< in/out: index page */
+ page_zip_des_t* page_zip,/*!< in/out: compressed page with enough
+ space available for inserting the record,
+ or NULL */
+ ulint need, /*!< in: total number of bytes needed */
+ ulint* heap_no)/*!< out: this contains the heap number
+ of the allocated record
+ if allocation succeeds */
+{
+ byte* block;
+ ulint avl_space;
+
+ ut_ad(page && heap_no);
+
+ avl_space = page_get_max_insert_size(page, 1);
+
+ if (avl_space >= need) {
+ const ulint h = page_dir_get_n_heap(page);
+ if (UNIV_UNLIKELY(h >= 8191)) {
+ /* At the minimum record size of 5+2 bytes,
+ we can only reach this condition when using
+ innodb_page_size=64k. */
+ ut_ad(srv_page_size == 65536);
+ return(NULL);
+ }
+ *heap_no = h;
+
+ block = page_header_get_ptr(page, PAGE_HEAP_TOP);
+
+ page_header_set_ptr(page, page_zip, PAGE_HEAP_TOP,
+ block + need);
+ page_dir_set_n_heap(page, page_zip, 1 + *heap_no);
+
+ return(block);
+ }
+
+ return(NULL);
+}
+
/***********************************************************//**
Inserts a record next to page cursor on an uncompressed page.
Returns pointer to inserted record if succeed, i.e., enough
diff --git a/storage/innobase/page/page0page.cc b/storage/innobase/page/page0page.cc
index 5140d0a783c..aab4fbe5d8b 100644
--- a/storage/innobase/page/page0page.cc
+++ b/storage/innobase/page/page0page.cc
@@ -251,43 +251,6 @@ page_set_autoinc(
}
}
-/************************************************************//**
-Allocates a block of memory from the heap of an index page.
-@return pointer to start of allocated buffer, or NULL if allocation fails */
-byte*
-page_mem_alloc_heap(
-/*================*/
- page_t* page, /*!< in/out: index page */
- page_zip_des_t* page_zip,/*!< in/out: compressed page with enough
- space available for inserting the record,
- or NULL */
- ulint need, /*!< in: total number of bytes needed */
- ulint* heap_no)/*!< out: this contains the heap number
- of the allocated record
- if allocation succeeds */
-{
- byte* block;
- ulint avl_space;
-
- ut_ad(page && heap_no);
-
- avl_space = page_get_max_insert_size(page, 1);
-
- if (avl_space >= need) {
- block = page_header_get_ptr(page, PAGE_HEAP_TOP);
-
- page_header_set_ptr(page, page_zip, PAGE_HEAP_TOP,
- block + need);
- *heap_no = page_dir_get_n_heap(page);
-
- page_dir_set_n_heap(page, page_zip, 1 + *heap_no);
-
- return(block);
- }
-
- return(NULL);
-}
-
/**********************************************************//**
Writes a log record of page creation. */
UNIV_INLINE
diff --git a/storage/maria/ma_create.c b/storage/maria/ma_create.c
index 0e5de2f8b89..9b9dfadfe54 100644
--- a/storage/maria/ma_create.c
+++ b/storage/maria/ma_create.c
@@ -75,7 +75,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
uint max_field_lengths, extra_header_size, column_nr;
uint internal_table= flags & HA_CREATE_INTERNAL_TABLE;
ulong reclength, real_reclength,min_pack_length;
- char kfilename[FN_REFLEN], klinkname[FN_REFLEN], *klinkname_ptr;
+ char kfilename[FN_REFLEN], klinkname[FN_REFLEN], *klinkname_ptr= NullS;
char dfilename[FN_REFLEN], dlinkname[FN_REFLEN], *dlinkname_ptr= 0;
ulong pack_reclength;
ulonglong tot_length,max_rows, tmp;
@@ -889,7 +889,6 @@ int maria_create(const char *name, enum data_file_type datafile_type,
fn_format(kfilename, name, "", MARIA_NAME_IEXT,
MY_UNPACK_FILENAME | MY_RETURN_REAL_PATH |
(have_iext ? MY_REPLACE_EXT : MY_APPEND_EXT));
- klinkname_ptr= NullS;
/*
Replace the current file.
Don't sync dir now if the data file has the same path.
diff --git a/storage/maria/ma_loghandler.c b/storage/maria/ma_loghandler.c
index f6a2919ddf5..aa4afaaec1a 100644
--- a/storage/maria/ma_loghandler.c
+++ b/storage/maria/ma_loghandler.c
@@ -3617,7 +3617,8 @@ my_bool translog_init_with_table(const char *directory,
int old_log_was_recovered= 0, logs_found= 0;
uint old_flags= flags;
uint32 start_file_num= 1;
- TRANSLOG_ADDRESS sure_page, last_page, last_valid_page, checkpoint_lsn;
+ TRANSLOG_ADDRESS UNINIT_VAR(sure_page), last_page, last_valid_page,
+ checkpoint_lsn;
my_bool version_changed= 0;
DBUG_ENTER("translog_init_with_table");
diff --git a/storage/myisam/mi_create.c b/storage/myisam/mi_create.c
index fd230698acc..9f17a9b2de9 100644
--- a/storage/myisam/mi_create.c
+++ b/storage/myisam/mi_create.c
@@ -46,7 +46,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
uint aligned_key_start, block_length, res;
uint internal_table= flags & HA_CREATE_INTERNAL_TABLE;
ulong reclength, real_reclength,min_pack_length;
- char kfilename[FN_REFLEN],klinkname[FN_REFLEN], *klinkname_ptr;
+ char kfilename[FN_REFLEN],klinkname[FN_REFLEN], *klinkname_ptr= 0;
char dfilename[FN_REFLEN],dlinkname[FN_REFLEN], *dlinkname_ptr= 0;
ulong pack_reclength;
ulonglong tot_length,max_rows, tmp;
@@ -622,7 +622,6 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
fn_format(kfilename, name, "", MI_NAME_IEXT,
MY_UNPACK_FILENAME | MY_RETURN_REAL_PATH |
(have_iext ? MY_REPLACE_EXT : MY_APPEND_EXT));
- klinkname_ptr= 0;
/* Replace the current file */
create_flag=(flags & HA_CREATE_KEEP_FILES) ? 0 : MY_DELETE_OLD;
}
diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c
index 5a59abcdf63..90092c40df9 100644
--- a/strings/ctype-ucs2.c
+++ b/strings/ctype-ucs2.c
@@ -827,7 +827,7 @@ my_strtoll10_mb2(CHARSET_INFO *cs __attribute__((unused)),
const char *nptr, char **endptr, int *error)
{
const uchar *s, *end, *start, *n_end, *true_end;
- uchar c;
+ uchar UNINIT_VAR(c);
unsigned long i, j, k;
ulonglong li;
int negative;