Commit 4cda50af authored by Sergei Golubchik's avatar Sergei Golubchik

Merge branch '10.4' into 10.5

parents 62a9a54a ac20edd7
......@@ -5929,5 +5929,55 @@ a b
2 30
DROP TABLE t1, t2;
#
# MDEV-33549: Incorrect handling of UPDATE in PS mode in case a table's colum declared as NOT NULL
#
CREATE TABLE t1 (a INT, b INT DEFAULT NULL);
INSERT INTO t1 VALUES (20, 30);
EXECUTE IMMEDIATE 'UPDATE t1 SET b=?' USING DEFAULT;
SELECT * FROM t1;
a b
20 NULL
# Run twice the same update in PS mode to check
# that no memory relating issues taken place.
PREPARE stmt FROM 'UPDATE t1 SET b=?';
EXECUTE stmt USING DEFAULT;
EXECUTE stmt USING DEFAULT;
# Clean up
DEALLOCATE PREPARE stmt;
DROP TABLE t1;
# The same test for multi-table update
CREATE TABLE t1 (a INT, b INT DEFAULT NULL);
CREATE TABLE t2 (a INT, c INT DEFAULT NULL);
INSERT INTO t1 VALUES (20, 30);
INSERT INTO t2 VALUES (20, 30);
EXECUTE IMMEDIATE 'UPDATE t1,t2 SET b=? WHERE t1.a=t2.a' USING DEFAULT;
SELECT * FROM t1;
a b
20 NULL
# Run twice the same multi-table update in PS mode to check
# that no memory relating issues taken place.
PREPARE stmt FROM 'UPDATE t1,t2 SET b=? WHERE t1.a=t2.a';
EXECUTE stmt USING DEFAULT;
EXECUTE stmt USING DEFAULT;
DEALLOCATE PREPARE stmt;
# Clean up
DROP TABLE t1;
# This time checks that a default value for table's column
# represented by a function call is handled correctly on UPDATE in PS mode
CREATE TABLE t1 (a INT, b INT DEFAULT MOD(a, 3));
INSERT INTO t1 VALUES (20, 30);
EXECUTE IMMEDIATE 'UPDATE t1, t2 SET b=? WHERE t1.a=t2.a' USING DEFAULT;
SELECT * FROM t1;
a b
20 2
# Run twice the same multi-table update in PS mode to check
# that no memory relating issues taken place.
PREPARE stmt FROM 'UPDATE t1, t2 SET b=? WHERE t1.a=t2.a';
EXECUTE stmt USING DEFAULT;
EXECUTE stmt USING DEFAULT;
# Clean up
DEALLOCATE PREPARE stmt;
DROP TABLE t1, t2;
#
# End of 10.4 tests
#
......@@ -5362,6 +5362,60 @@ SELECT * FROM t2;
# Cleanup
DROP TABLE t1, t2;
--echo #
--echo # MDEV-33549: Incorrect handling of UPDATE in PS mode in case a table's colum declared as NOT NULL
--echo #
CREATE TABLE t1 (a INT, b INT DEFAULT NULL);
INSERT INTO t1 VALUES (20, 30);
EXECUTE IMMEDIATE 'UPDATE t1 SET b=?' USING DEFAULT;
SELECT * FROM t1;
--echo # Run twice the same update in PS mode to check
--echo # that no memory relating issues taken place.
PREPARE stmt FROM 'UPDATE t1 SET b=?';
EXECUTE stmt USING DEFAULT;
EXECUTE stmt USING DEFAULT;
--echo # Clean up
DEALLOCATE PREPARE stmt;
DROP TABLE t1;
--echo # The same test for multi-table update
CREATE TABLE t1 (a INT, b INT DEFAULT NULL);
CREATE TABLE t2 (a INT, c INT DEFAULT NULL);
INSERT INTO t1 VALUES (20, 30);
INSERT INTO t2 VALUES (20, 30);
EXECUTE IMMEDIATE 'UPDATE t1,t2 SET b=? WHERE t1.a=t2.a' USING DEFAULT;
SELECT * FROM t1;
--echo # Run twice the same multi-table update in PS mode to check
--echo # that no memory relating issues taken place.
PREPARE stmt FROM 'UPDATE t1,t2 SET b=? WHERE t1.a=t2.a';
EXECUTE stmt USING DEFAULT;
EXECUTE stmt USING DEFAULT;
DEALLOCATE PREPARE stmt;
--echo # Clean up
DROP TABLE t1;
--echo # This time checks that a default value for table's column
--echo # represented by a function call is handled correctly on UPDATE in PS mode
CREATE TABLE t1 (a INT, b INT DEFAULT MOD(a, 3));
INSERT INTO t1 VALUES (20, 30);
EXECUTE IMMEDIATE 'UPDATE t1, t2 SET b=? WHERE t1.a=t2.a' USING DEFAULT;
SELECT * FROM t1;
--echo # Run twice the same multi-table update in PS mode to check
--echo # that no memory relating issues taken place.
PREPARE stmt FROM 'UPDATE t1, t2 SET b=? WHERE t1.a=t2.a';
EXECUTE stmt USING DEFAULT;
EXECUTE stmt USING DEFAULT;
--echo # Clean up
DEALLOCATE PREPARE stmt;
DROP TABLE t1, t2;
--echo #
--echo # End of 10.4 tests
--echo #
......@@ -5131,9 +5131,19 @@ bool Item_param::assign_default(Field *field)
}
if (m_default_field->default_value)
m_default_field->set_default();
return field_conv(field, m_default_field);
{
return m_default_field->default_value->expr->save_in_field(field, 0);
}
else if (m_default_field->is_null())
{
field->set_null();
return false;
}
else
{
field->set_notnull();
return field_conv(field, m_default_field);
}
}
......
......@@ -3995,6 +3995,12 @@ class Item_param :public Item_basic_value,
Item_param(THD *thd, const LEX_CSTRING *name_arg,
uint pos_in_query_arg, uint len_in_query_arg);
void cleanup() override
{
m_default_field= NULL;
Item::cleanup();
}
Type type() const override
{
// Don't pretend to be a constant unless value for this item is set.
......
......@@ -2955,7 +2955,6 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused)))
sigset_t set;
int sig;
my_thread_init(); // Init new thread
DBUG_ENTER("signal_hand");
signal_thread_in_use= 1;
/*
......@@ -3009,7 +3008,6 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused)))
{
DBUG_PRINT("quit",("signal_handler: calling my_thread_end()"));
my_thread_end();
DBUG_LEAVE; // Must match DBUG_ENTER()
signal_thread_in_use= 0;
pthread_exit(0); // Safety
return 0; // Avoid compiler warnings
......
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