Commit df2d6782 authored by Oleksandr Byelkin's avatar Oleksandr Byelkin

MDEV-15133: array bound (bulk) parameters of NULL propagate on next rows

Setting non_null value drops null_value flag.
Part 2 of 3.
Part 1 was 10.2 fix.
Part 3 is test for Connector C.
parent e300f0c9
...@@ -1738,7 +1738,7 @@ execute stmt using @a; ...@@ -1738,7 +1738,7 @@ execute stmt using @a;
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`?` decimal(2,1) DEFAULT NULL `?` decimal(2,1) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
drop table if exists t1; drop table if exists t1;
...@@ -4432,7 +4432,7 @@ EXECUTE stmt USING 10.123; ...@@ -4432,7 +4432,7 @@ EXECUTE stmt USING 10.123;
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`c1` decimal(5,3) DEFAULT NULL `c1` decimal(5,3) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1; DROP TABLE t1;
EXECUTE stmt USING 10.123e0; EXECUTE stmt USING 10.123e0;
...@@ -4446,49 +4446,49 @@ EXECUTE stmt USING CURRENT_DATE; ...@@ -4446,49 +4446,49 @@ EXECUTE stmt USING CURRENT_DATE;
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`c1` date DEFAULT NULL `c1` date NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1; DROP TABLE t1;
EXECUTE stmt USING CURRENT_TIMESTAMP; EXECUTE stmt USING CURRENT_TIMESTAMP;
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`c1` datetime DEFAULT NULL `c1` datetime NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1; DROP TABLE t1;
EXECUTE stmt USING CURRENT_TIMESTAMP(3); EXECUTE stmt USING CURRENT_TIMESTAMP(3);
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`c1` datetime(3) DEFAULT NULL `c1` datetime(3) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1; DROP TABLE t1;
EXECUTE stmt USING CURRENT_TIMESTAMP(6); EXECUTE stmt USING CURRENT_TIMESTAMP(6);
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`c1` datetime(6) DEFAULT NULL `c1` datetime(6) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1; DROP TABLE t1;
EXECUTE stmt USING CURRENT_TIME; EXECUTE stmt USING CURRENT_TIME;
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`c1` time DEFAULT NULL `c1` time NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1; DROP TABLE t1;
EXECUTE stmt USING CURRENT_TIME(3); EXECUTE stmt USING CURRENT_TIME(3);
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`c1` time(3) DEFAULT NULL `c1` time(3) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1; DROP TABLE t1;
EXECUTE stmt USING CURRENT_TIME(6); EXECUTE stmt USING CURRENT_TIME(6);
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`c1` time(6) DEFAULT NULL `c1` time(6) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1; DROP TABLE t1;
DEALLOCATE PREPARE stmt; DEALLOCATE PREPARE stmt;
...@@ -4633,7 +4633,7 @@ SHOW CREATE TABLE t1; ...@@ -4633,7 +4633,7 @@ SHOW CREATE TABLE t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` bigint(20) NOT NULL, `a` bigint(20) NOT NULL,
`b` decimal(3,1) DEFAULT NULL, `b` decimal(3,1) NOT NULL,
`c` double NOT NULL, `c` double NOT NULL,
`d` tinytext NOT NULL `d` tinytext NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
...@@ -4645,7 +4645,7 @@ SHOW CREATE TABLE t1; ...@@ -4645,7 +4645,7 @@ SHOW CREATE TABLE t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(2) NOT NULL, `a` int(2) NOT NULL,
`b` decimal(3,1) DEFAULT NULL, `b` decimal(3,1) NOT NULL,
`c` double NOT NULL, `c` double NOT NULL,
`d` varchar(3) NOT NULL `d` varchar(3) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
...@@ -4660,11 +4660,11 @@ TIMESTAMP'2001-01-01 10:20:30.123'; ...@@ -4660,11 +4660,11 @@ TIMESTAMP'2001-01-01 10:20:30.123';
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`t1` time DEFAULT NULL, `t1` time NOT NULL,
`t2` time(3) DEFAULT NULL, `t2` time(3) NOT NULL,
`d1` date DEFAULT NULL, `d1` date NOT NULL,
`dt1` datetime DEFAULT NULL, `dt1` datetime NOT NULL,
`dt2` datetime(3) DEFAULT NULL `dt2` datetime(3) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1; DROP TABLE t1;
# #
......
...@@ -3757,7 +3757,10 @@ Item_param::Item_param(THD *thd, const LEX_CSTRING *name_arg, ...@@ -3757,7 +3757,10 @@ Item_param::Item_param(THD *thd, const LEX_CSTRING *name_arg,
void Item_param::set_null() void Item_param::set_null()
{ {
DBUG_ENTER("Item_param::set_null"); DBUG_ENTER("Item_param::set_null");
/* These are cleared after each execution by reset() method */ /*
These are cleared after each execution by reset() method or by setting
other value.
*/
null_value= 1; null_value= 1;
/* /*
Because of NULL and string values we need to set max_length for each new Because of NULL and string values we need to set max_length for each new
...@@ -3846,6 +3849,7 @@ void Item_param::set_decimal(const my_decimal *dv, bool unsigned_arg) ...@@ -3846,6 +3849,7 @@ void Item_param::set_decimal(const my_decimal *dv, bool unsigned_arg)
unsigned_flag= unsigned_arg; unsigned_flag= unsigned_arg;
max_length= my_decimal_precision_to_length(value.m_decimal.intg + decimals, max_length= my_decimal_precision_to_length(value.m_decimal.intg + decimals,
decimals, unsigned_flag); decimals, unsigned_flag);
maybe_null= 0;
null_value= 0; null_value= 0;
fix_type(Item::DECIMAL_ITEM); fix_type(Item::DECIMAL_ITEM);
} }
...@@ -3857,6 +3861,8 @@ void Item_param::fix_temporal(uint32 max_length_arg, uint decimals_arg) ...@@ -3857,6 +3861,8 @@ void Item_param::fix_temporal(uint32 max_length_arg, uint decimals_arg)
collation.set_numeric(); collation.set_numeric();
max_length= max_length_arg; max_length= max_length_arg;
decimals= decimals_arg; decimals= decimals_arg;
maybe_null= 0;
null_value= 0;
fix_type(Item::DATE_ITEM); fix_type(Item::DATE_ITEM);
} }
...@@ -3866,6 +3872,7 @@ void Item_param::set_time(const MYSQL_TIME *tm, ...@@ -3866,6 +3872,7 @@ void Item_param::set_time(const MYSQL_TIME *tm,
{ {
DBUG_ASSERT(value.type_handler()->cmp_type() == TIME_RESULT); DBUG_ASSERT(value.type_handler()->cmp_type() == TIME_RESULT);
value.time= *tm; value.time= *tm;
maybe_null= 0;
null_value= 0; null_value= 0;
fix_temporal(max_length_arg, decimals_arg); fix_temporal(max_length_arg, decimals_arg);
} }
...@@ -4634,7 +4641,9 @@ Item_param::set_value(THD *thd, sp_rcontext *ctx, Item **it) ...@@ -4634,7 +4641,9 @@ Item_param::set_value(THD *thd, sp_rcontext *ctx, Item **it)
set_null(); set_null();
return false; return false;
} }
return null_value= false; /* It is wrapper => other set_* shoud set null_value */
DBUG_ASSERT(null_value == false);
return false;
} }
......
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