Commit 03ee23bc authored by Alexander Barkov's avatar Alexander Barkov

MDEV-17226 Column Data in Truncated on UNION to the length of the first value if using REPLACE

This problem was earlier fixed by:
  commit 55b27888

Adding MTR tests only.
parent 2d775fd0
#
# 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
#
--echo #
--echo # Start of 10.5 tests
--echo #
--echo #
--echo # MDEV-17226 Column Data in Truncated on UNION to the length of the first value if using REPLACE
--echo #
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;
SELECT 'a' UNION ALL SELECT REPLACE('a', col1, col2) FROM t2;
SELECT REPLACE('z', col1, col2) FROM t1 UNION ALL SELECT REPLACE('a', col1, col2) FROM t1;
SELECT REPLACE('z', col1, col2) FROM t2 UNION ALL SELECT REPLACE('a', col1, col2) FROM t2;
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;
CREATE TABLE t2 AS SELECT 'a' UNION ALL SELECT REPLACE('a', col1, col2) FROM t1;
SELECT * FROM t2;
SHOW CREATE TABLE t2;
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;
CREATE TABLE t2 AS SELECT 'a' UNION ALL SELECT REPLACE('aa', col1, col2) FROM t1;
SELECT * FROM t2;
SHOW CREATE TABLE t2;
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;
CREATE TABLE t2 AS SELECT 'a' UNION ALL SELECT REPLACE('aa', col1, col2) FROM t1;
SELECT * FROM t2;
SHOW CREATE TABLE t2;
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;
CREATE TABLE t2 AS SELECT 'a' UNION ALL SELECT REPLACE('aaa', col1, col2) FROM t1;
SELECT * FROM t2;
SHOW CREATE TABLE t2;
DROP TABLE t1, t2;
--echo #
--echo # End of 10.5 tests
--echo #
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment