Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions mysql-test/suite/innodb_fts/r/create.result
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,11 @@ ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Not implemented for sys
ALTER TABLE t1 ADD FULLTEXT INDEX(b), ALGORITHM=COPY;
ERROR HY000: Index 'FTS_DOC_ID_INDEX' is of wrong type for an InnoDB FULLTEXT index
DROP TABLE t1;
#
# MDEV-40985 row_end access out of bounds in ALTER TABLE
#
CREATE TABLE t1
(a TEXT,b INT AS(1),c INT AS(1),d INT AS(1),e INT AS(1),f INT AS(1),
FULLTEXT INDEX(a)) ENGINE=InnoDB;
ALTER TABLE t1 FORCE;
DROP TABLE t1;
10 changes: 10 additions & 0 deletions mysql-test/suite/innodb_fts/t/create.test
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,13 @@ ALTER TABLE t1 ADD FULLTEXT INDEX(b), ALGORITHM=INPLACE;
--error ER_INNODB_FT_WRONG_DOCID_INDEX
ALTER TABLE t1 ADD FULLTEXT INDEX(b), ALGORITHM=COPY;
DROP TABLE t1;

--echo #
--echo # MDEV-40985 row_end access out of bounds in ALTER TABLE
--echo #

CREATE TABLE t1
(a TEXT,b INT AS(1),c INT AS(1),d INT AS(1),e INT AS(1),f INT AS(1),
FULLTEXT INDEX(a)) ENGINE=InnoDB;
ALTER TABLE t1 FORCE;
DROP TABLE t1;
13 changes: 6 additions & 7 deletions storage/innobase/handler/handler0alter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4310,20 +4310,19 @@ ha_innobase_inplace_ctx::create_key_defs(

if (add_fts_doc_idx) {
index_def_t* index = indexdef++;
uint nfields = 1;

if (altered_table->versioned())
++nfields;
const uint nfields = altered_table->versioned() + 1;
index->fields = static_cast<index_field_t*>(
mem_heap_alloc(heap, sizeof(*index->fields) * nfields));
mem_heap_alloc(heap, nfields * sizeof *index->fields));
index->n_fields = nfields;
index->fields[0].col_no = fts_doc_id_col;
index->fields[0].prefix_len = 0;
index->fields[0].descending = false;
index->fields[0].is_v_col = false;
if (nfields == 2) {
index->fields[1].col_no
= altered_table->s->vers.end_fieldno;
/* FTS_DOC_ID_INDEX(FTS_DOC_ID,row_end) */
Comment thread
dr-m marked this conversation as resolved.
index->fields[1].col_no = innodb_col_no(
altered_table->field[
altered_table->s->vers.end_fieldno]);
index->fields[1].prefix_len = 0;
index->fields[1].descending = false;
index->fields[1].is_v_col = false;
Expand Down