Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

executor: add correctness tests about direct reading with ORDER BY and LIMIT #24455

Merged
merged 51 commits into from
May 14, 2021
Merged
Changes from 4 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
d22b8d5
add correctness tests about direct reading with ORDER BY and LIMIT
zhuo-zhi May 7, 2021
73e8b20
sort results before check
zhuo-zhi May 7, 2021
ff7b060
bugfix: prevent dual table
zhuo-zhi May 7, 2021
bee66a8
increase query number
zhuo-zhi May 7, 2021
ca03eac
change ORDER BY columns
zhuo-zhi May 7, 2021
eab6148
skip in DATA RACE mode
zhuo-zhi May 7, 2021
43d4f1d
prevent LIMIT 0
zhuo-zhi May 7, 2021
2d3ea39
add more test cases
zhuo-zhi May 7, 2021
072f073
change partition range and data num
zhuo-zhi May 8, 2021
1e0bbb6
change data num
zhuo-zhi May 8, 2021
ac448dc
Merge branch 'master' of https://github.com/pingcap/tidb into dev_par…
zhuo-zhi May 8, 2021
aad8212
resolve conflict
zhuo-zhi May 8, 2021
14211d9
Merge branch 'master' into dev_partitionTest
ti-chi-bot May 10, 2021
f64cc29
Merge branch 'master' into dev_partitionTest
zhuo-zhi May 10, 2021
2114d60
resolve merge conflict
zhuo-zhi May 10, 2021
7dd79d5
Merge branch 'master' into dev_partitionTest
ti-chi-bot May 10, 2021
c6637d1
Merge branch 'master' into dev_partitionTest
ti-chi-bot May 10, 2021
bab5d2f
Merge branch 'master' into dev_partitionTest
ti-chi-bot May 11, 2021
a135d5d
Merge branch 'master' into dev_partitionTest
qw4990 May 11, 2021
f68207f
Merge branch 'master' of https://github.com/pingcap/tidb into dev_par…
zhuo-zhi May 11, 2021
d284f20
Merge branch 'master' into dev_partitionTest
qw4990 May 11, 2021
5f6ff78
Merge branch 'master' into dev_partitionTest
ti-chi-bot May 11, 2021
44b10fc
Merge branch 'master' into dev_partitionTest
ti-chi-bot May 11, 2021
0848a2b
Merge branch 'master' into dev_partitionTest
ti-chi-bot May 11, 2021
4731782
Merge branch 'master' into dev_partitionTest
ti-chi-bot May 11, 2021
75e3fed
Merge branch 'master' into dev_partitionTest
ti-chi-bot May 11, 2021
51f3c86
Merge branch 'master' into dev_partitionTest
ti-chi-bot May 11, 2021
2b8231e
Merge branch 'master' into dev_partitionTest
ti-chi-bot May 11, 2021
d1ed259
Merge branch 'master' into dev_partitionTest
ti-chi-bot May 11, 2021
852f9b6
Merge branch 'master' into dev_partitionTest
ti-chi-bot May 11, 2021
c71d504
Merge branch 'master' into dev_partitionTest
qw4990 May 12, 2021
9e545fe
Merge branch 'master' into dev_partitionTest
ti-chi-bot May 12, 2021
e8de776
Merge branch 'master' into dev_partitionTest
ti-chi-bot May 12, 2021
e72eb48
Merge branch 'master' into dev_partitionTest
ti-chi-bot May 12, 2021
27bfcbe
Merge branch 'master' into dev_partitionTest
ti-chi-bot May 12, 2021
c58eb12
Merge branch 'master' into dev_partitionTest
ti-chi-bot May 12, 2021
2cd645d
Merge branch 'master' into dev_partitionTest
ti-chi-bot May 12, 2021
bfb49f0
Merge branch 'master' into dev_partitionTest
ti-chi-bot May 12, 2021
5e767f9
Merge branch 'master' into dev_partitionTest
ti-chi-bot May 12, 2021
8f7db0a
Merge branch 'master' into dev_partitionTest
ti-chi-bot May 12, 2021
1a4bef8
Merge branch 'master' into dev_partitionTest
ti-chi-bot May 12, 2021
f82b325
Merge branch 'master' into dev_partitionTest
ti-chi-bot May 12, 2021
b9cde04
Merge branch 'master' into dev_partitionTest
ti-chi-bot May 12, 2021
4bee259
Merge branch 'master' into dev_partitionTest
ti-chi-bot May 12, 2021
0449db5
decrease query number
zhuo-zhi May 13, 2021
3dd9819
Merge branch 'dev_partitionTest' of github.com:zhuo-zhi/tidb into dev…
zhuo-zhi May 13, 2021
9822aad
Merge branch 'master' into dev_partitionTest
qw4990 May 14, 2021
5787399
Merge branch 'master' into dev_partitionTest
qw4990 May 14, 2021
35fda93
Merge branch 'master' into dev_partitionTest
ti-chi-bot May 14, 2021
7430021
Merge branch 'master' into dev_partitionTest
ti-chi-bot May 14, 2021
495ffb1
Merge branch 'master' into dev_partitionTest
ti-chi-bot May 14, 2021
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
41 changes: 41 additions & 0 deletions executor/partition_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
package executor_test

