Skip to content

Commit dbd5dd7

Browse files
committed
45783
1 parent 601e21c commit dbd5dd7

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

pkg/planner/core/plan_cache_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1797,3 +1797,15 @@ partition by hash (a) partitions 3`)
17971797
require.False(t, tk.Session().GetSessionVars().FoundInPlanCache)
17981798
tk.MustQuery(`show warnings`).Check(testkit.Rows("Warning 1105 skip prepared plan-cache: query accesses partitioned tables is un-cacheable if tidb_partition_pruning_mode = 'static'"))
17991799
}
1800+
1801+
func Test45783(t *testing.T) {
1802+
store := testkit.CreateMockStore(t)
1803+
tk := testkit.NewTestKit(t, store)
1804+
tk.MustExec(`use test`)
1805+
tk.MustExec(`CREATE TABLE authors (id bigint NOT NULL AUTO_INCREMENT PRIMARY KEY, name varchar(255) NOT NULL, author_address_id bigint, author_address_extra_id bigint, organization_id varchar(255), owned_essay_id varchar(255), INDEX index_authors_on_author_address_id (author_address_id), INDEX index_authors_on_author_address_extra_id (author_address_extra_id));`)
1806+
tk.MustExec(`CREATE TABLE posts (id bigint NOT NULL AUTO_INCREMENT PRIMARY KEY, author_id bigint, title varchar(255) NOT NULL, body text NOT NULL, type varchar(255), legacy_comments_count int DEFAULT 0, taggings_with_delete_all_count int DEFAULT 0, taggings_with_destroy_count int DEFAULT 0, tags_count int DEFAULT 0, indestructible_tags_count int DEFAULT 0, tags_with_destroy_count int DEFAULT 0, tags_with_nullify_count int DEFAULT 0, INDEX index_posts_on_author_id (author_id));`)
1807+
tk.MustExec(`INSERT INTO authors (id, name, author_address_id, author_address_extra_id, organization_id, owned_essay_id) VALUES (1, 'David', 1, 2, 'No Such Agency', 'A Modest Proposal'), (2, 'Mary', 3, DEFAULT, DEFAULT, DEFAULT), (3, 'Bob', 4, DEFAULT, DEFAULT, DEFAULT);`)
1808+
tk.MustExec(`INSERT INTO posts (id, author_id, title, body, type, legacy_comments_count, taggings_with_delete_all_count, taggings_with_destroy_count, tags_count, indestructible_tags_count, tags_with_destroy_count, tags_with_nullify_count) VALUES (1, 1, 'Welcome to the weblog', 'Such a lovely day', 'Post', 2, DEFAULT, DEFAULT, 1, DEFAULT, DEFAULT, DEFAULT), (2, 1, 'So I was thinking', 'Like I hopefully always am', 'SpecialPost', 1, DEFAULT, DEFAULT, 1, DEFAULT, DEFAULT, DEFAULT), (3, 0, 'I don\'t have any comments', 'I just don\'t want to', 'Post', DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT), (4, 1, 'sti comments', 'hello', 'Post', 5, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT), (5, 1, 'sti me', 'hello', 'StiPost', 2, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT), (6, 1, 'habtm sti test', 'hello', 'Post', DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT), (7, 2, 'eager loading with OR\'d conditions', 'hello', 'Post', 1, DEFAULT, DEFAULT, 3, DEFAULT, DEFAULT, DEFAULT), (8, 3, 'misc post by bob', 'hello', 'Post', DEFAULT, DEFAULT, DEFAULT, 1, DEFAULT, DEFAULT, DEFAULT), (9, 2, 'misc post by mary', 'hullo', 'Post', DEFAULT, DEFAULT, DEFAULT, 1, DEFAULT, DEFAULT, DEFAULT), (10, 3, 'other post by bob', 'hello', 'Post', DEFAULT, DEFAULT, DEFAULT, 1, DEFAULT, DEFAULT, DEFAULT), (11, 2, 'other post by mary', 'hello', 'Post', DEFAULT, DEFAULT, DEFAULT, 1, DEFAULT, DEFAULT, DEFAULT);`)
1809+
tk.MustExec(`set tidb_enable_non_prepared_plan_cache=1;`)
1810+
tk.MustExec(`SELECT posts.* FROM posts WHERE (id = 1 or id = 9223372036854775808);`)
1811+
}

pkg/planner/optimize.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ func Optimize(ctx context.Context, sctx sessionctx.Context, node ast.Node, is in
333333
sessVars.StmtCtx.StmtHints = originStmtHints
334334
bestPlan, names, _, err = optimize(ctx, pctx, node, is)
335335
if err != nil {
336+
logutil.BgLogger().Info("bug here", zap.String("stask", errors.ErrorStack(err)))
336337
return nil, nil, err
337338
}
338339
}

0 commit comments

Comments
 (0)