Merge remote-tracking branch 'origin/bb-10.2-ext' into 10.3

This commit is contained in:
Alexander Barkov 2017-05-04 16:29:05 +04:00
commit 4991eab483
23 changed files with 1145 additions and 432 deletions

View file

@ -205,7 +205,7 @@ fi
max_no_embedded_configs="$SSL_LIBRARY --with-plugins=max"
max_no_qc_configs="$SSL_LIBRARY --with-plugins=max --without-query-cache"
max_configs="$SSL_LIBRARY --with-plugins=max --with-embedded-server --with-libevent --without-plugin=plugin_file_key_management"
max_configs="$SSL_LIBRARY --with-plugins=max --with-embedded-server --with-libevent --without-plugin=plugin_file_key_management --with-plugin-rocksdb=dynamic"
all_configs="$SSL_LIBRARY --with-plugins=max --with-embedded-server --with-innodb_plugin --with-libevent"
#

View file

@ -1000,14 +1000,14 @@ t2 CREATE TABLE `t2` (
`least____a_a` int(11) DEFAULT NULL,
`greatest_a_a` int(11) DEFAULT NULL,
`___________b` bit(8) DEFAULT NULL,
`case_______b` int(8) unsigned DEFAULT NULL,
`case_____b_b` int(8) unsigned DEFAULT NULL,
`coalesce___b` int(8) unsigned DEFAULT NULL,
`coalesce_b_b` int(8) unsigned DEFAULT NULL,
`if_______b_b` int(8) unsigned DEFAULT NULL,
`case_______b` bit(8) DEFAULT NULL,
`case_____b_b` bit(8) DEFAULT NULL,
`coalesce___b` bit(8) DEFAULT NULL,
`coalesce_b_b` bit(8) DEFAULT NULL,
`if_______b_b` bit(8) DEFAULT NULL,
`ifnull___b_b` bit(8) DEFAULT NULL,
`least____b_b` int(8) unsigned DEFAULT NULL,
`greatest_b_b` int(8) unsigned DEFAULT NULL
`least____b_b` bit(8) DEFAULT NULL,
`greatest_b_b` bit(8) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
@ -1119,18 +1119,18 @@ GREATEST(a, b) AS greatest_a_b,
GREATEST(b, a) AS greatest_b_a
FROM t1;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def case_____a_b 8 10 10 Y 32928 0 63
def case_____b_a 8 10 2 Y 32928 0 63
def coalesce_a_b 8 10 10 Y 32928 0 63
def coalesce_b_a 8 10 2 Y 32928 0 63
def if_______a_b 8 10 2 Y 32928 0 63
def if_______b_a 8 10 10 Y 32928 0 63
def ifnull___a_b 8 10 10 Y 32928 0 63
def ifnull___b_a 8 10 2 Y 32928 0 63
def least____a_b 8 10 2 Y 32928 0 63
def least____b_a 8 10 2 Y 32928 0 63
def greatest_a_b 8 10 10 Y 32928 0 63
def greatest_b_a 8 10 10 Y 32928 0 63
def case_____a_b 3 10 10 Y 32928 0 63
def case_____b_a 3 10 2 Y 32928 0 63
def coalesce_a_b 3 10 10 Y 32928 0 63
def coalesce_b_a 3 10 2 Y 32928 0 63
def if_______a_b 3 10 2 Y 32928 0 63
def if_______b_a 3 10 10 Y 32928 0 63
def ifnull___a_b 3 10 10 Y 32928 0 63
def ifnull___b_a 3 10 2 Y 32928 0 63
def least____a_b 3 10 2 Y 32928 0 63
def least____b_a 3 10 2 Y 32928 0 63
def greatest_a_b 3 10 10 Y 32928 0 63
def greatest_b_a 3 10 10 Y 32928 0 63
case_____a_b 4294967295
case_____b_a 50
coalesce_a_b 4294967295
@ -1177,14 +1177,14 @@ t2 CREATE TABLE `t2` (
`least____a_a` int(10) unsigned DEFAULT NULL,
`greatest_a_a` int(10) unsigned DEFAULT NULL,
`___________b` bit(8) DEFAULT NULL,
`case_______b` int(8) unsigned DEFAULT NULL,
`case_____b_b` int(8) unsigned DEFAULT NULL,
`coalesce___b` int(8) unsigned DEFAULT NULL,
`coalesce_b_b` int(8) unsigned DEFAULT NULL,
`if_______b_b` int(8) unsigned DEFAULT NULL,
`case_______b` bit(8) DEFAULT NULL,
`case_____b_b` bit(8) DEFAULT NULL,
`coalesce___b` bit(8) DEFAULT NULL,
`coalesce_b_b` bit(8) DEFAULT NULL,
`if_______b_b` bit(8) DEFAULT NULL,
`ifnull___b_b` bit(8) DEFAULT NULL,
`least____b_b` int(8) unsigned DEFAULT NULL,
`greatest_b_b` int(8) unsigned DEFAULT NULL
`least____b_b` bit(8) DEFAULT NULL,
`greatest_b_b` bit(8) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
@ -1212,8 +1212,8 @@ t2 CREATE TABLE `t2` (
`coalesce_b_a` int(10) unsigned DEFAULT NULL,
`if_______a_b` int(10) unsigned DEFAULT NULL,
`if_______b_a` int(10) unsigned DEFAULT NULL,
`ifnull___a_b` bigint(10) unsigned DEFAULT NULL,
`ifnull___b_a` bigint(10) unsigned DEFAULT NULL,
`ifnull___a_b` int(10) unsigned DEFAULT NULL,
`ifnull___b_a` int(10) unsigned DEFAULT NULL,
`least____a_b` int(10) unsigned DEFAULT NULL,
`least____b_a` int(10) unsigned DEFAULT NULL,
`greatest_a_b` int(10) unsigned DEFAULT NULL,
@ -1345,23 +1345,23 @@ SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`___________a` bit(7) DEFAULT NULL,
`case_______a` int(7) unsigned DEFAULT NULL,
`case_____a_a` int(7) unsigned DEFAULT NULL,
`coalesce___a` int(7) unsigned DEFAULT NULL,
`coalesce_a_a` int(7) unsigned DEFAULT NULL,
`if_______a_a` int(7) unsigned DEFAULT NULL,
`case_______a` bit(7) DEFAULT NULL,
`case_____a_a` bit(7) DEFAULT NULL,
`coalesce___a` bit(7) DEFAULT NULL,
`coalesce_a_a` bit(7) DEFAULT NULL,
`if_______a_a` bit(7) DEFAULT NULL,
`ifnull___a_a` bit(7) DEFAULT NULL,
`least____a_a` int(7) unsigned DEFAULT NULL,
`greatest_a_a` int(7) unsigned DEFAULT NULL,
`least____a_a` bit(7) DEFAULT NULL,
`greatest_a_a` bit(7) DEFAULT NULL,
`___________b` bit(8) DEFAULT NULL,
`case_______b` int(8) unsigned DEFAULT NULL,
`case_____b_b` int(8) unsigned DEFAULT NULL,
`coalesce___b` int(8) unsigned DEFAULT NULL,
`coalesce_b_b` int(8) unsigned DEFAULT NULL,
`if_______b_b` int(8) unsigned DEFAULT NULL,
`case_______b` bit(8) DEFAULT NULL,
`case_____b_b` bit(8) DEFAULT NULL,
`coalesce___b` bit(8) DEFAULT NULL,
`coalesce_b_b` bit(8) DEFAULT NULL,
`if_______b_b` bit(8) DEFAULT NULL,
`ifnull___b_b` bit(8) DEFAULT NULL,
`least____b_b` int(8) unsigned DEFAULT NULL,
`greatest_b_b` int(8) unsigned DEFAULT NULL
`least____b_b` bit(8) DEFAULT NULL,
`greatest_b_b` bit(8) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
@ -1383,18 +1383,18 @@ FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`case_____a_b` int(8) unsigned DEFAULT NULL,
`case_____b_a` int(8) unsigned DEFAULT NULL,
`coalesce_a_b` int(8) unsigned DEFAULT NULL,
`coalesce_b_a` int(8) unsigned DEFAULT NULL,
`if_______a_b` int(8) unsigned DEFAULT NULL,
`if_______b_a` int(8) unsigned DEFAULT NULL,
`case_____a_b` bit(8) DEFAULT NULL,
`case_____b_a` bit(8) DEFAULT NULL,
`coalesce_a_b` bit(8) DEFAULT NULL,
`coalesce_b_a` bit(8) DEFAULT NULL,
`if_______a_b` bit(8) DEFAULT NULL,
`if_______b_a` bit(8) DEFAULT NULL,
`ifnull___a_b` bit(8) DEFAULT NULL,
`ifnull___b_a` bit(8) DEFAULT NULL,
`least____a_b` int(8) unsigned DEFAULT NULL,
`least____b_a` int(8) unsigned DEFAULT NULL,
`greatest_a_b` int(8) unsigned DEFAULT NULL,
`greatest_b_a` int(8) unsigned DEFAULT NULL
`least____a_b` bit(8) DEFAULT NULL,
`least____b_a` bit(8) DEFAULT NULL,
`greatest_a_b` bit(8) DEFAULT NULL,
`greatest_b_a` bit(8) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
DROP TABLE t1;
@ -1429,8 +1429,8 @@ def coalesce___a 4 12 1 Y 32896 31 63
def coalesce_a_a 4 12 1 Y 32896 31 63
def if_______a_a 4 12 1 Y 32896 31 63
def ifnull___a_a 4 12 1 Y 32896 31 63
def least____a_a 5 23 1 Y 32896 31 63
def greatest_a_a 5 23 1 Y 32896 31 63
def least____a_a 4 23 1 Y 32896 31 63
def greatest_a_a 4 23 1 Y 32896 31 63
def test t1 t1 b ___________b 2 6 6 Y 32768 0 63
def case_______b 2 6 6 Y 32896 0 63
def case_____b_b 2 6 6 Y 32896 0 63
@ -1522,23 +1522,23 @@ SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`___________a` float DEFAULT NULL,
`case_______a` double DEFAULT NULL,
`case_____a_a` double DEFAULT NULL,
`coalesce___a` double DEFAULT NULL,
`coalesce_a_a` double DEFAULT NULL,
`if_______a_a` double DEFAULT NULL,
`case_______a` float DEFAULT NULL,
`case_____a_a` float DEFAULT NULL,
`coalesce___a` float DEFAULT NULL,
`coalesce_a_a` float DEFAULT NULL,
`if_______a_a` float DEFAULT NULL,
`ifnull___a_a` float DEFAULT NULL,
`least____a_a` double DEFAULT NULL,
`greatest_a_a` double DEFAULT NULL,
`least____a_a` float DEFAULT NULL,
`greatest_a_a` float DEFAULT NULL,
`___________b` smallint(6) DEFAULT NULL,
`case_______b` int(6) DEFAULT NULL,
`case_____b_b` int(6) DEFAULT NULL,
`coalesce___b` int(6) DEFAULT NULL,
`coalesce_b_b` int(6) DEFAULT NULL,
`if_______b_b` int(6) DEFAULT NULL,
`case_______b` smallint(6) DEFAULT NULL,
`case_____b_b` smallint(6) DEFAULT NULL,
`coalesce___b` smallint(6) DEFAULT NULL,
`coalesce_b_b` smallint(6) DEFAULT NULL,
`if_______b_b` smallint(6) DEFAULT NULL,
`ifnull___b_b` smallint(6) DEFAULT NULL,
`least____b_b` int(6) DEFAULT NULL,
`greatest_b_b` int(6) DEFAULT NULL
`least____b_b` smallint(6) DEFAULT NULL,
`greatest_b_b` smallint(6) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
@ -1560,12 +1560,12 @@ FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`case_____a_b` double DEFAULT NULL,
`case_____b_a` double DEFAULT NULL,
`coalesce_a_b` double DEFAULT NULL,
`coalesce_b_a` double DEFAULT NULL,
`if_______a_b` double DEFAULT NULL,
`if_______b_a` double DEFAULT NULL,
`case_____a_b` float DEFAULT NULL,
`case_____b_a` float DEFAULT NULL,
`coalesce_a_b` float DEFAULT NULL,
`coalesce_b_a` float DEFAULT NULL,
`if_______a_b` float DEFAULT NULL,
`if_______b_a` float DEFAULT NULL,
`ifnull___a_b` float DEFAULT NULL,
`ifnull___b_a` float DEFAULT NULL,
`least____a_b` double DEFAULT NULL,
@ -1885,14 +1885,14 @@ t2 CREATE TABLE `t2` (
`least____a_a` int(11) DEFAULT NULL,
`greatest_a_a` int(11) DEFAULT NULL,
`___________b` year(4) DEFAULT NULL,
`case_______b` int(4) unsigned DEFAULT NULL,
`case_____b_b` int(4) unsigned DEFAULT NULL,
`coalesce___b` int(4) unsigned DEFAULT NULL,
`coalesce_b_b` int(4) unsigned DEFAULT NULL,
`if_______b_b` int(4) unsigned DEFAULT NULL,
`case_______b` year(4) DEFAULT NULL,
`case_____b_b` year(4) DEFAULT NULL,
`coalesce___b` year(4) DEFAULT NULL,
`coalesce_b_b` year(4) DEFAULT NULL,
`if_______b_b` year(4) DEFAULT NULL,
`ifnull___b_b` year(4) DEFAULT NULL,
`least____b_b` int(4) unsigned DEFAULT NULL,
`greatest_b_b` int(4) unsigned DEFAULT NULL
`least____b_b` year(4) DEFAULT NULL,
`greatest_b_b` year(4) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
@ -2062,14 +2062,14 @@ t2 CREATE TABLE `t2` (
`least____a_a` int(10) unsigned DEFAULT NULL,
`greatest_a_a` int(10) unsigned DEFAULT NULL,
`___________b` year(4) DEFAULT NULL,
`case_______b` int(4) unsigned DEFAULT NULL,
`case_____b_b` int(4) unsigned DEFAULT NULL,
`coalesce___b` int(4) unsigned DEFAULT NULL,
`coalesce_b_b` int(4) unsigned DEFAULT NULL,
`if_______b_b` int(4) unsigned DEFAULT NULL,
`case_______b` year(4) DEFAULT NULL,
`case_____b_b` year(4) DEFAULT NULL,
`coalesce___b` year(4) DEFAULT NULL,
`coalesce_b_b` year(4) DEFAULT NULL,
`if_______b_b` year(4) DEFAULT NULL,
`ifnull___b_b` year(4) DEFAULT NULL,
`least____b_b` int(4) unsigned DEFAULT NULL,
`greatest_b_b` int(4) unsigned DEFAULT NULL
`least____b_b` year(4) DEFAULT NULL,
`greatest_b_b` year(4) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
@ -3512,5 +3512,40 @@ t2 CREATE TABLE `t2` (
DROP TABLE t2;
DROP TABLE t1;
#
# MDEV-12617 CASE and CASE-alike hybrid functions do not preserve exact data types
#
CREATE TABLE t1 (a FLOAT(10,2));
CREATE TABLE t2 AS SELECT COALESCE(a) FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`COALESCE(a)` float(10,2) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2, t1;
CREATE TABLE t1 (a FLOAT(10,2));
CREATE TABLE t2 AS SELECT LEAST(a,a) FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`LEAST(a,a)` float(19,2) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2, t1;
CREATE TABLE t1 (a TINYINT(1));
CREATE TABLE t2 AS SELECT COALESCE(a) FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`COALESCE(a)` tinyint(4) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2, t1;
CREATE TABLE t1 (a TINYINT(1));
CREATE TABLE t2 AS SELECT LEAST(a,a) FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`LEAST(a,a)` tinyint(4) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2, t1;
#
# End of 10.3 tests
#

View file

@ -297,6 +297,9 @@ STRINGpadpadpadpadpa
select lpad('STRING', 20, CONCAT('p','a','d') );
lpad('STRING', 20, CONCAT('p','a','d') )
padpadpadpadpaSTRING
select rpad('abcd',7),lpad('abcd',7);
rpad('abcd',7) lpad('abcd',7)
abcd abcd
select LEAST(NULL,'HARRY','HARRIOT',NULL,'HAROLD'),GREATEST(NULL,'HARRY','HARRIOT',NULL,'HAROLD');
LEAST(NULL,'HARRY','HARRIOT',NULL,'HAROLD') GREATEST(NULL,'HARRY','HARRIOT',NULL,'HAROLD')
NULL NULL
@ -637,9 +640,15 @@ latin2_general_ci 4
select collation(lpad(_latin2'a',4,_latin2'b')), coercibility(lpad(_latin2'a',4,_latin2'b'));
collation(lpad(_latin2'a',4,_latin2'b')) coercibility(lpad(_latin2'a',4,_latin2'b'))
latin2_general_ci 4
select collation(lpad(_latin2'a',4)), coercibility(lpad(_latin2'a',4));
collation(lpad(_latin2'a',4)) coercibility(lpad(_latin2'a',4))
latin2_general_ci 4
select collation(rpad(_latin2'a',4,_latin2'b')), coercibility(rpad(_latin2'a',4,_latin2'b'));
collation(rpad(_latin2'a',4,_latin2'b')) coercibility(rpad(_latin2'a',4,_latin2'b'))
latin2_general_ci 4
select collation(rpad(_latin2'a',4)), coercibility(rpad(_latin2'a',4));
collation(rpad(_latin2'a',4)) coercibility(rpad(_latin2'a',4))
latin2_general_ci 4
select collation(concat_ws(_latin2'a',_latin2'b')), coercibility(concat_ws(_latin2'a',_latin2'b'));
collation(concat_ws(_latin2'a',_latin2'b')) coercibility(concat_ws(_latin2'a',_latin2'b'))
latin2_general_ci 4
@ -707,6 +716,8 @@ substring(_latin2'a',1,1),
concat(_latin2'a',_latin2'b'),
lpad(_latin2'a',4,_latin2'b'),
rpad(_latin2'a',4,_latin2'b'),
lpad(_latin2'a',4),
rpad(_latin2'a',4),
concat_ws(_latin2'a',_latin2'b'),
make_set(255,_latin2'a',_latin2'b',_latin2'c'),
export_set(255,_latin2'y',_latin2'n',_latin2' '),
@ -742,6 +753,8 @@ t1 CREATE TABLE `t1` (
`concat(_latin2'a',_latin2'b')` varchar(2) CHARACTER SET latin2 DEFAULT NULL,
`lpad(_latin2'a',4,_latin2'b')` varchar(4) CHARACTER SET latin2 DEFAULT NULL,
`rpad(_latin2'a',4,_latin2'b')` varchar(4) CHARACTER SET latin2 DEFAULT NULL,
`lpad(_latin2'a',4)` varchar(4) CHARACTER SET latin2 DEFAULT NULL,
`rpad(_latin2'a',4)` varchar(4) CHARACTER SET latin2 DEFAULT NULL,
`concat_ws(_latin2'a',_latin2'b')` varchar(1) CHARACTER SET latin2 DEFAULT NULL,
`make_set(255,_latin2'a',_latin2'b',_latin2'c')` varchar(5) CHARACTER SET latin2 DEFAULT NULL,
`export_set(255,_latin2'y',_latin2'n',_latin2' ')` varchar(127) CHARACTER SET latin2 DEFAULT NULL,
@ -869,6 +882,16 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select lpad('a',4,'1') AS `lpad('a',4,'1')`
explain extended select rpad('a',4);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select rpad('a',4) AS `rpad('a',4)`
explain extended select lpad('a',4);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select lpad('a',4) AS `lpad('a',4)`
explain extended select concat_ws(',','',NULL,'a');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
@ -2213,6 +2236,76 @@ Warnings:
Warning 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated
Warning 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated
Warning 1301 Result of rpad() was larger than max_allowed_packet (1048576) - truncated
select rpad('hello', -1);
rpad('hello', -1)
NULL
select rpad('hello', -4294967295);
rpad('hello', -4294967295)
NULL
select rpad('hello', 4294967295);
rpad('hello', 4294967295)
NULL
Warnings:
Warning 1301 Result of rpad() was larger than max_allowed_packet (1048576) - truncated
select rpad('hello', -4294967296);
rpad('hello', -4294967296)
NULL
select rpad('hello', 4294967296);
rpad('hello', 4294967296)
NULL
Warnings:
Warning 1301 Result of rpad() was larger than max_allowed_packet (1048576) - truncated
select rpad('hello', -4294967297);
rpad('hello', -4294967297)
NULL
select rpad('hello', 4294967297);
rpad('hello', 4294967297)
NULL
Warnings:
Warning 1301 Result of rpad() was larger than max_allowed_packet (1048576) - truncated
select rpad('hello', -18446744073709551615);
rpad('hello', -18446744073709551615)
NULL
Warnings:
Warning 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated
Warning 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated
select rpad('hello', 18446744073709551615);
rpad('hello', 18446744073709551615)
NULL
Warnings:
Warning 1301 Result of rpad() was larger than max_allowed_packet (1048576) - truncated
select rpad('hello', -18446744073709551616);
rpad('hello', -18446744073709551616)
NULL
Warnings:
Warning 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated
Warning 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated
select rpad('hello', 18446744073709551616);
rpad('hello', 18446744073709551616)
NULL
Warnings:
Warning 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated
Warning 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated
Warning 1301 Result of rpad() was larger than max_allowed_packet (1048576) - truncated
select rpad('hello', -18446744073709551617);
rpad('hello', -18446744073709551617)
NULL
Warnings:
Warning 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated
Warning 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated
select rpad('hello', 18446744073709551617);
rpad('hello', 18446744073709551617)
NULL
Warnings:
Warning 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated
Warning 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated
Warning 1301 Result of rpad() was larger than max_allowed_packet (1048576) - truncated
select rpad('hello', 0, 'x');
rpad('hello', 0, 'x')
select rpad('hello', 0);
rpad('hello', 0)
select lpad('hello', -1, '1');
lpad('hello', -1, '1')
NULL
@ -2277,6 +2370,85 @@ Warnings:
Warning 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated
Warning 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated
Warning 1301 Result of lpad() was larger than max_allowed_packet (1048576) - truncated
select lpad('hello', -1);
lpad('hello', -1)
NULL
select lpad('hello', -4294967295);
lpad('hello', -4294967295)
NULL
select lpad('hello', 4294967295);
lpad('hello', 4294967295)
NULL
Warnings:
Warning 1301 Result of lpad() was larger than max_allowed_packet (1048576) - truncated
select lpad('hello', -4294967296);
lpad('hello', -4294967296)
NULL
select lpad('hello', 4294967296);
lpad('hello', 4294967296)
NULL
Warnings:
Warning 1301 Result of lpad() was larger than max_allowed_packet (1048576) - truncated
select lpad('hello', -4294967297);
lpad('hello', -4294967297)
NULL
select lpad('hello', 4294967297);
lpad('hello', 4294967297)
NULL
Warnings:
Warning 1301 Result of lpad() was larger than max_allowed_packet (1048576) - truncated
select lpad('hello', -18446744073709551615);
lpad('hello', -18446744073709551615)
NULL
Warnings:
Warning 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated
Warning 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated
select lpad('hello', 18446744073709551615);
lpad('hello', 18446744073709551615)
NULL
Warnings:
Warning 1301 Result of lpad() was larger than max_allowed_packet (1048576) - truncated
select lpad('hello', -18446744073709551616);
lpad('hello', -18446744073709551616)
NULL
Warnings:
Warning 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated
Warning 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated
select lpad('hello', 18446744073709551616);
lpad('hello', 18446744073709551616)
NULL
Warnings:
Warning 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated
Warning 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated
Warning 1301 Result of lpad() was larger than max_allowed_packet (1048576) - truncated
select lpad('hello', -18446744073709551617);
lpad('hello', -18446744073709551617)
NULL
Warnings:
Warning 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated
Warning 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated
select lpad('hello', 18446744073709551617);
lpad('hello', 18446744073709551617)
NULL
Warnings:
Warning 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated
Warning 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated
Warning 1301 Result of lpad() was larger than max_allowed_packet (1048576) - truncated
select lpad('hello', 0, 'x');
lpad('hello', 0, 'x')
select lpad('hello', 0);
lpad('hello', 0)
Check parameters count rpad / lpad
select rpad('x');
ERROR 42000: Incorrect parameter count in the call to native function 'rpad'
select rpad('x',2,'.','z');
ERROR 42000: Incorrect parameter count in the call to native function 'rpad'
select lpad('x');
ERROR 42000: Incorrect parameter count in the call to native function 'lpad'
select lpad('x',2,'.','z');
ERROR 42000: Incorrect parameter count in the call to native function 'lpad'
SET @orig_sql_mode = @@SQL_MODE;
SET SQL_MODE=traditional;
SELECT CHAR(0xff,0x8f USING utf8);
@ -2302,6 +2474,12 @@ abcxx
select lpad('abc', cast(5 as unsigned integer), 'x');
lpad('abc', cast(5 as unsigned integer), 'x')
xxabc
select rpad('abc', cast(5 as unsigned integer));
rpad('abc', cast(5 as unsigned integer))
abc
select lpad('abc', cast(5 as unsigned integer));
lpad('abc', cast(5 as unsigned integer))
abc
create table t1(f1 longtext);
insert into t1 values ("123"),("456");
select substring(f1,1,1) from t1 group by 1;
@ -2663,6 +2841,12 @@ NULL
SELECT LPAD('hi', DAY(FROM_UNIXTIME(-1)),'?');
LPAD('hi', DAY(FROM_UNIXTIME(-1)),'?')
NULL
SELECT RPAD('hi', DAY(FROM_UNIXTIME(-1)));
RPAD('hi', DAY(FROM_UNIXTIME(-1)))
NULL
SELECT LPAD('hi', DAY(FROM_UNIXTIME(-1)));
LPAD('hi', DAY(FROM_UNIXTIME(-1)))
NULL
create table t1 (i int);
insert into t1 values (null),(8);
select group_concat( i ), make_set( i, 'a', 'b' ) field from t1 group by field;

View file

@ -1,13 +1,105 @@
drop table if exists t1,t2;
select 1, 1.0, -1, "hello", NULL;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def 1 8 1 1 N 32897 0 63
def 1 3 1 1 N 32897 0 63
def 1.0 246 4 3 N 32897 1 63
def -1 8 2 2 N 32897 0 63
def -1 3 2 2 N 32897 0 63
def hello 253 5 5 N 1 39 8
def NULL 6 0 0 Y 32896 0 63
1 1.0 -1 hello NULL
1 1.0 -1 hello NULL
SELECT
1 AS c1,
11 AS c2,
111 AS c3,
1111 AS c4,
11111 AS c5,
111111 AS c6,
1111111 AS c7,
11111111 AS c8,
111111111 AS c9,
1111111111 AS c10,
11111111111 AS c11,
111111111111 AS c12,
1111111111111 AS c13,
11111111111111 AS c14,
111111111111111 AS c15,
1111111111111111 AS c16,
11111111111111111 AS c17,
111111111111111111 AS c18,
1111111111111111111 AS c19,
11111111111111111111 AS c20,
111111111111111111111 AS c21;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def c1 3 1 1 N 32897 0 63
def c2 3 2 2 N 32897 0 63
def c3 3 3 3 N 32897 0 63
def c4 3 4 4 N 32897 0 63
def c5 3 5 5 N 32897 0 63
def c6 3 6 6 N 32897 0 63
def c7 3 7 7 N 32897 0 63
def c8 3 8 8 N 32897 0 63
def c9 3 9 9 N 32897 0 63
def c10 8 10 10 N 32897 0 63
def c11 8 11 11 N 32897 0 63
def c12 8 12 12 N 32897 0 63
def c13 8 13 13 N 32897 0 63
def c14 8 14 14 N 32897 0 63
def c15 8 15 15 N 32897 0 63
def c16 8 16 16 N 32897 0 63
def c17 8 17 17 N 32897 0 63
def c18 8 18 18 N 32897 0 63
def c19 8 19 19 N 32897 0 63
def c20 8 20 20 N 32929 0 63
def c21 246 22 21 N 32897 0 63
c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21
1 11 111 1111 11111 111111 1111111 11111111 111111111 1111111111 11111111111 111111111111 1111111111111 11111111111111 111111111111111 1111111111111111 11111111111111111 111111111111111111 1111111111111111111 11111111111111111111 111111111111111111111
SELECT
-1 AS c1,
-11 AS c2,
-111 AS c3,
-1111 AS c4,
-11111 AS c5,
-111111 AS c6,
-1111111 AS c7,
-11111111 AS c8,
-111111111 AS c9,
-1111111111 AS c10,
-11111111111 AS c11,
-111111111111 AS c12,
-1111111111111 AS c13,
-11111111111111 AS c14,
-111111111111111 AS c15,
-1111111111111111 AS c16,
-11111111111111111 AS c17,
-111111111111111111 AS c18,
-1111111111111111111 AS c19,
-11111111111111111111 AS c20,
-111111111111111111111 AS c21;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def c1 3 2 2 N 32897 0 63
def c2 3 3 3 N 32897 0 63
def c3 3 4 4 N 32897 0 63
def c4 3 5 5 N 32897 0 63
def c5 3 6 6 N 32897 0 63
def c6 3 7 7 N 32897 0 63
def c7 3 8 8 N 32897 0 63
def c8 3 9 9 N 32897 0 63
def c9 8 10 10 N 32897 0 63
def c10 8 11 11 N 32897 0 63
def c11 8 12 12 N 32897 0 63
def c12 8 13 13 N 32897 0 63
def c13 8 14 14 N 32897 0 63
def c14 8 15 15 N 32897 0 63
def c15 8 16 16 N 32897 0 63
def c16 8 17 17 N 32897 0 63
def c17 8 18 18 N 32897 0 63
def c18 8 19 19 N 32897 0 63
def c19 8 20 20 N 32897 0 63
def c20 246 21 21 N 32897 0 63
def c21 246 22 22 N 32897 0 63
c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21
-1 -11 -111 -1111 -11111 -111111 -1111111 -11111111 -111111111 -1111111111 -11111111111 -111111111111 -1111111111111 -11111111111111 -111111111111111 -1111111111111111 -11111111111111111 -111111111111111111 -1111111111111111111 -11111111111111111111 -111111111111111111111
create table t1 (a tinyint, b smallint, c mediumint, d int, e bigint, f float(3,2), g double(4,3), h decimal(5,4), i year, j date, k timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, l datetime, m enum('a','b'), n set('a','b'), o char(10));
select * from t1;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr

View file

@ -613,22 +613,22 @@ FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`NULLIF(c_tinyint, 1)` int(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_smallint)` int(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_tinyint)` int(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_int)` int(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_bigint)` int(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_float)` int(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_double)` int(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_decimal103)` int(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_varchar10)` int(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_text)` int(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_blob)` int(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_enum)` int(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_datetime3)` int(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_timestamp3)` int(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_date)` int(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_time)` int(4) DEFAULT NULL
`NULLIF(c_tinyint, 1)` tinyint(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_smallint)` tinyint(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_tinyint)` tinyint(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_int)` tinyint(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_bigint)` tinyint(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_float)` tinyint(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_double)` tinyint(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_decimal103)` tinyint(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_varchar10)` tinyint(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_text)` tinyint(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_blob)` tinyint(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_enum)` tinyint(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_datetime3)` tinyint(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_timestamp3)` tinyint(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_date)` tinyint(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_time)` tinyint(4) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
CREATE TABLE t2 AS SELECT
@ -652,22 +652,22 @@ FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`NULLIF(c_smallint, 1)` int(6) DEFAULT NULL,
`NULLIF(c_smallint, c_smallint)` int(6) DEFAULT NULL,
`NULLIF(c_smallint, c_tinyint)` int(6) DEFAULT NULL,
`NULLIF(c_smallint, c_int)` int(6) DEFAULT NULL,
`NULLIF(c_smallint, c_bigint)` int(6) DEFAULT NULL,
`NULLIF(c_smallint, c_float)` int(6) DEFAULT NULL,
`NULLIF(c_smallint, c_double)` int(6) DEFAULT NULL,
`NULLIF(c_smallint, c_decimal103)` int(6) DEFAULT NULL,
`NULLIF(c_smallint, c_varchar10)` int(6) DEFAULT NULL,
`NULLIF(c_smallint, c_text)` int(6) DEFAULT NULL,
`NULLIF(c_smallint, c_blob)` int(6) DEFAULT NULL,
`NULLIF(c_smallint, c_enum)` int(6) DEFAULT NULL,
`NULLIF(c_smallint, c_datetime3)` int(6) DEFAULT NULL,
`NULLIF(c_smallint, c_timestamp3)` int(6) DEFAULT NULL,
`NULLIF(c_smallint, c_date)` int(6) DEFAULT NULL,
`NULLIF(c_smallint, c_time)` int(6) DEFAULT NULL
`NULLIF(c_smallint, 1)` smallint(6) DEFAULT NULL,
`NULLIF(c_smallint, c_smallint)` smallint(6) DEFAULT NULL,
`NULLIF(c_smallint, c_tinyint)` smallint(6) DEFAULT NULL,
`NULLIF(c_smallint, c_int)` smallint(6) DEFAULT NULL,
`NULLIF(c_smallint, c_bigint)` smallint(6) DEFAULT NULL,
`NULLIF(c_smallint, c_float)` smallint(6) DEFAULT NULL,
`NULLIF(c_smallint, c_double)` smallint(6) DEFAULT NULL,
`NULLIF(c_smallint, c_decimal103)` smallint(6) DEFAULT NULL,
`NULLIF(c_smallint, c_varchar10)` smallint(6) DEFAULT NULL,
`NULLIF(c_smallint, c_text)` smallint(6) DEFAULT NULL,
`NULLIF(c_smallint, c_blob)` smallint(6) DEFAULT NULL,
`NULLIF(c_smallint, c_enum)` smallint(6) DEFAULT NULL,
`NULLIF(c_smallint, c_datetime3)` smallint(6) DEFAULT NULL,
`NULLIF(c_smallint, c_timestamp3)` smallint(6) DEFAULT NULL,
`NULLIF(c_smallint, c_date)` smallint(6) DEFAULT NULL,
`NULLIF(c_smallint, c_time)` smallint(6) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
CREATE TABLE t2 AS SELECT
@ -769,22 +769,22 @@ FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`NULLIF(c_float, 1)` double DEFAULT NULL,
`NULLIF(c_float, c_smallint)` double DEFAULT NULL,
`NULLIF(c_float, c_tinyint)` double DEFAULT NULL,
`NULLIF(c_float, c_int)` double DEFAULT NULL,
`NULLIF(c_float, c_bigint)` double DEFAULT NULL,
`NULLIF(c_float, c_float)` double DEFAULT NULL,
`NULLIF(c_float, c_double)` double DEFAULT NULL,
`NULLIF(c_float, c_decimal103)` double DEFAULT NULL,
`NULLIF(c_float, c_varchar10)` double DEFAULT NULL,
`NULLIF(c_float, c_text)` double DEFAULT NULL,
`NULLIF(c_float, c_blob)` double DEFAULT NULL,
`NULLIF(c_float, c_enum)` double DEFAULT NULL,
`NULLIF(c_float, c_datetime3)` double DEFAULT NULL,
`NULLIF(c_float, c_timestamp3)` double DEFAULT NULL,
`NULLIF(c_float, c_date)` double DEFAULT NULL,
`NULLIF(c_float, c_time)` double DEFAULT NULL
`NULLIF(c_float, 1)` float DEFAULT NULL,
`NULLIF(c_float, c_smallint)` float DEFAULT NULL,
`NULLIF(c_float, c_tinyint)` float DEFAULT NULL,
`NULLIF(c_float, c_int)` float DEFAULT NULL,
`NULLIF(c_float, c_bigint)` float DEFAULT NULL,
`NULLIF(c_float, c_float)` float DEFAULT NULL,
`NULLIF(c_float, c_double)` float DEFAULT NULL,
`NULLIF(c_float, c_decimal103)` float DEFAULT NULL,
`NULLIF(c_float, c_varchar10)` float DEFAULT NULL,
`NULLIF(c_float, c_text)` float DEFAULT NULL,
`NULLIF(c_float, c_blob)` float DEFAULT NULL,
`NULLIF(c_float, c_enum)` float DEFAULT NULL,
`NULLIF(c_float, c_datetime3)` float DEFAULT NULL,
`NULLIF(c_float, c_timestamp3)` float DEFAULT NULL,
`NULLIF(c_float, c_date)` float DEFAULT NULL,
`NULLIF(c_float, c_time)` float DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
CREATE TABLE t2 AS SELECT

View file

@ -510,6 +510,29 @@ SHOW CREATE TABLE t2;
DROP TABLE t2;
DROP TABLE t1;
--echo #
--echo # MDEV-12617 CASE and CASE-alike hybrid functions do not preserve exact data types
--echo #
CREATE TABLE t1 (a FLOAT(10,2));
CREATE TABLE t2 AS SELECT COALESCE(a) FROM t1;
SHOW CREATE TABLE t2;
DROP TABLE t2, t1;
CREATE TABLE t1 (a FLOAT(10,2));
CREATE TABLE t2 AS SELECT LEAST(a,a) FROM t1;
SHOW CREATE TABLE t2;
DROP TABLE t2, t1;
CREATE TABLE t1 (a TINYINT(1));
CREATE TABLE t2 AS SELECT COALESCE(a) FROM t1;
SHOW CREATE TABLE t2;
DROP TABLE t2, t1;
CREATE TABLE t1 (a TINYINT(1));
CREATE TABLE t2 AS SELECT LEAST(a,a) FROM t1;
SHOW CREATE TABLE t2;
DROP TABLE t2, t1;
--echo #
--echo # End of 10.3 tests

View file

@ -119,6 +119,7 @@ select rpad('abcd',7,'ab'),lpad('abcd',7,'ab');
select rpad('abcd',1,'ab'),lpad('abcd',1,'ab');
select rpad('STRING', 20, CONCAT('p','a','d') );
select lpad('STRING', 20, CONCAT('p','a','d') );
select rpad('abcd',7),lpad('abcd',7);
select LEAST(NULL,'HARRY','HARRIOT',NULL,'HAROLD'),GREATEST(NULL,'HARRY','HARRIOT',NULL,'HAROLD');
select least(1,2,3) | greatest(16,32,8), least(5,4)*1,greatest(-1.0,1.0)*1,least(3,2,1)*1.0,greatest(1,1.1,1.0),least("10",9),greatest("A","B","0");
@ -373,7 +374,9 @@ select collation(right(_latin2'a',1)), coercibility(right(_latin2'a',1));
select collation(substring(_latin2'a',1,1)), coercibility(substring(_latin2'a',1,1));
select collation(concat(_latin2'a',_latin2'b')), coercibility(concat(_latin2'a',_latin2'b'));
select collation(lpad(_latin2'a',4,_latin2'b')), coercibility(lpad(_latin2'a',4,_latin2'b'));
select collation(lpad(_latin2'a',4)), coercibility(lpad(_latin2'a',4));
select collation(rpad(_latin2'a',4,_latin2'b')), coercibility(rpad(_latin2'a',4,_latin2'b'));
select collation(rpad(_latin2'a',4)), coercibility(rpad(_latin2'a',4));
select collation(concat_ws(_latin2'a',_latin2'b')), coercibility(concat_ws(_latin2'a',_latin2'b'));
select collation(make_set(255,_latin2'a',_latin2'b',_latin2'c')), coercibility(make_set(255,_latin2'a',_latin2'b',_latin2'c'));
select collation(export_set(255,_latin2'y',_latin2'n',_latin2' ')), coercibility(export_set(255,_latin2'y',_latin2'n',_latin2' '));
@ -408,6 +411,8 @@ select
concat(_latin2'a',_latin2'b'),
lpad(_latin2'a',4,_latin2'b'),
rpad(_latin2'a',4,_latin2'b'),
lpad(_latin2'a',4),
rpad(_latin2'a',4),
concat_ws(_latin2'a',_latin2'b'),
make_set(255,_latin2'a',_latin2'b',_latin2'c'),
export_set(255,_latin2'y',_latin2'n',_latin2' '),
@ -485,6 +490,8 @@ explain extended select concat('*',space(5),'*');
explain extended select reverse('abc');
explain extended select rpad('a',4,'1');
explain extended select lpad('a',4,'1');
explain extended select rpad('a',4);
explain extended select lpad('a',4);
explain extended select concat_ws(',','',NULL,'a');
explain extended select make_set(255,_latin2'a', _latin2'b', _latin2'c');
explain extended select elt(2,1);
@ -1105,6 +1112,21 @@ select rpad('hello', -18446744073709551616, '1');
select rpad('hello', 18446744073709551616, '1');
select rpad('hello', -18446744073709551617, '1');
select rpad('hello', 18446744073709551617, '1');
select rpad('hello', -1);
select rpad('hello', -4294967295);
select rpad('hello', 4294967295);
select rpad('hello', -4294967296);
select rpad('hello', 4294967296);
select rpad('hello', -4294967297);
select rpad('hello', 4294967297);
select rpad('hello', -18446744073709551615);
select rpad('hello', 18446744073709551615);
select rpad('hello', -18446744073709551616);
select rpad('hello', 18446744073709551616);
select rpad('hello', -18446744073709551617);
select rpad('hello', 18446744073709551617);
select rpad('hello', 0, 'x');
select rpad('hello', 0);
select lpad('hello', -1, '1');
select lpad('hello', -4294967295, '1');
@ -1119,7 +1141,32 @@ select lpad('hello', -18446744073709551616, '1');
select lpad('hello', 18446744073709551616, '1');
select lpad('hello', -18446744073709551617, '1');
select lpad('hello', 18446744073709551617, '1');
select lpad('hello', -1);
select lpad('hello', -4294967295);
select lpad('hello', 4294967295);
select lpad('hello', -4294967296);
select lpad('hello', 4294967296);
select lpad('hello', -4294967297);
select lpad('hello', 4294967297);
select lpad('hello', -18446744073709551615);
select lpad('hello', 18446744073709551615);
select lpad('hello', -18446744073709551616);
select lpad('hello', 18446744073709551616);
select lpad('hello', -18446744073709551617);
select lpad('hello', 18446744073709551617);
select lpad('hello', 0, 'x');
select lpad('hello', 0);
--echo Check parameters count rpad / lpad
--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
select rpad('x');
--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
select rpad('x',2,'.','z');
--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
select lpad('x');
--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
select lpad('x',2,'.','z');
#
# BUG#17047: CHAR() and IN() can return NULL without signaling NULL
@ -1141,6 +1188,8 @@ select substring('abc', cast(2 as unsigned int));
select repeat('a', cast(2 as unsigned int));
select rpad('abc', cast(5 as unsigned integer), 'x');
select lpad('abc', cast(5 as unsigned integer), 'x');
select rpad('abc', cast(5 as unsigned integer));
select lpad('abc', cast(5 as unsigned integer));
#
# Bug#15757: Wrong SUBSTRING() result when a tmp table was employed.
@ -1403,6 +1452,8 @@ SELECT RIGHT('1', DAY(FROM_UNIXTIME(-1)));
SELECT REPEAT('1', DAY(FROM_UNIXTIME(-1)));
SELECT RPAD('hi', DAY(FROM_UNIXTIME(-1)),'?');
SELECT LPAD('hi', DAY(FROM_UNIXTIME(-1)),'?');
SELECT RPAD('hi', DAY(FROM_UNIXTIME(-1)));
SELECT LPAD('hi', DAY(FROM_UNIXTIME(-1)));
#
# MDEV-4289 Assertion `0' fails in make_sortkey with GROUP_CONCAT, MAKE_SET, GROUP BY

View file

@ -14,6 +14,51 @@ drop table if exists t1,t2;
#
select 1, 1.0, -1, "hello", NULL;
SELECT
1 AS c1,
11 AS c2,
111 AS c3,
1111 AS c4,
11111 AS c5,
111111 AS c6,
1111111 AS c7,
11111111 AS c8,
111111111 AS c9,
1111111111 AS c10,
11111111111 AS c11,
111111111111 AS c12,
1111111111111 AS c13,
11111111111111 AS c14,
111111111111111 AS c15,
1111111111111111 AS c16,
11111111111111111 AS c17,
111111111111111111 AS c18,
1111111111111111111 AS c19,
11111111111111111111 AS c20,
111111111111111111111 AS c21;
SELECT
-1 AS c1,
-11 AS c2,
-111 AS c3,
-1111 AS c4,
-11111 AS c5,
-111111 AS c6,
-1111111 AS c7,
-11111111 AS c8,
-111111111 AS c9,
-1111111111 AS c10,
-11111111111 AS c11,
-111111111111 AS c12,
-1111111111111 AS c13,
-11111111111111 AS c14,
-111111111111111 AS c15,
-1111111111111111 AS c16,
-11111111111111111 AS c17,
-111111111111111111 AS c18,
-1111111111111111111 AS c19,
-11111111111111111111 AS c20,
-111111111111111111111 AS c21;
create table t1 (a tinyint, b smallint, c mediumint, d int, e bigint, f float(3,2), g double(4,3), h decimal(5,4), i year, j date, k timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, l datetime, m enum('a','b'), n set('a','b'), o char(10));
select * from t1;

View file

@ -6854,127 +6854,11 @@ bool Item_time_literal::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date)
Pack data in buffer for sending.
*/
bool Item_null::send(Protocol *protocol, String *packet)
bool Item_null::send(Protocol *protocol, st_value *buffer)
{
return protocol->store_null();
}
/**
This is only called from items that is not of type item_field.
*/
bool Item::send(Protocol *protocol, String *buffer)
{
bool UNINIT_VAR(result); // Will be set if null_value == 0
enum_field_types f_type;
switch ((f_type=field_type())) {
default:
case MYSQL_TYPE_NULL:
case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_ENUM:
case MYSQL_TYPE_SET:
case MYSQL_TYPE_TINY_BLOB:
case MYSQL_TYPE_MEDIUM_BLOB:
case MYSQL_TYPE_LONG_BLOB:
case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_GEOMETRY:
case MYSQL_TYPE_STRING:
case MYSQL_TYPE_VAR_STRING:
case MYSQL_TYPE_VARCHAR:
case MYSQL_TYPE_BIT:
case MYSQL_TYPE_NEWDECIMAL:
{
String *res;
if ((res=val_str(buffer)))
{
DBUG_ASSERT(!null_value);
result= protocol->store(res->ptr(),res->length(),res->charset());
}
else
{
DBUG_ASSERT(null_value);
}
break;
}
case MYSQL_TYPE_TINY:
{
longlong nr;
nr= val_int();
if (!null_value)
result= protocol->store_tiny(nr);
break;
}
case MYSQL_TYPE_SHORT:
case MYSQL_TYPE_YEAR:
{
longlong nr;
nr= val_int();
if (!null_value)
result= protocol->store_short(nr);
break;
}
case MYSQL_TYPE_INT24:
case MYSQL_TYPE_LONG:
{
longlong nr;
nr= val_int();
if (!null_value)
result= protocol->store_long(nr);
break;
}
case MYSQL_TYPE_LONGLONG:
{
longlong nr;
nr= val_int();
if (!null_value)
result= protocol->store_longlong(nr, unsigned_flag);
break;
}
case MYSQL_TYPE_FLOAT:
{
float nr;
nr= (float) val_real();
if (!null_value)
result= protocol->store(nr, decimals, buffer);
break;
}
case MYSQL_TYPE_DOUBLE:
{
double nr= val_real();
if (!null_value)
result= protocol->store(nr, decimals, buffer);
break;
}
case MYSQL_TYPE_DATETIME:
case MYSQL_TYPE_DATE:
case MYSQL_TYPE_TIMESTAMP:
{
MYSQL_TIME tm;
get_date(&tm, sql_mode_for_dates(current_thd));
if (!null_value)
{
if (f_type == MYSQL_TYPE_DATE)
return protocol->store_date(&tm);
else
result= protocol->store(&tm, decimals);
}
break;
}
case MYSQL_TYPE_TIME:
{
MYSQL_TIME tm;
get_time(&tm);
if (!null_value)
result= protocol->store_time(&tm, decimals);
break;
}
}
if (null_value)
result= protocol->store_null();
return result;
}
/**
Check if an item is a constant one and can be cached.
@ -7046,7 +6930,7 @@ bool Item::find_item_processor(void *arg)
return (this == ((Item *) arg));
}
bool Item_field::send(Protocol *protocol, String *buffer)
bool Item_field::send(Protocol *protocol, st_value *buffer)
{
return protocol->store(result_field);
}
@ -7776,11 +7660,11 @@ void Item_ref::print(String *str, enum_query_type query_type)
}
bool Item_ref::send(Protocol *prot, String *tmp)
bool Item_ref::send(Protocol *prot, st_value *buffer)
{
if (result_field)
return prot->store(result_field);
return (*ref)->send(prot, tmp);
return (*ref)->send(prot, buffer);
}
@ -8135,7 +8019,7 @@ bool Item_cache_wrapper::fix_fields(THD *thd __attribute__((unused)),
return FALSE;
}
bool Item_cache_wrapper::send(Protocol *protocol, String *buffer)
bool Item_cache_wrapper::send(Protocol *protocol, st_value *buffer)
{
if (result_field)
return protocol->store(result_field);
@ -8466,7 +8350,7 @@ Item* Item_cache_wrapper::get_tmp_table_item(THD *thd)
}
bool Item_direct_view_ref::send(Protocol *protocol, String *buffer)
bool Item_direct_view_ref::send(Protocol *protocol, st_value *buffer)
{
if (check_null_ref())
return protocol->store_null();
@ -8843,7 +8727,7 @@ bool Item_default_value::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate)
return Item_field::get_date(ltime, fuzzydate);
}
bool Item_default_value::send(Protocol *protocol, String *buffer)
bool Item_default_value::send(Protocol *protocol, st_value *buffer)
{
calculate();
return Item_field::send(protocol, buffer);
@ -8950,7 +8834,7 @@ bool Item_ignore_value::get_date(MYSQL_TIME *ltime, ulonglong fuzzydate)
return TRUE;
}
bool Item_ignore_value::send(Protocol *protocol, String *buffer)
bool Item_ignore_value::send(Protocol *protocol, st_value *buffer)
{
DBUG_ASSERT(0); // never should be called
return TRUE;

View file

@ -55,6 +55,23 @@ struct st_value
C_MODE_END
template<size_t buffer_size>
class ValueBuffer: public st_value
{
char buffer[buffer_size];
void reset_buffer()
{
m_string.set(buffer, buffer_size, &my_charset_bin);
}
public:
ValueBuffer()
{
reset_buffer();
}
};
const char *dbug_print_item(Item *item);
class Protocol;
@ -693,7 +710,10 @@ public:
{ return NULL; }
virtual int save_safe_in_field(Field *field)
{ return save_in_field(field, 1); }
virtual bool send(Protocol *protocol, String *str);
virtual bool send(Protocol *protocol, st_value *buffer)
{
return type_handler()->Item_send(this, protocol, buffer);
}
virtual bool eq(const Item *, bool binary_cmp) const;
virtual enum_field_types field_type() const= 0;
virtual const Type_handler *type_handler() const
@ -2090,7 +2110,7 @@ public:
inline bool const_item() const;
inline int save_in_field(Field *field, bool no_conversions);
inline bool send(Protocol *protocol, String *str);
inline bool send(Protocol *protocol, st_value *buffer);
bool check_vcol_func_processor(void *arg)
{
return mark_unsupported_function(m_name.str, arg, VCOL_IMPOSSIBLE);
@ -2111,9 +2131,9 @@ inline int Item_sp_variable::save_in_field(Field *field, bool no_conversions)
return this_item()->save_in_field(field, no_conversions);
}
inline bool Item_sp_variable::send(Protocol *protocol, String *str)
inline bool Item_sp_variable::send(Protocol *protocol, st_value *buffer)
{
return this_item()->send(protocol, str);
return this_item()->send(protocol, buffer);
}
@ -2399,9 +2419,9 @@ public:
return value_item->save_in_field(field, no_conversions);
}
bool send(Protocol *protocol, String *str)
bool send(Protocol *protocol, st_value *buffer)
{
return value_item->send(protocol, str);
return value_item->send(protocol, buffer);
}
bool check_vcol_func_processor(void *arg)
{
@ -2533,7 +2553,6 @@ public:
{
Type_std_attributes::set(par_field);
}
enum Type type() const { return FIELD_ITEM; }
double val_real() { return field->val_real(); }
longlong val_int() { return field->val_int(); }
@ -2592,7 +2611,7 @@ public:
my_decimal *val_decimal_result(my_decimal *);
bool val_bool_result();
bool is_null_result();
bool send(Protocol *protocol, String *str_arg);
bool send(Protocol *protocol, st_value *buffer);
void reset_field(Field *f);
bool fix_fields(THD *, Item **);
void fix_after_pullout(st_select_lex *new_parent, Item **ref);
@ -2837,7 +2856,7 @@ public:
my_decimal *val_decimal(my_decimal *);
int save_in_field(Field *field, bool no_conversions);
int save_safe_in_field(Field *field);
bool send(Protocol *protocol, String *str);
bool send(Protocol *protocol, st_value *buffer);
enum Item_result result_type () const { return STRING_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_NULL; }
bool basic_const_item() const { return 1; }
@ -3159,7 +3178,10 @@ public:
Item_int(THD *thd, const char *str_arg, uint length=64);
enum Type type() const { return INT_ITEM; }
enum Item_result result_type () const { return INT_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; }
enum_field_types field_type() const
{
return Item_int::type_handler()->field_type();
}
const Type_handler *type_handler() const
{
// The same condition is repeated in Item::create_tmp_field()
@ -4234,7 +4256,7 @@ public:
my_decimal *val_decimal_result(my_decimal *);
bool val_bool_result();
bool is_null_result();
bool send(Protocol *prot, String *tmp);
bool send(Protocol *prot, st_value *buffer);
void make_field(THD *thd, Send_field *field);
bool fix_fields(THD *, Item **);
void fix_after_pullout(st_select_lex *new_parent, Item **ref);
@ -4511,7 +4533,7 @@ public:
bool val_bool();
bool is_null();
bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate);
bool send(Protocol *protocol, String *buffer);
bool send(Protocol *protocol, st_value *buffer);
void save_org_in_field(Field *field,
fast_field_copier data __attribute__ ((__unused__)))
{
@ -4725,7 +4747,7 @@ public:
}
return Item_direct_ref::get_date(ltime, fuzzydate);
}
bool send(Protocol *protocol, String *buffer);
bool send(Protocol *protocol, st_value *buffer);
void save_org_in_field(Field *field,
fast_field_copier data __attribute__ ((__unused__)))
{
@ -5239,7 +5261,7 @@ public:
longlong val_int();
my_decimal *val_decimal(my_decimal *decimal_value);
bool get_date(MYSQL_TIME *ltime,ulonglong fuzzydate);
bool send(Protocol *protocol, String *buffer);
bool send(Protocol *protocol, st_value *buffer);
int save_in_field(Field *field_arg, bool no_conversions);
bool save_in_param(THD *thd, Item_param *param)
{
@ -5291,7 +5313,7 @@ public:
longlong val_int();
my_decimal *val_decimal(my_decimal *decimal_value);
bool get_date(MYSQL_TIME *ltime,ulonglong fuzzydate);
bool send(Protocol *protocol, String *buffer);
bool send(Protocol *protocol, st_value *buffer);
};

View file

@ -2786,7 +2786,7 @@ Item_func_nullif::is_null()
Item_func_case::Item_func_case(THD *thd, List<Item> &list,
Item *first_expr_arg, Item *else_expr_arg):
Item_func_hybrid_field_type(thd),
Item_func_case_expression(thd),
Predicant_to_list_comparator(thd, list.elements/*QQ*/),
first_expr_num(-1), else_expr_num(-1),
left_cmp_type(INT_RESULT), m_found_types(0)

View file

@ -965,13 +965,13 @@ public:
};
class Item_func_coalesce :public Item_func_hybrid_field_type
class Item_func_coalesce :public Item_func_case_expression
{
public:
Item_func_coalesce(THD *thd, Item *a, Item *b):
Item_func_hybrid_field_type(thd, a, b) {}
Item_func_case_expression(thd, a, b) {}
Item_func_coalesce(THD *thd, List<Item> &list):
Item_func_hybrid_field_type(thd, list) {}
Item_func_case_expression(thd, list) {}
double real_op();
longlong int_op();
String *str_op(String *);
@ -995,7 +995,7 @@ public:
IF(switch, arg1, arg2)
NVL2(switch, arg1, arg2)
*/
class Item_func_case_abbreviation2 :public Item_func_hybrid_field_type
class Item_func_case_abbreviation2 :public Item_func_case_expression
{
protected:
void fix_length_and_dec2(Item **items)
@ -1034,9 +1034,9 @@ protected:
public:
Item_func_case_abbreviation2(THD *thd, Item *a, Item *b):
Item_func_hybrid_field_type(thd, a, b) { }
Item_func_case_expression(thd, a, b) { }
Item_func_case_abbreviation2(THD *thd, Item *a, Item *b, Item *c):
Item_func_hybrid_field_type(thd, a, b, c) { }
Item_func_case_expression(thd, a, b, c) { }
};
@ -1056,8 +1056,6 @@ public:
maybe_null= args[1]->maybe_null;
}
const char *func_name() const { return "ifnull"; }
Field *create_field_for_create_select(TABLE *table)
{ return tmp_table_field_from_field_type(table); }
table_map not_null_tables() const { return 0; }
uint decimal_precision() const
@ -1161,7 +1159,7 @@ public:
};
class Item_func_nullif :public Item_func_hybrid_field_type
class Item_func_nullif :public Item_func_case_expression
{
Arg_comparator cmp;
/*
@ -1199,7 +1197,7 @@ public:
See also Item_func_nullif::fix_length_and_dec().
*/
Item_func_nullif(THD *thd, Item *a, Item *b):
Item_func_hybrid_field_type(thd, a, b, a),
Item_func_case_expression(thd, a, b, a),
m_cache(NULL),
m_arg0(NULL)
{ arg_count--; }
@ -2031,7 +2029,7 @@ public:
function and only comparators for there result types are used.
*/
class Item_func_case :public Item_func_hybrid_field_type,
class Item_func_case :public Item_func_case_expression,
public Predicant_to_list_comparator
{
int first_expr_num, else_expr_num;

View file

@ -2260,10 +2260,11 @@ protected:
};
class Create_func_lpad : public Create_func_arg3
class Create_func_lpad : public Create_native_func
{
public:
virtual Item *create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3);
virtual Item *create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list);
static Create_func_lpad s_singleton;
@ -2686,10 +2687,11 @@ protected:
};
class Create_func_rpad : public Create_func_arg3
class Create_func_rpad : public Create_native_func
{
public:
virtual Item *create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3);
virtual Item *create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list);
static Create_func_rpad s_singleton;
@ -5791,9 +5793,34 @@ Create_func_log2::create_1_arg(THD *thd, Item *arg1)
Create_func_lpad Create_func_lpad::s_singleton;
Item*
Create_func_lpad::create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3)
Create_func_lpad::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
return new (thd->mem_root) Item_func_lpad(thd, arg1, arg2, arg3);
Item *func= NULL;
int arg_count= item_list ? item_list->elements : 0;
switch (arg_count) {
case 2:
{
Item *param_1= item_list->pop();
Item *param_2= item_list->pop();
func= new (thd->mem_root) Item_func_lpad(thd, param_1, param_2);
break;
}
case 3:
{
Item *param_1= item_list->pop();
Item *param_2= item_list->pop();
Item *param_3= item_list->pop();
func= new (thd->mem_root) Item_func_lpad(thd, param_1, param_2, param_3);
break;
}
default:
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
break;
}
return func;
}
@ -6253,9 +6280,34 @@ Create_func_round::create_native(THD *thd, LEX_CSTRING *name,
Create_func_rpad Create_func_rpad::s_singleton;
Item*
Create_func_rpad::create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3)
Create_func_rpad::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
return new (thd->mem_root) Item_func_rpad(thd, arg1, arg2, arg3);
Item *func= NULL;
int arg_count= item_list ? item_list->elements : 0;
switch (arg_count) {
case 2:
{
Item *param_1= item_list->pop();
Item *param_2= item_list->pop();
func= new (thd->mem_root) Item_func_rpad(thd, param_1, param_2);
break;
}
case 3:
{
Item *param_1= item_list->pop();
Item *param_2= item_list->pop();
Item *param_3= item_list->pop();
func= new (thd->mem_root) Item_func_rpad(thd, param_1, param_2, param_3);
break;
}
default:
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
break;
}
return func;
}

