1/*****************************************************************************
2
3Copyright (c) 2016, 2018, MariaDB Corporation.
4
5This program is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License as published by the Free Software
7Foundation; version 2 of the License.
8
9This program is distributed in the hope that it will be useful, but WITHOUT
10ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
13You should have received a copy of the GNU General Public License along with
14this program; if not, write to the Free Software Foundation, Inc.,
1551 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
16
17*****************************************************************************/
18
19/**************************************************//**
20@file include/dict0defrag_bg.h
21Code used for background table and index
22defragmentation
23
24Created 25/08/2016 Jan Lindström
25*******************************************************/
26
27#ifndef dict0defrag_bg_h
28#define dict0defrag_bg_h
29
30#include "univ.i"
31
32#include "dict0types.h"
33#include "os0event.h"
34#include "os0thread.h"
35
36/*****************************************************************//**
37Initialize the defrag pool, called once during thread initialization. */
38void
39dict_defrag_pool_init(void);
40/*========================*/
41
42/*****************************************************************//**
43Free the resources occupied by the defrag pool, called once during
44thread de-initialization. */
45void
46dict_defrag_pool_deinit(void);
47/*==========================*/
48
49/*****************************************************************//**
50Add an index in a table to the defrag pool, which is processed by the
51background stats gathering thread. Only the table id and index id are
52added to the list, so the table can be closed after being enqueued and
53it will be opened when needed. If the table or index does not exist later
54(has been DROPped), then it will be removed from the pool and skipped. */
55void
56dict_stats_defrag_pool_add(
57/*=======================*/
58 const dict_index_t* index); /*!< in: table to add */
59
60/*****************************************************************//**
61Delete a given index from the auto defrag pool. */
62void
63dict_stats_defrag_pool_del(
64/*=======================*/
65 const dict_table_t* table, /*!<in: if given, remove
66 all entries for the table */
67 const dict_index_t* index); /*!< in: index to remove */
68
69/*****************************************************************//**
70Get the first index that has been added for updating persistent defrag
71stats and eventually save its stats. */
72void
73dict_defrag_process_entries_from_defrag_pool();
74/*===========================================*/
75
76/*********************************************************************//**
77Save defragmentation result.
78@return DB_SUCCESS or error code */
79dberr_t
80dict_stats_save_defrag_summary(
81/*============================*/
82 dict_index_t* index) /*!< in: index */
83 MY_ATTRIBUTE((warn_unused_result));
84
85/*********************************************************************//**
86Save defragmentation stats for a given index.
87@return DB_SUCCESS or error code */
88dberr_t
89dict_stats_save_defrag_stats(
90/*============================*/
91 dict_index_t* index); /*!< in: index */
92#endif /* dict0defrag_bg_h */
93