List:Commits« Previous MessageNext Message »
From:Martin Skold Date:January 25 2011 9:43am
Subject:bzr commit into mysql-5.1-telco-6.2 branch (Martin.Skold:3143) Bug#57437
View as plain text  
#At file:///home/marty/MySQL/mysql-5.1-telco-6.2/

 3143 Martin Skold	2011-01-25
      Bug#57437 CREATE TEMPORARY TABLE LIKE with ENGINE=NDBCluster causes mysqld crash?: Catch attempt to define temporary table in create method and return error
      modified:
        mysql-test/suite/ndb/r/ndb_temporary.result
        mysql-test/suite/ndb/t/ndb_temporary.test
        sql/ha_ndbcluster.cc
        sql/sql_table.cc

=== modified file 'mysql-test/suite/ndb/r/ndb_temporary.result'
--- a/mysql-test/suite/ndb/r/ndb_temporary.result	2007-08-02 22:14:05 +0000
+++ b/mysql-test/suite/ndb/r/ndb_temporary.result	2011-01-25 09:43:16 +0000
@@ -5,6 +5,10 @@ create temporary table t1 (a int key) en
 alter table t1 engine=ndb;
 ERROR HY000: Table storage engine 'ndbcluster' does not support the create option 'TEMPORARY'
 drop table t1;
+CREATE TABLE bar ( id TINYINT NOT NULL AUTO_INCREMENT PRIMARY KEY ) ENGINE=NDBCluster ;
+CREATE TEMPORARY TABLE foo LIKE bar ;
+ERROR HY000: Can't create table 'test.foo' (errno: 1478)
+DROP TABLE bar;
 SET SESSION storage_engine=NDBCLUSTER;
 create table t1 (a int key);
 select engine from information_schema.tables where table_name = 't1';

=== modified file 'mysql-test/suite/ndb/t/ndb_temporary.test'
--- a/mysql-test/suite/ndb/t/ndb_temporary.test	2007-07-04 20:38:53 +0000
+++ b/mysql-test/suite/ndb/t/ndb_temporary.test	2011-01-25 09:43:16 +0000
@@ -22,6 +22,14 @@ drop table t1;
 
 
 #
+# create temporary like on an ndb table should give an error (bug#57437)
+#
+CREATE TABLE bar ( id TINYINT NOT NULL AUTO_INCREMENT PRIMARY KEY ) ENGINE=NDBCluster ;
+--error ER_CANT_CREATE_TABLE
+CREATE TEMPORARY TABLE foo LIKE bar ;
+DROP TABLE bar;
+
+#
 # if default storage engine=ndb, temporary tables
 # without explicit engine= should be created as myisam
 #

=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc	2010-12-15 13:43:54 +0000
+++ b/sql/ha_ndbcluster.cc	2011-01-25 09:43:16 +0000
@@ -5604,6 +5604,7 @@ int ha_ndbcluster::create(const char *na
   size_t pack_length, length;
   uint i, pk_length= 0;
   uchar *data= NULL, *pack_data= NULL;
+  bool create_temporary= (create_info->options & HA_LEX_CREATE_TMP_TABLE);
   bool create_from_engine= (create_info->table_options & HA_OPTION_CREATE_FROM_ENGINE);
   bool is_truncate= (thd->lex->sql_command == SQLCOM_TRUNCATE);
   const char *tablespace= create_info->tablespace;
@@ -5613,6 +5614,19 @@ int ha_ndbcluster::create(const char *na
   DBUG_ENTER("ha_ndbcluster::create");
   DBUG_PRINT("enter", ("name: %s", name));
 
+  if (create_temporary)
+  {
+    /*
+      Ndb does not support temporary tables
+     */
+    my_errno= ER_ILLEGAL_HA_CREATE_OPTION;
+    DBUG_PRINT("info", ("Ndb doesn't support temporary tables"));
+    push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+                        ER_ILLEGAL_HA_CREATE_OPTION,
+                        "Ndb doesn't support temporary tables");
+    DBUG_RETURN(my_errno);
+  }
+
   DBUG_ASSERT(*fn_rext((char*)name) == 0);
   set_dbname(name);
   set_tabname(name);

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2010-10-06 10:06:47 +0000
+++ b/sql/sql_table.cc	2011-01-25 09:43:16 +0000
@@ -5399,9 +5399,9 @@ bool mysql_create_like_table(THD* thd, T
   err= ha_create_table(thd, dst_path, db, table_name, create_info, 1);
   VOID(pthread_mutex_unlock(&LOCK_open));
 
-  if (create_info->options & HA_LEX_CREATE_TMP_TABLE)
+  if (!err && create_info->options & HA_LEX_CREATE_TMP_TABLE)
   {
-    if (err || !open_temporary_table(thd, dst_path, db, table_name, 1,
+    if (!open_temporary_table(thd, dst_path, db, table_name, 1,
                                      OTM_OPEN))
     {
       (void) rm_temporary_table(create_info->db_type,

Thread
bzr commit into mysql-5.1-telco-6.2 branch (Martin.Skold:3143) Bug#57437Martin Skold25 Jan