-
Notifications
You must be signed in to change notification settings - Fork 6k
expression: add cast for eq expr when doing constant propagation | tidb-test=pr/2592 #63327
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
Merged
ti-chi-bot
merged 9 commits into
pingcap:master
from
guo-shaoge:adding_cast_when_propagation_const
Sep 4, 2025
+130
−1
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3e6d4f1
expression: add cast expr for eq when doing constant propagation
guo-shaoge 70c45a9
fix
guo-shaoge 81e754c
fix
guo-shaoge 663bac8
fix
guo-shaoge 629d921
fix
guo-shaoge 14a14f0
refine
guo-shaoge 1745510
refine
guo-shaoge f865b65
fix
guo-shaoge 3b3fea9
refine
guo-shaoge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_test") | ||
|
||
go_test( | ||
name = "constantpropagation_test", | ||
timeout = "short", | ||
srcs = [ | ||
"constant_propagation_test.go", | ||
"main_test.go", | ||
], | ||
flaky = True, | ||
deps = [ | ||
"//pkg/config", | ||
"//pkg/testkit", | ||
"//pkg/testkit/testmain", | ||
"//pkg/testkit/testsetup", | ||
"//pkg/util/timeutil", | ||
"@com_github_tikv_client_go_v2//tikv", | ||
"@org_uber_go_goleak//:goleak", | ||
], | ||
) |
41 changes: 41 additions & 0 deletions
41
pkg/expression/test/constantpropagation/constant_propagation_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright 2022 PingCAP, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package constantpropagation | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/pingcap/tidb/pkg/testkit" | ||
) | ||
|
||
func TestConstantPropagationMissingCastExpr(t *testing.T) { | ||
store, _ := testkit.CreateMockStoreAndDomain(t) | ||
hawkingrei marked this conversation as resolved.
Show resolved
Hide resolved
|
||
tk := testkit.NewTestKit(t, store) | ||
tk.MustExec("use test") | ||
tk.MustExec("create table tl50cb7440 (" + | ||
" col_43 decimal(30,30) not null," + | ||
" primary key (col_43) /*t![clustered_index] clustered */," + | ||
" unique key idx_12 (col_43)," + | ||
" key idx_13 (col_43)," + | ||
" unique key idx_14 (col_43)" + | ||
") engine=innodb default charset=utf8 collate=utf8_bin;") | ||
tk.MustExec("insert into tl50cb7440 values(0.000000000000000000000000000000),(0.400000000000000000000000000000);") | ||
tk.MustQuery("with cte_8911 (col_47665) as" + | ||
" (select mid(tl50cb7440.col_43, 6, 9) as r0" + | ||
" from tl50cb7440" + | ||
" where tl50cb7440.col_43 in (0, 0) and tl50cb7440.col_43 in (0))" + | ||
" (select 1" + | ||
" from cte_8911 where cte_8911.col_47665!='');").Check(testkit.Rows("1")) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright 2023 PingCAP, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package constantpropagation | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/pingcap/tidb/pkg/config" | ||
"github.com/pingcap/tidb/pkg/testkit/testmain" | ||
"github.com/pingcap/tidb/pkg/testkit/testsetup" | ||
"github.com/pingcap/tidb/pkg/util/timeutil" | ||
"github.com/tikv/client-go/v2/tikv" | ||
"go.uber.org/goleak" | ||
) | ||
|
||
func TestMain(m *testing.M) { | ||
testsetup.SetupForCommonTest() | ||
testmain.ShortCircuitForBench(m) | ||
|
||
config.UpdateGlobal(func(conf *config.Config) { | ||
conf.TiKVClient.AsyncCommit.SafeWindow = 0 | ||
conf.TiKVClient.AsyncCommit.AllowedClockDrift = 0 | ||
conf.Experimental.AllowsExpressionIndex = true | ||
}) | ||
tikv.EnableFailpoints() | ||
|
||
// Some test depends on the values of timeutil.SystemLocation() | ||
// If we don't SetSystemTZ() here, the value would change unpredictable. | ||
// Affected by the order whether a testsuite runs before or after integration test. | ||
// Note, SetSystemTZ() is a sync.Once operation. | ||
timeutil.SetSystemTZ("system") | ||
|
||
opts := []goleak.Option{ | ||
goleak.IgnoreTopFunction("github.com/golang/glog.(*fileSink).flushDaemon"), | ||
goleak.IgnoreTopFunction("github.com/bazelbuild/rules_go/go/tools/bzltestutil.RegisterTimeoutHandler.func1"), | ||
goleak.IgnoreTopFunction("github.com/lestrrat-go/httprc.runFetchWorker"), | ||
goleak.IgnoreTopFunction("go.etcd.io/etcd/client/pkg/v3/logutil.(*MergeLogger).outputLoop"), | ||
goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"), | ||
goleak.IgnoreTopFunction("github.com/pingcap/tidb/pkg/ttl/ttlworker.(*ttlScanWorker).loop"), | ||
goleak.IgnoreTopFunction("github.com/pingcap/tidb/pkg/ttl/client.(*mockClient).WatchCommand.func1"), | ||
goleak.IgnoreTopFunction("github.com/pingcap/tidb/pkg/ttl/ttlworker.(*JobManager).jobLoop"), | ||
} | ||
|
||
goleak.VerifyTestMain(m, opts...) | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.