From 860debaffc1e2dbfb30100ced1d2278f0e979956 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Tue, 8 Dec 2020 13:14:17 +0530 Subject: MDEV-515 innodb bulk insert - Introduced assign_stat_n_rows() in dict_table_t. It calculates the number of rows in the table and assign stat_n_rows during ha_innobase::open() - Introduced empty_table() in dict_table_t. Basically it empties all the indexes associated with table (not covered the fts index). This is undo operation of bulk operation. - Introduced new variable bulk_trx_id in dict_table_t. It stores the transaction id of bulk insert. Basically it is protected by exclusive lock of the table. - Introduced new variable non_empty in dict_table_t. It indicates the whether the table is empty. - If table is empty then INSERT, INSERT..SELECT does take exclusive lock on the table. - Introduced new undo log record "TRX_UNDO_UNEMPTY". It should be first undo log during bulk operation. While rollback, if innodb encounters the undo record then it should empty the table. Limitations: =========== - Parallel read should give empty table depends on bulk_trx_id - Need to handle the online alter when the table is empty. --- storage/innobase/include/dict0mem.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'storage/innobase/include/dict0mem.h') diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h index 1ad2517c8fb..d905b252571 100644 --- a/storage/innobase/include/dict0mem.h +++ b/storage/innobase/include/dict0mem.h @@ -1368,6 +1368,9 @@ public: everything in overflow) size of the longest possible row and index of a field which made index records too big to fit on a page.*/ inline record_size_info_t record_size_info() const; + + /** Empty the index content and reinitialize the root page */ + void empty(que_thr_t *thr); }; /** Detach a virtual column from an index. @@ -1950,6 +1953,25 @@ struct dict_table_t { char (&tbl_name)[NAME_LEN + 1], size_t *db_name_len, size_t *tbl_name_len) const; + /** Empty the table */ + void empty_table(que_thr_t *thr); + + /** Set bulk operation */ + void set_bulk_trx(ulint trx_id) + { + bulk_trx_id= trx_id; + } + + void remove_bulk_trx() + { + bulk_trx_id= 0; + } + + bool is_bulk_trx(ulint trx_id) + { + return bulk_trx_id == trx_id; + } + private: /** Initialize instant->field_map. @param[in] table table definition to copy from */ @@ -2316,6 +2338,10 @@ public: /** mysql_row_templ_t for base columns used for compute the virtual columns */ dict_vcol_templ_t* vc_templ; + + /** Trx id of bulk operation. This is under the protection of + exclusive lock of table object */ + trx_id_t bulk_trx_id; }; inline void dict_index_t::set_modified(mtr_t& mtr) const -- cgit v1.2.1