View file

@ -4981,7 +4981,7 @@ void Item_func_set_user_var::print_as_stmt(String *str,
args[0]->print_parenthesised(str, query_type, precedence());
}
bool Item_func_set_user_var::send(Protocol *protocol, String *str_arg)
bool Item_func_set_user_var::send(Protocol *protocol, st_value *buffer)
{
if (result_field)
{
@ -4989,7 +4989,7 @@ bool Item_func_set_user_var::send(Protocol *protocol, String *str_arg)
update();
return protocol->store(result_field);
}
return Item::send(protocol, str_arg);
return Item::send(protocol, buffer);
}
void Item_func_set_user_var::make_field(THD *thd, Send_field *tmp_field)

View file

@ -599,6 +599,38 @@ public:
};
/*
This class resembles SQL standard CASE-alike expressions:
CASE and its abbreviations COALESCE, NULLIF, IFNULL, IF.
<case expression> ::= <case abbreviation>
| <case specification>
*/
class Item_func_case_expression: public Item_func_hybrid_field_type
{
public:
Item_func_case_expression(THD *thd)
:Item_func_hybrid_field_type(thd)
{ }
Item_func_case_expression(THD *thd, Item *a)
:Item_func_hybrid_field_type(thd, a)
{ }
Item_func_case_expression(THD *thd, Item *a, Item *b)
:Item_func_hybrid_field_type(thd, a, b)
{ }
Item_func_case_expression(THD *thd, Item *a, Item *b, Item *c)
:Item_func_hybrid_field_type(thd, a, b, c)
{ }
Item_func_case_expression(THD *thd, List<Item> &list):
Item_func_hybrid_field_type(thd, list)
{ }
Field *create_tmp_field(bool group, TABLE *table)
{ return tmp_table_field_from_field_type(table); }
Field *create_field_for_create_select(TABLE *table)
{ return tmp_table_field_from_field_type(table); }
};
class Item_func_numhybrid: public Item_func_hybrid_field_type
{
protected:
@ -1404,6 +1436,10 @@ public:
Item_func_min_max(THD *thd, List<Item> &list, int cmp_sign_arg):
Item_hybrid_func(thd, list), cmp_sign(cmp_sign_arg)
{}
Field *create_tmp_field(bool group, TABLE *table)
{ return tmp_table_field_from_field_type(table); }
Field *create_field_for_create_select(TABLE *table)
{ return tmp_table_field_from_field_type(table); }
String *val_str_native(String *str);
double val_real_native();
longlong val_int_native();
@ -2212,7 +2248,7 @@ public:
bool is_null_result();
bool update_hash(void *ptr, uint length, enum Item_result type,
CHARSET_INFO *cs, bool unsigned_arg);
bool send(Protocol *protocol, String *str_arg);
bool send(Protocol *protocol, st_value *buffer);
void make_field(THD *thd, Send_field *tmp_field);
bool check(bool use_result_field);
void save_item_result(Item *item);

View file

@ -3152,11 +3152,22 @@ err:
}
void Item_func_rpad::fix_length_and_dec()
void Item_func_pad::fix_length_and_dec()
{
// Handle character set for args[0] and args[2].
if (agg_arg_charsets_for_string_result(collation, &args[0], 2, 2))
return;
if (arg_count == 3)
{
// Handle character set for args[0] and args[2].
if (agg_arg_charsets_for_string_result(collation, &args[0], 2, 2))
return;
}
else
{
if (agg_arg_charsets_for_string_result(collation, &args[0], 1, 1))
return;
pad_str.set_charset(collation.collation);
pad_str.append(" ", 1);
}
if (args[1]->const_item())
{
ulonglong char_length= (ulonglong) args[1]->val_int();
@ -3187,11 +3198,15 @@ String *Item_func_rpad::val_str(String *str)
longlong count= args[1]->val_int();
longlong byte_count;
String *res= args[0]->val_str(str);
String *rpad= args[2]->val_str(&rpad_str);
String *rpad= arg_count == 2 ? &pad_str : args[2]->val_str(&pad_str);
if (!res || args[1]->null_value || !rpad ||
((count < 0) && !args[1]->unsigned_flag))
goto err;
if (count == 0)
return make_empty_result();
null_value=0;
/* Assumes that the maximum length of a String is < INT_MAX32. */
/* Set here so that rest of code sees out-of-bound value as such. */
@ -3216,7 +3231,6 @@ String *Item_func_rpad::val_str(String *str)
res->length(res->charpos((int) count)); // Shorten result if longer
return (res);
}
pad_char_length= rpad->numchars();
byte_count= count * collation.collation->mbmaxlen;
{
@ -3230,8 +3244,15 @@ String *Item_func_rpad::val_str(String *str)
goto err;
}
}
if (args[2]->null_value || !pad_char_length)
goto err;
if (arg_count == 3)
{
if (args[2]->null_value || !(pad_char_length= rpad->numchars()))
goto err;
}
else
pad_char_length= 1; // Implicit space
res_byte_length= res->length(); /* Must be done before alloc_buffer */
if (!(res= alloc_buffer(res,str,&tmp_value, (ulong) byte_count)))
goto err;
@ -3260,32 +3281,6 @@ String *Item_func_rpad::val_str(String *str)
}
void Item_func_lpad::fix_length_and_dec()
{
// Handle character set for args[0] and args[2].
if (agg_arg_charsets_for_string_result(collation, &args[0], 2, 2))
return;
if (args[1]->const_item())
{
ulonglong char_length= (ulonglong) args[1]->val_int();
DBUG_ASSERT(collation.collation->mbmaxlen > 0);
/* Assumes that the maximum length of a String is < INT_MAX32. */
/* Set here so that rest of code sees out-of-bound value as such. */
if (args[1]->null_value)
char_length= 0;
else if (char_length > INT_MAX32)
char_length= INT_MAX32;
fix_char_length_ulonglong(char_length);
}
else
{
max_length= MAX_BLOB_WIDTH;
maybe_null= 1;
}
}
String *Item_func_lpad::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
@ -3294,11 +3289,15 @@ String *Item_func_lpad::val_str(String *str)
longlong count= args[1]->val_int();
longlong byte_count;
String *res= args[0]->val_str(&tmp_value);
String *pad= args[2]->val_str(&lpad_str);
String *pad= arg_count == 2 ? &pad_str : args[2]->val_str(&pad_str);
if (!res || args[1]->null_value || !pad ||
((count < 0) && !args[1]->unsigned_flag))
goto err;
if (count == 0)
return make_empty_result();
null_value=0;
/* Assumes that the maximum length of a String is < INT_MAX32. */
/* Set here so that rest of code sees out-of-bound value as such. */
@ -3327,7 +3326,6 @@ String *Item_func_lpad::val_str(String *str)
return res;
}
pad_char_length= pad->numchars();
byte_count= count * collation.collation->mbmaxlen;
{
@ -3342,9 +3340,16 @@ String *Item_func_lpad::val_str(String *str)
}
}
if (args[2]->null_value || !pad_char_length ||
str->alloc((uint32) byte_count))
if (str->alloc((uint32) byte_count))
goto err;
if (arg_count == 3)
{
if (args[2]->null_value || !(pad_char_length= pad->numchars()))
goto err;
}
else
pad_char_length= 1; // Implicit space
str->length(0);
str->set_charset(collation.collation);

View file

@ -1003,28 +1003,41 @@ public:
};
class Item_func_rpad :public Item_str_func
class Item_func_pad: public Item_str_func
{
protected:
String tmp_value, pad_str;
public:
Item_func_pad(THD *thd, Item *arg1, Item *arg2, Item *arg3):
Item_str_func(thd, arg1, arg2, arg3) {}
Item_func_pad(THD *thd, Item *arg1, Item *arg2):
Item_str_func(thd, arg1, arg2) {}
void fix_length_and_dec();
};
class Item_func_rpad :public Item_func_pad
{
String tmp_value, rpad_str;
public:
Item_func_rpad(THD *thd, Item *arg1, Item *arg2, Item *arg3):
Item_str_func(thd, arg1, arg2, arg3) {}
Item_func_pad(thd, arg1, arg2, arg3) {}
Item_func_rpad(THD *thd, Item *arg1, Item *arg2):
Item_func_pad(thd, arg1, arg2) {}
String *val_str(String *);
void fix_length_and_dec();
const char *func_name() const { return "rpad"; }
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_func_rpad>(thd, mem_root, this); }
};
class Item_func_lpad :public Item_str_func
class Item_func_lpad :public Item_func_pad
{
String tmp_value, lpad_str;
public:
Item_func_lpad(THD *thd, Item *arg1, Item *arg2, Item *arg3):
Item_str_func(thd, arg1, arg2, arg3) {}
Item_func_pad(thd, arg1, arg2, arg3) {}
Item_func_lpad(THD *thd, Item *arg1, Item *arg2):
Item_func_pad(thd, arg1, arg2) {}
String *val_str(String *);
void fix_length_and_dec();
const char *func_name() const { return "lpad"; }
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_func_lpad>(thd, mem_root, this); }

