Commit 9b18f5a5 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-16142 Merge new release of InnoDB MySQL 5.7.22 to 10.2

parents 82f0dc35 0da98472
...@@ -306,3 +306,14 @@ id member_id ...@@ -306,3 +306,14 @@ id member_id
SELECT * FROM payment_method; SELECT * FROM payment_method;
id member_id cardholder_address_id id member_id cardholder_address_id
DROP TABLE payment_method,address,member; DROP TABLE payment_method,address,member;
#
# Bug #26958695 INNODB NESTED STORED FIELD WITH CONSTRAINT KEY
# PRODUCE BROKEN TABLE (no bug in MariaDB)
#
create table t1(f1 int,f2 int, primary key(f1), key(f2, f1))engine=innodb;
create table t2(f1 int, f2 int as (2) stored, f3 int as (f2) stored,
foreign key(f1) references t1(f2) on update set NULL)
engine=innodb;
insert into t1 values(1, 1);
insert into t2(f1) values(1);
drop table t2, t1;
# Create statement with FK on base column of stored column
create table t1(f1 int, f2 int as(f1) stored,
foreign key(f1) references t2(f1) on delete cascade)engine=innodb;
ERROR HY000: Can't create table `test`.`t1` (errno: 150 "Foreign key constraint is incorrectly formed")
# adding new stored column during alter table copy operation.
create table t1(f1 int primary key) engine=innodb;
create table t2(f1 int not null, f2 int as (f1) virtual,
foreign key(f1) references t1(f1) on update cascade)engine=innodb;
alter table t2 add column f3 int as (f1) stored, add column f4 int as (f1) virtual;
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`f1` int(11) NOT NULL,
`f2` int(11) GENERATED ALWAYS AS (`f1`) VIRTUAL,
`f3` int(11) GENERATED ALWAYS AS (`f1`) STORED,
`f4` int(11) GENERATED ALWAYS AS (`f1`) VIRTUAL,
KEY `f1` (`f1`),
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f1`) REFERENCES `t1` (`f1`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t2;
# adding foreign key constraint for base columns during alter copy.
create table t2(f1 int not null, f2 int as (f1) stored) engine=innodb;
alter table t2 add foreign key(f1) references t1(f1) on update cascade, algorithm=copy;
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`f1` int(11) NOT NULL,
`f2` int(11) GENERATED ALWAYS AS (`f1`) STORED,
KEY `f1` (`f1`),
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f1`) REFERENCES `t1` (`f1`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t2;
# adding foreign key constraint for base columns during online alter.
create table t2(f1 int not null, f2 int as (f1) stored) engine=innodb;
set foreign_key_checks = 0;
alter table t2 add foreign key(f1) references t1(f1) on update cascade, algorithm=inplace;
ERROR 0A000: Cannot add foreign key on the base column of stored column
drop table t2;
# adding stored column via online alter.
create table t2(f1 int not null,
foreign key(f1) references t1(f1) on update cascade)engine=innodb;
alter table t2 add column f2 int as (f1) stored, algorithm=inplace;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY
drop table t2, t1;
#
# BUG#26731689 FK ON TABLE WITH GENERATED COLS: ASSERTION POS < N_DEF
#
CREATE TABLE s (a INT, b INT GENERATED ALWAYS AS (0) STORED, c INT,
d INT GENERATED ALWAYS AS (0) VIRTUAL, e INT) ENGINE=innodb;
CREATE TABLE t (a INT) ENGINE=innodb;
ALTER TABLE s ADD CONSTRAINT c FOREIGN KEY (e) REFERENCES t(a) ON UPDATE SET null;
ERROR HY000: Failed to add the foreign key constaint. Missing index for constraint 'c' in the referenced table 't'
ALTER TABLE t ADD PRIMARY KEY(a);
ALTER TABLE s ADD CONSTRAINT c FOREIGN KEY (e) REFERENCES t(a) ON UPDATE SET null;
DROP TABLE s,t;
CREATE TABLE s (a INT GENERATED ALWAYS AS (0) VIRTUAL,
b INT GENERATED ALWAYS AS (0) STORED, c INT) ENGINE=innodb;
CREATE TABLE t (a INT) ENGINE=innodb;
ALTER TABLE s ADD CONSTRAINT c FOREIGN KEY (c) REFERENCES t(a) ON UPDATE SET null;
ERROR HY000: Failed to add the foreign key constaint. Missing index for constraint 'c' in the referenced table 't'
ALTER TABLE t ADD PRIMARY KEY(a);
ALTER TABLE s ADD CONSTRAINT c FOREIGN KEY (c) REFERENCES t(a) ON UPDATE SET null;
DROP TABLE s,t;
CREATE TABLE s (a INT, b INT GENERATED ALWAYS AS (0) STORED) ENGINE=innodb;
CREATE TABLE t (a INT PRIMARY KEY) ENGINE=innodb;
ALTER TABLE s ADD CONSTRAINT c FOREIGN KEY (a) REFERENCES t(a) ON UPDATE SET null;
DROP TABLE s,t;
CREATE TABLE s (a INT, b INT) ENGINE=innodb;
CREATE TABLE t (a INT) ENGINE=innodb;
ALTER TABLE s ADD CONSTRAINT c FOREIGN KEY (a) REFERENCES t(a) ON UPDATE SET null;
ERROR HY000: Failed to add the foreign key constaint. Missing index for constraint 'c' in the referenced table 't'
ALTER TABLE t ADD PRIMARY KEY(a);
ALTER TABLE s ADD CONSTRAINT c FOREIGN KEY (a) REFERENCES t(a) ON UPDATE SET null;
DROP TABLE s,t;
...@@ -276,4 +276,16 @@ SELECT * FROM payment_method; ...@@ -276,4 +276,16 @@ SELECT * FROM payment_method;
DROP TABLE payment_method,address,member; DROP TABLE payment_method,address,member;
--echo #
--echo # Bug #26958695 INNODB NESTED STORED FIELD WITH CONSTRAINT KEY
--echo # PRODUCE BROKEN TABLE (no bug in MariaDB)
--echo #
create table t1(f1 int,f2 int, primary key(f1), key(f2, f1))engine=innodb;
create table t2(f1 int, f2 int as (2) stored, f3 int as (f2) stored,
foreign key(f1) references t1(f2) on update set NULL)
engine=innodb;
insert into t1 values(1, 1);
insert into t2(f1) values(1);
drop table t2, t1;
--source include/wait_until_count_sessions.inc --source include/wait_until_count_sessions.inc
--source include/have_innodb.inc
--echo # Create statement with FK on base column of stored column
--error ER_CANT_CREATE_TABLE
create table t1(f1 int, f2 int as(f1) stored,
foreign key(f1) references t2(f1) on delete cascade)engine=innodb;
--echo # adding new stored column during alter table copy operation.
create table t1(f1 int primary key) engine=innodb;
create table t2(f1 int not null, f2 int as (f1) virtual,
foreign key(f1) references t1(f1) on update cascade)engine=innodb;
# MySQL 5.7 would refuse this
#--error ER_ERROR_ON_RENAME
alter table t2 add column f3 int as (f1) stored, add column f4 int as (f1) virtual;
show create table t2;
drop table t2;
--echo # adding foreign key constraint for base columns during alter copy.
create table t2(f1 int not null, f2 int as (f1) stored) engine=innodb;
# MySQL 5.7 would refuse this
alter table t2 add foreign key(f1) references t1(f1) on update cascade, algorithm=copy;
show create table t2;
drop table t2;
--echo # adding foreign key constraint for base columns during online alter.
create table t2(f1 int not null, f2 int as (f1) stored) engine=innodb;
set foreign_key_checks = 0;
--error 138
alter table t2 add foreign key(f1) references t1(f1) on update cascade, algorithm=inplace;
drop table t2;
--echo # adding stored column via online alter.
create table t2(f1 int not null,
foreign key(f1) references t1(f1) on update cascade)engine=innodb;
--error ER_ALTER_OPERATION_NOT_SUPPORTED
alter table t2 add column f2 int as (f1) stored, algorithm=inplace;
drop table t2, t1;
--echo #
--echo # BUG#26731689 FK ON TABLE WITH GENERATED COLS: ASSERTION POS < N_DEF
--echo #
CREATE TABLE s (a INT, b INT GENERATED ALWAYS AS (0) STORED, c INT,
d INT GENERATED ALWAYS AS (0) VIRTUAL, e INT) ENGINE=innodb;
CREATE TABLE t (a INT) ENGINE=innodb;
# This would fail. No corresponding index
--error ER_FK_NO_INDEX_PARENT
ALTER TABLE s ADD CONSTRAINT c FOREIGN KEY (e) REFERENCES t(a) ON UPDATE SET null;
ALTER TABLE t ADD PRIMARY KEY(a);
ALTER TABLE s ADD CONSTRAINT c FOREIGN KEY (e) REFERENCES t(a) ON UPDATE SET null;
DROP TABLE s,t;
CREATE TABLE s (a INT GENERATED ALWAYS AS (0) VIRTUAL,
b INT GENERATED ALWAYS AS (0) STORED, c INT) ENGINE=innodb;
CREATE TABLE t (a INT) ENGINE=innodb;
# This would fail. No corresponding index
--error ER_FK_NO_INDEX_PARENT
ALTER TABLE s ADD CONSTRAINT c FOREIGN KEY (c) REFERENCES t(a) ON UPDATE SET null;
ALTER TABLE t ADD PRIMARY KEY(a);
ALTER TABLE s ADD CONSTRAINT c FOREIGN KEY (c) REFERENCES t(a) ON UPDATE SET null;
DROP TABLE s,t;
CREATE TABLE s (a INT, b INT GENERATED ALWAYS AS (0) STORED) ENGINE=innodb;
CREATE TABLE t (a INT PRIMARY KEY) ENGINE=innodb;
ALTER TABLE s ADD CONSTRAINT c FOREIGN KEY (a) REFERENCES t(a) ON UPDATE SET null;
DROP TABLE s,t;
CREATE TABLE s (a INT, b INT) ENGINE=innodb;
CREATE TABLE t (a INT) ENGINE=innodb;
# This would fail. No corresponding index
--error ER_FK_NO_INDEX_PARENT
ALTER TABLE s ADD CONSTRAINT c FOREIGN KEY (a) REFERENCES t(a) ON UPDATE SET null;
ALTER TABLE t ADD PRIMARY KEY(a);
ALTER TABLE s ADD CONSTRAINT c FOREIGN KEY (a) REFERENCES t(a) ON UPDATE SET null;
DROP TABLE s,t;
...@@ -21,6 +21,7 @@ call mtr.add_suppression("InnoDB: Plugin initialization aborted"); ...@@ -21,6 +21,7 @@ call mtr.add_suppression("InnoDB: Plugin initialization aborted");
call mtr.add_suppression("innodb_temporary and innodb_system file names seem to be the same"); call mtr.add_suppression("innodb_temporary and innodb_system file names seem to be the same");
call mtr.add_suppression("Could not create the shared innodb_temporary"); call mtr.add_suppression("Could not create the shared innodb_temporary");
call mtr.add_suppression("InnoDB: syntax error in file path"); call mtr.add_suppression("InnoDB: syntax error in file path");
call mtr.add_suppression("InnoDB: Unable to parse innodb_temp_data_file_path=");
--enable_query_log --enable_query_log
let $MYSQL_TMP_DIR = `select @@tmpdir`; let $MYSQL_TMP_DIR = `select @@tmpdir`;
......
#
# Bug Bug #27304661 MYSQL CRASH DOING SYNC INDEX ]
# [FATAL] INNODB: SEMAPHORE WAIT HAS LASTED > 600
#
CREATE TABLE t1 (
id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
f1 TEXT(500),
FULLTEXT idx (f1)
) ENGINE=InnoDB;
insert into t1 (f1) values ('fjdhfsjhf'),('dhjfhjshfj'),('dhjafjhfj');
set @save_table_definition_cache=@@global.table_definition_cache;
set @save_table_open_cache=@@global.table_open_cache;
set global table_definition_cache=400;
set global table_open_cache= 1024;
SET @save_dbug = @@GLOBAL.debug_dbug;
SET GLOBAL DEBUG_DBUG="+d,crash_if_fts_table_is_evicted";
set @@global.table_definition_cache=@save_table_definition_cache;
set @@global.table_open_cache=@save_table_open_cache;
drop table t1;
--source include/have_innodb.inc
--source include/have_debug.inc
--source include/big_test.inc
--echo #
--echo # Bug Bug #27304661 MYSQL CRASH DOING SYNC INDEX ]
--echo # [FATAL] INNODB: SEMAPHORE WAIT HAS LASTED > 600
--echo #
CREATE TABLE t1 (
id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
f1 TEXT(500),
FULLTEXT idx (f1)
) ENGINE=InnoDB;
insert into t1 (f1) values ('fjdhfsjhf'),('dhjfhjshfj'),('dhjafjhfj');
--source include/restart_mysqld.inc
set @save_table_definition_cache=@@global.table_definition_cache;
set @save_table_open_cache=@@global.table_open_cache;
set global table_definition_cache=400;
set global table_open_cache= 1024;
SET @save_dbug = @@GLOBAL.debug_dbug;
SET GLOBAL DEBUG_DBUG="+d,crash_if_fts_table_is_evicted";
#Create 1000 tables, try the best to evict t1 .
--disable_query_log
let $loop=1000;
while($loop)
{
eval create table t_$loop(id int, name text(100), fulltext idxt_$loop(name) )engine=innodb;
dec $loop;
}
let $loop=1000;
while($loop)
{
eval drop table t_$loop;
dec $loop;
}
SET GLOBAL DEBUG_DBUG = @save_dbug;
--enable_query_log
set @@global.table_definition_cache=@save_table_definition_cache;
set @@global.table_open_cache=@save_table_open_cache;
drop table t1;
/***************************************************************************** /*****************************************************************************
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc. Copyright (c) 2008, Google Inc.
Copyright (c) 2013, 2018, MariaDB Corporation. Copyright (c) 2013, 2018, MariaDB Corporation.
...@@ -2869,6 +2869,9 @@ buf_pool_resize() ...@@ -2869,6 +2869,9 @@ buf_pool_resize()
= buf_pool->n_chunks; = buf_pool->n_chunks;
warning = true; warning = true;
buf_pool->chunks_old = NULL; buf_pool->chunks_old = NULL;
for (ulint j = 0; j < buf_pool->n_chunks_new; j++) {
buf_pool_register_chunk(&(buf_pool->chunks[j]));
}
goto calc_buf_pool_size; goto calc_buf_pool_size;
} }
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc. Copyright (c) 2012, Facebook Inc.
Copyright (c) 2013, 2018, MariaDB Corporation. Copyright (c) 2013, 2018, MariaDB Corporation.
...@@ -1453,6 +1453,13 @@ dict_make_room_in_cache( ...@@ -1453,6 +1453,13 @@ dict_make_room_in_cache(
if (dict_table_can_be_evicted(table)) { if (dict_table_can_be_evicted(table)) {
DBUG_EXECUTE_IF("crash_if_fts_table_is_evicted",
{
if (table->fts &&
dict_table_has_fts_index(table)) {
ut_ad(0);
}
};);
dict_table_remove_from_cache_low(table, TRUE); dict_table_remove_from_cache_low(table, TRUE);
++n_evicted; ++n_evicted;
...@@ -2421,6 +2428,44 @@ dict_index_add_to_cache( ...@@ -2421,6 +2428,44 @@ dict_index_add_to_cache(
table, index, NULL, page_no, strict)); table, index, NULL, page_no, strict));
} }
/** Clears the virtual column's index list before index is
being freed.
@param[in] index Index being freed */
void
dict_index_remove_from_v_col_list(dict_index_t* index) {
/* Index is not completely formed */
if (!index->cached) {
return;
}
if (dict_index_has_virtual(index)) {
const dict_col_t* col;
const dict_v_col_t* vcol;
for (ulint i = 0; i < dict_index_get_n_fields(index); i++) {
col = dict_index_get_nth_col(index, i);
if (dict_col_is_virtual(col)) {
vcol = reinterpret_cast<const dict_v_col_t*>(
col);
/* This could be NULL, when we do add
virtual column, add index together. We do not
need to track this virtual column's index */
if (vcol->v_indexes == NULL) {
continue;
}
dict_v_idx_list::iterator it;
for (it = vcol->v_indexes->begin();
it != vcol->v_indexes->end(); ++it) {
dict_v_idx_t v_index = *it;
if (v_index.index == index) {
vcol->v_indexes->erase(it);
break;
}
}
}
}
}
}
/** Adds an index to the dictionary cache, with possible indexing newly /** Adds an index to the dictionary cache, with possible indexing newly
added column. added column.
@param[in,out] table table on which the index is @param[in,out] table table on which the index is
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc. Copyright (c) 2012, Facebook Inc.
Copyright (c) 2013, 2018, MariaDB Corporation. Copyright (c) 2013, 2018, MariaDB Corporation.
...@@ -1034,6 +1034,7 @@ dict_mem_index_free( ...@@ -1034,6 +1034,7 @@ dict_mem_index_free(
UT_DELETE(index->rtr_track->rtr_active); UT_DELETE(index->rtr_track->rtr_active);
} }
dict_index_remove_from_v_col_list(index);
mem_heap_free(index->heap); mem_heap_free(index->heap);
} }
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 2007, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2007, 2018, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2016, 2018, MariaDB Corporation. Copyright (c) 2016, 2018, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
...@@ -41,6 +41,9 @@ Completed 2011/7/10 Sunny and Jimmy Yang ...@@ -41,6 +41,9 @@ Completed 2011/7/10 Sunny and Jimmy Yang
/** The FTS optimize thread's work queue. */ /** The FTS optimize thread's work queue. */
static ib_wqueue_t* fts_optimize_wq; static ib_wqueue_t* fts_optimize_wq;
/** The FTS vector to store fts_slot_t */
static ib_vector_t* fts_slots;
/** Time to wait for a message. */ /** Time to wait for a message. */
static const ulint FTS_QUEUE_WAIT_IN_USECS = 5000000; static const ulint FTS_QUEUE_WAIT_IN_USECS = 5000000;
...@@ -2976,9 +2979,6 @@ fts_optimize_thread( ...@@ -2976,9 +2979,6 @@ fts_optimize_thread(
/*================*/ /*================*/
void* arg) /*!< in: work queue*/ void* arg) /*!< in: work queue*/
{ {
mem_heap_t* heap;
ib_vector_t* tables;
ib_alloc_t* heap_alloc;
ulint current = 0; ulint current = 0;
ibool done = FALSE; ibool done = FALSE;
ulint n_tables = 0; ulint n_tables = 0;
...@@ -2988,10 +2988,10 @@ fts_optimize_thread( ...@@ -2988,10 +2988,10 @@ fts_optimize_thread(
ut_ad(!srv_read_only_mode); ut_ad(!srv_read_only_mode);
my_thread_init(); my_thread_init();
heap = mem_heap_create(sizeof(dict_table_t*) * 64); ut_ad(fts_slots);
heap_alloc = ib_heap_allocator_create(heap);
tables = ib_vector_create(heap_alloc, sizeof(fts_slot_t), 4); /* Assign number of tables added in fts_slots_t to n_tables */
n_tables = ib_vector_size(fts_slots);
while (!done && srv_shutdown_state == SRV_SHUTDOWN_NONE) { while (!done && srv_shutdown_state == SRV_SHUTDOWN_NONE) {
...@@ -3005,10 +3005,10 @@ fts_optimize_thread( ...@@ -3005,10 +3005,10 @@ fts_optimize_thread(
fts_slot_t* slot; fts_slot_t* slot;
ut_a(ib_vector_size(tables) > 0); ut_a(ib_vector_size(fts_slots) > 0);
slot = static_cast<fts_slot_t*>( slot = static_cast<fts_slot_t*>(
ib_vector_get(tables, current)); ib_vector_get(fts_slots, current));
/* Handle the case of empty slots. */ /* Handle the case of empty slots. */
if (slot->state != FTS_STATE_EMPTY) { if (slot->state != FTS_STATE_EMPTY) {
...@@ -3021,8 +3021,8 @@ fts_optimize_thread( ...@@ -3021,8 +3021,8 @@ fts_optimize_thread(
++current; ++current;
/* Wrap around the counter. */ /* Wrap around the counter. */
if (current >= ib_vector_size(tables)) { if (current >= ib_vector_size(fts_slots)) {
n_optimize = fts_optimize_how_many(tables); n_optimize = fts_optimize_how_many(fts_slots);
current = 0; current = 0;
} }
...@@ -3036,7 +3036,7 @@ fts_optimize_thread( ...@@ -3036,7 +3036,7 @@ fts_optimize_thread(
/* Timeout ? */ /* Timeout ? */
if (msg == NULL) { if (msg == NULL) {
if (fts_is_sync_needed(tables)) { if (fts_is_sync_needed(fts_slots)) {
fts_need_sync = true; fts_need_sync = true;
} }
...@@ -3057,7 +3057,7 @@ fts_optimize_thread( ...@@ -3057,7 +3057,7 @@ fts_optimize_thread(
case FTS_MSG_ADD_TABLE: case FTS_MSG_ADD_TABLE:
ut_a(!done); ut_a(!done);
if (fts_optimize_new_table( if (fts_optimize_new_table(
tables, fts_slots,
static_cast<dict_table_t*>( static_cast<dict_table_t*>(
msg->ptr))) { msg->ptr))) {
++n_tables; ++n_tables;
...@@ -3067,7 +3067,7 @@ fts_optimize_thread( ...@@ -3067,7 +3067,7 @@ fts_optimize_thread(
case FTS_MSG_OPTIMIZE_TABLE: case FTS_MSG_OPTIMIZE_TABLE:
if (!done) { if (!done) {
fts_optimize_start_table( fts_optimize_start_table(
tables, fts_slots,
static_cast<dict_table_t*>( static_cast<dict_table_t*>(
msg->ptr)); msg->ptr));
} }
...@@ -3075,7 +3075,7 @@ fts_optimize_thread( ...@@ -3075,7 +3075,7 @@ fts_optimize_thread(
case FTS_MSG_DEL_TABLE: case FTS_MSG_DEL_TABLE:
if (fts_optimize_del_table( if (fts_optimize_del_table(
tables, static_cast<fts_msg_del_t*>( fts_slots, static_cast<fts_msg_del_t*>(
msg->ptr))) { msg->ptr))) {
--n_tables; --n_tables;
} }
...@@ -3098,7 +3098,7 @@ fts_optimize_thread( ...@@ -3098,7 +3098,7 @@ fts_optimize_thread(
mem_heap_free(msg->heap); mem_heap_free(msg->heap);
if (!done) { if (!done) {
n_optimize = fts_optimize_how_many(tables); n_optimize = fts_optimize_how_many(fts_slots);
} else { } else {
n_optimize = 0; n_optimize = 0;
} }
...@@ -3110,11 +3110,11 @@ fts_optimize_thread( ...@@ -3110,11 +3110,11 @@ fts_optimize_thread(
if (n_tables > 0) { if (n_tables > 0) {
ulint i; ulint i;
for (i = 0; i < ib_vector_size(tables); i++) { for (i = 0; i < ib_vector_size(fts_slots); i++) {
fts_slot_t* slot; fts_slot_t* slot;
slot = static_cast<fts_slot_t*>( slot = static_cast<fts_slot_t*>(
ib_vector_get(tables, i)); ib_vector_get(fts_slots, i));
if (slot->state != FTS_STATE_EMPTY) { if (slot->state != FTS_STATE_EMPTY) {
fts_optimize_sync_table(slot->table_id); fts_optimize_sync_table(slot->table_id);
...@@ -3122,7 +3122,7 @@ fts_optimize_thread( ...@@ -3122,7 +3122,7 @@ fts_optimize_thread(
} }
} }
ib_vector_free(tables); ib_vector_free(fts_slots);
ib::info() << "FTS optimize thread exiting."; ib::info() << "FTS optimize thread exiting.";
...@@ -3142,14 +3142,52 @@ void ...@@ -3142,14 +3142,52 @@ void
fts_optimize_init(void) fts_optimize_init(void)
/*===================*/ /*===================*/
{ {
mem_heap_t* heap;
ib_alloc_t* heap_alloc;
dict_table_t* table;
ut_ad(!srv_read_only_mode); ut_ad(!srv_read_only_mode);
/* For now we only support one optimize thread. */ /* For now we only support one optimize thread. */
ut_a(fts_optimize_wq == NULL); ut_a(fts_optimize_wq == NULL);
/* Create FTS optimize work queue */
fts_optimize_wq = ib_wqueue_create(); fts_optimize_wq = ib_wqueue_create();
fts_opt_shutdown_event = os_event_create(0);
ut_a(fts_optimize_wq != NULL); ut_a(fts_optimize_wq != NULL);
/* Create FTS vector to store fts_slot_t */
heap = mem_heap_create(sizeof(dict_table_t*) * 64);
heap_alloc = ib_heap_allocator_create(heap);
fts_slots = ib_vector_create(heap_alloc, sizeof(fts_slot_t), 4);
/* Add fts tables to the fts_slots vector which were skipped during restart */
std::vector<dict_table_t*> table_vector;
std::vector<dict_table_t*>::iterator it;
mutex_enter(&dict_sys->mutex);
for (table = UT_LIST_GET_FIRST(dict_sys->table_LRU);
table != NULL;
table = UT_LIST_GET_NEXT(table_LRU, table)) {
if (table->fts &&
dict_table_has_fts_index(table)) {
if (fts_optimize_new_table(fts_slots,
table)){
table_vector.push_back(table);
}
}
}
/* It is better to call dict_table_prevent_eviction()
outside the above loop because it operates on
dict_sys->table_LRU list.*/
for (it=table_vector.begin();it!=table_vector.end();++it) {
dict_table_prevent_eviction(*it);
}
mutex_exit(&dict_sys->mutex);
table_vector.clear();
fts_opt_shutdown_event = os_event_create(0);
last_check_sync_time = ut_time(); last_check_sync_time = ut_time();
os_thread_create(fts_optimize_thread, fts_optimize_wq, NULL); os_thread_create(fts_optimize_thread, fts_optimize_wq, NULL);
......
...@@ -3932,6 +3932,8 @@ innobase_init( ...@@ -3932,6 +3932,8 @@ innobase_init(
/* Supports raw devices */ /* Supports raw devices */
if (!srv_sys_space.parse_params(innobase_data_file_path, true)) { if (!srv_sys_space.parse_params(innobase_data_file_path, true)) {
ib::error() << "Unable to parse innodb_data_file_path="
<< innobase_data_file_path;
DBUG_RETURN(innobase_init_abort()); DBUG_RETURN(innobase_init_abort());
} }
...@@ -3950,6 +3952,8 @@ innobase_init( ...@@ -3950,6 +3952,8 @@ innobase_init(
srv_tmp_space.set_flags(FSP_FLAGS_PAGE_SSIZE()); srv_tmp_space.set_flags(FSP_FLAGS_PAGE_SSIZE());
if (!srv_tmp_space.parse_params(innobase_temp_data_file_path, false)) { if (!srv_tmp_space.parse_params(innobase_temp_data_file_path, false)) {
ib::error() << "Unable to parse innodb_temp_data_file_path="
<< innobase_temp_data_file_path;
DBUG_RETURN(innobase_init_abort()); DBUG_RETURN(innobase_init_abort());
} }
......
...@@ -5434,18 +5434,24 @@ alter_fill_stored_column( ...@@ -5434,18 +5434,24 @@ alter_fill_stored_column(
dict_s_col_list** s_cols, dict_s_col_list** s_cols,
mem_heap_t** s_heap) mem_heap_t** s_heap)
{ {
ulint n_cols = altered_table->s->fields; ulint n_cols = altered_table->s->fields;
ulint stored_col_no = 0;
for (ulint i = 0; i < n_cols; i++) { for (ulint i = 0; i < n_cols; i++) {
Field* field = altered_table->field[i]; Field* field = altered_table->field[i];
dict_s_col_t s_col; dict_s_col_t s_col;
if (!innobase_is_v_fld(field)) {
stored_col_no++;
}
if (!innobase_is_s_fld(field)) { if (!innobase_is_s_fld(field)) {
continue; continue;
} }
ulint num_base = 0; ulint num_base = 0;
dict_col_t* col = dict_table_get_nth_col(table, i); dict_col_t* col = dict_table_get_nth_col(table,
stored_col_no);
s_col.m_col = col; s_col.m_col = col;
s_col.s_pos = i; s_col.s_pos = i;
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc. Copyright (c) 2012, Facebook Inc.
Copyright (c) 2013, 2018, MariaDB Corporation. Copyright (c) 2013, 2018, MariaDB Corporation.
...@@ -1121,6 +1121,12 @@ dict_index_add_to_cache( ...@@ -1121,6 +1121,12 @@ dict_index_add_to_cache(
ibool strict) ibool strict)
MY_ATTRIBUTE((warn_unused_result)); MY_ATTRIBUTE((warn_unused_result));
/** Clears the virtual column's index list before index is being freed.
@param[in] index Index being freed */
void
dict_index_remove_from_v_col_list(
dict_index_t* index);
/** Adds an index to the dictionary cache, with possible indexing newly /** Adds an index to the dictionary cache, with possible indexing newly
added column. added column.
@param[in] table table on which the index is @param[in] table table on which the index is
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment