Bug #9842 Views:Any operation on a view created with merge option crashes mysql service.
Submitted: 12 Apr 2005 12:14 Modified: 17 May 2005 12:58
Reporter: Disha Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.0.3 Beta OS:Any (*)
Assigned to: Ingo Strüwing CPU Architecture:Any

[12 Apr 2005 12:14] Disha
Description:
IF we create a view using other two view (which are editable) and while creating the view we use the algorithm=merge option to explicitly set the view as editable, then the view is created but when trying to access the view the server crashes.

How to repeat:
Repro Steps: 
1. Start the MySQL client and connect to the database with valid user and password.
1. Select the TEST database with the USE command and set the delimiter to // as follows:
USE TEST
DELIMITER //
3. Run the following commands to create and populate tables.

drop table if exists t1//
create table t1(f1 char(0), f2 decimal (64) unsigned not null DEFAULT 9.9, f3 tinyint, f5 int)//
insert into t1(f2,f3,f5) values(1,1,1),(2,2,2),(3,3,0),(4,4,4),(5,5,5),(6,6,6),(7,7,0),(8,8,8),(9,9,9),(10,10,10)//

drop table if exists t2//
create table t2(f4 char binary, f5 int)//
insert into t2 values('a',1),('a',2),('a',0),('a',4),('a',5),('a',6),('a',0),('a',8),('a',9),('a',10)//

4. Now create the three views as follows:

drop view if exists v1//
create algorithm=merge view v1 as select t1.f1, t1.f2, t1.f3, t2.f4, t2.f5 from t1 inner join t2 using (f5)//
drop view if exists v2//
create algorithm=merge view v2 as select t1.f1, t1.f2, t1.f3, t2.f4, t2.f5 from t1 inner join t2 using (f5)//
drop view if exists v3//
create algorithm=merge view v3 as select v1.f1, v1.f2, v1.f3, v2.f4, v2.f5 from v1 inner join v2 using (f5)//

5. Now using the select statement list the values from each view as follows:

select * from v1//
select * from v2//
select * from v3//

Expected Results: 
1. Error should be displayed for the create view statement of view v3 as it cannot be editable/updatable.

Actual Results: 
1. No error is displayed for the create view statement of view v3 and when the select statement is executed for v3 the MySQL server service crashes and the connection is lost.

Attachments:
1. Please refer to the attached text file with the command output:
'Any operation on a view - Command output.txt'
[12 Apr 2005 12:15] Disha
Command output attached

Attachment: Any operation on a view - Command output.txt (text/plain), 2.93 KiB.

[12 Apr 2005 15:13] Geert Vanderkelen
Hi,

Thank you for this report. I could indeed reproduce it using 5.0.3beta, and the latest pull.
Looks like it happens with views of a view having a join, when selecting from it.

resolve_stack_dump output:
----------
0x818d28c handle_segfault + 588
0xffffe420 _end + -139617812
0x89e26b0 _end + 4971644
0x8295b32 _Z20mysql_handle_derivedP6st_lexPFiP3THDS0_P13st_table_listE + 82
0x81ce7e5 _Z20open_and_lock_tablesP3THDP13st_table_list + 101
0x81abc71 _Z21mysql_execute_commandP3THD + 29889
----------

Regards,

Geert
[6 May 2005 15:09] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/24583
[17 May 2005 12:58] Michael Widenius
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

Additional info:

This bug was fixed when bug #8528 was fixed
Fix will be in 5.0.6