Skip to content

Commit f6e0d3e

Browse files
YangKeaoti-chi-bot
authored andcommitted
This is an automated cherry-pick of pingcap#49527
Signed-off-by: ti-chi-bot <[email protected]>
1 parent 859fade commit f6e0d3e

File tree

6 files changed

+229
-1
lines changed

6 files changed

+229
-1
lines changed

DEPS.bzl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4787,15 +4787,37 @@ def go_deps():
47874787
name = "com_sourcegraph_sourcegraph_appdash",
47884788
build_file_proto_mode = "disable_global",
47894789
importpath = "sourcegraph.com/sourcegraph/appdash",
4790+
<<<<<<< HEAD
47904791
sum = "h1:ucqkfpjg9WzSUubAO62csmucvxl4/JeW3F4I4909XkM=",
47914792
version = "v0.0.0-20190731080439-ebfcffb1b5c0",
4793+
=======
4794+
sha256 = "c46b442fa40d2af48e08064f4c16ae3712953a9988cd0f7588fcf5e4fc7a2fed",
4795+
strip_prefix = "github.com/sourcegraph/[email protected]",
4796+
urls = [
4797+
"http://bazel-cache.pingcap.net:8080/gomod/github.com/sourcegraph/appdash/com_github_sourcegraph_appdash-v0.0.0-20190731080439-ebfcffb1b5c0.zip",
4798+
"http://ats.apps.svc/gomod/github.com/sourcegraph/appdash/com_github_sourcegraph_appdash-v0.0.0-20190731080439-ebfcffb1b5c0.zip",
4799+
"https://cache.hawkingrei.com/gomod/github.com/sourcegraph/appdash/com_github_sourcegraph_appdash-v0.0.0-20190731080439-ebfcffb1b5c0.zip",
4800+
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/sourcegraph/appdash/com_github_sourcegraph_appdash-v0.0.0-20190731080439-ebfcffb1b5c0.zip",
4801+
],
4802+
>>>>>>> 3a7bd532a26 (expression: ignore `TypeNULL` in `HandleBinaryLiteral` (#49527))
47924803
)
47934804
go_repository(
47944805
name = "com_sourcegraph_sourcegraph_appdash_data",
47954806
build_file_proto_mode = "disable_global",
47964807
importpath = "sourcegraph.com/sourcegraph/appdash-data",
4808+
<<<<<<< HEAD
47974809
sum = "h1:e1sMhtVq9AfcEy8AXNb8eSg6gbzfdpYhoNqnPJa+GzI=",
47984810
version = "v0.0.0-20151005221446-73f23eafcf67",
4811+
=======
4812+
sha256 = "59b71fa8cdb0fe2b1c02739ccf2daeaf28f2e22c4b178cdc8e1b902ad1022bc0",
4813+
strip_prefix = "github.com/sourcegraph/[email protected]",
4814+
urls = [
4815+
"http://bazel-cache.pingcap.net:8080/gomod/github.com/sourcegraph/appdash-data/com_github_sourcegraph_appdash_data-v0.0.0-20151005221446-73f23eafcf67.zip",
4816+
"http://ats.apps.svc/gomod/github.com/sourcegraph/appdash-data/com_github_sourcegraph_appdash_data-v0.0.0-20151005221446-73f23eafcf67.zip",
4817+
"https://cache.hawkingrei.com/gomod/github.com/sourcegraph/appdash-data/com_github_sourcegraph_appdash_data-v0.0.0-20151005221446-73f23eafcf67.zip",
4818+
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/sourcegraph/appdash-data/com_github_sourcegraph_appdash_data-v0.0.0-20151005221446-73f23eafcf67.zip",
4819+
],
4820+
>>>>>>> 3a7bd532a26 (expression: ignore `TypeNULL` in `HandleBinaryLiteral` (#49527))
47994821
)
48004822
go_repository(
48014823
name = "com_stathat_c_consistent",

expression/builtin_convert_charset.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,8 @@ func HandleBinaryLiteral(ctx sessionctx.Context, expr Expression, ec *ExprCollat
322322
return expr
323323
}
324324
return BuildToBinaryFunction(ctx, expr)
325-
} else if argChs == charset.CharsetBin && dstChs != charset.CharsetBin {
325+
} else if argChs == charset.CharsetBin && dstChs != charset.CharsetBin &&
326+
expr.GetType().GetType() != mysql.TypeNull {
326327
ft := expr.GetType().Clone()
327328
ft.SetCharset(ec.Charset)
328329
ft.SetCollate(ec.Collation)

go.mod

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,16 @@ require (
268268
replace (
269269
// fix potential security issue(CVE-2020-26160) introduced by indirect dependency.
270270
github.com/dgrijalva/jwt-go => github.com/form3tech-oss/jwt-go v3.2.6-0.20210809144907-32ab6a8243d7+incompatible
271+
<<<<<<< HEAD
271272
github.com/pingcap/tidb/parser => ./parser
272273
go.opencensus.io => go.opencensus.io v0.23.1-0.20220331163232-052120675fac
274+
=======
275+
github.com/go-ldap/ldap/v3 => github.com/YangKeao/ldap/v3 v3.4.5-0.20230421065457-369a3bab1117
276+
github.com/pingcap/tidb/pkg/parser => ./pkg/parser
277+
278+
// TODO: `sourcegraph.com/sourcegraph/appdash` has been archived, and the original host has been removed.
279+
// Please remove these dependencies.
280+
sourcegraph.com/sourcegraph/appdash => github.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0
281+
sourcegraph.com/sourcegraph/appdash-data => github.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67
282+
>>>>>>> 3a7bd532a26 (expression: ignore `TypeNULL` in `HandleBinaryLiteral` (#49527))
273283
)

go.sum

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,9 +898,16 @@ github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9
898898
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
899899
github.com/soheilhy/cmux v0.1.5 h1:jjzc5WVemNEDTLwv9tlmemhC73tI08BNOIGwBOo10Js=
900900
github.com/soheilhy/cmux v0.1.5/go.mod h1:T7TcVDs9LWfQgPlPsdngu6I6QIoyIFZDDC6sNE1GqG0=
901+
<<<<<<< HEAD
901902
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
902903
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
903904
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
905+
=======
906+
github.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0 h1:IJ3DuWHPTJrsqtIqjfdmPTELdTFGefvrOa2eTeRBleQ=
907+
github.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:V952P4GGl1v/MMynLwxVdWEbSZJx+n0oOO3ljnez+WU=
908+
github.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67 h1:8ZnTA26bBOoPkAbbitKPgNlpw0Bwt7ZlpYgZWHWJR/w=
909+
github.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67/go.mod h1:tNZjgbYncKL5HxvDULAr/mWDmFz4B7H8yrXEDlnoIiw=
910+
>>>>>>> 3a7bd532a26 (expression: ignore `TypeNULL` in `HandleBinaryLiteral` (#49527))
904911
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
905912
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
906913
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
@@ -1597,6 +1604,7 @@ rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8
15971604
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
15981605
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
15991606
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
1607+
<<<<<<< HEAD
16001608
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 h1:kDi4JBNAsJWfz1aEXhO8Jg87JJaPNLh5tIzYHgStQ9Y=
16011609
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2/go.mod h1:B+TnT182UBxE84DiCz4CVE26eOSDAeYCpfDnC2kdKMY=
16021610
sigs.k8s.io/structured-merge-diff/v4 v4.0.2/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw=
@@ -1609,4 +1617,12 @@ sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0 h1:ucqkfp
16091617
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
16101618
sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67 h1:e1sMhtVq9AfcEy8AXNb8eSg6gbzfdpYhoNqnPJa+GzI=
16111619
sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67/go.mod h1:L5q+DGLGOQFpo1snNEkLOJT2d1YTW66rWNzatr3He1k=
1620+
=======
1621+
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
1622+
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
1623+
sigs.k8s.io/structured-merge-diff/v4 v4.3.0 h1:UZbZAZfX0wV2zr7YZorDz6GXROfDFj6LvqCRm4VUVKk=
1624+
sigs.k8s.io/structured-merge-diff/v4 v4.3.0/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08=
1625+
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
1626+
sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=
1627+
>>>>>>> 3a7bd532a26 (expression: ignore `TypeNULL` in `HandleBinaryLiteral` (#49527))
16121628
stathat.com/c/consistent v1.0.0 h1:ezyc51EGcRPJUxfHGSgJjWzJdj3NiMU9pNfLNGiXV0c=
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
select cast('' as signed);
2+
cast('' as signed)
3+
0
4+
Level Code Message
5+
Warning 1292 Truncated incorrect INTEGER value: ''
6+
select cast('12345abcde' as signed);
7+
cast('12345abcde' as signed)
8+
12345
9+
Level Code Message
10+
Warning 1292 Truncated incorrect INTEGER value: '12345abcde'
11+
select cast('123e456' as signed);
12+
cast('123e456' as signed)
13+
123
14+
Level Code Message
15+
Warning 1292 Truncated incorrect INTEGER value: '123e456'
16+
select cast('-12345abcde' as signed);
17+
cast('-12345abcde' as signed)
18+
-12345
19+
Level Code Message
20+
Warning 1292 Truncated incorrect INTEGER value: '-12345abcde'
21+
select cast('-123e456' as signed);
22+
cast('-123e456' as signed)
23+
-123
24+
Level Code Message
25+
Warning 1292 Truncated incorrect INTEGER value: '-123e456'
26+
select coercibility(binary('a'));
27+
coercibility(binary('a'))
28+
2
29+
select coercibility(cast('a' as char(10)));
30+
coercibility(cast('a' as char(10)))
31+
2
32+
select coercibility(convert('abc', char(10)));
33+
coercibility(convert('abc', char(10)))
34+
2
35+
drop table if exists t;
36+
create table t(d1 double, f float, d2 decimal(24,8));
37+
insert into t values(0, 0, 0);
38+
select cast(111.1 as datetime) from t;
39+
cast(111.1 as datetime)
40+
2000-01-11 00:00:00
41+
select cast(1311.1 as datetime) from t;
42+
cast(1311.1 as datetime)
43+
NULL
44+
insert into t values(111.1, 1122.1, 31212.111);
45+
insert into t values(121212.1111, 1121212.111111, 11121212.111111);
46+
insert into t values(99991111.1111111, 101.1111111, 20121212121212.1111111);
47+
insert into t values(NULL, NULL, NULL);
48+
insert into t values(1.1, 48.1, 100.1);
49+
insert into t values(1301.11, 1131.111, 100001111.111);
50+
insert into t values(20121212121260.1111111, 20121212126012.1111111, 20121212241212.1111111);
51+
select cast(d1 as datetime), cast(f as datetime), cast(d2 as datetime) from t;
52+
cast(d1 as datetime) cast(f as datetime) cast(d2 as datetime)
53+
NULL NULL NULL
54+
NULL NULL NULL
55+
NULL NULL NULL
56+
NULL NULL NULL
57+
0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00
58+
2000-01-11 00:00:00 2000-11-22 00:00:00 2003-12-12 00:00:00
59+
2012-12-12 00:00:00 0112-12-12 00:00:00 1112-12-12 00:00:00
60+
9999-11-11 00:00:00 2000-01-01 00:00:00 2012-12-12 12:12:12
61+
drop table if exists t;
62+
create table t (col1 bigint, col2 double, col3 decimal, col4 varchar(20), col5 json);
63+
insert into t values (1, 1, 1, "1", "1");
64+
insert into t values (null, null, null, null, null);
65+
select cast(col1 as time), cast(col2 as time), cast(col3 as time), cast(col4 as time), cast(col5 as time) from t where col1 = 1;
66+
cast(col1 as time) cast(col2 as time) cast(col3 as time) cast(col4 as time) cast(col5 as time)
67+
00:00:01 00:00:01 00:00:01 00:00:01 NULL
68+
select cast(col1 as time), cast(col2 as time), cast(col3 as time), cast(col4 as time), cast(col5 as time) from t where col1 is null;
69+
cast(col1 as time) cast(col2 as time) cast(col3 as time) cast(col4 as time) cast(col5 as time)
70+
NULL NULL NULL NULL NULL
71+
select cast(col1 as time(31)) from t where col1 is null;
72+
Error 1426 (42000): Too big precision 31 specified for column 'CAST'. Maximum is 6.
73+
select cast(col2 as time(31)) from t where col1 is null;
74+
Error 1426 (42000): Too big precision 31 specified for column 'CAST'. Maximum is 6.
75+
select cast(col3 as time(31)) from t where col1 is null;
76+
Error 1426 (42000): Too big precision 31 specified for column 'CAST'. Maximum is 6.
77+
select cast(col4 as time(31)) from t where col1 is null;
78+
Error 1426 (42000): Too big precision 31 specified for column 'CAST'. Maximum is 6.
79+
select cast(col5 as time(31)) from t where col1 is null;
80+
Error 1426 (42000): Too big precision 31 specified for column 'CAST'. Maximum is 6.
81+
drop table if exists t1;
82+
create table t1 (c1 text);
83+
insert into t1 values ('a');
84+
update t1 set c1 = cast('61qw' as decimal);
85+
Error 1292 (22007): Truncated incorrect DECIMAL value: '61qw'
86+
select cast('61qw' as decimal);
87+
cast('61qw' as decimal)
88+
61
89+
Level Code Message
90+
Warning 1292 Truncated incorrect DECIMAL value: '61qw'
91+
drop table if exists t;
92+
create table t (y year);
93+
insert into t values (cast('14:15' as time));
94+
select 1 from t where y = YEAR(CURDATE());
95+
1
96+
1
97+
select cast(cast('14:15' as time) as year) = YEAR(CURDATE());
98+
cast(cast('14:15' as time) as year) = YEAR(CURDATE())
99+
1
100+
explain select null as a union all select 'a' as a;
101+
id estRows task access object operator info
102+
Union_8 2.00 root
103+
├─Projection_10 1.00 root <nil>->Column#3
104+
│ └─TableDual_11 1.00 root rows:1
105+
└─Projection_12 1.00 root a->Column#3
106+
└─TableDual_13 1.00 root rows:1
107+
select null as a union all select 'a' as a;
108+
a
109+
NULL
110+
a
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# TestCastStrToInt
2+
--enable_warnings
3+
select cast('' as signed);
4+
select cast('12345abcde' as signed);
5+
select cast('123e456' as signed);
6+
select cast('-12345abcde' as signed);
7+
select cast('-123e456' as signed);
8+
--disable_warnings
9+
10+
# TestCastCoer
11+
select coercibility(binary('a'));
12+
select coercibility(cast('a' as char(10)));
13+
select coercibility(convert('abc', char(10)));
14+
15+
# TestCastRealAsTime
16+
drop table if exists t;
17+
create table t(d1 double, f float, d2 decimal(24,8));
18+
insert into t values(0, 0, 0);
19+
select cast(111.1 as datetime) from t;
20+
select cast(1311.1 as datetime) from t;
21+
insert into t values(111.1, 1122.1, 31212.111);
22+
insert into t values(121212.1111, 1121212.111111, 11121212.111111);
23+
insert into t values(99991111.1111111, 101.1111111, 20121212121212.1111111);
24+
insert into t values(NULL, NULL, NULL);
25+
insert into t values(1.1, 48.1, 100.1);
26+
insert into t values(1301.11, 1131.111, 100001111.111);
27+
insert into t values(20121212121260.1111111, 20121212126012.1111111, 20121212241212.1111111);
28+
-- sorted_result
29+
select cast(d1 as datetime), cast(f as datetime), cast(d2 as datetime) from t;
30+
31+
# TestCastAsTime
32+
drop table if exists t;
33+
create table t (col1 bigint, col2 double, col3 decimal, col4 varchar(20), col5 json);
34+
insert into t values (1, 1, 1, "1", "1");
35+
insert into t values (null, null, null, null, null);
36+
select cast(col1 as time), cast(col2 as time), cast(col3 as time), cast(col4 as time), cast(col5 as time) from t where col1 = 1;
37+
select cast(col1 as time), cast(col2 as time), cast(col3 as time), cast(col4 as time), cast(col5 as time) from t where col1 is null;
38+
-- error 1426
39+
select cast(col1 as time(31)) from t where col1 is null;
40+
-- error 1426
41+
select cast(col2 as time(31)) from t where col1 is null;
42+
-- error 1426
43+
select cast(col3 as time(31)) from t where col1 is null;
44+
-- error 1426
45+
select cast(col4 as time(31)) from t where col1 is null;
46+
-- error 1426
47+
select cast(col5 as time(31)) from t where col1 is null;
48+
49+
# TestCastErrMsg
50+
drop table if exists t1;
51+
create table t1 (c1 text);
52+
insert into t1 values ('a');
53+
--error 1292
54+
update t1 set c1 = cast('61qw' as decimal);
55+
--enable_warnings
56+
select cast('61qw' as decimal);
57+
--disable_warnings
58+
59+
# TestCastTimeAsYear
60+
drop table if exists t;
61+
create table t (y year);
62+
insert into t values (cast('14:15' as time));
63+
select 1 from t where y = YEAR(CURDATE());
64+
select cast(cast('14:15' as time) as year) = YEAR(CURDATE());
65+
66+
# TestIssue49526
67+
explain select null as a union all select 'a' as a;
68+
--sorted_result
69+
select null as a union all select 'a' as a;

0 commit comments

Comments
 (0)