List:Commits« Previous MessageNext Message »
From:Georgi Kodinov Date:June 13 2011 4:50pm
Subject:bzr commit into mysql-trunk branch (Georgi.Kodinov:3196) Bug#11757216
View as plain text  
#At file:///Users/kgeorge/mysql/work/B11757216-trunk/ based on revid:mattias.jonsson@stripped

 3196 Georgi Kodinov	2011-06-13
      BUG# 11757216: 49232: --STORAGE-ENGINE SHOULD BE DECOUPLED FROM 
      DEFAULT TEMPTABLE TYPE
      
      Implemented a --default-temp-storage_engine variable to complement the 
      --default-storage-engine.
      It's default value is the same as of --default-storage-engine.
      But it's totally independent from --default-storage-engine.
      The value of --default-temp-storage-engine affects only the tables created 
      by CREATE TEMPORARY TABLE. All other internally created temp tables are not 
      affected by it.
      The special storage engine name "DEFAULT", when applied to such temporary
      tables work as an alias of the default temp table storage engine.
      Extended mysql-test-run.pl to issue --default-temp-storage-engine=myisam
      as a complement to --default-storage-engine=myisam.
      
      Test case added. 
      Affected test cases updated.

    added:
      mysql-test/suite/sys_vars/r/default_temp_storage_engine_basic.result
      mysql-test/suite/sys_vars/t/default_temp_storage_engine_basic.test
    modified:
      mysql-test/lib/mtr_cases.pm
      mysql-test/mysql-test-run.pl
      mysql-test/r/mysqld--help-notwin.result
      mysql-test/r/mysqld--help-win.result
      mysql-test/suite/binlog/t/binlog_row_mix_innodb_myisam-master.opt
      mysql-test/suite/binlog/t/binlog_stm_mix_innodb_myisam-master.opt
      mysql-test/t/bootstrap-master.opt
      mysql-test/t/bootstrap.test
      mysql-test/t/ctype_utf8mb4-master.opt
      sql/handler.cc
      sql/handler.h
      sql/mysqld.cc
      sql/mysqld.h
      sql/sql_class.h
      sql/sql_plugin.cc
      sql/sql_table.cc
      sql/sql_yacc.yy
      sql/sys_vars.cc
      sql/sys_vars.h
      sql/table.cc
=== modified file 'mysql-test/lib/mtr_cases.pm'
--- a/mysql-test/lib/mtr_cases.pm	2011-05-24 10:07:40 +0000
+++ b/mysql-test/lib/mtr_cases.pm	2011-06-13 16:49:58 +0000
@@ -613,9 +613,12 @@ sub optimize_cases {
     foreach my $opt ( @{$tinfo->{master_opt}} ) {
       my $default_engine=
 	mtr_match_prefix($opt, "--default-storage-engine=");
+      my $default_temp_engine=
+	mtr_match_prefix($opt, "--default-temp-storage-engine=");
 
       # Allow use of uppercase, convert to all lower case
       $default_engine =~ tr/A-Z/a-z/;
+      $default_temp_engine =~ tr/A-Z/a-z/;
 
       if (defined $default_engine){
 
@@ -638,6 +641,27 @@ sub optimize_cases {
 	$tinfo->{'innodb_test'}= 1
 	  if ( $default_engine =~ /^innodb/i );
       }
+      if (defined $default_temp_engine){
+
+	#print " $tinfo->{name}\n";
+	#print " - The test asked to use '$default_engine'\n";
+
+	#my $engine_value= $::mysqld_variables{$default_engine};
+	#print " - The mysqld_variables says '$engine_value'\n";
+
+	if ( ! exists $::mysqld_variables{$default_temp_engine} and
+	     ! exists $builtin_engines{$default_temp_engine} )
+	{
+	  $tinfo->{'skip'}= 1;
+	  $tinfo->{'comment'}=
+	    "'$default_temp_engine' not supported";
+	}
+
+	$tinfo->{'ndb_test'}= 1
+	  if ( $default_temp_engine =~ /^ndb/i );
+	$tinfo->{'innodb_test'}= 1
+	  if ( $default_temp_engine =~ /^innodb/i );
+      }
     }
 
     if ($quick_collect && ! $tinfo->{'skip'})
@@ -987,6 +1011,8 @@ sub collect_one_test_case {
     # the default storage engine is innodb.
     push(@{$tinfo->{'master_opt'}}, "--default-storage-engine=MyISAM");
     push(@{$tinfo->{'slave_opt'}}, "--default-storage-engine=MyISAM");
+    push(@{$tinfo->{'master_opt'}}, "--default-temp-storage-engine=MyISAM");
+    push(@{$tinfo->{'slave_opt'}}, "--default-temp-storage-engine=MyISAM");
   }
 
   if ( $tinfo->{'need_binlog'} )

=== modified file 'mysql-test/mysql-test-run.pl'
--- a/mysql-test/mysql-test-run.pl	2011-05-30 14:00:14 +0000
+++ b/mysql-test/mysql-test-run.pl	2011-06-13 16:49:58 +0000
@@ -1367,6 +1367,12 @@ sub command_line_setup {
       collect_option('default-storage-engine', $1);
       mtr_report("Using default engine '$1'")
     }
+    if ( $arg =~ /default-temp-storage-engine=(\S+)/ )
+    {
+      # Save this for collect phase
+      collect_option('default-temp-storage-engine', $1);
+      mtr_report("Using default temp engine '$1'")
+    }
   }
 
   if (IS_WINDOWS and defined $opt_mem) {

=== modified file 'mysql-test/r/mysqld--help-notwin.result'
--- a/mysql-test/r/mysqld--help-notwin.result	2011-05-26 05:50:01 +0000
+++ b/mysql-test/r/mysqld--help-notwin.result	2011-06-13 16:49:58 +0000
@@ -123,6 +123,9 @@ The following options may be given as th
  The DATETIME format (ignored)
  --default-storage-engine=name 
  The default storage engine for new tables
+ --default-temp-storage-engine=name 
+ The default storage engine for new explict temporary
+ tables
  --default-time-zone=name 
  Set the default time zone.
  --default-week-format=# 
@@ -789,6 +792,7 @@ console FALSE
 date-format %Y-%m-%d
 datetime-format %Y-%m-%d %H:%i:%s
 default-storage-engine InnoDB
+default-temp-storage-engine InnoDB
 default-time-zone (No default value)
 default-week-format 0
 delay-key-write ON

=== modified file 'mysql-test/r/mysqld--help-win.result'
--- a/mysql-test/r/mysqld--help-win.result	2011-05-26 05:50:01 +0000
+++ b/mysql-test/r/mysqld--help-win.result	2011-06-13 16:49:58 +0000
@@ -123,6 +123,9 @@ The following options may be given as th
  The DATETIME format (ignored)
  --default-storage-engine=name 
  The default storage engine for new tables
+ --default-temp-storage-engine=name 
+ The default storage engine for new explict temporary
+ tables
  --default-time-zone=name 
  Set the default time zone.
  --default-week-format=# 
@@ -793,6 +796,7 @@ console FALSE
 date-format %Y-%m-%d
 datetime-format %Y-%m-%d %H:%i:%s
 default-storage-engine InnoDB
+default-temp-storage-engine InnoDB
 default-time-zone (No default value)
 default-week-format 0
 delay-key-write ON

=== modified file 'mysql-test/suite/binlog/t/binlog_row_mix_innodb_myisam-master.opt'
--- a/mysql-test/suite/binlog/t/binlog_row_mix_innodb_myisam-master.opt	2010-06-17 20:51:35 +0000
+++ b/mysql-test/suite/binlog/t/binlog_row_mix_innodb_myisam-master.opt	2011-06-13 16:49:58 +0000
@@ -1 +1 @@
---innodb_lock_wait_timeout=2 --default-storage-engine=MyISAM
+--innodb_lock_wait_timeout=2 --default-storage-engine=MyISAM --default-temp-storage-engine=MyISAM

=== modified file 'mysql-test/suite/binlog/t/binlog_stm_mix_innodb_myisam-master.opt'
--- a/mysql-test/suite/binlog/t/binlog_stm_mix_innodb_myisam-master.opt	2010-06-21 07:58:54 +0000
+++ b/mysql-test/suite/binlog/t/binlog_stm_mix_innodb_myisam-master.opt	2011-06-13 16:49:58 +0000
@@ -1 +1 @@
---innodb_lock_wait_timeout=2 --binlog-direct-non-transactional-updates=FALSE --default-storage-engine=MyISAM
+--innodb_lock_wait_timeout=2 --binlog-direct-non-transactional-updates=FALSE --default-storage-engine=MyISAM --default-temp-storage-engine=MyISAM

=== added file 'mysql-test/suite/sys_vars/r/default_temp_storage_engine_basic.result'
--- a/mysql-test/suite/sys_vars/r/default_temp_storage_engine_basic.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/r/default_temp_storage_engine_basic.result	2011-06-13 16:49:58 +0000
@@ -0,0 +1,175 @@
+SET @start_global_value = @@global.default_temp_storage_engine;
+SELECT @start_global_value;
+@start_global_value
+InnoDB
+SET @start_session_value = @@session.default_temp_storage_engine;
+SELECT @start_session_value;
+@start_session_value
+InnoDB
+'#--------------------FN_DYNVARS_005_01-------------------------#'
+SET @@global.default_temp_storage_engine = INNODB;
+SET @@global.default_temp_storage_engine = DEFAULT;
+SELECT @@global.default_temp_storage_engine;
+@@global.default_temp_storage_engine
+InnoDB
+SET @@session.default_temp_storage_engine = INNODB;
+SET @@session.default_temp_storage_engine = DEFAULT;
+SELECT @@session.default_temp_storage_engine;
+@@session.default_temp_storage_engine
+InnoDB
+'#--------------------FN_DYNVARS_005_02-------------------------#'
+SET @@global.default_temp_storage_engine = MYISAM;
+SELECT @@global.default_temp_storage_engine;
+@@global.default_temp_storage_engine
+MyISAM
+SET @@global.default_temp_storage_engine = MERGE;
+SELECT @@global.default_temp_storage_engine;
+@@global.default_temp_storage_engine
+MRG_MYISAM
+SET @@global.default_temp_storage_engine = MEMORY;
+SELECT @@global.default_temp_storage_engine;
+@@global.default_temp_storage_engine
+MEMORY
+SET @@global.default_temp_storage_engine = INNODB;
+SELECT @@global.default_temp_storage_engine;
+@@global.default_temp_storage_engine
+InnoDB
+'#--------------------FN_DYNVARS_005_03-------------------------#'
+SET @@session.default_temp_storage_engine = MYISAM;
+SELECT @@session.default_temp_storage_engine;
+@@session.default_temp_storage_engine
+MyISAM
+SET @@session.default_temp_storage_engine = MERGE;
+SELECT @@session.default_temp_storage_engine;
+@@session.default_temp_storage_engine
+MRG_MYISAM
+SET @@session.default_temp_storage_engine = MEMORY;
+SELECT @@session.default_temp_storage_engine;
+@@session.default_temp_storage_engine
+MEMORY
+SET @@session.default_temp_storage_engine = INNODB;
+SELECT @@session.default_temp_storage_engine;
+@@session.default_temp_storage_engine
+InnoDB
+'#------------------FN_DYNVARS_005_04-----------------------#'
+SET @@global.default_temp_storage_engine = 8199;
+ERROR 42000: Incorrect argument type to variable 'default_temp_storage_engine'
+SET @@global.default_temp_storage_engine = NULL;
+ERROR 42000: Variable 'default_temp_storage_engine' can't be set to the value of 'NULL'
+SET @@global.default_temp_storage_engine = -1024;
+ERROR 42000: Incorrect argument type to variable 'default_temp_storage_engine'
+SET @@global.default_temp_storage_engine = 65530.34;
+ERROR 42000: Incorrect argument type to variable 'default_temp_storage_engine'
+SET @@global.default_temp_storage_engine = FILE;
+ERROR 42000: Unknown storage engine 'FILE'
+SET @@session.default_temp_storage_engine = 8199;
+ERROR 42000: Incorrect argument type to variable 'default_temp_storage_engine'
+SET @@session.default_temp_storage_engine = 65530.34;
+ERROR 42000: Incorrect argument type to variable 'default_temp_storage_engine'
+SET @@session.default_temp_storage_engine = RECORD;
+ERROR 42000: Unknown storage engine 'RECORD'
+'#------------------FN_DYNVARS_005_05-----------------------#'
+SELECT @@global.default_temp_storage_engine =
+VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
+WHERE VARIABLE_NAME='default_temp_storage_engine';
+@@global.default_temp_storage_engine =
+VARIABLE_VALUE
+1
+'#------------------FN_DYNVARS_005_06-----------------------#'
+SELECT @@session.default_temp_storage_engine =
+VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_VARIABLES
+WHERE VARIABLE_NAME='default_temp_storage_engine';
+@@session.default_temp_storage_engine =
+VARIABLE_VALUE
+1
+'#------------------FN_DYNVARS_005_07-----------------------#'
+SET @@global.default_temp_storage_engine = TRUE;
+ERROR 42000: Incorrect argument type to variable 'default_temp_storage_engine'
+SET @@global.default_temp_storage_engine = FALSE;
+ERROR 42000: Incorrect argument type to variable 'default_temp_storage_engine'
+'#---------------------FN_DYNVARS_001_8----------------------#'
+SET @@default_temp_storage_engine = MYISAM;
+SELECT @@default_temp_storage_engine = @@local.default_temp_storage_engine;
+@@default_temp_storage_engine = @@local.default_temp_storage_engine
+1
+SELECT @@local.default_temp_storage_engine = @@session.default_temp_storage_engine;
+@@local.default_temp_storage_engine = @@session.default_temp_storage_engine
+1
+'#---------------------FN_DYNVARS_001_9----------------------#'
+SET default_temp_storage_engine = MEMORY;
+SELECT @@default_temp_storage_engine;
+@@default_temp_storage_engine
+MEMORY
+SELECT local.default_temp_storage_engine;
+ERROR 42S02: Unknown table 'local' in field list
+SELECT session.default_temp_storage_engine;
+ERROR 42S02: Unknown table 'session' in field list
+SELECT default_temp_storage_engine = @@session.default_temp_storage_engine;
+ERROR 42S22: Unknown column 'default_temp_storage_engine' in 'field list'
+SET @@default_temp_storage_engine = @start_global_value;
+SET default_temp_storage_engine = MyISAM;
+SET default_storage_engine = MyISAM;
+CREATE TABLE t1 (a INT);
+CREATE TEMPORARY TABLE t2 (b INT);
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SHOW CREATE TABLE t2;
+Table	Create Table
+t2	CREATE TEMPORARY TABLE `t2` (
+  `b` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1, t2;
+SET default_temp_storage_engine = InnoDB;
+CREATE TABLE t1 (a INT);
+CREATE TEMPORARY TABLE t2 (b INT);
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SHOW CREATE TABLE t2;
+Table	Create Table
+t2	CREATE TEMPORARY TABLE `t2` (
+  `b` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+DROP TABLE t1, t2;
+SET default_storage_engine = MEMORY;
+CREATE TABLE t1 (a INT);
+CREATE TEMPORARY TABLE t2 (b INT);
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MEMORY DEFAULT CHARSET=latin1
+SHOW CREATE TABLE t2;
+Table	Create Table
+t2	CREATE TEMPORARY TABLE `t2` (
+  `b` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+DROP TABLE t1, t2;
+SET default_temp_storage_engine = DEFAULT;
+SET default_storage_engine = DEFAULT;
+CREATE TABLE t1 (a INT);
+CREATE TEMPORARY TABLE t2 (b INT);
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+SHOW CREATE TABLE t2;
+Table	Create Table
+t2	CREATE TEMPORARY TABLE `t2` (
+  `b` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+DROP TABLE t1, t2;
+SET @@global.default_temp_storage_engine = @start_global_value;
+SELECT @@global.default_temp_storage_engine;
+@@global.default_temp_storage_engine
+InnoDB
+SET @@session.default_temp_storage_engine = @start_session_value;
+SELECT @@session.default_temp_storage_engine;
+@@session.default_temp_storage_engine
+InnoDB

=== added file 'mysql-test/suite/sys_vars/t/default_temp_storage_engine_basic.test'
--- a/mysql-test/suite/sys_vars/t/default_temp_storage_engine_basic.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/default_temp_storage_engine_basic.test	2011-06-13 16:49:58 +0000
@@ -0,0 +1,197 @@
+--source include/not_embedded.inc
+--source include/have_innodb.inc
+--source include/load_sysvars.inc
+
+######################################################################
+#           START OF default_temp_storage_engine TESTS               #
+######################################################################
+
+
+#############################################################
+#                 Save initial value                        #
+#############################################################
+
+SET @start_global_value = @@global.default_temp_storage_engine;
+SELECT @start_global_value;
+SET @start_session_value = @@session.default_temp_storage_engine;
+SELECT @start_session_value;
+
+
+--echo '#--------------------FN_DYNVARS_005_01-------------------------#'
+######################################################################
+#     Display the DEFAULT value of default_temp_storage_engine       #
+######################################################################
+
+SET @@global.default_temp_storage_engine = INNODB;
+SET @@global.default_temp_storage_engine = DEFAULT;
+SELECT @@global.default_temp_storage_engine;
+
+SET @@session.default_temp_storage_engine = INNODB;
+SET @@session.default_temp_storage_engine = DEFAULT;
+SELECT @@session.default_temp_storage_engine;
+
+
+--echo '#--------------------FN_DYNVARS_005_02-------------------------#'
+########################################################################
+# Change the value of default_temp_storage_engine to a valid value for GLOBAL Scope #
+########################################################################
+
+SET @@global.default_temp_storage_engine = MYISAM;
+SELECT @@global.default_temp_storage_engine;
+SET @@global.default_temp_storage_engine = MERGE;
+SELECT @@global.default_temp_storage_engine;
+SET @@global.default_temp_storage_engine = MEMORY;
+SELECT @@global.default_temp_storage_engine;
+SET @@global.default_temp_storage_engine = INNODB;
+SELECT @@global.default_temp_storage_engine;
+
+
+--echo '#--------------------FN_DYNVARS_005_03-------------------------#'
+#########################################################################
+# Change the value of default_temp_storage_engine to a valid value for SESSION Scope #
+#########################################################################
+ 
+SET @@session.default_temp_storage_engine = MYISAM;
+SELECT @@session.default_temp_storage_engine;
+SET @@session.default_temp_storage_engine = MERGE;
+SELECT @@session.default_temp_storage_engine;
+SET @@session.default_temp_storage_engine = MEMORY;
+SELECT @@session.default_temp_storage_engine;
+SET @@session.default_temp_storage_engine = INNODB;
+SELECT @@session.default_temp_storage_engine;
+
+
+--echo '#------------------FN_DYNVARS_005_04-----------------------#'
+##################################################################
+# Change the value of default_temp_storage_engine to an invalid value         #
+##################################################################
+
+--Error ER_WRONG_TYPE_FOR_VAR
+SET @@global.default_temp_storage_engine = 8199;
+
+--Error ER_WRONG_VALUE_FOR_VAR
+SET @@global.default_temp_storage_engine = NULL;
+
+--Error ER_WRONG_TYPE_FOR_VAR
+SET @@global.default_temp_storage_engine = -1024;
+
+--Error ER_WRONG_TYPE_FOR_VAR
+SET @@global.default_temp_storage_engine = 65530.34;
+
+--Error ER_UNKNOWN_STORAGE_ENGINE
+SET @@global.default_temp_storage_engine = FILE;
+
+--Error ER_WRONG_TYPE_FOR_VAR
+SET @@session.default_temp_storage_engine = 8199;
+
+--Error ER_WRONG_TYPE_FOR_VAR
+SET @@session.default_temp_storage_engine = 65530.34;
+
+--Error ER_UNKNOWN_STORAGE_ENGINE
+SET @@session.default_temp_storage_engine = RECORD;
+
+
+--echo '#------------------FN_DYNVARS_005_05-----------------------#'
+####################################################################
+#   Check if the value in GLOBAL Table matches value in variable   #
+####################################################################
+
+
+SELECT @@global.default_temp_storage_engine =
+ VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
+  WHERE VARIABLE_NAME='default_temp_storage_engine';
+
+--echo '#------------------FN_DYNVARS_005_06-----------------------#'
+####################################################################
+#  Check if the value in SESSION Table matches value in variable   #
+####################################################################
+
+SELECT @@session.default_temp_storage_engine =
+ VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_VARIABLES
+  WHERE VARIABLE_NAME='default_temp_storage_engine';
+
+
+--echo '#------------------FN_DYNVARS_005_07-----------------------#'
+####################################################################
+#     Check if TRUE and FALSE values can be used on variable       #
+####################################################################
+
+--Error ER_WRONG_TYPE_FOR_VAR
+SET @@global.default_temp_storage_engine = TRUE;
+
+--Error ER_WRONG_TYPE_FOR_VAR
+SET @@global.default_temp_storage_engine = FALSE;
+
+
+--echo '#---------------------FN_DYNVARS_001_8----------------------#'
+###############################################################
+#  Check if accessing variable with SESSION,LOCAL and without #
+#  SCOPE points to same session variable                      #
+###############################################################
+
+SET @@default_temp_storage_engine = MYISAM;
+SELECT @@default_temp_storage_engine = @@local.default_temp_storage_engine;
+SELECT @@local.default_temp_storage_engine = @@session.default_temp_storage_engine;
+
+
+--echo '#---------------------FN_DYNVARS_001_9----------------------#'
+#########################################################################
+#   Check if default_temp_storage_engine can be accessed with and without @@ sign    #
+#########################################################################
+
+SET default_temp_storage_engine = MEMORY;
+SELECT @@default_temp_storage_engine;
+--Error ER_UNKNOWN_TABLE
+SELECT local.default_temp_storage_engine;
+--Error ER_UNKNOWN_TABLE
+SELECT session.default_temp_storage_engine;
+--Error ER_BAD_FIELD_ERROR
+SELECT default_temp_storage_engine = @@session.default_temp_storage_engine;
+
+# check the old obsolete name
+SET @@default_temp_storage_engine = @start_global_value;
+
+SET default_temp_storage_engine = MyISAM;
+SET default_storage_engine = MyISAM;
+CREATE TABLE t1 (a INT);
+CREATE TEMPORARY TABLE t2 (b INT);
+SHOW CREATE TABLE t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t1, t2;
+
+SET default_temp_storage_engine = InnoDB;
+CREATE TABLE t1 (a INT);
+CREATE TEMPORARY TABLE t2 (b INT);
+SHOW CREATE TABLE t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t1, t2;
+
+SET default_storage_engine = MEMORY;
+CREATE TABLE t1 (a INT);
+CREATE TEMPORARY TABLE t2 (b INT);
+SHOW CREATE TABLE t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t1, t2;
+
+SET default_temp_storage_engine = DEFAULT;
+SET default_storage_engine = DEFAULT;
+CREATE TABLE t1 (a INT);
+CREATE TEMPORARY TABLE t2 (b INT);
+SHOW CREATE TABLE t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t1, t2;
+
+####################################
+#     Restore initial value        #
+####################################
+
+SET @@global.default_temp_storage_engine = @start_global_value;
+SELECT @@global.default_temp_storage_engine;
+SET @@session.default_temp_storage_engine = @start_session_value;
+SELECT @@session.default_temp_storage_engine;
+
+
+#############################################################
+#       END OF default_temp_storage_engine TESTS            #
+#############################################################
+

=== modified file 'mysql-test/t/bootstrap-master.opt'
--- a/mysql-test/t/bootstrap-master.opt	2010-06-17 20:51:35 +0000
+++ b/mysql-test/t/bootstrap-master.opt	2011-06-13 16:49:58 +0000
@@ -1 +1,3 @@
---default-storage-engine=MyISAM --skip-innodb
+--default-storage-engine=MyISAM 
+--default-temp-storage-engine=MyISAM 
+--skip-innodb 

=== modified file 'mysql-test/t/bootstrap.test'
--- a/mysql-test/t/bootstrap.test	2011-03-24 10:35:12 +0000
+++ b/mysql-test/t/bootstrap.test	2011-06-13 16:49:58 +0000
@@ -8,7 +8,7 @@ drop table if exists t1;
 
 # Add the datadir to the bootstrap command
 let $MYSQLD_DATADIR= `select @@datadir`;
-let $MYSQLD_BOOTSTRAP_CMD= $MYSQLD_BOOTSTRAP_CMD --datadir=$MYSQLD_DATADIR --default-storage-engine=MyISAM --skip-innodb;
+let $MYSQLD_BOOTSTRAP_CMD= $MYSQLD_BOOTSTRAP_CMD --datadir=$MYSQLD_DATADIR --default-storage-engine=MyISAM --default-temp-storage-engine=MyISAM --skip-innodb;
 #
 # Check that --bootstrap reads from stdin
 #

=== modified file 'mysql-test/t/ctype_utf8mb4-master.opt'
--- a/mysql-test/t/ctype_utf8mb4-master.opt	2010-06-17 20:51:35 +0000
+++ b/mysql-test/t/ctype_utf8mb4-master.opt	2011-06-13 16:49:58 +0000
@@ -1 +1,2 @@
 --default-storage-engine=MyISAM
+--default-temp-storage-engine=MyISAM

=== modified file 'sql/handler.cc'
--- a/sql/handler.cc	2011-06-09 08:58:41 +0000
+++ b/sql/handler.cc	2011-06-13 16:49:58 +0000
@@ -110,7 +110,8 @@ static plugin_ref ha_default_plugin(THD 
 
 
 /** @brief
-  Return the default storage engine handlerton for thread
+  Return the default storage engine handlerton used for non-temp tables 
+  for thread
 
   SYNOPSIS
     ha_default_handlerton(thd)
@@ -129,6 +130,35 @@ handlerton *ha_default_handlerton(THD *t
 }
 
 
+static plugin_ref ha_default_temp_plugin(THD *thd)
+{
+  if (thd->variables.temp_table_plugin)
+    return thd->variables.temp_table_plugin;
+  return my_plugin_lock(thd, &global_system_variables.temp_table_plugin);
+}
+
+
+/** @brief
+  Return the default storage engine handlerton used for explicitly 
+  created temp tables for a thread
+
+  SYNOPSIS
+    ha_default_temp_handlerton(thd)
+    thd         current thread
+
+  RETURN
+    pointer to handlerton
+*/
+handlerton *ha_default_temp_handlerton(THD *thd)
+{
+  plugin_ref plugin= ha_default_temp_plugin(thd);
+  DBUG_ASSERT(plugin);
+  handlerton *hton= plugin_data(plugin, handlerton*);
+  DBUG_ASSERT(hton);
+  return hton;
+}
+
+
 /** @brief
   Return the storage engine handlerton for the supplied name
   
@@ -140,7 +170,8 @@ handlerton *ha_default_handlerton(THD *t
   RETURN
     pointer to storage engine plugin handle
 */
-plugin_ref ha_resolve_by_name(THD *thd, const LEX_STRING *name)
+plugin_ref ha_resolve_by_name(THD *thd, const LEX_STRING *name, 
+                              bool is_temp_table)
 {
   const LEX_STRING *table_alias;
   plugin_ref plugin;
@@ -150,7 +181,8 @@ redo:
   if (thd && !my_charset_latin1.coll->strnncoll(&my_charset_latin1,
                            (const uchar *)name->str, name->length,
                            (const uchar *)STRING_WITH_LEN("DEFAULT"), 0))
-    return ha_default_plugin(thd);
+    return is_temp_table ? 
+      ha_default_plugin(thd) : ha_default_temp_plugin(thd);
 
   if ((plugin= my_plugin_lock_by_name(thd, name, MYSQL_STORAGE_ENGINE_PLUGIN)))
   {

=== modified file 'sql/handler.h'
--- a/sql/handler.h	2011-06-01 09:11:28 +0000
+++ b/sql/handler.h	2011-06-13 16:49:58 +0000
@@ -2436,7 +2436,9 @@ extern ulong total_ha, total_ha_2pc;
 
 /* lookups */
 handlerton *ha_default_handlerton(THD *thd);
-plugin_ref ha_resolve_by_name(THD *thd, const LEX_STRING *name);
+handlerton *ha_default_temp_handlerton(THD *thd);
+plugin_ref ha_resolve_by_name(THD *thd, const LEX_STRING *name, 
+                              bool is_temp_table);
 plugin_ref ha_lock_engine(THD *thd, const handlerton *hton);
 handlerton *ha_resolve_by_legacy_type(THD *thd, enum legacy_db_type db_type);
 handler *get_new_handler(TABLE_SHARE *share, MEM_ROOT *alloc,

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2011-06-06 10:29:45 +0000
+++ b/sql/mysqld.cc	2011-06-13 16:49:58 +0000
@@ -338,6 +338,7 @@ static char *lc_time_names_name;
 char *my_bind_addr_str;
 static char *default_collation_name;
 char *default_storage_engine;
+char *default_temp_storage_engine;
 static char compiled_default_collation_name[]= MYSQL_DEFAULT_COLLATION_NAME;
 static I_List<THD> thread_cache;
 static bool binlog_format_used= false;
@@ -3338,6 +3339,7 @@ int init_common_variables()
 #else
   default_storage_engine= const_cast<char *>("InnoDB");
 #endif
+  default_temp_storage_engine= default_storage_engine;
 
   /*
     Add server status variables to the dynamic list of
@@ -4046,6 +4048,44 @@ err:
   DBUG_RETURN(1);
 }
 
+
+static bool
+initialize_storage_engine(char *se_name, const char *se_kind,
+                          plugin_ref *dest_plugin)
+{
+  LEX_STRING name= { se_name, strlen(se_name) };
+  plugin_ref plugin;
+  handlerton *hton;
+  if ((plugin= ha_resolve_by_name(0, &name, FALSE)))
+    hton= plugin_data(plugin, handlerton*);
+  else
+  {
+    sql_print_error("Unknown/unsupported storage engine: %s", se_name);
+    return true;
+  }
+  if (!ha_storage_engine_is_enabled(hton))
+  {
+    if (!opt_bootstrap)
+    {
+      sql_print_error("Default%s storage engine (%s) is not available",
+                      se_kind, se_name);
+      return true;
+    }
+    DBUG_ASSERT(*dest_plugin);
+  }
+  else
+  {
+    /*
+      Need to unlock as global_system_variables.table_plugin
+      was acquired during plugin_init()
+    */
+    plugin_unlock(0, *dest_plugin);
+    *dest_plugin= plugin;
+  }
+  return false;
+}
+
+
 static int init_server_components()
 {
   DBUG_ENTER("init_server_components");
@@ -4353,38 +4393,14 @@ a file name for --log-bin-index option",
 #endif
 
   /*
-    Set the default storage engine
+    Set the default storage engines
   */
-  LEX_STRING name= { default_storage_engine, strlen(default_storage_engine) };
-  plugin_ref plugin;
-  handlerton *hton;
-  if ((plugin= ha_resolve_by_name(0, &name)))
-    hton= plugin_data(plugin, handlerton*);
-  else
-  {
-    sql_print_error("Unknown/unsupported storage engine: %s",
-                    default_storage_engine);
+  if (initialize_storage_engine(default_storage_engine, "",
+                                &global_system_variables.table_plugin))
+    unireg_abort(1);
+  if (initialize_storage_engine(default_temp_storage_engine, " temp",
+                                &global_system_variables.temp_table_plugin))
     unireg_abort(1);
-  }
-  if (!ha_storage_engine_is_enabled(hton))
-  {
-    if (!opt_bootstrap)
-    {
-      sql_print_error("Default storage engine (%s) is not available",
-                      default_storage_engine);
-      unireg_abort(1);
-    }
-    DBUG_ASSERT(global_system_variables.table_plugin);
-  }
-  else
-  {
-    /*
-      Need to unlock as global_system_variables.table_plugin
-      was acquired during plugin_init()
-    */
-    plugin_unlock(0, global_system_variables.table_plugin);
-    global_system_variables.table_plugin= plugin;
-  }
 
   tc_log= (total_ha_2pc > 1 ? (opt_bin_log  ?
                                (TC_LOG *) &mysql_bin_log :
@@ -6144,6 +6160,10 @@ struct my_option my_long_options[]=
   {"default-storage-engine", 0, "The default storage engine for new tables",
    &default_storage_engine, 0, 0, GET_STR, REQUIRED_ARG,
    0, 0, 0, 0, 0, 0 },
+  {"default-temp-storage-engine", 0, 
+    "The default storage engine for new explict temporary tables",
+   &default_temp_storage_engine, 0, 0, GET_STR, REQUIRED_ARG,
+   0, 0, 0, 0, 0, 0 },
   {"default-time-zone", 0, "Set the default time zone.",
    &default_tz_name, &default_tz_name,
    0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },

=== modified file 'sql/mysqld.h'
--- a/sql/mysqld.h	2011-05-19 09:11:38 +0000
+++ b/sql/mysqld.h	2011-06-13 16:49:58 +0000
@@ -129,6 +129,7 @@ extern my_bool opt_enable_shared_memory;
 extern char *default_tz_name;
 extern Time_zone *default_tz;
 extern char *default_storage_engine;
+extern char *default_temp_storage_engine;
 extern bool opt_endinfo, using_udf_functions;
 extern my_bool locked_in_memory;
 extern bool opt_using_transactions;

=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h	2011-06-10 16:57:01 +0000
+++ b/sql/sql_class.h	2011-06-13 16:49:58 +0000
@@ -490,6 +490,7 @@ typedef struct system_variables
   my_bool big_tables;
 
   plugin_ref table_plugin;
+  plugin_ref temp_table_plugin;
 
   /* Only charset part of these variables is sensible */
   const CHARSET_INFO *character_set_filesystem;

=== modified file 'sql/sql_plugin.cc'
--- a/sql/sql_plugin.cc	2011-05-26 15:20:09 +0000
+++ b/sql/sql_plugin.cc	2011-06-13 16:49:58 +0000
@@ -1315,15 +1315,19 @@ int plugin_init(int *argc, char **argv, 
       if (is_myisam)
       {
         DBUG_ASSERT(!global_system_variables.table_plugin);
+        DBUG_ASSERT(!global_system_variables.temp_table_plugin);
         global_system_variables.table_plugin=
           my_intern_plugin_lock(NULL, plugin_int_to_ref(plugin_ptr));
-        DBUG_ASSERT(plugin_ptr->ref_count == 1);
+        global_system_variables.temp_table_plugin=
+          my_intern_plugin_lock(NULL, plugin_int_to_ref(plugin_ptr));
+        DBUG_ASSERT(plugin_ptr->ref_count == 2);
       }
     }
   }
 
   /* should now be set to MyISAM storage engine */
   DBUG_ASSERT(global_system_variables.table_plugin);
+  DBUG_ASSERT(global_system_variables.temp_table_plugin);
 
   mysql_mutex_unlock(&LOCK_plugin);
 
@@ -2605,13 +2609,16 @@ static char **mysql_sys_var_str(THD* thd
 void plugin_thdvar_init(THD *thd, bool enable_plugins)
 {
   plugin_ref old_table_plugin= thd->variables.table_plugin;
+  plugin_ref old_temp_table_plugin= thd->variables.temp_table_plugin;
   DBUG_ENTER("plugin_thdvar_init");
   
   thd->variables.table_plugin= NULL;
+  thd->variables.temp_table_plugin= NULL;
   cleanup_variables(thd, &thd->variables);
   
   thd->variables= global_system_variables;
   thd->variables.table_plugin= NULL;
+  thd->variables.temp_table_plugin= NULL;
 
   /* we are going to allocate these lazily */
   thd->variables.dynamic_variables_version= 0;
@@ -2624,6 +2631,9 @@ void plugin_thdvar_init(THD *thd, bool e
     thd->variables.table_plugin=
       my_intern_plugin_lock(NULL, global_system_variables.table_plugin);
     intern_plugin_unlock(NULL, old_table_plugin);
+    thd->variables.temp_table_plugin=
+      my_intern_plugin_lock(NULL, global_system_variables.temp_table_plugin);
+    intern_plugin_unlock(NULL, old_temp_table_plugin);
     mysql_mutex_unlock(&LOCK_plugin);
   }
   DBUG_VOID_RETURN;
@@ -2636,7 +2646,9 @@ void plugin_thdvar_init(THD *thd, bool e
 static void unlock_variables(THD *thd, struct system_variables *vars)
 {
   intern_plugin_unlock(NULL, vars->table_plugin);
+  intern_plugin_unlock(NULL, vars->temp_table_plugin);
   vars->table_plugin= NULL;
+  vars->temp_table_plugin= NULL;
 }
 
 
@@ -2677,6 +2689,7 @@ static void cleanup_variables(THD *thd, 
   mysql_rwlock_unlock(&LOCK_system_variables_hash);
 
   DBUG_ASSERT(vars->table_plugin == NULL);
+  DBUG_ASSERT(vars->temp_table_plugin == NULL);
 
   my_free(vars->dynamic_variables_ptr);
   vars->dynamic_variables_ptr= NULL;

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2011-06-10 16:57:01 +0000
+++ b/sql/sql_table.cc	2011-06-13 16:49:58 +0000
@@ -1132,7 +1132,7 @@ static int execute_ddl_log_action(THD *t
     frm_action= TRUE;
   else
   {
-    plugin_ref plugin= ha_resolve_by_name(thd, &handler_name);
+    plugin_ref plugin= ha_resolve_by_name(thd, &handler_name, FALSE);
     if (!plugin)
     {
       my_error(ER_ILLEGAL_HA, MYF(0), ddl_log_entry->handler_name);

=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy	2011-06-09 18:18:22 +0000
+++ b/sql/sql_yacc.yy	2011-06-13 16:49:58 +0000
@@ -2072,7 +2072,9 @@ create:
             lex->change=NullS;
             memset(&lex->create_info, 0, sizeof(lex->create_info));
             lex->create_info.options=$2 | $4;
-            lex->create_info.db_type= ha_default_handlerton(thd);
+            lex->create_info.db_type=
+              lex->create_info.options & HA_LEX_CREATE_TMP_TABLE ?
+              ha_default_temp_handlerton(thd) : ha_default_handlerton(thd);
             lex->create_info.default_table_charset= NULL;
             lex->name.str= 0;
             lex->name.length= 0;
@@ -2080,11 +2082,14 @@ create:
           }
           create2
           {
-            LEX *lex= YYTHD->lex;
+            THD *thd= YYTHD;
+            LEX *lex= thd->lex;
             lex->current_select= &lex->select_lex; 
             if (!lex->create_info.db_type)
             {
-              lex->create_info.db_type= ha_default_handlerton(YYTHD);
+              lex->create_info.db_type=
+                lex->create_info.options & HA_LEX_CREATE_TMP_TABLE ?
+                ha_default_temp_handlerton(thd) : ha_default_handlerton(thd);
               push_warning_printf(YYTHD, MYSQL_ERROR::WARN_LEVEL_WARN,
                                   ER_WARN_USING_OTHER_HANDLER,
                                   ER(ER_WARN_USING_OTHER_HANDLER),
@@ -5244,7 +5249,12 @@ default_collation:
 storage_engines:
           ident_or_text
           {
-            plugin_ref plugin= ha_resolve_by_name(YYTHD, &$1);
+            THD *thd= YYTHD;
+            LEX *lex= thd->lex;
+            plugin_ref plugin=
+              ha_resolve_by_name(thd, &$1,
+                lex->create_info.options & HA_LEX_CREATE_TMP_TABLE ?
+                ha_default_temp_handlerton(thd) : ha_default_handlerton(thd));
 
             if (plugin)
               $$= plugin_data(plugin, handlerton*);
@@ -5267,8 +5277,13 @@ storage_engines:
 known_storage_engines:
           ident_or_text
           {
-            plugin_ref plugin;
-            if ((plugin= ha_resolve_by_name(YYTHD, &$1)))
+            THD *thd= YYTHD;
+            LEX *lex= thd->lex;
+            plugin_ref plugin=
+              ha_resolve_by_name(thd, &$1,
+                lex->create_info.options & HA_LEX_CREATE_TMP_TABLE ?
+                ha_default_temp_handlerton(thd) : ha_default_handlerton(thd));
+            if (plugin)
               $$= plugin_data(plugin, handlerton*);
             else
             {

=== modified file 'sql/sys_vars.cc'
--- a/sql/sys_vars.cc	2011-06-10 16:57:01 +0000
+++ b/sql/sys_vars.cc	2011-06-13 16:49:58 +0000
@@ -2436,6 +2436,12 @@ static Sys_var_plugin Sys_default_storag
        MYSQL_STORAGE_ENGINE_PLUGIN, DEFAULT(&default_storage_engine),
        NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_not_null));
 
+static Sys_var_plugin Sys_default_temp_storage_engine(
+       "default_temp_storage_engine", "The default storage engine for new explict temporary tables",
+       SESSION_VAR(temp_table_plugin), NO_CMD_LINE,
+       MYSQL_STORAGE_ENGINE_PLUGIN, DEFAULT(&default_temp_storage_engine),
+       NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_not_null));
+
 //  Alias for @@default_storage_engine
 static Sys_var_plugin Sys_storage_engine(
        "storage_engine", "Alias for @@default_storage_engine. Deprecated",

=== modified file 'sql/sys_vars.h'
--- a/sql/sys_vars.h	2011-04-04 08:47:25 +0000
+++ b/sql/sys_vars.h	2011-06-13 16:49:58 +0000
@@ -1174,7 +1174,7 @@ public:
 
       // special code for storage engines (e.g. to handle historical aliases)
       if (plugin_type == MYSQL_STORAGE_ENGINE_PLUGIN)
-        plugin= ha_resolve_by_name(thd, &pname);
+        plugin= ha_resolve_by_name(thd, &pname, FALSE);
       else
         plugin= my_plugin_lock_by_name(thd, &pname, plugin_type);
       if (!plugin)
@@ -1226,7 +1226,7 @@ public:
 
     plugin_ref plugin;
     if (plugin_type == MYSQL_STORAGE_ENGINE_PLUGIN)
-      plugin= ha_resolve_by_name(thd, &pname);
+      plugin= ha_resolve_by_name(thd, &pname, FALSE);
     else
       plugin= my_plugin_lock_by_name(thd, &pname, plugin_type);
     DBUG_ASSERT(plugin);

=== modified file 'sql/table.cc'
--- a/sql/table.cc	2011-06-09 08:58:41 +0000
+++ b/sql/table.cc	2011-06-13 16:49:58 +0000
@@ -1014,7 +1014,7 @@ static int open_binary_frm(THD *thd, TAB
       name.str= (char*) next_chunk + 2;
       name.length= str_db_type_length;
 
-      plugin_ref tmp_plugin= ha_resolve_by_name(thd, &name);
+      plugin_ref tmp_plugin= ha_resolve_by_name(thd, &name, FALSE);
       if (tmp_plugin != NULL && !plugin_equals(tmp_plugin, share->db_plugin))
       {
         if (legacy_db_type > DB_TYPE_UNKNOWN &&


Attachment: [text/bzr-bundle] bzr/georgi.kodinov@oracle.com-20110613164958-pdaouo3fc5o4oys6.bundle
Thread
bzr commit into mysql-trunk branch (Georgi.Kodinov:3196) Bug#11757216Georgi Kodinov13 Jun