public class Workaround extends Object
| 构造器和说明 |
|---|
Workaround() |
| 限定符和类型 | 方法和说明 |
|---|---|
static long |
getSkRootPageNumber(TableDef tableDef,
String skName,
Optional<Integer> skOrdinal,
java.util.function.Function<Long,Index> func)
Get secondary key root page number.
|
public static long getSkRootPageNumber(TableDef tableDef, String skName, Optional<Integer> skOrdinal, java.util.function.Function<Long,Index> func)
Find clustered index root page and calculate sk page number based on it. Note that if table has ever been altered to add or remove indices, the secondary key root page number may be incorrect, and cause error.
MySQL will set FULLTEXT KEY, UNIQUE KEY ahead of normal KEY, but in
SHOW CREATE TABLE command, the FULLTEXT KEY goes to the end,
so here the workaround is to add the delta of fulltext key count.
More standard way would be to look up root page number by:
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES; before 5.7
or
SELECT * FROM INFORMATION_SCHEMA.INNODB_INDEXES; after 8.0
tableDef - table definitionskName - secondary key nameskOrdinal - secondary key ordinal in SHOW CREATE TABLE commandfunc - function to apply on page number and return the loaded index pageCopyright © 2019–2020 Alibaba Group Holding Limited. All rights reserved.