Skip to content

Commit 0cbf578

Browse files
committed
Add dict_index_t member functions for determining index type
1 parent 16d4315 commit 0cbf578

File tree

3 files changed

+21
-140
lines changed

3 files changed

+21
-140
lines changed

storage/innobase/include/dict0dict.h

Lines changed: 6 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -689,65 +689,14 @@ do { \
689689
dict_table_skip_corrupt_index(index); \
690690
} while (0)
691691

692-
/********************************************************************//**
693-
Check whether the index is the clustered index.
694-
@return nonzero for clustered index, zero for other indexes */
695-
UNIV_INLINE
696-
ulint
697-
dict_index_is_clust(
698-
/*================*/
699-
const dict_index_t* index) /*!< in: index */
700-
MY_ATTRIBUTE((warn_unused_result));
701-
702-
/** Check if index is auto-generated clustered index.
703-
@param[in] index index
704-
705-
@return true if index is auto-generated clustered index. */
706-
UNIV_INLINE
707-
bool
708-
dict_index_is_auto_gen_clust(
709-
const dict_index_t* index);
710-
711-
/********************************************************************//**
712-
Check whether the index is unique.
713-
@return nonzero for unique index, zero for other indexes */
714-
UNIV_INLINE
715-
ulint
716-
dict_index_is_unique(
717-
/*=================*/
718-
const dict_index_t* index) /*!< in: index */
719-
MY_ATTRIBUTE((warn_unused_result));
720-
/********************************************************************//**
721-
Check whether the index is a Spatial Index.
722-
@return nonzero for Spatial Index, zero for other indexes */
723-
UNIV_INLINE
724-
ulint
725-
dict_index_is_spatial(
726-
/*==================*/
727-
const dict_index_t* index) /*!< in: index */
728-
MY_ATTRIBUTE((warn_unused_result));
729-
692+
#define dict_index_is_clust(index) (index)->is_clust()
693+
#define dict_index_is_auto_gen_clust(index) (index)->is_gen_clust()
694+
#define dict_index_is_unique(index) (index)->is_unique()
695+
#define dict_index_is_spatial(index) (index)->is_spatial()
696+
#define dict_index_is_ibuf(index) (index)->is_ibuf()
697+
#define dict_index_is_sec_or_ibuf(index) !(index)->is_primary()
730698
#define dict_index_has_virtual(index) (index)->has_virtual()
731699

732-
/********************************************************************//**
733-
Check whether the index is the insert buffer tree.
734-
@return nonzero for insert buffer, zero for other indexes */
735-
UNIV_INLINE
736-
ulint
737-
dict_index_is_ibuf(
738-
/*===============*/
739-
const dict_index_t* index) /*!< in: index */
740-
MY_ATTRIBUTE((warn_unused_result));
741-
/********************************************************************//**
742-
Check whether the index is a secondary index or the insert buffer tree.
743-
@return nonzero for insert buffer, zero for other indexes */
744-
UNIV_INLINE
745-
ulint
746-
dict_index_is_sec_or_ibuf(
747-
/*======================*/
748-
const dict_index_t* index) /*!< in: index */
749-
MY_ATTRIBUTE((warn_unused_result));
750-
751700
/** Get all the FTS indexes on a table.
752701
@param[in] table table
753702
@param[out] indexes all FTS indexes on this table

storage/innobase/include/dict0dict.ic

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -260,89 +260,6 @@ dict_table_get_next_index(
260260
}
261261
#endif /* UNIV_DEBUG */
262262

263-
/********************************************************************//**
264-
Check whether the index is the clustered index.
265-
@return nonzero for clustered index, zero for other indexes */
266-
UNIV_INLINE
267-
ulint
268-
dict_index_is_clust(
269-
/*================*/
270-
const dict_index_t* index) /*!< in: index */
271-
{
272-
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
273-
return(index->type & DICT_CLUSTERED);
274-
}
275-
276-
/** Check if index is auto-generated clustered index.
277-
@param[in] index index
278-
279-
@return true if index is auto-generated clustered index. */
280-
UNIV_INLINE
281-
bool
282-
dict_index_is_auto_gen_clust(
283-
const dict_index_t* index)
284-
{
285-
return(index->type == DICT_CLUSTERED);
286-
}
287-
288-
/********************************************************************//**
289-
Check whether the index is unique.
290-
@return nonzero for unique index, zero for other indexes */
291-
UNIV_INLINE
292-
ulint
293-
dict_index_is_unique(
294-
/*=================*/
295-
const dict_index_t* index) /*!< in: index */
296-
{
297-
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
298-
299-
return(index->type & DICT_UNIQUE);
300-
}
301-
302-
/********************************************************************//**
303-
Check whether the index is a Spatial Index.
304-
@return nonzero for Spatial Index, zero for other indexes */
305-
UNIV_INLINE
306-
ulint
307-
dict_index_is_spatial(
308-
/*==================*/
309-
const dict_index_t* index) /*!< in: index */
310-
{
311-
ut_ad(index);
312-
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
313-
314-
return ulint(UNIV_EXPECT(index->type & DICT_SPATIAL, 0));
315-
}
316-
317-
/********************************************************************//**
318-
Check whether the index is the insert buffer tree.
319-
@return nonzero for insert buffer, zero for other indexes */
320-
UNIV_INLINE
321-
ulint
322-
dict_index_is_ibuf(
323-
/*===============*/
324-
const dict_index_t* index) /*!< in: index */
325-
{
326-
ut_ad(index);
327-
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
328-
329-
return(index->type & DICT_IBUF);
330-
}
331-
332-
/********************************************************************//**
333-
Check whether the index is a secondary index or the insert buffer tree.
334-
@return nonzero for insert buffer, zero for other indexes */
335-
UNIV_INLINE
336-
ulint
337-
dict_index_is_sec_or_ibuf(
338-
/*======================*/
339-
const dict_index_t* index) /*!< in: index */
340-
{
341-
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
342-
343-
return((index->type & (DICT_CLUSTERED | DICT_IBUF)) != DICT_CLUSTERED);
344-
}
345-
346263
/********************************************************************//**
347264
Gets the number of user-defined non-virtual columns in a table in the
348265
dictionary cache.

storage/innobase/include/dict0mem.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,21 @@ struct dict_index_t {
10851085
return DICT_CLUSTERED == (type & (DICT_CLUSTERED | DICT_IBUF));
10861086
}
10871087

1088+
/** @return whether this is a generated clustered index */
1089+
bool is_gen_clust() const { return type == DICT_CLUSTERED; }
1090+
1091+
/** @return whether this is a clustered index */
1092+
bool is_clust() const { return type & DICT_CLUSTERED; }
1093+
1094+
/** @return whether this is a unique index */
1095+
bool is_unique() const { return type & DICT_UNIQUE; }
1096+
1097+
/** @return whether this is a spatial index */
1098+
bool is_spatial() const { return UNIV_UNLIKELY(type & DICT_SPATIAL); }
1099+
1100+
/** @return whether this is the change buffer */
1101+
bool is_ibuf() const { return UNIV_UNLIKELY(type & DICT_IBUF); }
1102+
10881103
/** @return whether the index includes virtual columns */
10891104
bool has_virtual() const { return type & DICT_VIRTUAL; }
10901105

0 commit comments

Comments
 (0)