Skip to content

Commit

Permalink
Merge 10.2 into 10.3
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-m committed Jan 7, 2020
2 parents 7753a29 + 82187a1 commit eda7197
Show file tree
Hide file tree
Showing 15 changed files with 392 additions and 191 deletions.
190 changes: 190 additions & 0 deletions include/intrusive_list.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
/*
Copyright (c) 2019, 2020, MariaDB
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-1335 USA
*/

#pragma once

#include <cstddef>
#include <iterator>

namespace intrusive
{

// Derive your class from this struct to insert to a linked list.
template <class Tag= void> struct list_node
{
list_node(list_node *next= NULL, list_node *prev= NULL)
: next(next), prev(prev)
{
}

list_node *next;
list_node *prev;
};

// Modelled after std::list<T>
template <class T, class Tag= void> class list
{
public:
typedef list_node<Tag> ListNode;
class Iterator;

// All containers in C++ should define these types to implement generic
// container interface.
typedef T value_type;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef value_type &reference;
typedef const value_type &const_reference;
typedef T *pointer;
typedef const T *const_pointer;
typedef Iterator iterator;
typedef Iterator const_iterator; /* FIXME */
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const iterator> const_reverse_iterator;

class Iterator
{
public:
// All iterators in C++ should define these types to implement generic
// iterator interface.
typedef std::bidirectional_iterator_tag iterator_category;
typedef T value_type;
typedef std::ptrdiff_t difference_type;
typedef T *pointer;
typedef T &reference;

Iterator(ListNode *node) : node_(node) {}

Iterator &operator++()
{
node_= node_->next;
return *this;
}
Iterator operator++(int)
{
Iterator tmp(*this);
operator++();
return tmp;
}

Iterator &operator--()
{
node_= node_->prev;
return *this;
}
Iterator operator--(int)
{
Iterator tmp(*this);
operator--();
return tmp;
}

reference operator*() { return *static_cast<pointer>(node_); }
pointer operator->() { return static_cast<pointer>(node_); }

bool operator==(const Iterator &rhs) { return node_ == rhs.node_; }
bool operator!=(const Iterator &rhs) { return !(*this == rhs); }

private:
ListNode *node_;

friend class list;
};

list() : sentinel_(&sentinel_, &sentinel_), size_(0) {}

reference front() { return *begin(); }
reference back() { return *--end(); }
const_reference front() const { return *begin(); }
const_reference back() const { return *--end(); }

iterator begin() { return iterator(sentinel_.next); }
const_iterator begin() const
{
return iterator(const_cast<ListNode *>(sentinel_.next));
}
iterator end() { return iterator(&sentinel_); }
const_iterator end() const
{
return iterator(const_cast<ListNode *>(&sentinel_));
}

reverse_iterator rbegin() { return reverse_iterator(end()); }
const_reverse_iterator rbegin() const { return reverse_iterator(end()); }
reverse_iterator rend() { return reverse_iterator(begin()); }
const_reverse_iterator rend() const { return reverse_iterator(begin()); }

bool empty() const { return size_ == 0; }
size_type size() const { return size_; }

void clear()
{
sentinel_.next= &sentinel_;
sentinel_.prev= &sentinel_;
size_= 0;
}

iterator insert(iterator pos, reference value)
{
ListNode *curr= pos.node_;
ListNode *prev= pos.node_->prev;

prev->next= &value;
curr->prev= &value;

static_cast<ListNode &>(value).prev= prev;
static_cast<ListNode &>(value).next= curr;

++size_;
return iterator(&value);
}

iterator erase(iterator pos)
{
ListNode *prev= pos.node_->prev;
ListNode *next= pos.node_->next;

prev->next= next;
next->prev= prev;

// This is not required for list functioning. But maybe it'll prevent bugs
// and ease debugging.
ListNode *curr= pos.node_;
curr->prev= NULL;
curr->next= NULL;

--size_;
return next;
}

void push_back(reference value) { insert(end(), value); }
void pop_back() { erase(end()); }

void push_front(reference value) { insert(begin(), value); }
void pop_front() { erase(begin()); }

// STL version is O(n) but this is O(1) because an element can't be inserted
// several times in the same intrusive list.
void remove(reference value) { erase(iterator(&value)); }

private:
ListNode sentinel_;
size_type size_;
};

} // namespace intrusive
6 changes: 3 additions & 3 deletions mysql-test/main/group_by.result
Original file line number Diff line number Diff line change
Expand Up @@ -2831,16 +2831,16 @@ drop table t1;
# MDEV-20922: Adding an order by changes the query results
#
CREATE TABLE t1(a int, b int);
INSERT INTO t1 values (1, 100), (2, 200), (3, 100), (4, 200);
INSERT INTO t1 values (1, 100), (2, 200), (3, 100), (4, 200), (5, 200);
create view v1 as select a, b+1 as x from t1;
SELECT x, COUNT(DISTINCT a) AS y FROM v1 GROUP BY x ORDER BY y;
x y
101 2
201 2
201 3
SELECT b+1 AS x, COUNT(DISTINCT a) AS y FROM t1 GROUP BY x ORDER BY y;
x y
101 2
201 2
201 3
drop view v1;
drop table t1;
#
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/main/group_by.test
Original file line number Diff line number Diff line change
Expand Up @@ -1950,7 +1950,7 @@ drop table t1;
--echo #

CREATE TABLE t1(a int, b int);
INSERT INTO t1 values (1, 100), (2, 200), (3, 100), (4, 200);
INSERT INTO t1 values (1, 100), (2, 200), (3, 100), (4, 200), (5, 200);

create view v1 as select a, b+1 as x from t1;

Expand Down
26 changes: 25 additions & 1 deletion mysql-test/suite/innodb/r/row_size_error_log_warnings_3.result
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,30 @@ col_1 TEXT
) ENGINE=INNODB ROW_FORMAT=COMPACT;
Warnings:
Warning 139 Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline.
TRUNCATE TABLE t1;
Warnings:
Warning 139 Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline.
OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
test.t1 optimize status OK
Warnings:
Warning 139 Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline.
ALTER TABLE t1 FORCE;
Warnings:
Warning 139 Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline.
SET innodb_strict_mode = ON;
TRUNCATE TABLE t1;
Warnings:
Warning 139 Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline.
OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
test.t1 optimize status OK
Warnings:
Warning 139 Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline.
ALTER TABLE t1 FORCE;
Warnings:
Warning 139 Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline.
DROP TABLE t1;
SET @@global.log_warnings = 2;
SET innodb_strict_mode = 1;
10 changes: 9 additions & 1 deletion mysql-test/suite/innodb/t/row_size_error_log_warnings_3.test
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@ CREATE TABLE t1 (
,col_10 TEXT
,col_11 TEXT
) ENGINE=INNODB ROW_FORMAT=COMPACT;
--enable_warnings
TRUNCATE TABLE t1;
OPTIMIZE TABLE t1;
ALTER TABLE t1 FORCE;
SET innodb_strict_mode = ON;
TRUNCATE TABLE t1;
OPTIMIZE TABLE t1;
ALTER TABLE t1 FORCE;
DROP TABLE t1;
--disable_warnings

SET @@global.log_warnings = 2;
SET innodb_strict_mode = 1;
9 changes: 9 additions & 0 deletions mysql-test/suite/wsrep/r/variables.result
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ SELECT @@global.wsrep_slave_threads;
SELECT @@global.wsrep_cluster_address;
@@global.wsrep_cluster_address

SELECT @@global.wsrep_on;
@@global.wsrep_on
1
SHOW STATUS LIKE 'threads_connected';
Variable_name Value
Threads_connected 1
Expand All @@ -179,6 +182,9 @@ libgalera_smm.so
SELECT @@global.wsrep_cluster_address;
@@global.wsrep_cluster_address

SELECT @@global.wsrep_on;
@@global.wsrep_on
1
SHOW STATUS LIKE 'threads_connected';
Variable_name Value
Threads_connected 1
Expand Down Expand Up @@ -206,6 +212,9 @@ libgalera_smm.so
SELECT @@global.wsrep_cluster_address;
@@global.wsrep_cluster_address
gcomm://
SELECT @@global.wsrep_on;
@@global.wsrep_on
1
SHOW STATUS LIKE 'threads_connected';
Variable_name Value
Threads_connected 1
Expand Down
4 changes: 4 additions & 0 deletions mysql-test/suite/wsrep/t/variables.test
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ eval SET GLOBAL wsrep_provider= '$WSREP_PROVIDER';
SELECT @@global.wsrep_provider;
SELECT @@global.wsrep_slave_threads;
SELECT @@global.wsrep_cluster_address;
SELECT @@global.wsrep_on;
SHOW STATUS LIKE 'threads_connected';
SHOW STATUS LIKE 'wsrep_thread_count';
--echo
Expand All @@ -91,6 +92,7 @@ eval SET GLOBAL wsrep_provider= '$WSREP_PROVIDER';
--replace_regex /.*libgalera_smm.*/libgalera_smm.so/
SELECT @@global.wsrep_provider;
SELECT @@global.wsrep_cluster_address;
SELECT @@global.wsrep_on;
SHOW STATUS LIKE 'threads_connected';
SHOW STATUS LIKE 'wsrep_thread_count';
--echo
Expand All @@ -113,6 +115,7 @@ SELECT VARIABLE_VALUE AS EXPECT_2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VA
--replace_regex /.*libgalera_smm.*/libgalera_smm.so/
SELECT @@global.wsrep_provider;
SELECT @@global.wsrep_cluster_address;
SELECT @@global.wsrep_on;
SHOW STATUS LIKE 'threads_connected';
SHOW STATUS LIKE 'wsrep_thread_count';
--echo
Expand All @@ -135,6 +138,7 @@ SHOW STATUS LIKE 'threads_connected';
#
set wsrep_on=0;
set wsrep_on=1;
--source include/wait_until_connected_again.inc
create user test@localhost;
connect con1,localhost,test;
set auto_increment_increment=10;
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/fil/fil0crypt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2335,7 +2335,7 @@ static void fil_crypt_rotation_list_fill()
}
}

UT_LIST_ADD_LAST(fil_system.rotation_list, space);
fil_system.rotation_list.push_back(*space);
}
}

Expand Down
Loading

0 comments on commit eda7197

Please sign in to comment.