View file

@ -791,8 +791,7 @@ bool Protocol::send_result_set_metadata(List<Item> *list, uint flags)
{
List_iterator_fast<Item> it(*list);
Item *item;
uchar buff[MAX_FIELD_WIDTH];
String tmp((char*) buff,sizeof(buff),&my_charset_bin);
ValueBuffer<MAX_FIELD_WIDTH> tmp;
Protocol_text prot(thd);
String *local_packet= prot.storage_packet();
CHARSET_INFO *thd_charset= thd->variables.character_set_results;
@ -800,7 +799,9 @@ bool Protocol::send_result_set_metadata(List<Item> *list, uint flags)
if (flags & SEND_NUM_ROWS)
{ // Packet with number of elements
uchar buff[MAX_INT_WIDTH];
uchar *pos= net_store_length(buff, list->elements);
DBUG_ASSERT(pos <= buff + sizeof(buff));
if (my_net_write(&thd->net, buff, (size_t) (pos-buff)))
DBUG_RETURN(1);
}
@ -968,15 +969,20 @@ bool Protocol::write()
bool Protocol::send_result_set_row(List<Item> *row_items)
{
char buffer[MAX_FIELD_WIDTH];
String str_buffer(buffer, sizeof (buffer), &my_charset_bin);
List_iterator_fast<Item> it(*row_items);
DBUG_ENTER("Protocol::send_result_set_row");
for (Item *item= it++; item; item= it++)
{
if (item->send(this, &str_buffer))
/*
ValueBuffer::m_string can be altered during Item::send().
It's important to declare value_buffer inside the loop,
to have ValueBuffer::m_string point to ValueBuffer::buffer
on every iteration.
*/
ValueBuffer<MAX_FIELD_WIDTH> value_buffer;
if (item->send(this, &value_buffer))
{
// If we're out of memory, reclaim some, to help us recover.
this->free();
@ -985,12 +991,6 @@ bool Protocol::send_result_set_row(List<Item> *row_items)
/* Item::send() may generate an error. If so, abort the loop. */
if (thd->is_error())
DBUG_RETURN(TRUE);
/*
Reset str_buffer to its original state, as it may have been altered in
Item::send().
*/
str_buffer.set(buffer, sizeof(buffer), &my_charset_bin);
}
DBUG_RETURN(FALSE);

View file

@ -2985,7 +2985,7 @@ sp_head::show_routine_code(THD *thd)
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR, tmp);
}
protocol->prepare_for_resend();
protocol->store((longlong)ip);
protocol->store_long(ip);
buffer.set("", 0, system_charset_info);
i->print(&buffer);

View file

@ -513,6 +513,21 @@ Type_handler_hybrid_field_type::aggregate_for_result(const Type_handler *other)
}
/*
This method is called for CASE (and its abbreviations) and LEAST/GREATEST
when data type aggregation returned LONGLONG and there were some BIT
expressions. This helps to adjust the data type from LONGLONG to LONG
if all expressions fit.
*/
const Type_handler *
Type_handler::bit_and_int_mixture_handler(uint max_char_length)
{
if (max_char_length <= MY_INT32_NUM_DECIMAL_DIGITS)
return &type_handler_long;
return &type_handler_longlong;
}
/**
@brief Aggregates field types from the array of items.
@ -552,6 +567,8 @@ Type_handler_hybrid_field_type::aggregate_for_result(const char *funcname,
Item **items, uint nitems,
bool treat_bit_as_number)
{
bool bit_and_non_bit_mixture_found= false;
uint32 max_display_length;
if (!nitems || items[0]->result_type() == ROW_RESULT)
{
DBUG_ASSERT(0);
@ -559,12 +576,15 @@ Type_handler_hybrid_field_type::aggregate_for_result(const char *funcname,
return true;
}
set_handler(items[0]->type_handler());
max_display_length= items[0]->max_display_length();
for (uint i= 1 ; i < nitems ; i++)
{
const Type_handler *cur= items[i]->type_handler();
set_if_bigger(max_display_length, items[i]->max_display_length());
if (treat_bit_as_number &&
((type_handler() == &type_handler_bit) ^ (cur == &type_handler_bit)))
{
bit_and_non_bit_mixture_found= true;
if (type_handler() == &type_handler_bit)
set_handler(&type_handler_longlong); // BIT + non-BIT
else
@ -577,6 +597,8 @@ Type_handler_hybrid_field_type::aggregate_for_result(const char *funcname,
return true;
}
}
if (bit_and_non_bit_mixture_found && type_handler() == &type_handler_longlong)
set_handler(Type_handler::bit_and_int_mixture_handler(max_display_length));
return false;
}
@ -728,7 +750,9 @@ Type_handler_hybrid_field_type::aggregate_for_min_max(const Type_handler *h)
}
else
{
m_type_handler= &type_handler_double;
// Preserve FLOAT if two FLOATs, set to DOUBLE otherwise.
if (m_type_handler != &type_handler_float || h != &type_handler_float)
m_type_handler= &type_handler_double;
}
return false;
}
@ -738,12 +762,19 @@ bool
Type_handler_hybrid_field_type::aggregate_for_min_max(const char *funcname,
Item **items, uint nitems)
{
bool bit_and_non_bit_mixture_found= false;
uint32 max_display_length;
// LEAST/GREATEST require at least two arguments
DBUG_ASSERT(nitems > 1);
set_handler(items[0]->type_handler());
max_display_length= items[0]->max_display_length();
for (uint i= 1; i < nitems; i++)
{
const Type_handler *cur= items[i]->type_handler();
set_if_bigger(max_display_length, items[i]->max_display_length());
// Check if BIT + non-BIT, or non-BIT + BIT
bit_and_non_bit_mixture_found|= (m_type_handler == &type_handler_bit) !=
(cur == &type_handler_bit);
if (aggregate_for_min_max(cur))
{
my_error(ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION, MYF(0),
@ -751,6 +782,8 @@ Type_handler_hybrid_field_type::aggregate_for_min_max(const char *funcname,
return true;
}
}
if (bit_and_non_bit_mixture_found && type_handler() == &type_handler_longlong)
set_handler(Type_handler::bit_and_int_mixture_handler(max_display_length));
return false;
}
@ -4028,3 +4061,114 @@ bool Type_handler_time_common::
}
/***************************************************************************/
bool Type_handler_null::
Item_send(Item *item, Protocol *protocol, st_value *buf) const
{
return protocol->store_null();
}
bool Type_handler::
Item_send_str(Item *item, Protocol *protocol, st_value *buf) const
{
String *res;
if ((res= item->val_str(&buf->m_string)))
{
DBUG_ASSERT(!item->null_value);
return protocol->store(res->ptr(), res->length(), res->charset());
}
DBUG_ASSERT(item->null_value);
return protocol->store_null();
}
bool Type_handler::
Item_send_tiny(Item *item, Protocol *protocol, st_value *buf) const
{
longlong nr= item->val_int();
if (!item->null_value)
return protocol->store_tiny(nr);
return protocol->store_null();
}
bool Type_handler::
Item_send_short(Item *item, Protocol *protocol, st_value *buf) const
{
longlong nr= item->val_int();
if (!item->null_value)
return protocol->store_short(nr);
return protocol->store_null();
}
bool Type_handler::
Item_send_long(Item *item, Protocol *protocol, st_value *buf) const
{
longlong nr= item->val_int();
if (!item->null_value)
return protocol->store_long(nr);
return protocol->store_null();
}
bool Type_handler::
Item_send_longlong(Item *item, Protocol *protocol, st_value *buf) const
{
longlong nr= item->val_int();
if (!item->null_value)
return protocol->store_longlong(nr, item->unsigned_flag);
return protocol->store_null();
}
bool Type_handler::
Item_send_float(Item *item, Protocol *protocol, st_value *buf) const
{
float nr= (float) item->val_real();
if (!item->null_value)
return protocol->store(nr, item->decimals, &buf->m_string);
return protocol->store_null();
}
bool Type_handler::
Item_send_double(Item *item, Protocol *protocol, st_value *buf) const
{
double nr= item->val_real();
if (!item->null_value)
return protocol->store(nr, item->decimals, &buf->m_string);
return protocol->store_null();
}
bool Type_handler::
Item_send_datetime(Item *item, Protocol *protocol, st_value *buf) const
{
item->get_date(&buf->value.m_time, sql_mode_for_dates(current_thd));
if (!item->null_value)
return protocol->store(&buf->value.m_time, item->decimals);
return protocol->store_null();
}
bool Type_handler::
Item_send_date(Item *item, Protocol *protocol, st_value *buf) const
{
item->get_date(&buf->value.m_time, sql_mode_for_dates(current_thd));
if (!item->null_value)
return protocol->store_date(&buf->value.m_time);
return protocol->store_null();
}
bool Type_handler::
Item_send_time(Item *item, Protocol *protocol, st_value *buf) const
{
item->get_time(&buf->value.m_time);
if (!item->null_value)
return protocol->store_time(&buf->value.m_time, item->decimals);
return protocol->store_null();
}
/***************************************************************************/

View file

@ -63,6 +63,7 @@ class in_vector;
class Sort_param;
class Arg_comparator;
struct st_value;
class Protocol;
struct TABLE;
struct SORT_FIELD_ATTR;
@ -465,6 +466,7 @@ public:
Type_all_attributes(const Type_all_attributes *other)
:Type_std_attributes(other)
{ }
virtual ~Type_all_attributes() {}
// Returns total number of decimal digits
virtual uint decimal_precision() const= 0;
/*
@ -531,9 +533,20 @@ protected:
bool
Item_func_or_sum_illegal_param(const Item_func_or_sum *) const;
bool check_null(const Item *item, st_value *value) const;
bool Item_send_str(Item *item, Protocol *protocol, st_value *buf) const;
bool Item_send_tiny(Item *item, Protocol *protocol, st_value *buf) const;
bool Item_send_short(Item *item, Protocol *protocol, st_value *buf) const;
bool Item_send_long(Item *item, Protocol *protocol, st_value *buf) const;
bool Item_send_longlong(Item *item, Protocol *protocol, st_value *buf) const;
bool Item_send_float(Item *item, Protocol *protocol, st_value *buf) const;
bool Item_send_double(Item *item, Protocol *protocol, st_value *buf) const;
bool Item_send_time(Item *item, Protocol *protocol, st_value *buf) const;
bool Item_send_date(Item *item, Protocol *protocol, st_value *buf) const;
bool Item_send_datetime(Item *item, Protocol *protocol, st_value *buf) const;
public:
static const Type_handler *blob_type_handler(uint max_octet_length);
static const Type_handler *string_type_handler(uint max_octet_length);
static const Type_handler *bit_and_int_mixture_handler(uint max_char_len);
/**
Return a string type handler for Item
If too_big_for_varchar() returns a BLOB variant, according to length.
@ -670,6 +683,7 @@ public:
virtual uint32 max_display_length(const Item *item) const= 0;
virtual bool Item_save_in_value(Item *item, st_value *value) const= 0;
virtual bool Item_send(Item *item, Protocol *p, st_value *buf) const= 0;
virtual int Item_save_in_field(Item *item, Field *field,
bool no_conversions) const= 0;
@ -886,6 +900,11 @@ public:
return 0;
}
bool Item_save_in_value(Item *item, st_value *value) const;
bool Item_send(Item *item, Protocol *protocol, st_value *buf) const
{
DBUG_ASSERT(0);
return true;
}
int Item_save_in_field(Item *item, Field *field, bool no_conversions) const
{
DBUG_ASSERT(0);
@ -1155,6 +1174,10 @@ public:
SORT_FIELD_ATTR *attr) const;
uint32 max_display_length(const Item *item) const;
bool Item_save_in_value(Item *item, st_value *value) const;
bool Item_send(Item *item, Protocol *protocol, st_value *buf) const
{
return Item_send_str(item, protocol, buf);
}
int Item_save_in_field(Item *item, Field *field, bool no_conversions) const;
Item_cache *Item_get_cache(THD *thd, const Item *item) const;
bool set_comparator_func(Arg_comparator *cmp) const;
@ -1340,6 +1363,10 @@ public:
return Item_temporal_precision(item, false);
}
bool Item_save_in_value(Item *item, st_value *value) const;
bool Item_send(Item *item, Protocol *protocol, st_value *buf) const
{
return Item_send_str(item, protocol, buf);
}
int Item_save_in_field(Item *item, Field *field, bool no_conversions) const;
String *print_item_value(THD *thd, Item *item, String *str) const
{
@ -1424,6 +1451,10 @@ public:
const Name name() const { return m_name_tiny; }
enum_field_types field_type() const { return MYSQL_TYPE_TINY; }
uint32 max_display_length(const Item *item) const { return 4; }
bool Item_send(Item *item, Protocol *protocol, st_value *buf) const
{
return Item_send_tiny(item, protocol, buf);
}
Field *make_conversion_table_field(TABLE *TABLE, uint metadata,
const Field *target) const;
Field *make_table_field(const LEX_CSTRING *name,
@ -1440,6 +1471,10 @@ public:
virtual ~Type_handler_short() {}
const Name name() const { return m_name_short; }
enum_field_types field_type() const { return MYSQL_TYPE_SHORT; }
bool Item_send(Item *item, Protocol *protocol, st_value *buf) const
{
return Item_send_short(item, protocol, buf);
}
uint32 max_display_length(const Item *item) const { return 6; }
Field *make_conversion_table_field(TABLE *TABLE, uint metadata,
const Field *target) const;
@ -1461,6 +1496,10 @@ public:
{
return MY_INT32_NUM_DECIMAL_DIGITS;
}
bool Item_send(Item *item, Protocol *protocol, st_value *buf) const
{
return Item_send_long(item, protocol, buf);
}
Field *make_conversion_table_field(TABLE *TABLE, uint metadata,
const Field *target) const;
Field *make_table_field(const LEX_CSTRING *name,
@ -1478,6 +1517,10 @@ public:
const Name name() const { return m_name_longlong; }
enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; }
uint32 max_display_length(const Item *item) const { return 20; }
bool Item_send(Item *item, Protocol *protocol, st_value *buf) const
{
return Item_send_longlong(item, protocol, buf);
}
Field *make_conversion_table_field(TABLE *TABLE, uint metadata,
const Field *target) const;
Field *make_table_field(const LEX_CSTRING *name,
@ -1494,6 +1537,10 @@ public:
virtual ~Type_handler_int24() {}
const Name name() const { return m_name_mediumint; }
enum_field_types field_type() const { return MYSQL_TYPE_INT24; }
bool Item_send(Item *item, Protocol *protocol, st_value *buf) const
{
return Item_send_long(item, protocol, buf);
}
uint32 max_display_length(const Item *item) const { return 8; }
Field *make_conversion_table_field(TABLE *, uint metadata,
const Field *target) const;
@ -1512,6 +1559,10 @@ public:
const Name name() const { return m_name_year; }
enum_field_types field_type() const { return MYSQL_TYPE_YEAR; }
uint32 max_display_length(const Item *item) const;
bool Item_send(Item *item, Protocol *protocol, st_value *buf) const
{
return Item_send_short(item, protocol, buf);
}
Field *make_conversion_table_field(TABLE *, uint metadata,
const Field *target) const;
Field *make_table_field(const LEX_CSTRING *name,
@ -1529,6 +1580,10 @@ public:
const Name name() const { return m_name_bit; }
enum_field_types field_type() const { return MYSQL_TYPE_BIT; }
uint32 max_display_length(const Item *item) const;
bool Item_send(Item *item, Protocol *protocol, st_value *buf) const
{
return Item_send_str(item, protocol, buf);
}
String *print_item_value(THD *thd, Item *item, String *str) const
{
return print_item_value_csstr(thd, item, str);
@ -1550,6 +1605,10 @@ public:
const Name name() const { return m_name_float; }
enum_field_types field_type() const { return MYSQL_TYPE_FLOAT; }
uint32 max_display_length(const Item *item) const { return 25; }
bool Item_send(Item *item, Protocol *protocol, st_value *buf) const
{
return Item_send_float(item, protocol, buf);
}
Field *make_num_distinct_aggregator_field(MEM_ROOT *, const Item *) const;
Field *make_conversion_table_field(TABLE *, uint metadata,
const Field *target) const;
@ -1568,6 +1627,10 @@ public:
const Name name() const { return m_name_double; }
enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; }
uint32 max_display_length(const Item *item) const { return 53; }
bool Item_send(Item *item, Protocol *protocol, st_value *buf) const
{
return Item_send_double(item, protocol, buf);
}
Field *make_conversion_table_field(TABLE *, uint metadata,
const Field *target) const;
Field *make_table_field(const LEX_CSTRING *name,
@ -1598,6 +1661,10 @@ public:
}
const Type_handler *type_handler_for_comparison() const;
bool Item_save_in_value(Item *item, st_value *value) const;
bool Item_send(Item *item, Protocol *protocol, st_value *buf) const
{
return Item_send_time(item, protocol, buf);
}
int Item_save_in_field(Item *item, Field *field, bool no_conversions) const;
String *print_item_value(THD *thd, Item *item, String *str) const;
bool Item_hybrid_func_fix_attributes(THD *thd, Item_hybrid_func *func,
@ -1640,6 +1707,10 @@ public:
virtual ~Type_handler_temporal_with_date() {}
const Type_handler *type_handler_for_comparison() const;
bool Item_save_in_value(Item *item, st_value *value) const;
bool Item_send(Item *item, Protocol *protocol, st_value *buf) const
{
return Item_send_date(item, protocol, buf);
}
int Item_save_in_field(Item *item, Field *field, bool no_conversions) const;
cmp_item *make_cmp_item(THD *thd, CHARSET_INFO *cs) const;
in_vector *make_in_vector(THD *, const Item_func_in *, uint nargs) const;
@ -1708,6 +1779,10 @@ public:
{
return Item_divisor_precision_increment_with_seconds(item);
}
bool Item_send(Item *item, Protocol *protocol, st_value *buf) const
{
return Item_send_datetime(item, protocol, buf);
}
String *print_item_value(THD *thd, Item *item, String *str) const;
bool Item_hybrid_func_fix_attributes(THD *thd, Item_hybrid_func *func,
Item **items, uint nitems) const;
@ -1760,6 +1835,10 @@ public:
{
return Item_divisor_precision_increment_with_seconds(item);
}
bool Item_send(Item *item, Protocol *protocol, st_value *buf) const
{
return Item_send_datetime(item, protocol, buf);
}
String *print_item_value(THD *thd, Item *item, String *str) const;
bool Item_hybrid_func_fix_attributes(THD *thd, Item_hybrid_func *func,
Item **items, uint nitems) const;
@ -1839,6 +1918,7 @@ public:
const Type_handler *type_handler_for_union(const Item *) const;
uint32 max_display_length(const Item *item) const { return 0; }
bool Item_save_in_value(Item *item, st_value *value) const;
bool Item_send(Item *item, Protocol *protocol, st_value *buf) const;
Field *make_conversion_table_field(TABLE *, uint metadata,
const Field *target) const;
Field *make_table_field(const LEX_CSTRING *name,

View file

@ -772,6 +772,11 @@ Virtual_column_info *add_virtual_expression(THD *thd, Item *expr)
Lex_dyncol_type_st Lex_dyncol_type;
Lex_for_loop_st for_loop;
Lex_for_loop_bounds_st for_loop_bounds;
struct
{
LEX_CSTRING name;
uint offset;
} sp_cursor_name_and_offset;
/* pointers */
Create_field *create_field;
@ -860,10 +865,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%parse-param { THD *thd }
%lex-param { THD *thd }
/*
Currently there are 103 shift/reduce conflicts.
Currently there are 102 shift/reduce conflicts.
We should not introduce new conflicts any more.
*/
%expect 103
%expect 102
/*
Comments for TOKENS.
@ -1642,6 +1647,11 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%type <field_type> int_type real_type
%type <Lex_field_type> type_with_opt_collate field_type
field_type_numeric
field_type_string
field_type_lob
field_type_temporal
field_type_misc
%type <Lex_dyncol_type> opt_dyncol_type dyncol_type
numeric_dyncol_type temporal_dyncol_type string_dyncol_type
@ -1788,6 +1798,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%type <Lex_length_and_dec> precision opt_precision float_options
%type <symbol> keyword keyword_sp
keyword_sp_data_type
keyword_sp_not_data_type
%type <lex_user> user grant_user grant_role user_or_role current_role
admin_option_for_role user_maybe_role
@ -6244,6 +6256,14 @@ column_default_expr:
;
field_type:
field_type_numeric
| field_type_temporal
| field_type_string
| field_type_lob
| field_type_misc
;
field_type_numeric:
int_type opt_field_length field_options { $$.set($1, $2); }
| real_type opt_precision field_options { $$.set($1, $2); }
| FLOAT_SYM float_options field_options
@ -6274,7 +6294,17 @@ field_type:
{
$$.set(MYSQL_TYPE_TINY, "1");
}
| char opt_field_length_default_1 opt_binary
| DECIMAL_SYM float_options field_options
{ $$.set(MYSQL_TYPE_NEWDECIMAL, $2);}
| NUMERIC_SYM float_options field_options
{ $$.set(MYSQL_TYPE_NEWDECIMAL, $2);}
| FIXED_SYM float_options field_options
{ $$.set(MYSQL_TYPE_NEWDECIMAL, $2);}
;
field_type_string:
char opt_field_length_default_1 opt_binary
{
$$.set(MYSQL_TYPE_STRING, $2);
}
@ -6302,7 +6332,10 @@ field_type:
Lex->charset=&my_charset_bin;
$$.set(MYSQL_TYPE_VARCHAR, $2);
}
| YEAR_SYM opt_field_length field_options
;
field_type_temporal:
YEAR_SYM opt_field_length field_options
{
if ($2)
{
@ -6345,7 +6378,11 @@ field_type:
| DATETIME opt_field_length
{ $$.set(opt_mysql56_temporal_format ?
MYSQL_TYPE_DATETIME2 : MYSQL_TYPE_DATETIME, $2); }
| TINYBLOB
;
field_type_lob:
TINYBLOB
{
Lex->charset=&my_charset_bin;
$$.set(MYSQL_TYPE_TINY_BLOB);
@ -6391,18 +6428,16 @@ field_type:
{ $$.set(MYSQL_TYPE_MEDIUM_BLOB); }
| LONGTEXT opt_binary
{ $$.set(MYSQL_TYPE_LONG_BLOB); }
| DECIMAL_SYM float_options field_options
{ $$.set(MYSQL_TYPE_NEWDECIMAL, $2);}
| NUMERIC_SYM float_options field_options
{ $$.set(MYSQL_TYPE_NEWDECIMAL, $2);}
| FIXED_SYM float_options field_options
{ $$.set(MYSQL_TYPE_NEWDECIMAL, $2);}
| ENUM '(' string_list ')' opt_binary
| LONG_SYM opt_binary
{ $$.set(MYSQL_TYPE_MEDIUM_BLOB); }
;
field_type_misc:
ENUM '(' string_list ')' opt_binary
{ $$.set(MYSQL_TYPE_ENUM); }
| SET '(' string_list ')' opt_binary
{ $$.set(MYSQL_TYPE_SET); }
| LONG_SYM opt_binary
{ $$.set(MYSQL_TYPE_MEDIUM_BLOB); }
;
spatial_type:
@ -12202,17 +12237,17 @@ drop:
Lex->set_command(SQLCOM_DROP_SERVER, $3);
Lex->server_options.reset($4);
}
| DROP opt_temporary SEQUENCE_SYM opt_if_exists
| DROP opt_temporary SEQUENCE_SYM opt_if_exists
{
LEX *lex= Lex;
lex->set_command(SQLCOM_DROP_SEQUENCE, $2, $4);
lex->table_type= TABLE_TYPE_SEQUENCE;
YYPS->m_lock_type= TL_UNLOCK;
YYPS->m_mdl_type= MDL_EXCLUSIVE;
}
table_list
{}
{
LEX *lex= Lex;
lex->set_command(SQLCOM_DROP_SEQUENCE, $2, $4);
lex->table_type= TABLE_TYPE_SEQUENCE;
YYPS->m_lock_type= TL_UNLOCK;
YYPS->m_mdl_type= MDL_EXCLUSIVE;
}
table_list
{}
;
table_list:
@ -14094,7 +14129,7 @@ simple_ident:
lip->get_tok_end())))
MYSQL_YYABORT;
}
| simple_ident_q2 { $$= $1; }
| simple_ident_q2
| ident '.' ident
{
LEX *lex= thd->lex;
@ -14481,6 +14516,49 @@ keyword:
* conflicts.
*/
keyword_sp:
keyword_sp_data_type
| keyword_sp_not_data_type
;
/*
These keywords are generally allowed as identifiers,
but not allowed as non-delimited SP variable names in sql_mode=ORACLE.
*/
keyword_sp_data_type:
BIT_SYM {}
| BOOLEAN_SYM {} /* PLSQL-R */
| BOOL_SYM {}
| CLOB {}
| DATE_SYM {} /* Oracle-R, PLSQL-R */
| DATETIME {}
| ENUM {}
| FIXED_SYM {}
| GEOMETRYCOLLECTION {}
| GEOMETRY_SYM {}
| LINESTRING {}
| MEDIUM_SYM {}
| MULTILINESTRING {}
| MULTIPOINT {}
| MULTIPOLYGON {}
| NATIONAL_SYM {}
| NCHAR_SYM {}
| NUMBER_SYM {} /* Oracle-R, PLSQL-R */
| NVARCHAR_SYM {}
| POINT_SYM {}
| POLYGON {}
| RAW {} /* Oracle-R */
| ROW_SYM {}
| SERIAL_SYM {}
| TEXT_SYM {}
| TIMESTAMP {}
| TIME_SYM {} /* Oracle-R */
| VARCHAR2 {} /* Oracle-R, PLSQL-R */
| YEAR_SYM {}
;
keyword_sp_not_data_type:
ACTION {}
| ADDDATE_SYM {}
| ADMIN_SYM {}
@ -14498,10 +14576,7 @@ keyword_sp:
| AUTO_SYM {}
| AVG_ROW_LENGTH {}
| AVG_SYM {}
| BIT_SYM {}
| BLOCK_SYM {}
| BOOL_SYM {}
| BOOLEAN_SYM {}
| BTREE_SYM {}
| CASCADED {}
| CATALOG_NAME_SYM {}
@ -14510,7 +14585,6 @@ keyword_sp:
| CIPHER_SYM {}
| CLIENT_SYM {}
| CLASS_ORIGIN_SYM {}
| CLOB {}
| COALESCE {}
| CODE_SYM {}
| COLLATION_SYM {}
@ -14540,8 +14614,6 @@ keyword_sp:
| CYCLE_SYM {}
| DATA_SYM {}
| DATAFILE_SYM {}
| DATETIME {}
| DATE_SYM {}
| DAY_SYM {}
| DECODE_SYM {}
| DEFINER_SYM {}
@ -14557,7 +14629,6 @@ keyword_sp:
| DYNAMIC_SYM {}
| ELSIF_SYM {}
| ENDS_SYM {}
| ENUM {}
| ENGINE_SYM {}
| ENGINES_SYM {}
| ERROR_SYM {}
@ -14579,11 +14650,8 @@ keyword_sp:
| FULL {}
| FILE_SYM {}
| FIRST_SYM {}
| FIXED_SYM {}
| GENERAL {}
| GENERATED_SYM {}
| GEOMETRY_SYM {}
| GEOMETRYCOLLECTION {}
| GET_FORMAT {}
| GRANTS {}
| GLOBAL_SYM {}
@ -14615,7 +14683,6 @@ keyword_sp:
| LEAVES {}
| LESS_SYM {}
| LEVEL_SYM {}
| LINESTRING {}
| LIST_SYM {}
| LOCAL_SYM {}
| LOCKS_SYM {}
@ -14649,7 +14716,6 @@ keyword_sp:
| MAX_STATEMENT_TIME_SYM {}
| MAX_UPDATES_PER_HOUR {}
| MAX_USER_CONNECTIONS_SYM {}
| MEDIUM_SYM {}
| MEMORY_SYM {}
| MERGE_SYM {}
| MESSAGE_TEXT_SYM {}
@ -14661,16 +14727,11 @@ keyword_sp:
| MODIFY_SYM {}
| MODE_SYM {}
| MONTH_SYM {}
| MULTILINESTRING {}
| MULTIPOINT {}
| MULTIPOLYGON {}
| MUTEX_SYM {}
| MYSQL_SYM {}
| MYSQL_ERRNO_SYM {}
| NAME_SYM {}
| NAMES_SYM {}
| NATIONAL_SYM {}
| NCHAR_SYM {}
| NEXT_SYM {}
| NEXTVAL_SYM {}
| NEW_SYM {}
@ -14683,8 +14744,6 @@ keyword_sp:
| NODEGROUP_SYM {}
| NONE_SYM {}
| NOTFOUND_SYM {}
| NUMBER_SYM {}
| NVARCHAR_SYM {}
| OF_SYM {} /* SQL-1999-R, Oracle-R */
| OFFSET_SYM {}
| OLD_PASSWORD_SYM {}
@ -14701,8 +14760,6 @@ keyword_sp:
| PHASE_SYM {}
| PLUGIN_SYM {}
| PLUGINS_SYM {}
| POINT_SYM {}
| POLYGON {}
| PRESERVE_SYM {}
| PREV_SYM {}
| PREVIOUS_SYM {}
@ -14716,7 +14773,6 @@ keyword_sp:
| QUERY_SYM {}
| QUICK {}
| RAISE_SYM {}
| RAW {}
| READ_ONLY_SYM {}
| REBUILD_SYM {}
| RECOVER_SYM {}
@ -14736,7 +14792,7 @@ keyword_sp:
| RESUME_SYM {}
| RETURNED_SQLSTATE_SYM {}
| RETURNS_SYM {}
| REUSE_SYM {}
| REUSE_SYM {} /* Oracle-R */
| REVERSE_SYM {}
| ROLE_SYM {}
| ROLLUP_SYM {}
@ -14745,13 +14801,11 @@ keyword_sp:
| ROWTYPE_SYM {}
| ROW_COUNT_SYM {}
| ROW_FORMAT_SYM {}
| ROW_SYM {}
| RTREE_SYM {}
| SCHEDULE_SYM {}
| SCHEMA_NAME_SYM {}
| SECOND_SYM {}
| SEQUENCE_SYM {}
| SERIAL_SYM {}
| SERIALIZABLE_SYM {}
| SESSION_SYM {}
| SIMPLE_SYM {}
@ -14786,15 +14840,12 @@ keyword_sp:
| TABLESPACE {}
| TEMPORARY {}
| TEMPTABLE_SYM {}
| TEXT_SYM {}
| THAN_SYM {}
| TRANSACTION_SYM {}
| TRANSACTIONAL_SYM {}
| TRIGGERS_SYM {}
| TIMESTAMP {}
| TIMESTAMP_ADD {}
| TIMESTAMP_DIFF {}
| TIME_SYM {}
| TYPES_SYM {}
| TYPE_SYM {}
| UDF_RETURNS_SYM {}
@ -14807,7 +14858,6 @@ keyword_sp:
| UNTIL_SYM {}
| USER_SYM {}
| USE_FRM {}
| VARCHAR2 {}
| VARIABLES {}
| VIEW_SYM {}
| VIRTUAL_SYM {}
@ -14819,7 +14869,6 @@ keyword_sp:
| WORK_SYM {}
| X509_SYM {}
| XML_SYM {}
| YEAR_SYM {}
| VIA_SYM {}
;
@ -15975,11 +16024,6 @@ opt_release:
| NO_SYM RELEASE_SYM { $$= TVL_NO; }
;
opt_savepoint:
/* empty */ {}
| SAVEPOINT_SYM {}
;
commit:
COMMIT_SYM opt_work opt_chain opt_release
{
@ -16002,13 +16046,18 @@ rollback:
lex->tx_chain= $3;
lex->tx_release= $4;
}
| ROLLBACK_SYM opt_work
TO_SYM opt_savepoint ident
| ROLLBACK_SYM opt_work TO_SYM SAVEPOINT_SYM ident
{
LEX *lex=Lex;
lex->sql_command= SQLCOM_ROLLBACK_TO_SAVEPOINT;
lex->ident= $5;
}
| ROLLBACK_SYM opt_work TO_SYM ident
{
LEX *lex=Lex;
lex->sql_command= SQLCOM_ROLLBACK_TO_SAVEPOINT;
lex->ident= $4;
}
;
savepoint:

View file

@ -274,10 +274,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%parse-param { THD *thd }
%lex-param { THD *thd }
/*
Currently there are 105 shift/reduce conflicts.
Currently there are 104 shift/reduce conflicts.
We should not introduce new conflicts any more.
*/
%expect 105
%expect 104
/*
Comments for TOKENS.
@ -14721,7 +14721,7 @@ keyword_sp:
/*
These keywords are generally allowed as identifiers,
but not allowed as non-delimited SP variable names.
but not allowed as non-delimited SP variable names in sql_mode=ORACLE.
*/
keyword_sp_data_type:
BIT_SYM {}
@ -16262,11 +16262,6 @@ opt_release:
| NO_SYM RELEASE_SYM { $$= TVL_NO; }
;
opt_savepoint:
/* empty */ {}
| SAVEPOINT_SYM {}
;
commit:
COMMIT_SYM opt_work opt_chain opt_release
{
@ -16289,13 +16284,18 @@ rollback:
lex->tx_chain= $3;
lex->tx_release= $4;
}
| ROLLBACK_SYM opt_work
TO_SYM opt_savepoint ident
| ROLLBACK_SYM opt_work TO_SYM SAVEPOINT_SYM ident
{
LEX *lex=Lex;
lex->sql_command= SQLCOM_ROLLBACK_TO_SAVEPOINT;
lex->ident= $5;
}
| ROLLBACK_SYM opt_work TO_SYM ident
{
LEX *lex=Lex;
lex->sql_command= SQLCOM_ROLLBACK_TO_SAVEPOINT;
lex->ident= $4;
}
;
savepoint: