Bug #336 Subselects with tables does not work as values for local SP variables
Submitted: 27 Apr 2003 9:02 Modified: 4 Dec 2003 6:25
Reporter: Per-Erik Martin Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:5.0 OS:Any (all)
Assigned to: Per-Erik Martin CPU Architecture:Any

[27 Apr 2003 9:02] Per-Erik Martin
Description:
Assigning a local SP variables to a subselect that's using tables causes
a the server to crash.

How to repeat:
use test;

delimiter |;

drop table if exists t1|
drop table if exists t2|
drop procedure if exists sub2|

create table t1 (
	id   char(16) not null,
        data int not null
)|

create table t2 (
        data int not null
)|

insert into t2 values (1), (2), (3)|

create procedure sub2(id char(16))
begin
  declare x int;
  set x = (select sum(t.data) from test.t2 t);
  insert into test.t1 values (id, x);
end|

call sub2("foo")|
[4 Dec 2003 6:25] Per-Erik Martin
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Subselects as values for SET in an SP is disabled for the time being.
This can probably be made to work in the future, but at the first attempt
it turned out to be more involved than anticipated.
[24 Aug 2004 15:59] Per-Erik Martin
This has now been fixed.