From 9d82b7e82a1137995f0a9e0671cd8d55e627c567 Mon Sep 17 00:00:00 2001 From: YangKeao Date: Sun, 17 Dec 2023 22:22:51 +0800 Subject: [PATCH 1/3] This is an automated cherry-pick of #49527 Signed-off-by: ti-chi-bot --- DEPS.bzl | 24 +++++++++---------- go.mod | 5 ++++ go.sum | 11 +++++---- pkg/expression/builtin_convert_charset.go | 3 ++- .../integrationtest/r/expression/cast.result | 23 ++++++++++++++++++ tests/integrationtest/t/expression/cast.test | 15 ++++++++++++ 6 files changed, 64 insertions(+), 17 deletions(-) diff --git a/DEPS.bzl b/DEPS.bzl index e85bec77d6251..489cf1a5648e3 100644 --- a/DEPS.bzl +++ b/DEPS.bzl @@ -9186,26 +9186,26 @@ def go_deps(): name = "com_sourcegraph_sourcegraph_appdash", build_file_proto_mode = "disable_global", importpath = "sourcegraph.com/sourcegraph/appdash", - sha256 = "bd2492d9db05362c2fecd0b3d0f6002c89a6d90d678fb93b4158298ab883736f", - strip_prefix = "sourcegraph.com/sourcegraph/appdash@v0.0.0-20190731080439-ebfcffb1b5c0", + sha256 = "c46b442fa40d2af48e08064f4c16ae3712953a9988cd0f7588fcf5e4fc7a2fed", + strip_prefix = "github.com/sourcegraph/appdash@v0.0.0-20190731080439-ebfcffb1b5c0", urls = [ - "http://bazel-cache.pingcap.net:8080/gomod/sourcegraph.com/sourcegraph/appdash/com_sourcegraph_sourcegraph_appdash-v0.0.0-20190731080439-ebfcffb1b5c0.zip", - "http://ats.apps.svc/gomod/sourcegraph.com/sourcegraph/appdash/com_sourcegraph_sourcegraph_appdash-v0.0.0-20190731080439-ebfcffb1b5c0.zip", - "https://cache.hawkingrei.com/gomod/sourcegraph.com/sourcegraph/appdash/com_sourcegraph_sourcegraph_appdash-v0.0.0-20190731080439-ebfcffb1b5c0.zip", - "https://storage.googleapis.com/pingcapmirror/gomod/sourcegraph.com/sourcegraph/appdash/com_sourcegraph_sourcegraph_appdash-v0.0.0-20190731080439-ebfcffb1b5c0.zip", + "http://bazel-cache.pingcap.net:8080/gomod/github.com/sourcegraph/appdash/com_github_sourcegraph_appdash-v0.0.0-20190731080439-ebfcffb1b5c0.zip", + "http://ats.apps.svc/gomod/github.com/sourcegraph/appdash/com_github_sourcegraph_appdash-v0.0.0-20190731080439-ebfcffb1b5c0.zip", + "https://cache.hawkingrei.com/gomod/github.com/sourcegraph/appdash/com_github_sourcegraph_appdash-v0.0.0-20190731080439-ebfcffb1b5c0.zip", + "https://storage.googleapis.com/pingcapmirror/gomod/github.com/sourcegraph/appdash/com_github_sourcegraph_appdash-v0.0.0-20190731080439-ebfcffb1b5c0.zip", ], ) go_repository( name = "com_sourcegraph_sourcegraph_appdash_data", build_file_proto_mode = "disable_global", importpath = "sourcegraph.com/sourcegraph/appdash-data", - sha256 = "382adefecd62bb79172e2552bcfb7d45f47122f9bd22259b0566b26fb2627b87", - strip_prefix = "sourcegraph.com/sourcegraph/appdash-data@v0.0.0-20151005221446-73f23eafcf67", + sha256 = "59b71fa8cdb0fe2b1c02739ccf2daeaf28f2e22c4b178cdc8e1b902ad1022bc0", + strip_prefix = "github.com/sourcegraph/appdash-data@v0.0.0-20151005221446-73f23eafcf67", urls = [ - "http://bazel-cache.pingcap.net:8080/gomod/sourcegraph.com/sourcegraph/appdash-data/com_sourcegraph_sourcegraph_appdash_data-v0.0.0-20151005221446-73f23eafcf67.zip", - "http://ats.apps.svc/gomod/sourcegraph.com/sourcegraph/appdash-data/com_sourcegraph_sourcegraph_appdash_data-v0.0.0-20151005221446-73f23eafcf67.zip", - "https://cache.hawkingrei.com/gomod/sourcegraph.com/sourcegraph/appdash-data/com_sourcegraph_sourcegraph_appdash_data-v0.0.0-20151005221446-73f23eafcf67.zip", - "https://storage.googleapis.com/pingcapmirror/gomod/sourcegraph.com/sourcegraph/appdash-data/com_sourcegraph_sourcegraph_appdash_data-v0.0.0-20151005221446-73f23eafcf67.zip", + "http://bazel-cache.pingcap.net:8080/gomod/github.com/sourcegraph/appdash-data/com_github_sourcegraph_appdash_data-v0.0.0-20151005221446-73f23eafcf67.zip", + "http://ats.apps.svc/gomod/github.com/sourcegraph/appdash-data/com_github_sourcegraph_appdash_data-v0.0.0-20151005221446-73f23eafcf67.zip", + "https://cache.hawkingrei.com/gomod/github.com/sourcegraph/appdash-data/com_github_sourcegraph_appdash_data-v0.0.0-20151005221446-73f23eafcf67.zip", + "https://storage.googleapis.com/pingcapmirror/gomod/github.com/sourcegraph/appdash-data/com_github_sourcegraph_appdash_data-v0.0.0-20151005221446-73f23eafcf67.zip", ], ) go_repository( diff --git a/go.mod b/go.mod index 2a2dcb768375e..8375477e9a5d3 100644 --- a/go.mod +++ b/go.mod @@ -312,4 +312,9 @@ replace ( github.com/dgrijalva/jwt-go => github.com/form3tech-oss/jwt-go v3.2.6-0.20210809144907-32ab6a8243d7+incompatible github.com/go-ldap/ldap/v3 => github.com/YangKeao/ldap/v3 v3.4.5-0.20230421065457-369a3bab1117 github.com/pingcap/tidb/pkg/parser => ./pkg/parser + + // TODO: `sourcegraph.com/sourcegraph/appdash` has been archived, and the original host has been removed. + // Please remove these dependencies. + sourcegraph.com/sourcegraph/appdash => github.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0 + sourcegraph.com/sourcegraph/appdash-data => github.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67 ) diff --git a/go.sum b/go.sum index 12dc5d097e6a4..19a1197bb7cc7 100644 --- a/go.sum +++ b/go.sum @@ -940,9 +940,16 @@ github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9 github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/soheilhy/cmux v0.1.5 h1:jjzc5WVemNEDTLwv9tlmemhC73tI08BNOIGwBOo10Js= github.com/soheilhy/cmux v0.1.5/go.mod h1:T7TcVDs9LWfQgPlPsdngu6I6QIoyIFZDDC6sNE1GqG0= +<<<<<<< HEAD github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +======= +github.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0 h1:IJ3DuWHPTJrsqtIqjfdmPTELdTFGefvrOa2eTeRBleQ= +github.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:V952P4GGl1v/MMynLwxVdWEbSZJx+n0oOO3ljnez+WU= +github.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67 h1:8ZnTA26bBOoPkAbbitKPgNlpw0Bwt7ZlpYgZWHWJR/w= +github.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67/go.mod h1:tNZjgbYncKL5HxvDULAr/mWDmFz4B7H8yrXEDlnoIiw= +>>>>>>> 3a7bd532a26 (expression: ignore `TypeNULL` in `HandleBinaryLiteral` (#49527)) github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.2.1/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= @@ -1651,9 +1658,5 @@ sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ih sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= -sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0 h1:ucqkfpjg9WzSUubAO62csmucvxl4/JeW3F4I4909XkM= -sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= -sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67 h1:e1sMhtVq9AfcEy8AXNb8eSg6gbzfdpYhoNqnPJa+GzI= -sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67/go.mod h1:L5q+DGLGOQFpo1snNEkLOJT2d1YTW66rWNzatr3He1k= stathat.com/c/consistent v1.0.0 h1:ezyc51EGcRPJUxfHGSgJjWzJdj3NiMU9pNfLNGiXV0c= stathat.com/c/consistent v1.0.0/go.mod h1:QkzMWzcbB+yQBL2AttO6sgsQS/JSTapcDISJalmCDS0= diff --git a/pkg/expression/builtin_convert_charset.go b/pkg/expression/builtin_convert_charset.go index e46f9e633c0f7..3c57407e50f7f 100644 --- a/pkg/expression/builtin_convert_charset.go +++ b/pkg/expression/builtin_convert_charset.go @@ -322,7 +322,8 @@ func HandleBinaryLiteral(ctx sessionctx.Context, expr Expression, ec *ExprCollat return expr } return BuildToBinaryFunction(ctx, expr) - } else if argChs == charset.CharsetBin && dstChs != charset.CharsetBin { + } else if argChs == charset.CharsetBin && dstChs != charset.CharsetBin && + expr.GetType().GetType() != mysql.TypeNull { ft := expr.GetType().Clone() ft.SetCharset(ec.Charset) ft.SetCollate(ec.Collation) diff --git a/tests/integrationtest/r/expression/cast.result b/tests/integrationtest/r/expression/cast.result index e41cd0e192f69..a6cc3e51b9259 100644 --- a/tests/integrationtest/r/expression/cast.result +++ b/tests/integrationtest/r/expression/cast.result @@ -88,3 +88,26 @@ cast('61qw' as decimal) 61 Level Code Message Warning 1292 Truncated incorrect DECIMAL value: '61qw' +<<<<<<< HEAD +======= +drop table if exists t; +create table t (y year); +insert into t values (cast('14:15' as time)); +select 1 from t where y = YEAR(CURDATE()); +1 +1 +select cast(cast('14:15' as time) as year) = YEAR(CURDATE()); +cast(cast('14:15' as time) as year) = YEAR(CURDATE()) +1 +explain select null as a union all select 'a' as a; +id estRows task access object operator info +Union_8 2.00 root +├─Projection_10 1.00 root ->Column#3 +│ └─TableDual_11 1.00 root rows:1 +└─Projection_12 1.00 root a->Column#3 + └─TableDual_13 1.00 root rows:1 +select null as a union all select 'a' as a; +a +NULL +a +>>>>>>> 3a7bd532a26 (expression: ignore `TypeNULL` in `HandleBinaryLiteral` (#49527)) diff --git a/tests/integrationtest/t/expression/cast.test b/tests/integrationtest/t/expression/cast.test index 362f0032ef4dc..b24c95899c9b2 100644 --- a/tests/integrationtest/t/expression/cast.test +++ b/tests/integrationtest/t/expression/cast.test @@ -55,3 +55,18 @@ update t1 set c1 = cast('61qw' as decimal); --enable_warnings select cast('61qw' as decimal); --disable_warnings +<<<<<<< HEAD +======= + +# TestCastTimeAsYear +drop table if exists t; +create table t (y year); +insert into t values (cast('14:15' as time)); +select 1 from t where y = YEAR(CURDATE()); +select cast(cast('14:15' as time) as year) = YEAR(CURDATE()); + +# TestIssue49526 +explain select null as a union all select 'a' as a; +--sorted_result +select null as a union all select 'a' as a; +>>>>>>> 3a7bd532a26 (expression: ignore `TypeNULL` in `HandleBinaryLiteral` (#49527)) From 8f2fdd02b39325e29a02352397dadbcc94970efa Mon Sep 17 00:00:00 2001 From: Yang Keao Date: Mon, 18 Dec 2023 16:11:33 +0800 Subject: [PATCH 2/3] resolve conflict Signed-off-by: Yang Keao --- go.sum | 6 ------ tests/integrationtest/r/expression/cast.result | 12 ------------ tests/integrationtest/t/expression/cast.test | 10 ---------- 3 files changed, 28 deletions(-) diff --git a/go.sum b/go.sum index 19a1197bb7cc7..f0df92ef439d1 100644 --- a/go.sum +++ b/go.sum @@ -940,16 +940,10 @@ github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9 github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/soheilhy/cmux v0.1.5 h1:jjzc5WVemNEDTLwv9tlmemhC73tI08BNOIGwBOo10Js= github.com/soheilhy/cmux v0.1.5/go.mod h1:T7TcVDs9LWfQgPlPsdngu6I6QIoyIFZDDC6sNE1GqG0= -<<<<<<< HEAD -github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= -github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -======= github.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0 h1:IJ3DuWHPTJrsqtIqjfdmPTELdTFGefvrOa2eTeRBleQ= github.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:V952P4GGl1v/MMynLwxVdWEbSZJx+n0oOO3ljnez+WU= github.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67 h1:8ZnTA26bBOoPkAbbitKPgNlpw0Bwt7ZlpYgZWHWJR/w= github.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67/go.mod h1:tNZjgbYncKL5HxvDULAr/mWDmFz4B7H8yrXEDlnoIiw= ->>>>>>> 3a7bd532a26 (expression: ignore `TypeNULL` in `HandleBinaryLiteral` (#49527)) github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.2.1/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= diff --git a/tests/integrationtest/r/expression/cast.result b/tests/integrationtest/r/expression/cast.result index a6cc3e51b9259..65c13192b3575 100644 --- a/tests/integrationtest/r/expression/cast.result +++ b/tests/integrationtest/r/expression/cast.result @@ -88,17 +88,6 @@ cast('61qw' as decimal) 61 Level Code Message Warning 1292 Truncated incorrect DECIMAL value: '61qw' -<<<<<<< HEAD -======= -drop table if exists t; -create table t (y year); -insert into t values (cast('14:15' as time)); -select 1 from t where y = YEAR(CURDATE()); -1 -1 -select cast(cast('14:15' as time) as year) = YEAR(CURDATE()); -cast(cast('14:15' as time) as year) = YEAR(CURDATE()) -1 explain select null as a union all select 'a' as a; id estRows task access object operator info Union_8 2.00 root @@ -110,4 +99,3 @@ select null as a union all select 'a' as a; a NULL a ->>>>>>> 3a7bd532a26 (expression: ignore `TypeNULL` in `HandleBinaryLiteral` (#49527)) diff --git a/tests/integrationtest/t/expression/cast.test b/tests/integrationtest/t/expression/cast.test index b24c95899c9b2..ab76178175b28 100644 --- a/tests/integrationtest/t/expression/cast.test +++ b/tests/integrationtest/t/expression/cast.test @@ -55,18 +55,8 @@ update t1 set c1 = cast('61qw' as decimal); --enable_warnings select cast('61qw' as decimal); --disable_warnings -<<<<<<< HEAD -======= - -# TestCastTimeAsYear -drop table if exists t; -create table t (y year); -insert into t values (cast('14:15' as time)); -select 1 from t where y = YEAR(CURDATE()); -select cast(cast('14:15' as time) as year) = YEAR(CURDATE()); # TestIssue49526 explain select null as a union all select 'a' as a; --sorted_result select null as a union all select 'a' as a; ->>>>>>> 3a7bd532a26 (expression: ignore `TypeNULL` in `HandleBinaryLiteral` (#49527)) From 253c1f99d98d5278248888a890606fc8a77f955a Mon Sep 17 00:00:00 2001 From: Yang Keao Date: Fri, 22 Dec 2023 00:43:22 +0800 Subject: [PATCH 3/3] fix go.sum Signed-off-by: Yang Keao --- go.sum | 3 +++ 1 file changed, 3 insertions(+) diff --git a/go.sum b/go.sum index f0df92ef439d1..7f34ca7750b1c 100644 --- a/go.sum +++ b/go.sum @@ -944,6 +944,9 @@ github.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0 h1:IJ3DuWHPTJr github.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:V952P4GGl1v/MMynLwxVdWEbSZJx+n0oOO3ljnez+WU= github.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67 h1:8ZnTA26bBOoPkAbbitKPgNlpw0Bwt7ZlpYgZWHWJR/w= github.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67/go.mod h1:tNZjgbYncKL5HxvDULAr/mWDmFz4B7H8yrXEDlnoIiw= +github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= +github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.2.1/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=