Skip to content

Commit

Permalink
Merge branch '10.4' into 10.5
Browse files Browse the repository at this point in the history
  • Loading branch information
vuvova committed Mar 13, 2024
2 parents 62a9a54 + ac20edd commit 4cda50a
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 5 deletions.
50 changes: 50 additions & 0 deletions mysql-test/main/ps.result
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
54 changes: 54 additions & 0 deletions mysql-test/main/ps.test
Original file line number Diff line number Diff line change
Expand Up @@ -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 #
16 changes: 13 additions & 3 deletions sql/item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}


Expand Down
6 changes: 6 additions & 0 deletions sql/item.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 0 additions & 2 deletions sql/mysqld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/*
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4cda50a

Please sign in to comment.