List:Commits« Previous MessageNext Message »
From:msvensson Date:October 3 2006 7:28am
Subject:bk commit into 5.1 tree (msvensson:1.2339)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of msvensson. When msvensson does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2006-10-03 09:28:44+02:00, msvensson@neptunus.(none) +34 -0
  Merge neptunus.(none):/home/msvensson/mysql/mysql-5.1
  into  neptunus.(none):/home/msvensson/mysql/mysql-5.1-new-maint
  MERGE: 1.2328.1.15

  BitKeeper/etc/ignore@stripped, 2006-10-03 09:24:41+02:00, msvensson@neptunus.(none) +0 -0
    auto-union
    MERGE: 1.253.1.5

  mysql-test/r/ctype_ucs.result@stripped, 2006-10-03 09:24:45+02:00, msvensson@neptunus.(none) +0 -2
    Auto merged
    MERGE: 1.50.1.2

  mysql-test/r/func_gconcat.result@stripped, 2006-10-03 09:24:46+02:00, msvensson@neptunus.(none) +0 -0
    Auto merged
    MERGE: 1.60.1.1

  mysql-test/r/func_group.result@stripped, 2006-10-03 09:24:46+02:00, msvensson@neptunus.(none) +0 -0
    Auto merged
    MERGE: 1.52.1.1

  mysql-test/r/group_by.result@stripped, 2006-10-03 09:24:46+02:00, msvensson@neptunus.(none) +0 -0
    Auto merged
    MERGE: 1.72.1.1

  mysql-test/r/partition.result@stripped, 2006-10-03 09:24:46+02:00, msvensson@neptunus.(none) +0 -0
    Auto merged
    MERGE: 1.57.1.1

  mysql-test/r/ps.result@stripped, 2006-10-03 09:24:46+02:00, msvensson@neptunus.(none) +0 -0
    Auto merged
    MERGE: 1.73.1.1

  mysql-test/r/subselect.result@stripped, 2006-10-03 09:24:46+02:00, msvensson@neptunus.(none) +0 -0
    Auto merged
    MERGE: 1.152.1.1

  mysql-test/r/view.result@stripped, 2006-10-03 09:24:46+02:00, msvensson@neptunus.(none) +0 -0
    Auto merged
    MERGE: 1.179.1.2

  mysql-test/t/ctype_ucs.test@stripped, 2006-10-03 09:24:46+02:00, msvensson@neptunus.(none) +0 -0
    Auto merged
    MERGE: 1.46.1.1

  mysql-test/t/func_gconcat.test@stripped, 2006-10-03 09:24:46+02:00, msvensson@neptunus.(none) +0 -0
    Auto merged
    MERGE: 1.46.1.1

  mysql-test/t/ps.test@stripped, 2006-10-03 09:24:46+02:00, msvensson@neptunus.(none) +0 -0
    Auto merged
    MERGE: 1.71.1.1

  mysql-test/t/view.test@stripped, 2006-10-03 09:24:46+02:00, msvensson@neptunus.(none) +0 -10
    Auto merged
    MERGE: 1.160.2.3

  sql/field.h@stripped, 2006-10-03 09:24:46+02:00, msvensson@neptunus.(none) +0 -0
    Auto merged
    MERGE: 1.188.1.1

  sql/filesort.cc@stripped, 2006-10-03 09:24:46+02:00, msvensson@neptunus.(none) +0 -0
    Auto merged
    MERGE: 1.111.1.1

  sql/item.cc@stripped, 2006-10-03 09:24:46+02:00, msvensson@neptunus.(none) +0 -0
    Auto merged
    MERGE: 1.211.1.1

  sql/item_cmpfunc.cc@stripped, 2006-10-03 09:24:47+02:00, msvensson@neptunus.(none) +0 -0
    Auto merged
    MERGE: 1.221.1.3

  sql/item_cmpfunc.h@stripped, 2006-10-03 09:24:47+02:00, msvensson@neptunus.(none) +0 -0
    Auto merged
    MERGE: 1.134.1.1

  sql/item_sum.cc@stripped, 2006-10-03 09:24:47+02:00, msvensson@neptunus.(none) +0 -0
    Auto merged
    MERGE: 1.190.1.1

  sql/log.cc@stripped, 2006-10-03 09:24:47+02:00, msvensson@neptunus.(none) +0 -0
    Auto merged
    MERGE: 1.233.1.1

  sql/mysql_priv.h@stripped, 2006-10-03 09:24:47+02:00, msvensson@neptunus.(none) +0 -0
    Auto merged
    MERGE: 1.442.1.4

  sql/mysqld.cc@stripped, 2006-10-03 09:24:47+02:00, msvensson@neptunus.(none) +0 -0
    Auto merged
    MERGE: 1.578.1.2

  sql/opt_range.cc@stripped, 2006-10-03 09:24:48+02:00, msvensson@neptunus.(none) +0 -0
    Auto merged
    MERGE: 1.235.1.3

  sql/share/errmsg.txt@stripped, 2006-10-03 09:28:40+02:00, msvensson@neptunus.(none) +0 -2
    Manul merge(conflict with new german text)
    MERGE: 1.125.1.5

  sql/sql_base.cc@stripped, 2006-10-03 09:24:48+02:00, msvensson@neptunus.(none) +0 -0
    Auto merged
    MERGE: 1.353.1.1

  sql/sql_insert.cc@stripped, 2006-10-03 09:24:48+02:00, msvensson@neptunus.(none) +0 -0
    Auto merged
    MERGE: 1.225.1.1

  sql/sql_lex.cc@stripped, 2006-10-03 09:24:48+02:00, msvensson@neptunus.(none) +0 -0
    Auto merged
    MERGE: 1.198.1.1

  sql/sql_select.cc@stripped, 2006-10-03 09:24:48+02:00, msvensson@neptunus.(none) +0 -0
    Auto merged
    MERGE: 1.440.1.4

  sql/sql_view.cc@stripped, 2006-10-03 09:24:49+02:00, msvensson@neptunus.(none) +0 -0
    Auto merged
    MERGE: 1.105.1.1

  sql/sql_yacc.yy@stripped, 2006-10-03 09:24:49+02:00, msvensson@neptunus.(none) +0 -0
    Auto merged
    MERGE: 1.502.1.3

  sql/unireg.cc@stripped, 2006-10-03 09:28:40+02:00, msvensson@neptunus.(none) +11 -11
    Manual merge(as it is in 5.1)
    MERGE: 1.84.1.1

  storage/innobase/handler/ha_innodb.cc@stripped, 2006-10-03 09:24:49+02:00, msvensson@neptunus.(none) +0 -0
    Auto merged
    MERGE: 1.295.1.7

  storage/innobase/handler/ha_innodb.h@stripped, 2006-10-03 09:24:50+02:00, msvensson@neptunus.(none) +0 -0
    Auto merged
    MERGE: 1.126.1.2

  storage/myisam/mi_check.c@stripped, 2006-10-03 09:24:50+02:00, msvensson@neptunus.(none) +0 -0
    Auto merged
    MERGE: 1.150.1.1

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	msvensson
# Host:	neptunus.(none)
# Root:	/home/msvensson/mysql/mysql-5.1-new-maint/RESYNC

--- 1.234/sql/log.cc	2006-10-03 09:28:53 +02:00
+++ 1.235/sql/log.cc	2006-10-03 09:28:53 +02:00
@@ -1580,17 +1580,18 @@
   if (log_type == LOG_NORMAL)
   {
     char *end;
-    int len=my_snprintf(buff, sizeof(buff), "%s, Version: %s. "
+    int len=my_snprintf(buff, sizeof(buff), "%s, Version: %s (%s). "
 #ifdef EMBEDDED_LIBRARY
-		        "embedded library\n", my_progname, server_version
+                        "embedded library\n",
+                        my_progname, server_version, MYSQL_COMPILATION_COMMENT
 #elif __NT__
 			"started with:\nTCP Port: %d, Named Pipe: %s\n",
-			my_progname, server_version, mysqld_port,
-                        mysqld_unix_port
+                        my_progname, server_version, MYSQL_COMPILATION_COMMENT,
+                        mysqld_port, mysqld_unix_port
 #else
 			"started with:\nTcp port: %d  Unix socket: %s\n",
-			my_progname, server_version, mysqld_port,
-                        mysqld_unix_port
+                        my_progname, server_version, MYSQL_COMPILATION_COMMENT,
+                        mysqld_port, mysqld_unix_port
 #endif
                        );
     end= strnmov(buff + len, "Time                 Id Command    Argument\n",

--- 1.446/sql/mysql_priv.h	2006-10-03 09:28:53 +02:00
+++ 1.447/sql/mysql_priv.h	2006-10-03 09:28:53 +02:00
@@ -140,7 +140,18 @@
 #define MAX_ACCEPT_RETRY	10	// Test accept this many times
 #define MAX_FIELDS_BEFORE_HASH	32
 #define USER_VARS_HASH_SIZE     16
-#define STACK_MIN_SIZE		8192	// Abort if less stack during eval.
+
+/* 
+ Value of 9236 discovered through binary search 2006-09-26 on Ubuntu Dapper
+ Drake, libc6 2.3.6-0ubuntu2, Linux kernel 2.6.15-27-686, on x86.  (Added 
+ 100 bytes as reasonable buffer against growth and other environments'
+ requirements.)
+
+ Feel free to raise this by the smallest amount you can to get the
+ "execution_constants" test to pass.
+ */
+#define STACK_MIN_SIZE		9336	// Abort if less stack during eval.  
+
 #define STACK_MIN_SIZE_FOR_OPEN 1024*80
 #define STACK_BUFF_ALLOC	256	// For stack overrun checks
 #ifndef MYSQLD_NET_RETRY_COUNT
@@ -1428,10 +1439,12 @@
 
 
 int vprint_msg_to_log(enum loglevel level, const char *format, va_list args);
-void sql_print_error(const char *format, ...);
-void sql_print_warning(const char *format, ...);
-void sql_print_information(const char *format, ...);
-typedef void (*sql_print_message_func)(const char *format, ...);
+void sql_print_error(const char *format, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
+void sql_print_warning(const char *format, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
+void sql_print_information(const char *format, ...)
+  ATTRIBUTE_FORMAT(printf, 1, 2);
+typedef void (*sql_print_message_func)(const char *format, ...)
+  ATTRIBUTE_FORMAT(printf, 1, 2);
 extern sql_print_message_func sql_print_message_handlers[];
 
 /* type of the log table */

--- 1.582/sql/mysqld.cc	2006-10-03 09:28:53 +02:00
+++ 1.583/sql/mysqld.cc	2006-10-03 09:28:53 +02:00
@@ -354,6 +354,14 @@
 my_bool opt_show_slave_auth_info, opt_sql_bin_update = 0;
 my_bool opt_log_slave_updates= 0;
 my_bool	opt_innodb;
+
+/*
+  Legacy global handlerton. These will be removed (please do not add more).
+*/
+handlerton *heap_hton;
+handlerton *myisam_hton;
+handlerton *partition_hton;
+
 #ifdef WITH_INNOBASE_STORAGE_ENGINE
 extern ulong innobase_fast_shutdown;
 extern ulong innobase_large_page_size;

--- 1.237/sql/opt_range.cc	2006-10-03 09:28:53 +02:00
+++ 1.238/sql/opt_range.cc	2006-10-03 09:28:53 +02:00
@@ -6954,8 +6954,9 @@
       ulong count=count_key_part_usage(root,pos->next_key_part);
       if (count > pos->next_key_part->use_count)
       {
-	sql_print_information("Use_count: Wrong count for key at 0x%lx, %lu should be %lu",
-			pos,pos->next_key_part->use_count,count);
+        sql_print_information("Use_count: Wrong count for key at 0x%lx, %lu "
+                              "should be %lu", (long unsigned int)pos,
+                              pos->next_key_part->use_count, count);
 	return;
       }
       pos->next_key_part->test_use_count(root);
@@ -6963,7 +6964,7 @@
   }
   if (e_count != elements)
     sql_print_warning("Wrong use count: %u (should be %u) for tree at 0x%lx",
-		    e_count, elements, (gptr) this);
+                      e_count, elements, (long unsigned int) this);
 }
 
 #endif

--- 1.86/sql/unireg.cc	2006-10-03 09:28:53 +02:00
+++ 1.87/sql/unireg.cc	2006-10-03 09:28:53 +02:00
@@ -866,19 +866,19 @@
     /*
       regfield don't have to be deleted as it's allocated with sql_alloc()
     */
-    Field *regfield=make_field(&share,
-                               (char*) buff+field->offset + data_offset,
-                               field->length,
-                               null_pos + null_count / 8,
-			       null_count & 7,
-			       field->pack_flag,
-			       field->sql_type,
-			       field->charset,
-			       field->geom_type,
-			       field->unireg_check,
-			       field->save_interval ? field->save_interval :
-                               field->interval, 
-			       field->field_name);
+    Field *regfield= make_field(&share,
+                                (char*) buff+field->offset + data_offset,
+                                field->length,
+                                null_pos + null_count / 8,
+                                null_count & 7,
+                                field->pack_flag,
+                                field->sql_type,
+                                field->charset,
+                                field->geom_type,
+                                field->unireg_check,
+                                field->save_interval ? field->save_interval :
+                                field->interval, 
+                                field->field_name);
     if (!regfield)
       goto err;                                 // End of memory
 

--- 1.128/sql/share/errmsg.txt	2006-10-03 09:28:53 +02:00
+++ 1.129/sql/share/errmsg.txt	2006-10-03 09:28:53 +02:00
@@ -3791,7 +3791,7 @@
         dan "Tabellerne i MERGE er ikke defineret ens"
         nla "Niet alle tabellen in de MERGE tabel hebben identieke gedefinities"
-        eng "All tables in the MERGE table are not identically defined"
+        eng "Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists"
         ger "Nicht alle Tabellen in der MERGE-Tabelle sind gleich definiert"
@@ -5960,9 +5960,9 @@
         eng "Error during starting/stopping of the scheduler. Error code %u"
 ER_PARTITION_MERGE_ERROR
-        eng "%s handler cannot be used in partitioned tables"
-        ger "%s-Handler kann in partitionierten Tabellen nicht verwendet werden"
+        eng "Engine cannot be used in partitioned tables"
+        ger "Engine kann in partitionierten Tabellen nicht verwendet werden"
 ER_CANT_ACTIVATE_LOG
         eng "Cannot activate '%-.64s' log"
         ger "Kann Logdatei '%-.64s' nicht aktivieren"

--- 1.303/storage/innobase/handler/ha_innodb.cc	2006-10-03 09:28:53 +02:00
+++ 1.304/storage/innobase/handler/ha_innodb.cc	2006-10-03 09:28:53 +02:00
@@ -54,6 +54,12 @@
 pthread_mutex_t commit_cond_m;
 bool innodb_inited= 0;
 
+/*
+  This needs to exist until the query cache callback is removed
+  or learns to pass hton.
+*/
+static handlerton *legacy_innodb_hton;
+
 /*-----------------------------------------------------------------*/
 /* These variables are used to implement (semi-)synchronous MySQL binlog
 replication for InnoDB tables. */
@@ -197,22 +203,25 @@
 	my_bool not_used __attribute__((unused)));
 static INNOBASE_SHARE *get_share(const char *table_name);
 static void free_share(INNOBASE_SHARE *share);
-static int innobase_close_connection(THD* thd);
-static int innobase_commit(THD* thd, bool all);
-static int innobase_rollback(THD* thd, bool all);
-static int innobase_rollback_to_savepoint(THD* thd, void *savepoint);
-static int innobase_savepoint(THD* thd, void *savepoint);
-static int innobase_release_savepoint(THD* thd, void *savepoint);
-static handler *innobase_create_handler(TABLE_SHARE *table,
+static int innobase_close_connection(handlerton *hton, THD* thd);
+static int innobase_commit(handlerton *hton, THD* thd, bool all);
+static int innobase_rollback(handlerton *hton, THD* thd, bool all);
+static int innobase_rollback_to_savepoint(handlerton *hton, THD* thd, 
+           void *savepoint);
+static int innobase_savepoint(handlerton *hton, THD* thd, void *savepoint);
+static int innobase_release_savepoint(handlerton *hton, THD* thd, 
+           void *savepoint);
+static handler *innobase_create_handler(handlerton *hton,
+                                        TABLE_SHARE *table,
                                         MEM_ROOT *mem_root);
 
 static const char innobase_hton_name[]= "InnoDB";
 
-handlerton *innobase_hton;
-
-static handler *innobase_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root)
+static handler *innobase_create_handler(handlerton *hton,
+                                        TABLE_SHARE *table, 
+                                        MEM_ROOT *mem_root)
 {
-  return new (mem_root) ha_innobase(table);
+  return new (mem_root) ha_innobase(hton, table);
 }
 
 
@@ -380,7 +389,8 @@
 int
 innobase_release_temporary_latches(
 /*===============================*/
-	THD *thd)
+         handlerton *hton,
+	 THD *thd)
 {
 	trx_t*	trx;
 
@@ -389,7 +399,7 @@
 		return 0;
 	}
 
-	trx = (trx_t*) thd->ha_data[innobase_hton->slot];
+	trx = (trx_t*) thd->ha_data[hton->slot];
 
 	if (trx) {
 		innobase_release_stat_resources(trx);
@@ -841,13 +851,14 @@
 check_trx_exists(
 /*=============*/
 			/* out: InnoDB transaction handle */
+	handlerton*	hton,	/* in: handlerton for innodb */
 	THD*	thd)	/* in: user thread handle */
 {
 	trx_t*	trx;
 
 	ut_ad(thd == current_thd);
 
-	trx = (trx_t*) thd->ha_data[innobase_hton->slot];
+	trx = (trx_t*) thd->ha_data[hton->slot];
 
 	if (trx == NULL) {
 		DBUG_ASSERT(thd != NULL);
@@ -861,7 +872,7 @@
 		CPU time */
 		trx->support_xa = (ibool)(thd->variables.innodb_support_xa);
 
-		thd->ha_data[innobase_hton->slot] = trx;
+		thd->ha_data[hton->slot] = trx;
 	} else {
 		if (trx->magic_n != TRX_MAGIC_N) {
 			mem_analyze_corruption(trx);
@@ -889,8 +900,8 @@
 /*************************************************************************
 Construct ha_innobase handler. */
 
-ha_innobase::ha_innobase(TABLE_SHARE *table_arg)
-  :handler(innobase_hton, table_arg),
+ha_innobase::ha_innobase(handlerton *hton, TABLE_SHARE *table_arg)
+  :handler(hton, table_arg),
   int_table_flags(HA_REC_NOT_IN_SEQ |
 		  HA_NULL_IN_KEY |
 		  HA_CAN_INDEX_BLOBS |
@@ -917,7 +928,7 @@
 	row_prebuilt_t*	prebuilt = (row_prebuilt_t*) innobase_prebuilt;
 	trx_t*		trx;
 
-	trx = check_trx_exists(thd);
+	trx = check_trx_exists(ht, thd);
 
 	if (prebuilt->trx != trx) {
 
@@ -938,10 +949,11 @@
 void
 innobase_register_stmt(
 /*===================*/
+        handlerton*	hton,	/* in: Innobase hton */
 	THD*	thd)	/* in: MySQL thd (connection) object */
 {
 	/* Register the statement */
-	trans_register_ha(thd, FALSE, innobase_hton);
+	trans_register_ha(thd, FALSE, hton);
 }
 
 /*************************************************************************
@@ -955,17 +967,18 @@
 void
 innobase_register_trx_and_stmt(
 /*===========================*/
+        handlerton *hton, /* in: Innobase handlerton */
 	THD*	thd)	/* in: MySQL thd (connection) object */
 {
 	/* NOTE that actually innobase_register_stmt() registers also
 	the transaction in the AUTOCOMMIT=1 mode. */
 
-	innobase_register_stmt(thd);
+	innobase_register_stmt(hton, thd);
 
 	if (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) {
 
 		/* No autocommit mode, register for a transaction */
-		trans_register_ha(thd, TRUE, innobase_hton);
+		trans_register_ha(thd, TRUE, hton);
 	}
 }
 
@@ -1061,7 +1074,7 @@
 		return((my_bool)FALSE);
 	}
 
-	trx = check_trx_exists(thd);
+	trx = check_trx_exists(legacy_innodb_hton, thd);
 	if (trx->has_search_latch) {
 		ut_print_timestamp(stderr);
 		sql_print_error("The calling thread is holding the adaptive "
@@ -1120,7 +1133,7 @@
 
 	if (trx->active_trans == 0) {
 
-		innobase_register_trx_and_stmt(thd);
+		innobase_register_trx_and_stmt(legacy_innodb_hton, thd);
 		trx->active_trans = 1;
 	}
 
@@ -1295,7 +1308,7 @@
 
 	if (prebuilt->trx->active_trans == 0) {
 
-		innobase_register_trx_and_stmt(current_thd);
+		innobase_register_trx_and_stmt(ht, current_thd);
 
 		prebuilt->trx->active_trans = 1;
 	}
@@ -1338,7 +1351,8 @@
 	char		*default_path;
 
 	DBUG_ENTER("innobase_init");
-        innobase_hton= (handlerton *)p;
+        handlerton *innobase_hton= (handlerton *)p;
+        legacy_innodb_hton= innobase_hton;
 
         innobase_hton->state=have_innodb;
         innobase_hton->db_type= DB_TYPE_INNODB;
@@ -1613,7 +1627,7 @@
 Closes an InnoDB database. */
 
 int
-innobase_end(ha_panic_function type)
+innobase_end(handlerton *hton, ha_panic_function type)
 /*==============*/
 				/* out: TRUE if error */
 {
@@ -1651,7 +1665,7 @@
 the logs, and the name of this function should be innobase_checkpoint. */
 
 bool
-innobase_flush_logs(void)
+innobase_flush_logs(handlerton *hton)
 /*=====================*/
 				/* out: TRUE if error */
 {
@@ -1690,6 +1704,7 @@
 innobase_start_trx_and_assign_read_view(
 /*====================================*/
 			/* out: 0 */
+        handlerton *hton, /* in: Innodb handlerton */ 
 	THD*	thd)	/* in: MySQL thread handle of the user for whom
 			the transaction should be committed */
 {
@@ -1699,7 +1714,7 @@
 
 	/* Create a new trx struct for thd, if it does not yet have one */
 
-	trx = check_trx_exists(thd);
+	trx = check_trx_exists(hton, thd);
 
 	/* This is just to play safe: release a possible FIFO ticket and
 	search latch. Since we will reserve the kernel mutex, we have to
@@ -1718,9 +1733,7 @@
 	/* Set the MySQL flag to mark that there is an active transaction */
 
 	if (trx->active_trans == 0) {
-
-		innobase_register_trx_and_stmt(current_thd);
-
+		innobase_register_trx_and_stmt(hton, current_thd);
 		trx->active_trans = 1;
 	}
 
@@ -1735,7 +1748,8 @@
 innobase_commit(
 /*============*/
 			/* out: 0 */
-	THD*	thd,	/* in: MySQL thread handle of the user for whom
+        handlerton *hton, /* in: Innodb handlerton */ 
+	THD* 	thd,	/* in: MySQL thread handle of the user for whom
 			the transaction should be committed */
 	bool	all)	/* in:	TRUE - commit transaction
 				FALSE - the current SQL statement ended */
@@ -1745,7 +1759,7 @@
 	DBUG_ENTER("innobase_commit");
 	DBUG_PRINT("trans", ("ending transaction"));
 
-	trx = check_trx_exists(thd);
+	trx = check_trx_exists(hton, thd);
 
 	/* Update the info whether we should skip XA steps that eat CPU time */
 	trx->support_xa = (ibool)(thd->variables.innodb_support_xa);
@@ -1871,6 +1885,7 @@
 innobase_report_binlog_offset_and_commit(
 /*=====================================*/
 				/* out: 0 */
+        handlerton *hton, /* in: Innodb handlerton */ 
 	THD*	thd,		/* in: user thread */
 	void*	trx_handle,	/* in: InnoDB trx handle */
 	char*	log_file_name,	/* in: latest binlog file name */
@@ -1888,7 +1903,7 @@
 
 	trx->flush_log_later = TRUE;
 
-	innobase_commit(thd, TRUE);
+	innobase_commit(hton, thd, TRUE);
 
 	trx->flush_log_later = FALSE;
 
@@ -1936,11 +1951,12 @@
 innobase_commit_complete(
 /*=====================*/
 				/* out: 0 */
+        handlerton *hton, /* in: Innodb handlerton */ 
 	THD*	thd)		/* in: user thread */
 {
 	trx_t*	trx;
 
-	trx = (trx_t*) thd->ha_data[innobase_hton->slot];
+	trx = (trx_t*) thd->ha_data[hton->slot];
 
 	if (trx && trx->active_trans) {
 
@@ -1964,6 +1980,7 @@
 innobase_rollback(
 /*==============*/
 			/* out: 0 or error number */
+        handlerton *hton, /* in: Innodb handlerton */ 
 	THD*	thd,	/* in: handle to the MySQL thread of the user
 			whose transaction should be rolled back */
 	bool	all)	/* in:	TRUE - commit transaction
@@ -1975,7 +1992,7 @@
 	DBUG_ENTER("innobase_rollback");
 	DBUG_PRINT("trans", ("aborting transaction"));
 
-	trx = check_trx_exists(thd);
+	trx = check_trx_exists(hton, thd);
 
 	/* Update the info whether we should skip XA steps that eat CPU time */
 	trx->support_xa = (ibool)(thd->variables.innodb_support_xa);
@@ -2047,6 +2064,7 @@
 /*===========================*/
 				/* out: 0 if success, HA_ERR_NO_SAVEPOINT if
 				no savepoint with the given name */
+        handlerton *hton,       /* in: Innodb handlerton */ 
 	THD*	thd,		/* in: handle to the MySQL thread of the user
 				whose transaction should be rolled back */
 	void*	savepoint)	/* in: savepoint data */
@@ -2058,7 +2076,7 @@
 
 	DBUG_ENTER("innobase_rollback_to_savepoint");
 
-	trx = check_trx_exists(thd);
+	trx = check_trx_exists(hton, thd);
 
 	/* Release a possible FIFO ticket and search latch. Since we will
 	reserve the kernel mutex, we have to release the search system latch
@@ -2083,6 +2101,7 @@
 /*=======================*/
 				/* out: 0 if success, HA_ERR_NO_SAVEPOINT if
 				no savepoint with the given name */
+        handlerton*	hton,	/* in: handlerton for Innodb */
 	THD*	thd,		/* in: handle to the MySQL thread of the user
 				whose transaction should be rolled back */
 	void*	savepoint)	/* in: savepoint data */
@@ -2093,7 +2112,7 @@
 
 	DBUG_ENTER("innobase_release_savepoint");
 
-	trx = check_trx_exists(thd);
+	trx = check_trx_exists(hton, thd);
 
 	/* TODO: use provided savepoint data area to store savepoint data */
 
@@ -2111,6 +2130,7 @@
 innobase_savepoint(
 /*===============*/
 				/* out: always 0, that is, always succeeds */
+	handlerton*	hton,   /* in: handle to the Innodb handlerton */
 	THD*	thd,		/* in: handle to the MySQL thread */
 	void*	savepoint)	/* in: savepoint data */
 {
@@ -2127,7 +2147,7 @@
 	DBUG_ASSERT(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN) ||
 		thd->in_sub_stmt);
 
-	trx = check_trx_exists(thd);
+	trx = check_trx_exists(hton, thd);
 
 	/* Release a possible FIFO ticket and search latch. Since we will
 	reserve the kernel mutex, we have to release the search system latch
@@ -2154,12 +2174,13 @@
 innobase_close_connection(
 /*======================*/
 			/* out: 0 or error number */
+        handlerton*	hton,	/* in:  innobase handlerton */
 	THD*	thd)	/* in: handle to the MySQL thread of the user
 			whose resources should be free'd */
 {
 	trx_t*	trx;
 
-	trx = (trx_t*)thd->ha_data[innobase_hton->slot];
+	trx = (trx_t*)thd->ha_data[hton->slot];
 
 	ut_a(trx);
 
@@ -3254,11 +3275,11 @@
 	DBUG_ENTER("ha_innobase::write_row");
 
 	if (prebuilt->trx !=
-			(trx_t*) current_thd->ha_data[innobase_hton->slot]) {
+			(trx_t*) current_thd->ha_data[ht->slot]) {
 	  sql_print_error("The transaction object for the table handle is at "
 			  "%p, but for the current thread it is at %p",
 			  prebuilt->trx,
-			  (trx_t*) current_thd->ha_data[innobase_hton->slot]);
+			  (trx_t*) current_thd->ha_data[ht->slot]);
 
 		fputs("InnoDB: Dump of 200 bytes around prebuilt: ", stderr);
 		ut_print_buf(stderr, ((const byte*)prebuilt) - 100, 200);
@@ -3266,7 +3287,7 @@
 			"InnoDB: Dump of 200 bytes around transaction.all: ",
 			stderr);
 		ut_print_buf(stderr,
-		 ((byte*)(&(current_thd->ha_data[innobase_hton->slot]))) - 100,
+		 ((byte*)(&(current_thd->ha_data[ht->slot]))) - 100,
 								200);
 		putc('\n', stderr);
 		ut_error;
@@ -3320,7 +3341,7 @@
 			no need to re-acquire locks on it. */
 
 			/* Altering to InnoDB format */
-			innobase_commit(user_thd, 1);
+			innobase_commit(ht, user_thd, 1);
 			/* Note that this transaction is still active. */
 			prebuilt->trx->active_trans = 1;
 			/* We will need an IX lock on the destination table. */
@@ -3336,7 +3357,7 @@
 
 			/* Commit the transaction.  This will release the table
 			locks, so they have to be acquired again. */
-			innobase_commit(user_thd, 1);
+			innobase_commit(ht, user_thd, 1);
 			/* Note that this transaction is still active. */
 			prebuilt->trx->active_trans = 1;
 			/* Re-acquire the table lock on the source table. */
@@ -3643,7 +3664,7 @@
 	DBUG_ENTER("ha_innobase::update_row");
 
 	ut_a(prebuilt->trx ==
-		(trx_t*) current_thd->ha_data[innobase_hton->slot]);
+		(trx_t*) current_thd->ha_data[ht->slot]);
 
 	if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
 		table->timestamp_field->set_time();
@@ -3704,7 +3725,7 @@
 	DBUG_ENTER("ha_innobase::delete_row");
 
 	ut_a(prebuilt->trx ==
-		(trx_t*) current_thd->ha_data[innobase_hton->slot]);
+		(trx_t*) current_thd->ha_data[ht->slot]);
 
 	if (last_query_id != user_thd->query_id) {
 		prebuilt->sql_stat_start = TRUE;
@@ -3802,7 +3823,7 @@
 	row_prebuilt_t*	prebuilt = (row_prebuilt_t*) innobase_prebuilt;
 
 	ut_a(prebuilt->trx ==
-		(trx_t*) current_thd->ha_data[innobase_hton->slot]);
+		(trx_t*) current_thd->ha_data[ht->slot]);
 
 	/* Row read type is set to semi consistent read if this was
 	requested by the MySQL and either innodb_locks_unsafe_for_binlog
@@ -3969,7 +3990,7 @@
 	DBUG_ENTER("index_read");
 
 	ut_a(prebuilt->trx ==
-		(trx_t*) current_thd->ha_data[innobase_hton->slot]);
+		(trx_t*) current_thd->ha_data[ht->slot]);
 
 	statistic_increment(current_thd->status_var.ha_read_key_count,
 		&LOCK_status);
@@ -4084,7 +4105,7 @@
 
 	ut_ad(user_thd == current_thd);
 	ut_a(prebuilt->trx ==
-		(trx_t*) current_thd->ha_data[innobase_hton->slot]);
+		(trx_t*) current_thd->ha_data[ht->slot]);
 
 	active_index = keynr;
 
@@ -4174,7 +4195,7 @@
 	DBUG_ENTER("general_fetch");
 
 	ut_a(prebuilt->trx ==
-		(trx_t*) current_thd->ha_data[innobase_hton->slot]);
+		(trx_t*) current_thd->ha_data[ht->slot]);
 
 	innodb_srv_conc_enter_innodb(prebuilt->trx);
 
@@ -4410,7 +4431,7 @@
 		&LOCK_status);
 
 	ut_a(prebuilt->trx ==
-		(trx_t*) current_thd->ha_data[innobase_hton->slot]);
+		(trx_t*) current_thd->ha_data[ht->slot]);
 
 	if (prebuilt->clust_index_was_generated) {
 		/* No primary key was defined for the table and we
@@ -4460,7 +4481,7 @@
 	uint		len;
 
 	ut_a(prebuilt->trx ==
-		(trx_t*) current_thd->ha_data[innobase_hton->slot]);
+		(trx_t*) current_thd->ha_data[ht->slot]);
 
 	if (prebuilt->clust_index_was_generated) {
 		/* No primary key was defined for the table and we
@@ -4787,7 +4808,7 @@
 	/* Get the transaction associated with the current thd, or create one
 	if not yet created */
 
-	parent_trx = check_trx_exists(thd);
+	parent_trx = check_trx_exists(ht, thd);
 
 	/* In case MySQL calls this in the middle of a SELECT query, release
 	possible adaptive hash latch to avoid deadlocks of threads */
@@ -4960,7 +4981,7 @@
 
 	ut_a(prebuilt->trx && prebuilt->trx->magic_n == TRX_MAGIC_N);
 	ut_a(prebuilt->trx ==
-		(trx_t*) current_thd->ha_data[innobase_hton->slot]);
+		(trx_t*) current_thd->ha_data[ht->slot]);
 
 	dict_table = prebuilt->table;
 	trx = prebuilt->trx;
@@ -5040,7 +5061,7 @@
 	/* Get the transaction associated with the current thd, or create one
 	if not yet created */
 
-	parent_trx = check_trx_exists(thd);
+	parent_trx = check_trx_exists(ht, thd);
 
 	/* In case MySQL calls this in the middle of a SELECT query, release
 	possible adaptive hash latch to avoid deadlocks of threads */
@@ -5107,6 +5128,7 @@
 innobase_drop_database(
 /*===================*/
 			/* out: error number */
+        handlerton *hton, /* in: handlerton of Innodb */
 	char*	path)	/* in: database path; inside InnoDB the name
 			of the last directory in the path is used as
 			the database name: for example, in 'mysql/data/test'
@@ -5122,7 +5144,7 @@
 	/* Get the transaction associated with the current thd, or create one
 	if not yet created */
 
-	parent_trx = check_trx_exists(current_thd);
+	parent_trx = check_trx_exists(hton, current_thd);
 
 	/* In case MySQL calls this in the middle of a SELECT query, release
 	possible adaptive hash latch to avoid deadlocks of threads */
@@ -5201,7 +5223,7 @@
 	/* Get the transaction associated with the current thd, or create one
 	if not yet created */
 
-	parent_trx = check_trx_exists(current_thd);
+	parent_trx = check_trx_exists(ht, current_thd);
 
 	/* In case MySQL calls this in the middle of a SELECT query, release
 	possible adaptive hash latch to avoid deadlocks of threads */
@@ -5288,7 +5310,7 @@
 	DBUG_ENTER("records_in_range");
 
 	ut_a(prebuilt->trx ==
-		(trx_t*) current_thd->ha_data[innobase_hton->slot]);
+		(trx_t*) current_thd->ha_data[ht->slot]);
 
 	prebuilt->trx->op_info = (char*)"estimating records in index range";
 
@@ -5730,7 +5752,7 @@
 
 	ut_a(prebuilt->trx && prebuilt->trx->magic_n == TRX_MAGIC_N);
 	ut_a(prebuilt->trx ==
-		(trx_t*) current_thd->ha_data[innobase_hton->slot]);
+		(trx_t*) current_thd->ha_data[ht->slot]);
 
 	if (prebuilt->mysql_template == NULL) {
 		/* Build the template; we will use a dummy template
@@ -6014,7 +6036,7 @@
 	DBUG_ENTER("ha_innobase::can_switch_engines");
 
 	ut_a(prebuilt->trx ==
-		(trx_t*) current_thd->ha_data[innobase_hton->slot]);
+		(trx_t*) current_thd->ha_data[ht->slot]);
 
 	prebuilt->trx->op_info =
 			"determining if there are foreign key constraints";
@@ -6193,10 +6215,10 @@
 	/* Set the MySQL flag to mark that there is an active transaction */
 	if (trx->active_trans == 0) {
 
-		innobase_register_trx_and_stmt(thd);
+		innobase_register_trx_and_stmt(ht, thd);
 		trx->active_trans = 1;
 	} else {
-		innobase_register_stmt(thd);
+		innobase_register_stmt(ht, thd);
 	}
 
 	return(0);
@@ -6269,10 +6291,10 @@
 		transaction */
 		if (trx->active_trans == 0) {
 
-			innobase_register_trx_and_stmt(thd);
+			innobase_register_trx_and_stmt(ht, thd);
 			trx->active_trans = 1;
 		} else if (trx->n_mysql_tables_in_use == 0) {
-			innobase_register_stmt(thd);
+			innobase_register_stmt(ht, thd);
 		}
 
 		trx->n_mysql_tables_in_use++;
@@ -6350,7 +6372,7 @@
 
 		if (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) {
 			if (trx->active_trans != 0) {
-				innobase_commit(thd, TRUE);
+				innobase_commit(ht, thd, TRUE);
 			}
 		} else {
 			if (trx->isolation_level <= TRX_ISO_READ_COMMITTED
@@ -6431,7 +6453,7 @@
 	/* Set the MySQL flag to mark that there is an active transaction */
 	if (trx->active_trans == 0) {
 
-		innobase_register_trx_and_stmt(thd);
+		innobase_register_trx_and_stmt(ht, thd);
 		trx->active_trans = 1;
 	}
 
@@ -6479,6 +6501,7 @@
 bool
 innodb_show_status(
 /*===============*/
+	handlerton*	hton,	/* in: the innodb handlerton */
 	THD*	thd,	/* in: the MySQL query thread of the caller */
 	stat_print_fn *stat_print)
 {
@@ -6494,7 +6517,7 @@
 		DBUG_RETURN(FALSE);
 	}
 
-	trx = check_trx_exists(thd);
+	trx = check_trx_exists(hton, thd);
 
 	innobase_release_stat_resources(trx);
 
@@ -6569,6 +6592,7 @@
 bool
 innodb_mutex_show_status(
 /*=====================*/
+	handlerton*	hton,	/* in: the innodb handlerton */
 	THD*		thd,		/* in: the MySQL query thread of the
 					caller */
 	stat_print_fn*	stat_print)
@@ -6650,14 +6674,15 @@
 	DBUG_RETURN(FALSE);
 }
 
-bool innobase_show_status(THD* thd, stat_print_fn* stat_print,
-	enum ha_stat_type stat_type)
+bool innobase_show_status(handlerton *hton, THD* thd, 
+                          stat_print_fn* stat_print,
+                          enum ha_stat_type stat_type)
 {
 	switch (stat_type) {
 	case HA_ENGINE_STATUS:
-		return innodb_show_status(thd, stat_print);
+		return innodb_show_status(hton, thd, stat_print);
 	case HA_ENGINE_MUTEX:
-		return innodb_mutex_show_status(thd, stat_print);
+		return innodb_mutex_show_status(hton, thd, stat_print);
 	default:
 		return FALSE;
 	}
@@ -6757,7 +6782,7 @@
 	because we call update_thd() later, in ::external_lock()! Failure to
 	understand this caused a serious memory corruption bug in 5.1.11. */
 
-	trx = check_trx_exists(thd);
+	trx = check_trx_exists(ht, thd);
 
 	/* NOTE: MySQL can call this function with lock 'type' TL_IGNORE!
 	Be careful to ignore TL_IGNORE if we are going to do something with
@@ -7143,7 +7168,7 @@
 bool
 ha_innobase::get_error_message(int error, String *buf)
 {
-	trx_t*	trx = check_trx_exists(current_thd);
+	trx_t*	trx = check_trx_exists(ht, current_thd);
 
 	buf->copy(trx->detailed_error, strlen(trx->detailed_error),
 		system_charset_info);
@@ -7362,13 +7387,14 @@
 innobase_xa_prepare(
 /*================*/
 			/* out: 0 or error number */
+        handlerton *hton,
 	THD*	thd,	/* in: handle to the MySQL thread of the user
 			whose XA transaction should be prepared */
 	bool	all)	/* in: TRUE - commit transaction
 			FALSE - the current SQL statement ended */
 {
 	int error = 0;
-	trx_t* trx = check_trx_exists(thd);
+	trx_t* trx = check_trx_exists(hton, thd);
 
 	if (thd->lex->sql_command != SQLCOM_XA_PREPARE &&
 	    (all || !(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))))
@@ -7458,6 +7484,7 @@
 /*================*/
 				/* out: number of prepared transactions
 				stored in xid_list */
+        handlerton *hton,
 	XID*	xid_list,	/* in/out: prepared transactions */
 	uint	len)		/* in: number of slots in xid_list */
 {
@@ -7477,6 +7504,7 @@
 innobase_commit_by_xid(
 /*===================*/
 			/* out: 0 or error number */
+        handlerton *hton,
 	XID*	xid)	/* in: X/Open XA transaction identification */
 {
 	trx_t*	trx;
@@ -7500,6 +7528,7 @@
 innobase_rollback_by_xid(
 /*=====================*/
 			/* out: 0 or error number */
+        handlerton *hton,
 	XID	*xid)	/* in: X/Open XA transaction identification */
 {
 	trx_t*	trx;
@@ -7521,13 +7550,12 @@
 
 void*
 innobase_create_cursor_view(
-/*========================*/
-						/* out: pointer to cursor
-						view or NULL */
-	THD*			thd)		/* in: user thread handle */
+                          /* out: pointer to cursor view or NULL */
+        handlerton *hton, /* in: innobase hton */
+	THD* thd)	  /* in: user thread handle */
 {
 	return(read_cursor_view_create_for_mysql(
-					check_trx_exists(thd)));
+					check_trx_exists(hton, thd)));
 }
 
 /***********************************************************************
@@ -7537,11 +7565,11 @@
 
 void
 innobase_close_cursor_view(
-/*=======================*/
+        handlerton *hton,
 	THD*	thd,	/* in: user thread handle */
 	void*	curview)/* in: Consistent read view to be closed */
 {
-	read_cursor_view_close_for_mysql(check_trx_exists(current_thd),
+	read_cursor_view_close_for_mysql(check_trx_exists(hton, current_thd),
 						(cursor_view_t*) curview);
 }
 
@@ -7554,10 +7582,11 @@
 void
 innobase_set_cursor_view(
 /*=====================*/
+        handlerton *hton,
 	THD*	thd,	/* in: user thread handle */
 	void*	curview)/* in: Consistent cursor view to be set */
 {
-	read_cursor_set_for_mysql(check_trx_exists(current_thd),
+	read_cursor_set_for_mysql(check_trx_exists(hton, current_thd),
 						(cursor_view_t*) curview);
 }
 

--- 1.128/storage/innobase/handler/ha_innodb.h	2006-10-03 09:28:53 +02:00
+++ 1.129/storage/innobase/handler/ha_innodb.h	2006-10-03 09:28:53 +02:00
@@ -80,7 +80,7 @@
 
 	/* Init values for the class: */
  public:
-	ha_innobase(TABLE_SHARE *table_arg);
+	ha_innobase(handlerton *hton, TABLE_SHARE *table_arg);
 	~ha_innobase() {}
 	/*
 	  Get the row type from the storage engine.  If this method returns
@@ -238,8 +238,8 @@
 }
 
 int innobase_init(void);
-int innobase_end(ha_panic_function type);
-bool innobase_flush_logs(void);
+int innobase_end(handlerton *hton, ha_panic_function type);
+bool innobase_flush_logs(handlerton *hton);
 uint innobase_get_free_space(void);
 
 /*
@@ -256,14 +256,14 @@
 void innobase_store_binlog_offset_and_flush_log(char *binlog_name,longlong offset);
 #endif
 
-void innobase_drop_database(char *path);
-bool innobase_show_status(THD* thd, stat_print_fn*, enum ha_stat_type);
+void innobase_drop_database(handlerton *hton, char *path);
+bool innobase_show_status(handlerton *hton, THD* thd, stat_print_fn*, enum ha_stat_type);
 
-int innobase_release_temporary_latches(THD *thd);
+int innobase_release_temporary_latches(handlerton *hton, THD *thd);
 
-void innobase_store_binlog_offset_and_flush_log(char *binlog_name,longlong offset);
+void innobase_store_binlog_offset_and_flush_log(handlerton *hton, char *binlog_name,longlong offset);
 
-int innobase_start_trx_and_assign_read_view(THD* thd);
+int innobase_start_trx_and_assign_read_view(handlerton *hton, THD* thd);
 
 /***********************************************************************
 This function is used to prepare X/Open XA distributed transaction   */
@@ -271,6 +271,7 @@
 int innobase_xa_prepare(
 /*====================*/
 			/* out: 0 or error number */
+        handlerton *hton, /* in: innobase hton */
 	THD*	thd,	/* in: handle to the MySQL thread of the user
 			whose XA transaction should be prepared */
 	bool	all);	/* in: TRUE - commit transaction
@@ -283,6 +284,7 @@
 /*====================*/
 				/* out: number of prepared transactions
 				stored in xid_list */
+        handlerton *hton, /* in: innobase hton */
 	XID*	xid_list,	/* in/out: prepared transactions */
 	uint	len);		/* in: number of slots in xid_list */
 
@@ -293,6 +295,7 @@
 int innobase_commit_by_xid(
 /*=======================*/
 			/* out: 0 or error number */
+        handlerton *hton, /* in: innobase hton */
 	XID*	xid);	/* in : X/Open XA Transaction Identification */
 
 /***********************************************************************
@@ -301,6 +304,7 @@
 
 int innobase_rollback_by_xid(
 			/* out: 0 or error number */
+        handlerton *hton, /* in: innobase hton */
 	XID	*xid);	/* in : X/Open XA Transaction Identification */
 
 
@@ -312,10 +316,9 @@
 
 void*
 innobase_create_cursor_view(
-/*========================*/
-						/* out: pointer to cursor
-						view or NULL */
-	THD*			thd);		/* in: user thread handle */
+			  /* out: Pointer to cursor view or NULL */
+        handlerton *hton, /* in: innobase hton */
+	THD* thd);	  /* in: user thread handle */
 
 /***********************************************************************
 Close the given consistent cursor view of a transaction and restore
@@ -325,6 +328,7 @@
 void
 innobase_close_cursor_view(
 /*=======================*/
+        handlerton *hton, /* in: innobase hton */
 	THD*	thd,		/* in: user thread handle */
 	void*	curview);	/* in: Consistent read view to be closed */
 
@@ -338,5 +342,6 @@
 void
 innobase_set_cursor_view(
 /*=====================*/
+        handlerton *hton, /* in: innobase hton */
 	THD*	thd,		/* in: user thread handle */
 	void*	curview);	/* in: Consistent read view to be set */

--- 1.58/mysql-test/r/partition.result	2006-10-03 09:28:53 +02:00
+++ 1.59/mysql-test/r/partition.result	2006-10-03 09:28:53 +02:00
@@ -68,7 +68,7 @@
 engine = csv
 partition by list (a)
 (partition p0 values in (null));
-ERROR HY000: CSV handler cannot be used in partitioned tables
+ERROR HY000: Engine cannot be used in partitioned tables
 create table t1 (a bigint)
 partition by range (a)
 (partition p0 values less than (0xFFFFFFFFFFFFFFFF),
@@ -102,7 +102,7 @@
 engine = csv
 partition by list (a)
 (partition p0 values in (null));
-ERROR HY000: CSV handler cannot be used in partitioned tables
+ERROR HY000: Engine cannot be used in partitioned tables
 create table t1 (a int)
 partition by key(a)
 (partition p0 engine = MEMORY);
@@ -1054,7 +1054,7 @@
 create table t1 (a int)
 partition by key (a)
 (partition p0 engine = MERGE);
-ERROR HY000: MyISAM Merge handler cannot be used in partitioned tables
+ERROR HY000: Engine cannot be used in partitioned tables
 create table t1 (a varchar(1))
 partition by key (a)
 as select 'a';

--- 1.74/mysql-test/r/ps.result	2006-10-03 09:28:54 +02:00
+++ 1.75/mysql-test/r/ps.result	2006-10-03 09:28:54 +02:00
@@ -499,6 +499,54 @@
 execute stmt;
 drop temporary table t1;
 deallocate prepare stmt;
+CREATE TABLE t1(
+ID int(10) unsigned NOT NULL auto_increment,
+Member_ID varchar(15) NOT NULL default '',
+Action varchar(12) NOT NULL,
+Action_Date datetime NOT NULL,
+Track varchar(15) default NULL,
+User varchar(12) default NULL,
+Date_Updated timestamp NOT NULL default CURRENT_TIMESTAMP on update
+CURRENT_TIMESTAMP,
+PRIMARY KEY (ID),
+KEY Action (Action),
+KEY Action_Date (Action_Date)
+);
+INSERT INTO t1(Member_ID, Action, Action_Date, Track) VALUES
+('111111', 'Disenrolled', '2006-03-01', 'CAD' ),
+('111111', 'Enrolled', '2006-03-01', 'CAD' ),
+('111111', 'Disenrolled', '2006-07-03', 'CAD' ),
+('222222', 'Enrolled', '2006-03-07', 'CAD' ),
+('222222', 'Enrolled', '2006-03-07', 'CHF' ),
+('222222', 'Disenrolled', '2006-08-02', 'CHF' ),
+('333333', 'Enrolled', '2006-03-01', 'CAD' ),
+('333333', 'Disenrolled', '2006-03-01', 'CAD' ),
+('444444', 'Enrolled', '2006-03-01', 'CAD' ),
+('555555', 'Disenrolled', '2006-03-01', 'CAD' ),
+('555555', 'Enrolled', '2006-07-21', 'CAD' ),
+('555555', 'Disenrolled', '2006-03-01', 'CHF' ),
+('666666', 'Enrolled', '2006-02-09', 'CAD' ),
+('666666', 'Enrolled', '2006-05-12', 'CHF' ),
+('666666', 'Disenrolled', '2006-06-01', 'CAD' );
+PREPARE STMT FROM
+"SELECT GROUP_CONCAT(Track SEPARATOR ', ') FROM t1
+  WHERE Member_ID=? AND Action='Enrolled' AND
+        (Track,Action_Date) IN (SELECT Track, MAX(Action_Date) FROM t1
+                                  WHERE Member_ID=?
+                                    GROUP BY Track 
+                                      HAVING Track>='CAD' AND
+                                             MAX(Action_Date)>'2006-03-01')";
+SET @id='111111';
+EXECUTE STMT USING @id,@id;
+GROUP_CONCAT(Track SEPARATOR ', ')
+NULL
+SET @id='222222';
+EXECUTE STMT USING @id,@id;
+GROUP_CONCAT(Track SEPARATOR ', ')
+CAD
+DEALLOCATE PREPARE STMT;
+DROP TABLE t1;
+End of 4.1 tests
 create table t1 (a varchar(20));
 insert into t1 values ('foo');
 prepare stmt FROM 'SELECT char_length (a) FROM t1';
Thread
bk commit into 5.1 tree (msvensson:1.2339)msvensson3 Oct