Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions br/pkg/restore/log_client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1648,6 +1648,11 @@ func (rc *LogClient) generateRepairIngestIndexSQLs(
addArgs = append(addArgs, info.SchemaName.O, info.TableName.O, info.IndexInfo.Name.O)
addArgs = append(addArgs, info.ColumnArgs...)
}
// WHERE CONDITION
if len(info.IndexInfo.ConditionExprString) > 0 {
addSQL.WriteString(" WHERE ")
addSQL.WriteString(info.IndexInfo.ConditionExprString)
}
// USING BTREE/HASH/RTREE
indexTypeStr := info.IndexInfo.Tp.String()
if len(indexTypeStr) > 0 {
Expand Down
8 changes: 8 additions & 0 deletions br/tests/br_pitr/check/check_ingest_repair.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ check_contains "ON DELETE SET NULL ON UPDATE CASCADE"
run_sql "SELECT count(*) AS RESCNT FROM INFORMATION_SCHEMA.TIDB_INDEXES WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 'pairs19' AND INDEX_ID = 2 AND IS_GLOBAL = 1;"
check_contains "RESCNT: 1"

## check table test.pairs20
run_sql "SELECT COUNT(*) AS RESCNT FROM INFORMATION_SCHEMA.TIDB_INDEXES WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 'pairs20' AND INDEX_ID > 2 AND PREDICATE = '\`id\` > 5'"
check_contains "RESCNT: 2"

# adjust some index to be visible
run_sql "ALTER TABLE test.pairs ALTER INDEX i1 VISIBLE;"

Expand Down Expand Up @@ -198,3 +202,7 @@ run_sql "select count(*) AS RESCNT from test.pairs19 use index(i1) where pid = 1
check_not_contains "RESCNT: 0"
run_sql "select count(*) AS RESCNT from test.pairs19 use index(i1) where pid = 10;"
check_not_contains "RESCNT: 0"
run_sql "select count(*) AS RESCNT from test.pairs20 use index(i1) where pid1 = 10";
check_not_contains "RESCNT: 0"
run_sql "select count(*) AS RESCNT from test.pairs20 use index(i2) where pid2 = 10";
check_not_contains "RESCNT: 0"
4 changes: 4 additions & 0 deletions br/tests/br_pitr/incremental_data/ingest_repair.sql
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,7 @@ ALTER TABLE test2.pairs18_child ADD CONSTRAINT fk_0 FOREIGN KEY (pid) REFERENCES

-- test global index
alter table test.pairs19 add unique index i1(pid) global;

-- test patial index
ALTER TABLE test.pairs20 ADD INDEX i1(pid1) WHERE id > 5;
ALTER TABLE test.pairs20 ADD UNIQUE INDEX i2(pid2) WHERE id > 5;
4 changes: 4 additions & 0 deletions br/tests/br_pitr/prepare_data/ingest_repair.sql
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,7 @@ INSERT INTO test2.pairs18_child VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5);
-- test global index
CREATE TABLE test.pairs19 (id int, pid int) partition by range(id) (partition p0 values less than (6), partition p1 values less than (11));
INSERT INTO test.pairs19 values (1, 1), (10, 10);

-- test partial index
CREATE TABLE test.pairs20 (id int PRIMARY KEY, pid1 int, pid2 int);
INSERT INTO test.pairs20 values (1, 1, 1), (10, 10, 10);
Loading