Skip to content

Commit 92ac1de

Browse files
committed
fix conflict
1 parent dcff133 commit 92ac1de

File tree

7 files changed

+4
-2627
lines changed

7 files changed

+4
-2627
lines changed

expression/builtin_cast.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -284,13 +284,7 @@ func (c *castAsStringFunctionClass) getFunction(ctx sessionctx.Context, args []E
284284
if err != nil {
285285
return nil, err
286286
}
287-
<<<<<<< HEAD:expression/builtin_cast.go
288-
if args[0].GetType().Hybrid() {
289-
sig = &builtinCastStringAsStringSig{bf}
290-
sig.setPbCode(tipb.ScalarFuncSig_CastStringAsString)
291-
return sig, nil
292-
=======
293-
if ft := args[0].GetType(ctx.GetEvalCtx()); ft.Hybrid() {
287+
if ft := args[0].GetType(); ft.Hybrid() {
294288
castBitAsUnBinary := ft.GetType() == mysql.TypeBit && c.tp.GetCharset() != charset.CharsetBin
295289
if !castBitAsUnBinary {
296290
sig = &builtinCastStringAsStringSig{bf}
@@ -304,7 +298,6 @@ func (c *castAsStringFunctionClass) getFunction(ctx sessionctx.Context, args []E
304298
tp.SetCollate(charset.CollationBin)
305299
tp.AddFlag(mysql.BinaryFlag)
306300
args[0] = BuildCastFunction(ctx, args[0], tp)
307-
>>>>>>> 38104f4f328 (expression: fix tikv crash when `bool like cast(bit as char)` (#57484)):pkg/expression/builtin_cast.go
308301
}
309302
argTp := args[0].GetType().EvalType()
310303
switch argTp {

expression/builtin_convert_charset.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ type builtinInternalFromBinarySig struct {
166166
func (b *builtinInternalFromBinarySig) Clone() builtinFunc {
167167
newSig := &builtinInternalFromBinarySig{}
168168
newSig.cloneFrom(&b.baseBuiltinFunc)
169-
newSig.cannotConvertStringAsWarning = b.cannotConvertStringAsWarning
170169
return newSig
171170
}
172171

pkg/planner/core/integration_test.go

Lines changed: 0 additions & 2320 deletions
This file was deleted.

planner/core/integration_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,15 +1405,15 @@ func TestBitColumnPushDown(t *testing.T) {
14051405
tk.MustQuery(sql).Check(testkit.Rows("A"))
14061406
tk.MustQuery(fmt.Sprintf("explain analyze %s", sql)).CheckAt([]int{0, 3, 6}, rows)
14071407

1408-
rows[1][2] = `eq(cast(test.t1.a, var_string(1)), "A")`
1408+
rows[1][2] = `eq(cast(from_binary(cast(test.t1.a, binary(1))), var_string(1)), "A")`
14091409
sql = "select a from t1 where cast(a as char)='A'"
14101410
tk.MustQuery(sql).Check(testkit.Rows("A"))
14111411
tk.MustQuery(fmt.Sprintf("explain analyze %s", sql)).CheckAt([]int{0, 3, 6}, rows)
14121412

14131413
tk.MustExec("insert into mysql.expr_pushdown_blacklist values('bit', 'tikv','');")
14141414
tk.MustExec("admin reload expr_pushdown_blacklist;")
14151415
rows = [][]interface{}{
1416-
{"Selection_5", "root", `eq(cast(test.t1.a, var_string(1)), "A")`},
1416+
{"Selection_5", "root", `eq(cast(from_binary(cast(test.t1.a, binary(1))), var_string(1)), "A")`},
14171417
{"└─TableReader_7", "root", "data:TableFullScan_6"},
14181418
{" └─TableFullScan_6", "cop[tikv]", "keep order:false, stats:pseudo"},
14191419
}

tests/integrationtest/r/expression/cast.result

Lines changed: 0 additions & 180 deletions
Original file line numberDiff line numberDiff line change
@@ -1,183 +1,3 @@
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 '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 '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 '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 '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 'CAST'. Maximum is 6.
81-
drop table if exists t;
82-
create table t(a varchar(50));
83-
insert into t values ('2020-01-01 12:00:00.123456 +0600 PST');
84-
insert into t values ('2020-01-01 12:00:00.123456 -0600 PST');
85-
insert into t values ('2020-01-01 12:00:00.123456');
86-
select cast(a as datetime(3)) from t;
87-
cast(a as datetime(3))
88-
2020-01-01 12:00:00.123
89-
2020-01-01 12:00:00.123
90-
2020-01-01 12:00:00.123
91-
drop table if exists t1;
92-
create table t1 (c1 text);
93-
insert into t1 values ('a');
94-
update t1 set c1 = cast('61qw' as decimal);
95-
Error 1292 (22007): Truncated incorrect DECIMAL value: '61qw'
96-
select cast('61qw' as decimal);
97-
cast('61qw' as decimal)
98-
61
99-
Level Code Message
100-
Warning 1292 Truncated incorrect DECIMAL value: '61qw'
101-
drop table if exists t;
102-
create table t (y year);
103-
insert into t values (cast('14:15' as time));
104-
select 1 from t where y = YEAR(CURDATE());
105-
1
106-
1
107-
select cast(cast('14:15' as time) as year) = YEAR(CURDATE());
108-
cast(cast('14:15' as time) as year) = YEAR(CURDATE())
109-
1
110-
explain select null as a union all select 'a' as a;
111-
id estRows task access object operator info
112-
Union_8 2.00 root
113-
├─Projection_10 1.00 root <nil>->Column#3
114-
│ └─TableDual_11 1.00 root rows:1
115-
└─Projection_12 1.00 root a->Column#3
116-
└─TableDual_13 1.00 root rows:1
117-
select null as a union all select 'a' as a;
118-
a
119-
NULL
120-
a
121-
drop table if exists t0;
122-
create table t0(c0 tinyint(1) unsigned not null );
123-
insert into t0 values (1);
124-
select * from t0 where case 0 when t0.c0 > -1.194192591e9 then null else 1 end;
125-
c0
126-
1
127-
select t0.c0 > -1.194192591e9 from t0;
128-
t0.c0 > -1.194192591e9
129-
1
130-
select t0.c0 < -1.194192591e9 from t0;
131-
t0.c0 < -1.194192591e9
132-
0
133-
select -1.194192591e9 > t0.c0 from t0;
134-
-1.194192591e9 > t0.c0
135-
0
136-
select -1.194192591e9 < t0.c0 from t0;
137-
-1.194192591e9 < t0.c0
138-
1
139-
select t0.c0 > 1.194192591e9 from t0;
140-
t0.c0 > 1.194192591e9
141-
0
142-
select t0.c0 < 1.194192591e9 from t0;
143-
t0.c0 < 1.194192591e9
144-
1
145-
select 1.194192591e9 > t0.c0 from t0;
146-
1.194192591e9 > t0.c0
147-
1
148-
select 1.194192591e9 < t0.c0 from t0;
149-
1.194192591e9 < t0.c0
150-
0
151-
drop table if exists test;
152-
CREATE TABLE `test` (
153-
`id` bigint(20) NOT NULL,
154-
`update_user` varchar(32) DEFAULT NULL,
155-
PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */
156-
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
157-
insert into test values(1,'张三');
158-
insert into test values(2,'李四');
159-
insert into test values(3,'张三');
160-
insert into test values(4,'李四');
161-
select * from test order by cast(update_user as char character set gbk) desc , id limit 3;
162-
id update_user
163-
1 张三
164-
3 张三
165-
2 李四
166-
drop table test;
167-
CREATE TABLE `test` (
168-
`id` bigint NOT NULL,
169-
`update_user` varchar(32) CHARACTER SET gbk COLLATE gbk_chinese_ci DEFAULT NULL,
170-
PRIMARY KEY (`id`)
171-
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
172-
insert into test values(1,'张三');
173-
insert into test values(2,'李四');
174-
insert into test values(3,'张三');
175-
insert into test values(4,'李四');
176-
select * from test order by cast(update_user as char) desc , id limit 3;
177-
id update_user
178-
2 李四
179-
4 李四
180-
1 张三
1811
drop table if exists test;
1822
create table test(a bit(24));
1833
insert into test values('中');

tests/integrationtest/t/expression/cast.test

Lines changed: 0 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -1,118 +1,3 @@
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-
drop table if exists t;
49-
create table t(a varchar(50));
50-
insert into t values ('2020-01-01 12:00:00.123456 +0600 PST');
51-
insert into t values ('2020-01-01 12:00:00.123456 -0600 PST');
52-
insert into t values ('2020-01-01 12:00:00.123456');
53-
select cast(a as datetime(3)) from t;
54-
55-
# TestCastErrMsg
56-
drop table if exists t1;
57-
create table t1 (c1 text);
58-
insert into t1 values ('a');
59-
--error 1292
60-
update t1 set c1 = cast('61qw' as decimal);
61-
--enable_warnings
62-
select cast('61qw' as decimal);
63-
--disable_warnings
64-
65-
# TestCastTimeAsYear
66-
drop table if exists t;
67-
create table t (y year);
68-
insert into t values (cast('14:15' as time));
69-
select 1 from t where y = YEAR(CURDATE());
70-
select cast(cast('14:15' as time) as year) = YEAR(CURDATE());
71-
72-
# TestIssue49526
73-
explain select null as a union all select 'a' as a;
74-
--sorted_result
75-
select null as a union all select 'a' as a;
76-
77-
# TestNegFloatConvertToUnsigned
78-
drop table if exists t0;
79-
create table t0(c0 tinyint(1) unsigned not null );
80-
insert into t0 values (1);
81-
select * from t0 where case 0 when t0.c0 > -1.194192591e9 then null else 1 end;
82-
select t0.c0 > -1.194192591e9 from t0;
83-
select t0.c0 < -1.194192591e9 from t0;
84-
select -1.194192591e9 > t0.c0 from t0;
85-
select -1.194192591e9 < t0.c0 from t0;
86-
select t0.c0 > 1.194192591e9 from t0;
87-
select t0.c0 < 1.194192591e9 from t0;
88-
select 1.194192591e9 > t0.c0 from t0;
89-
select 1.194192591e9 < t0.c0 from t0;
90-
91-
# TestCastAsStringExplicitCharSet
92-
drop table if exists test;
93-
CREATE TABLE `test` (
94-
`id` bigint(20) NOT NULL,
95-
`update_user` varchar(32) DEFAULT NULL,
96-
PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */
97-
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
98-
insert into test values(1,'张三');
99-
insert into test values(2,'李四');
100-
insert into test values(3,'张三');
101-
insert into test values(4,'李四');
102-
select * from test order by cast(update_user as char character set gbk) desc , id limit 3;
103-
104-
drop table test;
105-
CREATE TABLE `test` (
106-
`id` bigint NOT NULL,
107-
`update_user` varchar(32) CHARACTER SET gbk COLLATE gbk_chinese_ci DEFAULT NULL,
108-
PRIMARY KEY (`id`)
109-
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
110-
insert into test values(1,'张三');
111-
insert into test values(2,'李四');
112-
insert into test values(3,'张三');
113-
insert into test values(4,'李四');
114-
select * from test order by cast(update_user as char) desc , id limit 3;
115-
1161
# issue #56494, cast bit as char
1172
drop table if exists test;
1183
create table test(a bit(24));

tests/realtikvtest/pushdowntest/expr_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ package pushdowntest
1717
import (
1818
"testing"
1919

20-
"github.com/pingcap/tidb/pkg/testkit"
20+
"github.com/pingcap/tidb/testkit"
2121
"github.com/pingcap/tidb/tests/realtikvtest"
2222
"github.com/stretchr/testify/require"
2323
)

0 commit comments

Comments
 (0)