Skip to content

Commit 4cda50a

Browse files
committed
Merge branch '10.4' into 10.5
2 parents 62a9a54 + ac20edd commit 4cda50a

File tree

5 files changed

+123
-5
lines changed

5 files changed

+123
-5
lines changed

mysql-test/main/ps.result

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5929,5 +5929,55 @@ a b
59295929
2 30
59305930
DROP TABLE t1, t2;
59315931
#
5932+
# MDEV-33549: Incorrect handling of UPDATE in PS mode in case a table's colum declared as NOT NULL
5933+
#
5934+
CREATE TABLE t1 (a INT, b INT DEFAULT NULL);
5935+
INSERT INTO t1 VALUES (20, 30);
5936+
EXECUTE IMMEDIATE 'UPDATE t1 SET b=?' USING DEFAULT;
5937+
SELECT * FROM t1;
5938+
a b
5939+
20 NULL
5940+
# Run twice the same update in PS mode to check
5941+
# that no memory relating issues taken place.
5942+
PREPARE stmt FROM 'UPDATE t1 SET b=?';
5943+
EXECUTE stmt USING DEFAULT;
5944+
EXECUTE stmt USING DEFAULT;
5945+
# Clean up
5946+
DEALLOCATE PREPARE stmt;
5947+
DROP TABLE t1;
5948+
# The same test for multi-table update
5949+
CREATE TABLE t1 (a INT, b INT DEFAULT NULL);
5950+
CREATE TABLE t2 (a INT, c INT DEFAULT NULL);
5951+
INSERT INTO t1 VALUES (20, 30);
5952+
INSERT INTO t2 VALUES (20, 30);
5953+
EXECUTE IMMEDIATE 'UPDATE t1,t2 SET b=? WHERE t1.a=t2.a' USING DEFAULT;
5954+
SELECT * FROM t1;
5955+
a b
5956+
20 NULL
5957+
# Run twice the same multi-table update in PS mode to check
5958+
# that no memory relating issues taken place.
5959+
PREPARE stmt FROM 'UPDATE t1,t2 SET b=? WHERE t1.a=t2.a';
5960+
EXECUTE stmt USING DEFAULT;
5961+
EXECUTE stmt USING DEFAULT;
5962+
DEALLOCATE PREPARE stmt;
5963+
# Clean up
5964+
DROP TABLE t1;
5965+
# This time checks that a default value for table's column
5966+
# represented by a function call is handled correctly on UPDATE in PS mode
5967+
CREATE TABLE t1 (a INT, b INT DEFAULT MOD(a, 3));
5968+
INSERT INTO t1 VALUES (20, 30);
5969+
EXECUTE IMMEDIATE 'UPDATE t1, t2 SET b=? WHERE t1.a=t2.a' USING DEFAULT;
5970+
SELECT * FROM t1;
5971+
a b
5972+
20 2
5973+
# Run twice the same multi-table update in PS mode to check
5974+
# that no memory relating issues taken place.
5975+
PREPARE stmt FROM 'UPDATE t1, t2 SET b=? WHERE t1.a=t2.a';
5976+
EXECUTE stmt USING DEFAULT;
5977+
EXECUTE stmt USING DEFAULT;
5978+
# Clean up
5979+
DEALLOCATE PREPARE stmt;
5980+
DROP TABLE t1, t2;
5981+
#
59325982
# End of 10.4 tests
59335983
#

mysql-test/main/ps.test

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5362,6 +5362,60 @@ SELECT * FROM t2;
53625362
# Cleanup
53635363
DROP TABLE t1, t2;
53645364

5365+
--echo #
5366+
--echo # MDEV-33549: Incorrect handling of UPDATE in PS mode in case a table's colum declared as NOT NULL
5367+
--echo #
5368+
5369+
CREATE TABLE t1 (a INT, b INT DEFAULT NULL);
5370+
INSERT INTO t1 VALUES (20, 30);
5371+
EXECUTE IMMEDIATE 'UPDATE t1 SET b=?' USING DEFAULT;
5372+
SELECT * FROM t1;
5373+
5374+
--echo # Run twice the same update in PS mode to check
5375+
--echo # that no memory relating issues taken place.
5376+
PREPARE stmt FROM 'UPDATE t1 SET b=?';
5377+
EXECUTE stmt USING DEFAULT;
5378+
EXECUTE stmt USING DEFAULT;
5379+
5380+
--echo # Clean up
5381+
DEALLOCATE PREPARE stmt;
5382+
DROP TABLE t1;
5383+
5384+
--echo # The same test for multi-table update
5385+
CREATE TABLE t1 (a INT, b INT DEFAULT NULL);
5386+
CREATE TABLE t2 (a INT, c INT DEFAULT NULL);
5387+
5388+
INSERT INTO t1 VALUES (20, 30);
5389+
INSERT INTO t2 VALUES (20, 30);
5390+
5391+
EXECUTE IMMEDIATE 'UPDATE t1,t2 SET b=? WHERE t1.a=t2.a' USING DEFAULT;
5392+
SELECT * FROM t1;
5393+
--echo # Run twice the same multi-table update in PS mode to check
5394+
--echo # that no memory relating issues taken place.
5395+
PREPARE stmt FROM 'UPDATE t1,t2 SET b=? WHERE t1.a=t2.a';
5396+
EXECUTE stmt USING DEFAULT;
5397+
EXECUTE stmt USING DEFAULT;
5398+
DEALLOCATE PREPARE stmt;
5399+
--echo # Clean up
5400+
DROP TABLE t1;
5401+
5402+
--echo # This time checks that a default value for table's column
5403+
--echo # represented by a function call is handled correctly on UPDATE in PS mode
5404+
CREATE TABLE t1 (a INT, b INT DEFAULT MOD(a, 3));
5405+
INSERT INTO t1 VALUES (20, 30);
5406+
EXECUTE IMMEDIATE 'UPDATE t1, t2 SET b=? WHERE t1.a=t2.a' USING DEFAULT;
5407+
SELECT * FROM t1;
5408+
5409+
--echo # Run twice the same multi-table update in PS mode to check
5410+
--echo # that no memory relating issues taken place.
5411+
PREPARE stmt FROM 'UPDATE t1, t2 SET b=? WHERE t1.a=t2.a';
5412+
EXECUTE stmt USING DEFAULT;
5413+
EXECUTE stmt USING DEFAULT;
5414+
5415+
--echo # Clean up
5416+
DEALLOCATE PREPARE stmt;
5417+
DROP TABLE t1, t2;
5418+
53655419
--echo #
53665420
--echo # End of 10.4 tests
53675421
--echo #

sql/item.cc

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5131,9 +5131,19 @@ bool Item_param::assign_default(Field *field)
51315131
}
51325132

51335133
if (m_default_field->default_value)
5134-
m_default_field->set_default();
5135-
5136-
return field_conv(field, m_default_field);
5134+
{
5135+
return m_default_field->default_value->expr->save_in_field(field, 0);
5136+
}
5137+
else if (m_default_field->is_null())
5138+
{
5139+
field->set_null();
5140+
return false;
5141+
}
5142+
else
5143+
{
5144+
field->set_notnull();
5145+
return field_conv(field, m_default_field);
5146+
}
51375147
}
51385148

51395149

sql/item.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3995,6 +3995,12 @@ class Item_param :public Item_basic_value,
39953995
Item_param(THD *thd, const LEX_CSTRING *name_arg,
39963996
uint pos_in_query_arg, uint len_in_query_arg);
39973997

3998+
void cleanup() override
3999+
{
4000+
m_default_field= NULL;
4001+
Item::cleanup();
4002+
}
4003+
39984004
Type type() const override
39994005
{
40004006
// Don't pretend to be a constant unless value for this item is set.

sql/mysqld.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2955,7 +2955,6 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused)))
29552955
sigset_t set;
29562956
int sig;
29572957
my_thread_init(); // Init new thread
2958-
DBUG_ENTER("signal_hand");
29592958
signal_thread_in_use= 1;
29602959

29612960
/*
@@ -3009,7 +3008,6 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused)))
30093008
{
30103009
DBUG_PRINT("quit",("signal_handler: calling my_thread_end()"));
30113010
my_thread_end();
3012-
DBUG_LEAVE; // Must match DBUG_ENTER()
30133011
signal_thread_in_use= 0;
30143012
pthread_exit(0); // Safety
30153013
return 0; // Avoid compiler warnings

0 commit comments

Comments
 (0)