Skip to content

Commit

Permalink
Merge 10.2 into bb-10.2-ext
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-m committed Feb 8, 2018
2 parents 3cad31f + f01ce62 commit c567369
Show file tree
Hide file tree
Showing 21 changed files with 176 additions and 48 deletions.
10 changes: 10 additions & 0 deletions mysql-test/r/dyncol.result
Original file line number Diff line number Diff line change
Expand Up @@ -1883,6 +1883,16 @@ SELECT COLUMN_JSON(COLUMN_CREATE('test','First line\nSecond line')) AS json;
json
{"test":"First line\u000ASecond line"}
#
# MDEV-15230: column_json breaks cyrillic in 10.1.31
#
set names utf8;
create table t1 (b blob);
insert into t1 values (column_create('description',column_create('title','Описание')));
select column_json(b) from t1;
column_json(b)
{"description":{"title":"Описание"}}
drop table t1;
#
# end of 10.0 tests
#
#
Expand Down
31 changes: 31 additions & 0 deletions mysql-test/suite/innodb/r/mvcc.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
SET @save_per_table= @@GLOBAL.innodb_file_per_table;
SET GLOBAL innodb_file_per_table= 1;
#
# MDEV-15249 Crash in MVCC read after IMPORT TABLESPACE
#
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES(0);
FLUSH TABLES t1 WITH READ LOCK;
UNLOCK TABLES;
START TRANSACTION WITH CONSISTENT SNAPSHOT;
connect con1,localhost,root,,;
ALTER TABLE t1 FORCE, ALGORITHM=COPY;
connection default;
SELECT * FROM t1;
ERROR HY000: Table definition has changed, please retry transaction
COMMIT;
START TRANSACTION WITH CONSISTENT SNAPSHOT;
connection con1;
ALTER TABLE t1 DISCARD TABLESPACE;
ALTER TABLE t1 IMPORT TABLESPACE;
disconnect con1;
connection default;
# FIXME: Block this with ER_TABLE_DEF_CHANGED
SELECT * FROM t1;
a
COMMIT;
SELECT * FROM t1;
a
0
DROP TABLE t1;
SET GLOBAL innodb_file_per_table= @save_per_table;
1 change: 1 addition & 0 deletions mysql-test/suite/innodb/r/recovery_shutdown.result
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,5 @@ INSERT INTO t1(a) SELECT NULL FROM t1;
connection default;
SET GLOBAL innodb_flush_log_at_trx_commit=1;
CREATE TABLE u(a SERIAL) ENGINE=INNODB;
FLUSH TABLES;
DROP TABLE t,u;
52 changes: 52 additions & 0 deletions mysql-test/suite/innodb/t/mvcc.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
--source include/have_innodb.inc

SET @save_per_table= @@GLOBAL.innodb_file_per_table;
SET GLOBAL innodb_file_per_table= 1;

let MYSQLD_DATADIR =`SELECT @@datadir`;

--echo #
--echo # MDEV-15249 Crash in MVCC read after IMPORT TABLESPACE
--echo #

CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES(0);
FLUSH TABLES t1 WITH READ LOCK;
perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_backup_tablespace("test", "t1");
EOF
UNLOCK TABLES;

START TRANSACTION WITH CONSISTENT SNAPSHOT;

connect (con1,localhost,root,,);
ALTER TABLE t1 FORCE, ALGORITHM=COPY;

connection default;
--error ER_TABLE_DEF_CHANGED
SELECT * FROM t1;
COMMIT;
START TRANSACTION WITH CONSISTENT SNAPSHOT;

connection con1;

ALTER TABLE t1 DISCARD TABLESPACE;

perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_restore_tablespace("test", "t1");
EOF

ALTER TABLE t1 IMPORT TABLESPACE;
disconnect con1;

connection default;
--echo # FIXME: Block this with ER_TABLE_DEF_CHANGED
SELECT * FROM t1;
COMMIT;
SELECT * FROM t1;

DROP TABLE t1;

SET GLOBAL innodb_file_per_table= @save_per_table;
2 changes: 2 additions & 0 deletions mysql-test/suite/innodb/t/recovery_shutdown.test
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ INSERT INTO t1(a) SELECT NULL FROM t1;
SET GLOBAL innodb_flush_log_at_trx_commit=1;
CREATE TABLE u(a SERIAL) ENGINE=INNODB;

FLUSH TABLES;

--let $shutdown_timeout=0
--source include/restart_mysqld.inc
--let $shutdown_timeout=60
Expand Down
9 changes: 9 additions & 0 deletions mysql-test/t/dyncol.test
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,15 @@ SELECT COLUMN_JSON(COLUMN_CREATE('a',1 AS DECIMAL,'b',1 AS DECIMAL));
SELECT COLUMN_JSON(COLUMN_CREATE('test','"\\\t\n\Z')) AS json;
SELECT COLUMN_JSON(COLUMN_CREATE('test','First line\nSecond line')) AS json;

--echo #
--echo # MDEV-15230: column_json breaks cyrillic in 10.1.31
--echo #
set names utf8;
create table t1 (b blob);
insert into t1 values (column_create('description',column_create('title','Описание')));
select column_json(b) from t1;
drop table t1;

--echo #
--echo # end of 10.0 tests
--echo #
Expand Down
1 change: 1 addition & 0 deletions mysql-test/unstable-tests
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ main.innodb_mysql_lock : MDEV-7861 - Wrong result
main.join_outer : Modified in 10.2.12
main.kill-2 : MDEV-13257 - Wrong result
main.log_slow : MDEV-13263 - Wrong result
main.mdev-504 : MDEV-15171 - warning
main.mysql_client_test_nonblock : CONC-208 - Error on Power
main.mysql_upgrade_noengine : MDEV-14355 - Wrong result
main.mysql_upgrade_ssl : MDEV-13492 - Unknown SSL error
Expand Down
2 changes: 1 addition & 1 deletion mysys/ma_dyncol.c
Original file line number Diff line number Diff line change
Expand Up @@ -3833,7 +3833,7 @@ my_bool dynstr_append_json_quoted(DYNAMIC_STRING *str,
for (i= 0; i < len; i++)
{
register char c= append[i];
if (unlikely(c <= 0x1F))
if (unlikely(((uchar)c) <= 0x1F))
{
if (lim < 5)
{
Expand Down
27 changes: 25 additions & 2 deletions storage/innobase/btr/btr0cur.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2811,7 +2811,7 @@ btr_cur_ins_lock_and_undo(
}

if (flags & BTR_NO_UNDO_LOG_FLAG) {
roll_ptr = 0;
roll_ptr = roll_ptr_t(1) << ROLL_PTR_INSERT_FLAG_POS;
} else {
err = trx_undo_report_row_operation(thr, index, entry,
NULL, 0, NULL, NULL,
Expand Down Expand Up @@ -3016,7 +3016,7 @@ btr_cur_optimistic_insert(

DBUG_LOG("ib_cur",
"insert " << index->name << " (" << index->id << ") by "
<< ib::hex(thr ? trx_get_id_for_print(thr_get_trx(thr)) : 0)
<< ib::hex(thr ? thr->graph->trx->id : 0)
<< ' ' << rec_printer(entry).str());
DBUG_EXECUTE_IF("do_page_reorganize",
btr_page_reorganize(page_cursor, index, mtr););
Expand All @@ -3033,6 +3033,29 @@ btr_cur_optimistic_insert(
goto fail_err;
}

#ifdef UNIV_DEBUG
if (!(flags & BTR_CREATE_FLAG)
&& index->is_primary() && page_is_leaf(page)) {
const dfield_t* trx_id = dtuple_get_nth_field(
entry, dict_col_get_clust_pos(
dict_table_get_sys_col(index->table,
DATA_TRX_ID),
index));

ut_ad(trx_id->len == DATA_TRX_ID_LEN);
ut_ad(trx_id[1].len == DATA_ROLL_PTR_LEN);
ut_ad(*static_cast<const byte*>
(trx_id[1].data) & 0x80);
if (!(flags & BTR_NO_UNDO_LOG_FLAG)) {
ut_ad(thr->graph->trx->id);
ut_ad(thr->graph->trx->id
== trx_read_trx_id(
static_cast<const byte*>(
trx_id->data)));
}
}
#endif

*rec = page_cur_tuple_insert(
page_cursor, entry, index, offsets, heap,
n_ext, mtr);
Expand Down
7 changes: 7 additions & 0 deletions storage/innobase/include/dict0mem.h
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,13 @@ struct dict_index_t{
and the .ibd file is missing, or a
page cannot be read or decrypted */
inline bool is_readable() const;

/** @return whether the index is the primary key index
(not the clustered index of the change buffer) */
bool is_primary() const
{
return DICT_CLUSTERED == (type & (DICT_CLUSTERED | DICT_IBUF));
}
};

/** The status of online index creation */
Expand Down
7 changes: 4 additions & 3 deletions storage/innobase/include/row0ins.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, MariaDB Corporation.
Copyright (c) 2017, 2018, 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
Expand Down Expand Up @@ -198,10 +198,11 @@ struct ins_node_t{
this should be reset to NULL */
UT_LIST_BASE_NODE_T(dtuple_t)
entry_list;/* list of entries, one for each index */
byte* row_id_buf;/* buffer for the row id sys field in row */
/** buffer for the system columns */
byte sys_buf[DATA_ROW_ID_LEN
+ DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN];
trx_id_t trx_id; /*!< trx id or the last trx which executed the
node */
byte* trx_id_buf;/* buffer for the trx id sys field in row */
mem_heap_t* entry_sys_heap;
/* memory heap used as auxiliary storage;
entry_list and sys fields are stored here;
Expand Down
4 changes: 2 additions & 2 deletions storage/innobase/include/row0upd.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2018, 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
Expand Down Expand Up @@ -126,8 +127,7 @@ row_upd_rec_sys_fields(
dict_index_t* index, /*!< in: clustered index */
const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */
const trx_t* trx, /*!< in: transaction */
roll_ptr_t roll_ptr);/*!< in: roll ptr of the undo log record,
can be 0 during IMPORT */
roll_ptr_t roll_ptr);/*!< in: DB_ROLL_PTR to the undo log */
/*********************************************************************//**
Sets the trx id or roll ptr field of a clustered index entry. */
void
Expand Down
5 changes: 2 additions & 3 deletions storage/innobase/include/row0upd.ic
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*****************************************************************************

Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, MariaDB Corporation.
Copyright (c) 2017, 2018, 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
Expand Down Expand Up @@ -165,8 +165,7 @@ row_upd_rec_sys_fields(
dict_index_t* index, /*!< in: clustered index */
const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */
const trx_t* trx, /*!< in: transaction */
roll_ptr_t roll_ptr)/*!< in: roll ptr of the undo log record,
can be 0 during IMPORT */
roll_ptr_t roll_ptr)/*!< in: DB_ROLL_PTR to the undo log */
{
ut_ad(dict_index_is_clust(index));
ut_ad(rec_offs_validate(rec, index, offsets));
Expand Down
13 changes: 4 additions & 9 deletions storage/innobase/row/row0import.cc
Original file line number Diff line number Diff line change
Expand Up @@ -897,13 +897,11 @@ class PageConverter : public AbstractCallback {
@param index the index being converted
@param rec record to update
@param offsets column offsets for the record
@param deleted true if row is delete marked
@return DB_SUCCESS or error code. */
dberr_t adjust_cluster_record(
const dict_index_t* index,
rec_t* rec,
const ulint* offsets,
bool deleted) UNIV_NOTHROW;
const ulint* offsets) UNIV_NOTHROW;

/** Find an index with the matching id.
@return row_index_t* instance or 0 */
Expand Down Expand Up @@ -1675,14 +1673,12 @@ PageConverter::purge(const ulint* offsets) UNIV_NOTHROW
/** Adjust the BLOB references and sys fields for the current record.
@param rec record to update
@param offsets column offsets for the record
@param deleted true if row is delete marked
@return DB_SUCCESS or error code. */
dberr_t
PageConverter::adjust_cluster_record(
const dict_index_t* index,
rec_t* rec,
const ulint* offsets,
bool deleted) UNIV_NOTHROW
const ulint* offsets) UNIV_NOTHROW
{
dberr_t err;

Expand All @@ -1694,7 +1690,7 @@ PageConverter::adjust_cluster_record(

row_upd_rec_sys_fields(
rec, m_page_zip_ptr, m_cluster_index, m_offsets,
m_trx, 0);
m_trx, roll_ptr_t(1) << ROLL_PTR_INSERT_FLAG_POS);
}

return(err);
Expand Down Expand Up @@ -1737,8 +1733,7 @@ PageConverter::update_records(
if (clust_index) {

dberr_t err = adjust_cluster_record(
m_index->m_srv_index, rec, m_offsets,
deleted);
m_index->m_srv_index, rec, m_offsets);

if (err != DB_SUCCESS) {
return(err);
Expand Down
Loading

0 comments on commit c567369

Please sign in to comment.