summaryrefslogtreecommitdiffstats
path: root/mysql-test/main/func_replace.result
blob: 7f354d529df615135bf8c59d2cab3886a0e8a7b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#
# Start of 10.5 tests
#
#
# MDEV-17226 Column Data in Truncated on UNION to the length of the first value if using REPLACE
#
CREATE TABLE t1 (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
col1 VARCHAR (2),
col2 VARCHAR (2),
PRIMARY KEY (id)
);
CREATE TABLE t2 (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
col1 VARCHAR (1),
col2 VARCHAR (2),
PRIMARY KEY (id)
);
INSERT INTO t1 (col1, col2) VALUES ("a", "ba");
INSERT INTO t2 (col1, col2) VALUES ("a", "ba");
SELECT 'a' UNION ALL SELECT REPLACE('a', col1, col2) FROM t1;
a
a
ba
SELECT 'a' UNION ALL SELECT REPLACE('a', col1, col2) FROM t2;
a
a
ba
SELECT REPLACE('z', col1, col2) FROM t1 UNION ALL SELECT REPLACE('a', col1, col2) FROM t1;
REPLACE('z', col1, col2)
z
ba
SELECT REPLACE('z', col1, col2) FROM t2 UNION ALL SELECT REPLACE('a', col1, col2) FROM t2;
REPLACE('z', col1, col2)
z
ba
DROP TABLE t1, t2;
CREATE TABLE t1 (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
col1 VARCHAR (2),
col2 VARCHAR (2),
PRIMARY KEY (id)
);
INSERT INTO t1 (col1, col2) VALUES ('a', 'ba');
SELECT REPLACE('a', col1, col2) FROM t1;
REPLACE('a', col1, col2)
ba
CREATE TABLE t2 AS SELECT 'a' UNION ALL SELECT REPLACE('a', col1, col2) FROM t1;
SELECT * FROM t2;
a
a
ba
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` varchar(2) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
DROP TABLE t1, t2;
CREATE TABLE t1 (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
col1 VARCHAR (1),
col2 VARCHAR (10),
PRIMARY KEY (id)
);
INSERT INTO t1 (col1, col2) VALUES ('a', '0123456789');
SELECT REPLACE('aa', col1, col2) FROM t1;
REPLACE('aa', col1, col2)
01234567890123456789
CREATE TABLE t2 AS SELECT 'a' UNION ALL SELECT REPLACE('aa', col1, col2) FROM t1;
SELECT * FROM t2;
a
a
01234567890123456789
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` varchar(20) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
DROP TABLE t1, t2;
CREATE TABLE t1 (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
col1 VARCHAR (1),
col2 VARCHAR (20),
PRIMARY KEY (id)
);
INSERT INTO t1 (col1, col2) VALUES ('a', 'aaaaaaaaaabbbbbbbbbb');
SELECT REPLACE('aa', col1, col2) FROM t1;
REPLACE('aa', col1, col2)
aaaaaaaaaabbbbbbbbbbaaaaaaaaaabbbbbbbbbb
CREATE TABLE t2 AS SELECT 'a' UNION ALL SELECT REPLACE('aa', col1, col2) FROM t1;
SELECT * FROM t2;
a
a
aaaaaaaaaabbbbbbbbbbaaaaaaaaaabbbbbbbbbb
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` varchar(40) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
DROP TABLE t1, t2;
CREATE TABLE t1 (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
col1 VARCHAR (1),
col2 VARCHAR (30),
PRIMARY KEY (id)
);
INSERT INTO t1 (col1, col2) VALUES ('a', 'aaaaaaaaaabbbbbbbbbbcccccccccc');
SELECT REPLACE('aaa', col1, col2) FROM t1;
REPLACE('aaa', col1, col2)
aaaaaaaaaabbbbbbbbbbccccccccccaaaaaaaaaabbbbbbbbbbccccccccccaaaaaaaaaabbbbbbbbbbcccccccccc
CREATE TABLE t2 AS SELECT 'a' UNION ALL SELECT REPLACE('aaa', col1, col2) FROM t1;
SELECT * FROM t2;
a
a
aaaaaaaaaabbbbbbbbbbccccccccccaaaaaaaaaabbbbbbbbbbccccccccccaaaaaaaaaabbbbbbbbbbcccccccccc
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` varchar(90) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
DROP TABLE t1, t2;
#
# End of 10.5 tests
#