diff options
-rw-r--r-- | mysql-test/main/sp-anchor-row-type-table.result | 44 | ||||
-rw-r--r-- | mysql-test/main/sp-anchor-row-type-table.test | 55 | ||||
-rw-r--r-- | sql/field.cc | 3 |
3 files changed, 102 insertions, 0 deletions
diff --git a/mysql-test/main/sp-anchor-row-type-table.result b/mysql-test/main/sp-anchor-row-type-table.result index c28d26304db..5e3b655a75b 100644 --- a/mysql-test/main/sp-anchor-row-type-table.result +++ b/mysql-test/main/sp-anchor-row-type-table.result @@ -814,3 +814,47 @@ t2 CREATE TABLE `t2` ( `text0` text DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci DROP TABLE t1; +# +# End of 10.3 tests +# +# +# Start of 10.4 tests +# +# +# MDEV-31250 ROW variables do not get assigned from subselects +# +CREATE TABLE t1 (a INT, b TEXT); +INSERT INTO t1 VALUES (1,'b1'); +BEGIN NOT ATOMIC +DECLARE r ROW TYPE OF t1; +SELECT * INTO r FROM t1 WHERE a=1; +SELECT r.a, r.b; +END; +$$ +r.a r.b +1 b1 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b TEXT); +INSERT INTO t1 VALUES (1,'b1'); +BEGIN NOT ATOMIC +DECLARE r ROW TYPE OF t1; +SET r=(SELECT * FROM t1 WHERE a=1); +SELECT r.a, r.b; +END; +$$ +r.a r.b +1 b1 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b TEXT); +INSERT INTO t1 VALUES (1,'b1'); +BEGIN NOT ATOMIC +DECLARE r ROW TYPE OF t1 DEFAULT (SELECT * FROM t1 WHERE a=1); +SELECT r.a, r.b; +END; +$$ +r.a r.b +1 b1 +DROP TABLE t1; +# +# End of 10.4 tests +# diff --git a/mysql-test/main/sp-anchor-row-type-table.test b/mysql-test/main/sp-anchor-row-type-table.test index 3f04dc68586..213460ed38f 100644 --- a/mysql-test/main/sp-anchor-row-type-table.test +++ b/mysql-test/main/sp-anchor-row-type-table.test @@ -881,3 +881,58 @@ END; $$ DELIMITER ;$$ DROP TABLE t1; + +--echo # +--echo # End of 10.3 tests +--echo # + + +--echo # +--echo # Start of 10.4 tests +--echo # + +--echo # +--echo # MDEV-31250 ROW variables do not get assigned from subselects +--echo # + +CREATE TABLE t1 (a INT, b TEXT); +INSERT INTO t1 VALUES (1,'b1'); +DELIMITER $$; +BEGIN NOT ATOMIC + DECLARE r ROW TYPE OF t1; + SELECT * INTO r FROM t1 WHERE a=1; + SELECT r.a, r.b; +END; +$$ +DELIMITER ;$$ +DROP TABLE t1; + + +CREATE TABLE t1 (a INT, b TEXT); +INSERT INTO t1 VALUES (1,'b1'); +DELIMITER $$; +BEGIN NOT ATOMIC + DECLARE r ROW TYPE OF t1; + SET r=(SELECT * FROM t1 WHERE a=1); + SELECT r.a, r.b; +END; +$$ +DELIMITER ;$$ +DROP TABLE t1; + + +CREATE TABLE t1 (a INT, b TEXT); +INSERT INTO t1 VALUES (1,'b1'); +DELIMITER $$; +BEGIN NOT ATOMIC + DECLARE r ROW TYPE OF t1 DEFAULT (SELECT * FROM t1 WHERE a=1); + SELECT r.a, r.b; +END; +$$ +DELIMITER ;$$ +DROP TABLE t1; + + +--echo # +--echo # End of 10.4 tests +--echo # diff --git a/sql/field.cc b/sql/field.cc index 14252033a01..ff45b6c5de9 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -2543,6 +2543,8 @@ bool Field_row::sp_prepare_and_store_item(THD *thd, Item **value) fixed underlying Item_field pointing to Field_row. - In case if we're assigning from a ROW() value, src and value[0] will point to the same Item_row. + - In case if we're assigning from a subselect, src and value[0] also + point to the same Item_singlerow_subselect. */ Item *src; if (!(src= thd->sp_fix_func_item(value)) || @@ -2554,6 +2556,7 @@ bool Field_row::sp_prepare_and_store_item(THD *thd, Item **value) DBUG_RETURN(true); } + src->bring_value(); DBUG_RETURN(m_table->sp_set_all_fields_from_item(thd, src)); } |