import (
"fmt"
"math/rand"
"strings"

. "github.com/pingcap/check"
"github.com/pingcap/parser/model"
"github.com/pingcap/tidb/infoschema"
Expand Down Expand Up @@ -222,6 +226,43 @@ func (s *partitionTableSuite) TestPartitionInfoDisable(c *C) {
tk.MustQuery("select * from t_info_null where (date = '2020-10-02' or date = '2020-10-06') and app = 'xxx' and media = '19003006'").Check(testkit.Rows())
}

func (s *partitionTableSuite) TestOrderByandLimit(c *C) {
qw4990 marked this conversation as resolved.
Show resolved Hide resolved
tk := testkit.NewTestKitWithInit(c, s.store)
tk.MustExec("create database test_orderby_limit")
tk.MustExec("use test_orderby_limit")
tk.MustExec("set @@tidb_partition_prune_mode = 'dynamic'")

// range partition table
tk.MustExec(`create table trange(a int, b int, index idx_a(a)) partition by range(a) (
partition p0 values less than(3),
partition p1 values less than (5),
partition p2 values less than(11));`)
qw4990 marked this conversation as resolved.
Show resolved Hide resolved

// regular table
tk.MustExec("create table tregular(a int, b int, index idx_a(a))")

// generate some random data to be inserted
vals := make([]string, 0, 100)
for i := 0; i < 100; i++ {
vals = append(vals, fmt.Sprintf("(%v, %v)", rand.Intn(11), rand.Intn(20)))
}
qw4990 marked this conversation as resolved.
Show resolved Hide resolved

tk.MustExec("insert into trange values " + strings.Join(vals, ","))
tk.MustExec("insert into tregular values " + strings.Join(vals, ","))

// generate some random querys
for i := 0; i < 100; i++ {
// explain select * from t where a > {y} use index(idx_a) order by a limit {x}; // check if IndexLookUp is used
// select * from t where a > {y} use index(idx_a) order by a limit {x}; // it can return the correct result
x := rand.Intn(10)
y := rand.Intn(100)
queryPartition := fmt.Sprintf("select * from trange use index(idx_a) where a > %v order by a limit %v;", x, y)
queryRegular := fmt.Sprintf("select * from tregular use index(idx_a) where a > %v order by a limit %v;", x, y)
c.Assert(tk.HasPlan(queryPartition, "IndexLookUp"), IsTrue) // check if IndexLookUp is used
tk.MustQuery(queryPartition).Sort().Check(tk.MustQuery(queryRegular).Sort().Rows())
}
}

func (s *globalIndexSuite) TestGlobalIndexScan(c *C) {
tk := testkit.NewTestKitWithInit(c, s.store)
tk.MustExec("drop table if exists p")
Expand Down