Bug #44925 Foreign keys: funcs_1.memory/myisam_views test failures
Submitted: 18 May 2009 7:46 Modified: 28 May 2009 16:41
Reporter: Dmitry Lenev Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:6.1-fk OS:Any
Assigned to: Dmitry Lenev

[18 May 2009 7:46] Dmitry Lenev
Description:
funcs_1.memory_views and funcs_1.myisam_views tests are failing on server built from mysql-6.1-fk tree. Initial analysis shows that these failures are likely to be caused by changes in CREATE TABLE implementation introduced as part of new foreign keys work.

How to repeat:
Run funcs_1.memory_views or funcs_1.myisam_views test on server mysql-6.1-fk tree
and you will get something like:

==============================================================================

TEST                                      RESULT   TIME (ms)
------------------------------------------------------------

funcs_1.memory_views                     [ fail ]
        Test ended at 2009-05-18 11:44:43

CURRENT_TEST: funcs_1.memory_views
mysqltest: In included file "./suite/funcs_1/views/views_master.inc": At line 726: query 'Create table test.v111(f1 int )' succeeded - should have failed with errno 1050...

The result from queries just before the failure was:
< snip >
DROP VIEW  v1;
DROP TABLE t1;

Testcase 3.3.1.10 
--------------------------------------------------------------------------------
Drop view if exists test.v1 ;
Create view test.v1 AS Select * from test.tb2 ;
Create view test.v1 AS Select F59 from test.tb2 ;
ERROR 42S01: Table 'v1' already exists
Create view      v1 AS Select F59 from test.tb2 ;
ERROR 42S01: Table 'v1' already exists

Testcase 3.3.1.11 
--------------------------------------------------------------------------------
Create view test.tb2 AS Select f59,f60 from test.tb2 limit 100 ;
ERROR 42S01: Table 'tb2' already exists
Create view      tb2 AS Select f59,f60 from test.tb2 limit 100 ;
ERROR 42S01: Table 'tb2' already exists
Drop view if exists test.v111 ;
Create view test.v111 as select * from tb2 limit 50;
[28 May 2009 15:14] 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/commits/75165

2721 Dmitry Lenev	2009-05-28
      Fix for bug #44925 "Foreign keys: funcs_1.memory/myisam_views test
      failures".
      
      In mysql-6.1-fk tree tests memory_views and myisam_views in funcs_1
      suite were failing because CREATE TABLE statement failed to detect 
      that there is already existing view with the same name as table 
      being created in case when this view was processed with the help
      of derived table mechanism.
      
      In the process of implementing support for new foreign keys the way
      in which CREATE TABLE performs metadata and table locking was changed
      to be similar to how it is done in CREATE TABLE ... SELECT. 
      In particular, now it either opens and locks target table (i.e. one
      to be created) or obtains exclusive metadata lock on it. In cases
      when target table happened to be a view which was resolved through
      derived table, code responsible for derived table processing changed
      table_name member in element of table list representing target table
      to be the name of corresponding temporary table. And such a 'wrong'
      table name caused check for the target table existence which occured 
      later to return wrong results (i.e. that table didn't exist).
      
      This fix simply disables processing of derived tables when opening
      tables for ordinary CREATE TABLE. We are not using results of such 
      processing in any way and doing so allows to avoid 'corrupting'
      table list element for target table and therefore confusing code
      performing check for table existence.
[28 May 2009 16:41] Dmitry Lenev
Fix for this bug was pushed into mysql-6.1-fk tree. Since this bug was reported against tree which is not publicly available yet I am simply closing this bug.