Closed xiaoma20082008 closed 4 years ago
Good catch!
Just as the javadoc explains:
Get secondary key root page number.
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
Currently sk root page number will be calculated per above. To locate the exact page number, the system tablespace is the where to find, but now the framework is not able to read system table to retrieve the information. So that's why the class name is Workaround
. PR is welcomed.
BTW, The command to query by sk:
java -jar /Users/xu/IdeaProjects/innodb-java-reader-ali-github/innodb-java-reader-cli/target/innodb-java-reader-cli.jar \
-ibd-file-path /usr/local/mysql/data/test/issue.ibd \
-create-table-sql-file-path issue.sql \
-showheader -c query-by-sk -args ">=;0;<;0" -skname idx_name
Got it, Thank you!!! @neoremind
@xiaoma20082008 I have delivered a new release, you can specify secondary key root page number if necessary, please refer to https://github.com/alibaba/innodb-java-reader/blob/master/docs/FAQ.md#1-how-to-specify-secondary-key-root-page-number. Any questions, feel free to let me know.
LGTM! Thank you!
my mysql env is:
my runtime env was under intellij idea and jdk is:
my command is here:
my table is here:
exception is here:
and my question is how to get the root page id of a secondary index at getSkRootPageNumber Here is the code
but I'm Confused about
long skRootPageNumber = rootIndex.getPageNumber() + fulltextKeyCount + ordinal + 1;
, I think whether you should use the FsegHeader to get the secondary index's pageNo as it's documentedcould you explain it? Thank you !!!