Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-17459

Allow instant ALTER TABLE even if FULLTEXT INDEX exists

    XMLWordPrintable

    Details

      Description

      The function fts_fetch_doc_from_rec() and possibly other code for dealing with FULLTEXT INDEX assumes that no instant ALTER TABLE has been used.

      It seems that this code may not be ready for MDEV-11369 either.

      The following raw test demonstrates the problem:

      --source include/have_innodb.inc
      --disable_abort_on_error
      --disable_warnings
       
      CREATE TABLE IF NOT EXISTS t1 (col1 INT, col2 INT, col_int INTEGER, col_text TEXT) ENGINE = InnoDB  ;
      ALTER TABLE t1 ADD FULLTEXT KEY `Marvão_ftidx1` ( col_text ), ADD FULLTEXT KEY IF NOT EXISTS `Marvão_ftidx1` ( col_text )  ;
      INSERT INTO t1 (col1,col2, col_int, col_text) VALUES ( 1, 1, 1 - 1, REPEAT(CAST( 1 AS CHAR(1)), @fill_amount) ) ;
      ALTER TABLE t1 ADD COLUMN col_int_copy INTEGER FIRST, ALGORITHM = DEFAULT  ;
      ALTER TABLE t1 DROP COLUMN IF EXISTS col_int  ;
      ALTER TABLE t1 CHANGE COLUMN IF EXISTS col_int_copy Col_int INTEGER, LOCK = NONE, ALGORITHM = INPLACE  ;
      UPDATE t1 SET col1 = 28 LIMIT 2;
      ALTER TABLE t1 ADD FULLTEXT KEY `Marvão_ftidx1` ( col_text ), ADD FULLTEXT KEY IF NOT EXISTS `Marvão_ftidx1` ( col_text )  ;
      INSERT INTO t1 (col1,col2, col_int, col_text) VALUES ( 1, 1, 1 - 1, REPEAT(CAST( 1 AS CHAR(1)), @fill_amount) ) ;
      DROP TABLE t1;
      

      10.4-mdev-15562 ba5168fd8fa96a580645ecb0450e8ac5d53c86dd

      mysqld: fts/fts0fts.cc:3265: void fts_fetch_doc_from_rec(fts_get_doc_t*, dict_index_t*, btr_pcur_t*, ulint*, fts_doc_t*): Assertion `!page_rec_is_comp(clust_rec) || rec_get_status(clust_rec) == REC_STATUS_ORDINARY' failed.
      

      I believe that a similar failure should be possible already on 10.3 when a user-created FTS_DOC_ID exists and MDEV-11369 Instant ADD COLUMN is used. Please clean up the test and check if 10.3 is affected.

      Suggestions:

      1. Ensure that the hidden metadata record is always skipped. (Add debug assertions.)
      2. Properly handle records on which instantly added fields are present.
      3. Also test with UNIQUE INDEX FTS_DOC_ID_INDEX(FTS_DOC_ID) such that the table does not have any PRIMARY KEY.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              thiru Thirunarayanan Balathandayuthapani
              Reporter:
              marko Marko Mäkelä
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated: