List:Commits« Previous MessageNext Message »
From:knielsen Date:October 4 2006 9:33am
Subject:bk commit into 5.1 tree (knielsen:1.2298)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of knielsen. When knielsen 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-04 11:33:28+02:00, knielsen@stripped +37 -0
  Merge bk-internal.mysql.com:/dev/shm/knielsen/mysql-5.1-ndb-bj
  into  bk-internal.mysql.com:/dev/shm/knielsen/mysql-5.1-new-ndb
  MERGE: 1.2273.1.46

  client/mysqltest.c@stripped, 2006-10-04 11:23:53+02:00, knielsen@stripped +0 -3
    Auto merged
    MERGE: 1.221.3.1

  include/config-netware.h@stripped, 2006-10-04 11:23:53+02:00, knielsen@stripped +0 -0
    Auto merged
    MERGE: 1.16.2.1

  mysql-test/r/csv.result@stripped, 2006-10-04 11:23:54+02:00, knielsen@stripped +0 -0
    Auto merged
    MERGE: 1.10.2.1

  mysql-test/r/ctype_utf8.result@stripped, 2006-10-04 11:23:54+02:00, knielsen@stripped +0 -0
    Auto merged
    MERGE: 1.98.1.3

  mysql-test/r/func_time.result@stripped, 2006-10-04 11:23:54+02:00, knielsen@stripped +0 -0
    Auto merged
    MERGE: 1.68.2.1

  mysql-test/t/csv.test@stripped, 2006-10-04 11:23:54+02:00, knielsen@stripped +0 -0
    Auto merged
    MERGE: 1.12.2.1

  mysql-test/t/ctype_utf8.test@stripped, 2006-10-04 11:23:54+02:00, knielsen@stripped +0 -0
    Auto merged
    MERGE: 1.89.1.3

  mysql-test/t/func_time.test@stripped, 2006-10-04 11:23:54+02:00, knielsen@stripped +0 -0
    Auto merged
    MERGE: 1.54.2.1

  sql/ha_ndbcluster.cc@stripped, 2006-10-04 11:23:54+02:00, knielsen@stripped +0 -0
    Auto merged
    MERGE: 1.348.4.14

  sql/item_timefunc.cc@stripped, 2006-10-04 11:23:54+02:00, knielsen@stripped +0 -0
    Auto merged
    MERGE: 1.129.2.1

  sql/sql_acl.cc@stripped, 2006-10-04 11:23:54+02:00, knielsen@stripped +0 -0
    Auto merged
    MERGE: 1.204.2.1

  sql/sql_base.cc@stripped, 2006-10-04 11:23:54+02:00, knielsen@stripped +0 -0
    Auto merged
    MERGE: 1.345.1.3

  sql/sql_lex.h@stripped, 2006-10-04 11:23:55+02:00, knielsen@stripped +0 -0
    Auto merged
    MERGE: 1.234.1.10

  sql/sql_view.cc@stripped, 2006-10-04 11:23:55+02:00, knielsen@stripped +0 -0
    Auto merged
    MERGE: 1.101.4.4

  sql/table.cc@stripped, 2006-10-04 11:23:55+02:00, knielsen@stripped +0 -0
    Auto merged
    MERGE: 1.239.1.6

  storage/csv/ha_tina.cc@stripped, 2006-10-04 11:31:55+02:00, knielsen@stripped +0 -19
    manual merge.
    MERGE: 1.55.3.1

  storage/innobase/btr/btr0btr.c@stripped, 2006-10-04 11:32:07+02:00, knielsen@stripped +0 -0
    SCCS merged
    MERGE: 1.44.2.1

  storage/innobase/buf/buf0buf.c@stripped, 2006-10-04 11:32:09+02:00, knielsen@stripped +0 -0
    SCCS merged
    MERGE: 1.53.2.1

  storage/innobase/dict/dict0dict.c@stripped, 2006-10-04 11:32:11+02:00, knielsen@stripped +0 -0
    SCCS merged
    MERGE: 1.83.2.1

  storage/innobase/fil/fil0fil.c@stripped, 2006-10-04 11:32:12+02:00, knielsen@stripped +0 -0
    SCCS merged
    MERGE: 1.65.2.1

  storage/innobase/fsp/fsp0fsp.c@stripped, 2006-10-04 11:32:12+02:00, knielsen@stripped +0 -0
    SCCS merged
    MERGE: 1.28.2.1

  storage/innobase/handler/ha_innodb.cc@stripped, 2006-10-04 11:32:46+02:00, knielsen@stripped +0 -0
    SCCS merged
    MERGE: 1.284.3.2

  storage/innobase/handler/ha_innodb.cc@stripped, 2006-10-04 11:23:53+02:00, knielsen@stripped +0 -0
    Merge rename: sql/ha_innodb.cc -> storage/innobase/handler/ha_innodb.cc

  storage/innobase/include/btr0cur.ic@stripped, 2006-10-04 11:33:09+02:00, knielsen@stripped +0 -4
    use local
    MERGE: 1.6.2.1

  storage/innobase/include/buf0buf.ic@stripped, 2006-10-04 11:33:16+02:00, knielsen@stripped +0 -0
    SCCS merged
    MERGE: 1.20.2.1

  storage/innobase/log/log0log.c@stripped, 2006-10-04 11:33:17+02:00, knielsen@stripped +0 -0
    SCCS merged
    MERGE: 1.47.2.1

  storage/innobase/log/log0recv.c@stripped, 2006-10-04 11:33:18+02:00, knielsen@stripped +0 -0
    SCCS merged
    MERGE: 1.55.2.1

  storage/innobase/os/os0file.c@stripped, 2006-10-04 11:33:19+02:00, knielsen@stripped +0 -0
    SCCS merged
    MERGE: 1.116.2.1

  storage/innobase/row/row0mysql.c@stripped, 2006-10-04 11:33:20+02:00, knielsen@stripped +0 -0
    SCCS merged
    MERGE: 1.128.2.1

  storage/innobase/row/row0sel.c@stripped, 2006-10-04 11:33:20+02:00, knielsen@stripped +0 -0
    SCCS merged
    MERGE: 1.106.2.1

  storage/innobase/srv/srv0start.c@stripped, 2006-10-04 11:33:23+02:00, knielsen@stripped +0 -0
    SCCS merged
    MERGE: 1.93.2.1

  storage/innobase/ut/ut0dbg.c@stripped, 2006-10-04 11:33:24+02:00, knielsen@stripped +0 -0
    SCCS merged
    MERGE: 1.11.2.1

  storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp@stripped, 2006-10-04 11:23:55+02:00, knielsen@stripped +0 -0
    Auto merged
    MERGE: 1.81.2.1

  storage/ndb/src/mgmapi/mgmapi.cpp@stripped, 2006-10-04 11:23:55+02:00, knielsen@stripped +0 -0
    Auto merged
    MERGE: 1.69.1.1

  storage/ndb/src/ndbapi/Ndb.cpp@stripped, 2006-10-04 11:23:55+02:00, knielsen@stripped +0 -0
    Auto merged
    MERGE: 1.77.1.1

  storage/ndb/src/ndbapi/ndberror.c@stripped, 2006-10-04 11:23:55+02:00, knielsen@stripped +0 -0
    Auto merged
    MERGE: 1.71.1.1

  storage/ndb/tools/ndb_condig.cpp@stripped, 2006-10-04 11:23:55+02:00, knielsen@stripped +0 -0
    Auto merged
    MERGE: 1.12.1.2

  tests/mysql_client_test.c@stripped, 2006-10-04 11:23:55+02:00, knielsen@stripped +0 -0
    Auto merged
    MERGE: 1.204.2.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:	knielsen
# Host:	bk-internal.mysql.com
# Root:	/dev/shm/knielsen/mysql-5.1-new-ndb/RESYNC

--- 1.241/sql/table.cc	2006-10-04 11:33:36 +02:00
+++ 1.242/sql/table.cc	2006-10-04 11:33:36 +02:00
@@ -93,6 +93,7 @@
 {
   MEM_ROOT mem_root;
   TABLE_SHARE *share;
+  char *key_buff, *path_buff;
   char path[FN_REFLEN];
   uint path_length;
   DBUG_ENTER("alloc_table_share");
@@ -103,22 +104,17 @@
                                     table_list->db,
                                     table_list->table_name, "", 0);
   init_sql_alloc(&mem_root, TABLE_ALLOC_BLOCK_SIZE, 0);
-  if ((share= (TABLE_SHARE*) alloc_root(&mem_root,
-					sizeof(*share) + key_length +
-                                        path_length +1)))
+  if (multi_alloc_root(&mem_root,
+                       &share, sizeof(*share),
+                       &key_buff, key_length,
+                       &path_buff, path_length + 1,
+                       NULL))
   {
     bzero((char*) share, sizeof(*share));
-    share->table_cache_key.str=    (char*) (share+1);
-    share->table_cache_key.length= key_length;
-    memcpy(share->table_cache_key.str, key, key_length);
-
-    /* Use the fact the key is db/0/table_name/0 */
-    share->db.str=            share->table_cache_key.str;
-    share->db.length=         strlen(share->db.str);
-    share->table_name.str=    share->db.str + share->db.length + 1;
-    share->table_name.length= strlen(share->table_name.str);
 
-    share->path.str= share->table_cache_key.str+ key_length;
+    share->set_table_cache_key(key_buff, key, key_length);
+
+    share->path.str= path_buff;
     share->path.length= path_length;
     strmov(share->path.str, path);
     share->normalized_path.str=    share->path.str;
@@ -1475,11 +1471,23 @@
 #ifdef WITH_PARTITION_STORAGE_ENGINE
   if (share->partition_info_len)
   {
-    MEM_ROOT **root_ptr, *old_root;
+  /*
+    In this execution we must avoid calling thd->change_item_tree since
+    we might release memory before statement is completed. We do this
+    by changing to a new statement arena. As part of this arena we also
+    set the memory root to be the memory root of the table since we
+    call the parser and fix_fields which both can allocate memory for
+    item objects. We keep the arena to ensure that we can release the
+    free_list when closing the table object.
+    SEE Bug #21658
+  */
+
+    Query_arena *backup_stmt_arena_ptr= thd->stmt_arena;
+    Query_arena backup_arena;
+    Query_arena part_func_arena(&outparam->mem_root, Query_arena::INITIALIZED);
+    thd->set_n_backup_active_arena(&part_func_arena, &backup_arena);
+    thd->stmt_arena= &part_func_arena;
     bool tmp;
-    root_ptr= my_pthread_getspecific_ptr(MEM_ROOT**, THR_MALLOC);
-    old_root= *root_ptr;
-    *root_ptr= &outparam->mem_root;
 
     tmp= mysql_unpack_partition(thd, share->partition_info,
                                 share->partition_info_len,
@@ -1491,7 +1499,10 @@
     DBUG_PRINT("info", ("autopartitioned: %u", share->auto_partitioned));
     if (!tmp)
       tmp= fix_partition_func(thd, outparam, is_create_table);
-    *root_ptr= old_root;
+    thd->stmt_arena= backup_stmt_arena_ptr;
+    thd->restore_active_arena(&part_func_arena, &backup_arena);
+    if (!tmp)
+      outparam->part_info->item_free_list= part_func_arena.free_list;
     if (tmp)
     {
       if (is_create_table)
@@ -2246,7 +2257,7 @@
 
 bool check_db_name(char *name)
 {
-  char *start=name;
+  uint name_length= 0;  // name length in symbols
   /* Used to catch empty names and names with end space */
   bool last_char_is_space= TRUE;
 
@@ -2266,13 +2277,15 @@
         name += len;
         continue;
       }
+    name_length++;
     }
 #else
     last_char_is_space= *name==' ';
 #endif
+    name_length++;
     name++;
   }
-  return last_char_is_space || (uint) (name - start) > NAME_LEN;
+  return last_char_is_space || name_length > NAME_LEN;
 }
 
 
@@ -2354,28 +2367,28 @@
   Checks whether a table is intact. Should be done *just* after the table has
   been opened.
   
-  Synopsis
+  SYNOPSIS
     table_check_intact()
-      table         - the table to check
-      table_f_count - expected number of columns in the table
-      table_def     - expected structure of the table (column name and type)
-    last_create_time- the table->file->create_time of the table in memory
-                      we have checked last time
-      error_num     - ER_XXXX from the error messages file. When 0 no error
-                      is sent to the client in case types does not match.
-                      If different col number either 
-                      ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE or 
-                      ER_COL_COUNT_DOESNT_MATCH_CORRUPTED is used
+      table             The table to check
+      table_f_count     Expected number of columns in the table
+      table_def         Expected structure of the table (column name and type)
+      last_create_time  The table->file->create_time of the table in memory
+                        we have checked last time
+      error_num         ER_XXXX from the error messages file. When 0 no error
+                        is sent to the client in case types does not match.
+                        If different col number either 
+                        ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE or 
+                        ER_COL_COUNT_DOESNT_MATCH_CORRUPTED is used
 
   RETURNS
-    0   - OK
-    1   - There was an error
+    FALSE  OK
+    TRUE   There was an error
 */
 
 my_bool
-table_check_intact(TABLE *table, uint table_f_count,
-                   TABLE_FIELD_W_TYPE *table_def, time_t *last_create_time,
-                   int error_num)
+table_check_intact(TABLE *table, const uint table_f_count,
+                   const TABLE_FIELD_W_TYPE *table_def,
+                   time_t *last_create_time, int error_num)
 {
   uint i;
   my_bool error= FALSE;
@@ -2390,7 +2403,7 @@
     DBUG_PRINT("info", ("I am suspecting, checking table"));
     if (fields_diff_count)
     {
-      // previous MySQL version
+      /* previous MySQL version */
       error= TRUE;
       if (MYSQL_VERSION_ID > table->s->mysql_version)
       {
@@ -2413,22 +2426,22 @@
       else
       {
         /*
-          moving from newer mysql to older one -> let's say not an error but
+          Moving from newer mysql to older one -> let's say not an error but
           will check the definition afterwards. If a column was added at the
           end then we don't care much since it's not in the middle.
         */
         error= FALSE;
       }
     }
-    //definitely something has changed
+    /* definitely something has changed */
     char buffer[255];
     for (i=0 ; i < table_f_count; i++, table_def++)
     {      
       String sql_type(buffer, sizeof(buffer), system_charset_info);
       sql_type.length(0);
       /*
-        name changes are not fatal, we use sequence numbers => no prob for us
-        but this can show tampered table or broken table.
+        Name changes are not fatal, we use sequence numbers => no problem
+        for us but this can show tampered table or broken table.
       */
       if (i < table->s->fields)
       {
@@ -2442,7 +2455,7 @@
         }
                         
         /*
-          IF the type does not match than something is really wrong
+          If the type does not match than something is really wrong
           Check up to length - 1. Why?
           1. datetime -> datetim -> the same
           2. int(11) -> int(11  -> the same

--- 1.102/mysql-test/r/ctype_utf8.result	2006-10-04 11:33:36 +02:00
+++ 1.103/mysql-test/r/ctype_utf8.result	2006-10-04 11:33:36 +02:00
@@ -924,6 +924,37 @@
 select ifnull(NULL, _utf8'string');
 ifnull(NULL, _utf8'string')
 string
+set names utf8;
+create table t1 (s1 char(5) character set utf8 collate utf8_lithuanian_ci);
+insert into t1 values ('I'),('K'),('Y');
+select * from t1 where s1 < 'K' and s1 = 'Y';
+s1
+I
+Y
+select * from t1 where 'K' > s1 and s1 = 'Y';
+s1
+I
+Y
+drop table t1;
+create table t1 (s1 char(5) character set utf8 collate utf8_czech_ci);
+insert into t1 values ('c'),('d'),('h'),('ch'),('CH'),('cH'),('Ch'),('i');
+select * from t1 where s1 > 'd' and s1 = 'CH';
+s1
+ch
+CH
+Ch
+select * from t1 where 'd' < s1 and s1 = 'CH';
+s1
+ch
+CH
+Ch
+select * from t1 where s1 = 'cH' and s1 <> 'ch';
+s1
+cH
+select * from t1 where 'cH' = s1 and s1 <> 'ch';
+s1
+cH
+drop table t1;
 create table t1 (a varchar(255)) default character set utf8;
 insert into t1 values (1.0);
 drop table t1;
@@ -1309,6 +1340,19 @@
 a
 e
 drop table t1;
+set names utf8;
+grant select on test.* to юзер_юзер@localhost;
+user()
+юзер_юзер@localhost
+revoke all on test.* from юзер_юзер@localhost;
+drop user юзер_юзер@localhost;
+create database имя_базы_в_кодировке_утф8_длиной_больше_чем_45;
+use имя_базы_в_кодировке_утф8_длиной_больше_чем_45;
+select database();
+database()
+имя_базы_в_кодировке_утф8_длиной_больше_чем_45
+drop database имя_базы_в_кодировке_утф8_длиной_больше_чем_45;
+use test;
 CREATE TABLE t1(id varchar(20) NOT NULL) DEFAULT CHARSET=utf8;
 INSERT INTO t1 VALUES ('xxx'), ('aa'), ('yyy'), ('aa');
 SELECT id FROM t1;

--- 1.91/mysql-test/t/ctype_utf8.test	2006-10-04 11:33:36 +02:00
+++ 1.92/mysql-test/t/ctype_utf8.test	2006-10-04 11:33:36 +02:00
@@ -728,6 +728,24 @@
 select ifnull(NULL, _utf8'string');
 
 #
+# Bug#9509 Optimizer: wrong result after AND with comparisons
+#
+set names utf8;
+create table t1 (s1 char(5) character set utf8 collate utf8_lithuanian_ci);
+insert into t1 values ('I'),('K'),('Y');
+select * from t1 where s1 < 'K' and s1 = 'Y';
+select * from t1 where 'K' > s1 and s1 = 'Y';
+drop table t1;
+
+create table t1 (s1 char(5) character set utf8 collate utf8_czech_ci);
+insert into t1 values ('c'),('d'),('h'),('ch'),('CH'),('cH'),('Ch'),('i');
+select * from t1 where s1 > 'd' and s1 = 'CH';
+select * from t1 where 'd' < s1 and s1 = 'CH';
+select * from t1 where s1 = 'cH' and s1 <> 'ch';
+select * from t1 where 'cH' = s1 and s1 <> 'ch';
+drop table t1;
+
+#
 # Bug#10714: Inserting double value into utf8 column crashes server
 #
 create table t1 (a varchar(255)) default character set utf8;
@@ -1050,6 +1068,23 @@
 explain select a from t1 group by a;
 select a from t1 group by a;
 drop table t1;
+
+#
+# Bug#20393: User name truncation in mysql client
+# Bug#21432: Database/Table name limited to 64 bytes, not chars, problems with multi-byte
+#
+set names utf8;
+#create user юзер_юзер@localhost;
+grant select on test.* to юзер_юзер@localhost;
+--exec $MYSQL --default-character-set=utf8 --user=юзер_юзер -e "select user()"
+revoke all on test.* from юзер_юзер@localhost;
+drop user юзер_юзер@localhost;
+
+create database имя_базы_в_кодировке_утф8_длиной_больше_чем_45;
+use имя_базы_в_кодировке_утф8_длиной_больше_чем_45;
+select database();
+drop database имя_базы_в_кодировке_утф8_длиной_больше_чем_45;
+use test;
 
 # End of 4.1 tests
 

--- 1.108/sql/sql_view.cc	2006-10-04 11:33:36 +02:00
+++ 1.109/sql/sql_view.cc	2006-10-04 11:33:36 +02:00
@@ -25,7 +25,7 @@
 
 #define MD5_BUFF_LENGTH 33
 
-const LEX_STRING view_type= { (char*) STRING_WITH_LEN("VIEW") };
+const LEX_STRING view_type= { C_STRING_WITH_LEN("VIEW") };
 
 static int mysql_register_view(THD *thd, TABLE_LIST *view,
 			       enum_view_create_mode mode);
@@ -581,40 +581,40 @@
   parse()
 */
 static File_option view_parameters[]=
-{{{(char*) STRING_WITH_LEN("query")},
+{{{ C_STRING_WITH_LEN("query")},
   offsetof(TABLE_LIST, query),
   FILE_OPTIONS_ESTRING},
- {{(char*) STRING_WITH_LEN("md5")},
+ {{ C_STRING_WITH_LEN("md5")},
   offsetof(TABLE_LIST, md5),
   FILE_OPTIONS_STRING},
- {{(char*) STRING_WITH_LEN("updatable")},
+ {{ C_STRING_WITH_LEN("updatable")},
   offsetof(TABLE_LIST, updatable_view),
   FILE_OPTIONS_ULONGLONG},
- {{(char*) STRING_WITH_LEN("algorithm")},
+ {{ C_STRING_WITH_LEN("algorithm")},
   offsetof(TABLE_LIST, algorithm),
   FILE_OPTIONS_ULONGLONG},
- {{(char*) STRING_WITH_LEN("definer_user")},
+ {{ C_STRING_WITH_LEN("definer_user")},
   offsetof(TABLE_LIST, definer.user),
   FILE_OPTIONS_STRING},
- {{(char*) STRING_WITH_LEN("definer_host")},
+ {{ C_STRING_WITH_LEN("definer_host")},
   offsetof(TABLE_LIST, definer.host),
   FILE_OPTIONS_STRING},
- {{(char*) STRING_WITH_LEN("suid")},
+ {{ C_STRING_WITH_LEN("suid")},
   offsetof(TABLE_LIST, view_suid),
   FILE_OPTIONS_ULONGLONG},
- {{(char*) STRING_WITH_LEN("with_check_option")},
+ {{ C_STRING_WITH_LEN("with_check_option")},
   offsetof(TABLE_LIST, with_check),
   FILE_OPTIONS_ULONGLONG},
- {{(char*) STRING_WITH_LEN("revision")},
+ {{ C_STRING_WITH_LEN("revision")},
   offsetof(TABLE_LIST, revision),
   FILE_OPTIONS_REV},
- {{(char*) STRING_WITH_LEN("timestamp")},
+ {{ C_STRING_WITH_LEN("timestamp")},
   offsetof(TABLE_LIST, timestamp),
   FILE_OPTIONS_TIMESTAMP},
- {{(char*)STRING_WITH_LEN("create-version")},
+ {{ C_STRING_WITH_LEN("create-version")},
   offsetof(TABLE_LIST, file_version),
   FILE_OPTIONS_ULONGLONG},
- {{(char*) STRING_WITH_LEN("source")},
+ {{ C_STRING_WITH_LEN("source")},
   offsetof(TABLE_LIST, source),
   FILE_OPTIONS_ESTRING},
  {{NullS, 0},			0,
@@ -1070,6 +1070,30 @@
     if (lex->binlog_row_based_if_mixed)
       old_lex->binlog_row_based_if_mixed= TRUE;
 #endif
+    bool view_is_mergeable= (table->algorithm != VIEW_ALGORITHM_TMPTABLE &&
+                             lex->can_be_merged());
+    TABLE_LIST *view_main_select_tables;
+    if (view_is_mergeable)
+    {
+      /*
+        Currently 'view_main_select_tables' differs from 'view_tables'
+        only then view has CONVERT_TZ() function in its select list.
+        This may change in future, for example if we enable merging of
+        views with subqueries in select list.
+      */
+      view_main_select_tables=
+        (TABLE_LIST*)lex->select_lex.table_list.first;
+
+      /*
+        Let us set proper lock type for tables of the view's main
+        select since we may want to perform update or insert on
+        view. This won't work for view containing union. But this is
+        ok since we don't allow insert and update on such views
+        anyway.
+      */
+      for (tbl= view_main_select_tables; tbl; tbl= tbl->next_local)
+        tbl->lock_type= table->lock_type;
+    }
 
     /*
       If we are opening this view as part of implicit LOCK TABLES, then
@@ -1125,43 +1149,26 @@
       - VIEW SELECT allow merging
       - VIEW used in subquery or command support MERGE algorithm
     */
-    if (table->algorithm != VIEW_ALGORITHM_TMPTABLE &&
-	lex->can_be_merged() &&
+    if (view_is_mergeable &&
         (table->select_lex->master_unit() != &old_lex->unit ||
          old_lex->can_use_merged()) &&
         !old_lex->can_not_use_merged())
     {
-      List_iterator_fast<TABLE_LIST> ti(view_select->top_join_list);
-      /*
-        Currently 'view_main_select_tables' differs from 'view_tables'
-        only then view has CONVERT_TZ() function in its select list.
-        This may change in future, for example if we enable merging
-        of views with subqueries in select list.
-      */
-      TABLE_LIST *view_main_select_tables=
-                    (TABLE_LIST*)lex->select_lex.table_list.first;
       /* lex should contain at least one table */
       DBUG_ASSERT(view_main_select_tables != 0);
 
+      List_iterator_fast<TABLE_LIST> ti(view_select->top_join_list);
+
       table->effective_algorithm= VIEW_ALGORITHM_MERGE;
       DBUG_PRINT("info", ("algorithm: MERGE"));
       table->updatable= (table->updatable_view != 0);
       table->effective_with_check=
         old_lex->get_effective_with_check(table);
       table->merge_underlying_list= view_main_select_tables;
-      /*
-        Let us set proper lock type for tables of the view's main select
-        since we may want to perform update or insert on view. This won't
-        work for view containing union. But this is ok since we don't
-        allow insert and update on such views anyway.
 
-        Also we fill correct wanted privileges.
-      */
-      for (tbl= table->merge_underlying_list; tbl; tbl= tbl->next_local)
-      {
-        tbl->lock_type= table->lock_type;
+      /* Fill correct wanted privileges. */
+      for (tbl= view_main_select_tables; tbl; tbl= tbl->next_local)
         tbl->grant.want_privilege= top_view->grant.orig_want_privilege;
-      }
 
       /* prepare view context */
       lex->select_lex.context.resolve_in_table_list_only(view_main_select_tables);

--- 1.13/storage/ndb/tools/ndb_condig.cpp	2006-10-04 11:33:36 +02:00
+++ 1.14/storage/ndb/tools/ndb_condig.cpp	2006-10-04 11:33:36 +02:00
@@ -67,7 +67,7 @@
   { "ndb-connectstring", 256,
     "Set connect string for connecting to ndb_mgmd. " 
     "Syntax: \"[nodeid=<id>;][host=]<hostname>[:<port>]\". " 
-    "Overides specifying entries in NDB_CONNECTSTRING and Ndb.cfg", 
+    "Overrides specifying entries in NDB_CONNECTSTRING and my.cnf", 
     (gptr*) &g_connectstring, (gptr*) &g_connectstring, 
     0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
   { "ndb-shm", 256, "Print nodes",

--- 1.83/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp	2006-10-04 11:33:36 +02:00
+++ 1.84/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp	2006-10-04 11:33:37 +02:00
@@ -6699,7 +6699,13 @@
         }
       }
     }
-    ndbrequire(count == (2U + (1 + noOfReplicas) * noOfFragments)); 
+    if(count != (2U + (1 + noOfReplicas) * noOfFragments)){
+        char buf[255];
+        BaseString::snprintf(buf, sizeof(buf),
+                           "Illegal configuration change: NoOfReplicas."
+                           " Can't be applied online ");
+        progError(__LINE__, NDBD_EXIT_INVALID_CONFIG, buf);
+    }
     
     CreateFragmentationConf * const conf = 
       (CreateFragmentationConf*)signal->getDataPtrSend();

--- 1.70/storage/ndb/src/mgmapi/mgmapi.cpp	2006-10-04 11:33:37 +02:00
+++ 1.71/storage/ndb/src/mgmapi/mgmapi.cpp	2006-10-04 11:33:37 +02:00
@@ -1306,6 +1306,45 @@
   return 0;
 }
 
+static const char *clusterlog_names[]=
+  { "startup", "shutdown", "statistics", "checkpoint", "noderestart", "connection", "info", "warning", "error", "congestion", "debug", "backup" };
+
+extern "C"
+const unsigned int *
+ndb_mgm_get_clusterlog_loglevel(NdbMgmHandle handle)
+{
+  SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_get_clusterlog_loglevel");
+  int loglevel_count = CFG_MAX_LOGLEVEL - CFG_MIN_LOGLEVEL + 1 ;
+  static unsigned int loglevel[CFG_MAX_LOGLEVEL - CFG_MIN_LOGLEVEL + 1] = {0,0,0,0,0,0,0,0,0,0,0,0};
+  const ParserRow<ParserDummy> getloglevel_reply[] = {
+    MGM_CMD("get cluster loglevel", NULL, ""),
+    MGM_ARG(clusterlog_names[0], Int, Mandatory, ""),
+    MGM_ARG(clusterlog_names[1], Int, Mandatory, ""),
+    MGM_ARG(clusterlog_names[2], Int, Mandatory, ""),
+    MGM_ARG(clusterlog_names[3], Int, Mandatory, ""),
+    MGM_ARG(clusterlog_names[4], Int, Mandatory, ""),
+    MGM_ARG(clusterlog_names[5], Int, Mandatory, ""),
+    MGM_ARG(clusterlog_names[6], Int, Mandatory, ""),
+    MGM_ARG(clusterlog_names[7], Int, Mandatory, ""),
+    MGM_ARG(clusterlog_names[8], Int, Mandatory, ""),
+    MGM_ARG(clusterlog_names[9], Int, Mandatory, ""),
+    MGM_ARG(clusterlog_names[10], Int, Mandatory, ""),
+    MGM_ARG(clusterlog_names[11], Int, Mandatory, ""),
+  };
+  CHECK_HANDLE(handle, NULL);
+  CHECK_CONNECTED(handle, NULL);
+
+  Properties args;
+  const Properties *reply;
+  reply = ndb_mgm_call(handle, getloglevel_reply, "get cluster loglevel", &args);
+  CHECK_REPLY(reply, NULL);
+
+  for(int i=0; i < loglevel_count; i++) {
+    reply->get(clusterlog_names[i], &loglevel[i]);
+  }
+  return loglevel;
+}
+
 extern "C"
 int 
 ndb_mgm_set_clusterlog_loglevel(NdbMgmHandle handle, int nodeId,

--- 1.78/storage/ndb/src/ndbapi/Ndb.cpp	2006-10-04 11:33:37 +02:00
+++ 1.79/storage/ndb/src/ndbapi/Ndb.cpp	2006-10-04 11:33:37 +02:00
@@ -1147,8 +1147,13 @@
     theError.code = tOperation->theError.code;
   DBUG_ASSERT(theError.code != 0);
 
+  NdbError savedError;
+  savedError = theError;
+
   if (tConnection != NULL)
     this->closeTransaction(tConnection);
+
+  theError = savedError;
 
   DBUG_RETURN(-1);
 }

--- 1.355/sql/ha_ndbcluster.cc	2006-10-04 11:33:37 +02:00
+++ 1.356/sql/ha_ndbcluster.cc	2006-10-04 11:33:37 +02:00
@@ -49,6 +49,16 @@
 extern const char *opt_ndbcluster_connectstring;
 extern ulong opt_ndb_cache_check_time;
 
+// ndb interface initialization/cleanup
+#ifdef  __cplusplus
+extern "C" {
+#endif
+extern void ndb_init_internal();
+extern void ndb_end_internal();
+#ifdef  __cplusplus
+}
+#endif
+
 const char *ndb_distribution_names[]= {"KEYHASH", "LINHASH", NullS};
 TYPELIB ndb_distribution_typelib= { array_elements(ndb_distribution_names)-1,
                                     "", ndb_distribution_names, NULL };
@@ -3976,7 +3986,14 @@
   if (lock_type != F_UNLCK)
   {
     DBUG_PRINT("info", ("lock_type != F_UNLCK"));
-    if (!thd->transaction.on)
+    if (thd->lex->sql_command == SQLCOM_LOAD)
+    {
+      m_transaction_on= FALSE;
+      /* Would be simpler if has_transactions() didn't always say "yes" */
+      thd->options|= OPTION_STATUS_NO_TRANS_UPDATE;
+      thd->no_trans_update= TRUE;
+    }
+    else if (!thd->transaction.on)
       m_transaction_on= FALSE;
     else
       m_transaction_on= thd->variables.ndb_use_transactions;
@@ -6229,25 +6246,40 @@
   List<char> delete_list;
   while ((file_name=it++))
   {
+    bool file_on_disk= false;
     DBUG_PRINT("info", ("%s", file_name));     
     if (hash_search(&ndb_tables, file_name, strlen(file_name)))
     {
       DBUG_PRINT("info", ("%s existed in NDB _and_ on disk ", file_name));
-      // File existed in NDB and as frm file, put in ok_tables list
-      my_hash_insert(&ok_tables, (byte*)file_name);
-      continue;
+      file_on_disk= true;
     }
     
-    // File is not in NDB, check for .ndb file with this name
+    // Check for .ndb file with this name
     build_table_filename(name, sizeof(name), db, file_name, ha_ndb_ext, 0);
     DBUG_PRINT("info", ("Check access for %s", name));
     if (my_access(name, F_OK))
     {
       DBUG_PRINT("info", ("%s did not exist on disk", name));     
       // .ndb file did not exist on disk, another table type
+      if (file_on_disk)
+      {
+	// Ignore this ndb table
+	gptr record=  hash_search(&ndb_tables, file_name, strlen(file_name));
+	DBUG_ASSERT(record);
+	hash_delete(&ndb_tables, record);
+	push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+			    ER_TABLE_EXISTS_ERROR,
+			    "Local table %s.%s shadows ndb table",
+			    db, file_name);
+      }
+      continue;
+    }
+    if (file_on_disk) 
+    {
+      // File existed in NDB and as frm file, put in ok_tables list
+      my_hash_insert(&ok_tables, (byte*)file_name);
       continue;
     }
-
     DBUG_PRINT("info", ("%s existed on disk", name));     
     // The .ndb file exists on disk, but it's not in list of tables in ndb
     // Verify that handler agrees table is gone.
@@ -6388,11 +6420,17 @@
     ndbcluster_binlog_init_handlerton();
 #endif
     h.flags=            HTON_CAN_RECREATE | HTON_TEMPORARY_NOT_SUPPORTED;
+    h.discover=         ndbcluster_discover;
+    h.find_files= ndbcluster_find_files;
+    h.table_exists_in_engine= ndbcluster_table_exists_in_engine;
   }
 
   if (have_ndbcluster != SHOW_OPTION_YES)
     DBUG_RETURN(0); // nothing else to do
 
+  // Initialize ndb interface
+  ndb_init_internal();
+
   // Set connectstring if specified
   if (opt_ndbcluster_connectstring != 0)
     DBUG_PRINT("connectstring", ("%s", opt_ndbcluster_connectstring));     
@@ -6542,6 +6580,9 @@
   delete g_ndb_cluster_connection;
   g_ndb_cluster_connection= NULL;
 
+  // cleanup ndb interface
+  ndb_end_internal();
+
   pthread_mutex_destroy(&ndbcluster_mutex);
   pthread_mutex_destroy(&LOCK_ndb_util_thread);
   pthread_cond_destroy(&COND_ndb_util_thread);
@@ -8573,11 +8614,13 @@
             DBUG_PRINT("info", ("FIELD_ITEM"));
             DBUG_PRINT("info", ("table %s", tab->getName()));
             DBUG_PRINT("info", ("column %s", field->field_name));
+            DBUG_PRINT("info", ("type %d", field->type()));
             DBUG_PRINT("info", ("result type %d", field->result_type()));
             
             // Check that we are expecting a field and with the correct
             // result type
             if (context->expecting(Item::FIELD_ITEM) &&
+                context->expecting_field_type(field->type()) &&
                 (context->expecting_field_result(field->result_type()) ||
                  // Date and year can be written as string or int
                  ((type == MYSQL_TYPE_TIME ||
@@ -8600,7 +8643,7 @@
               curr_cond->ndb_item= new Ndb_item(field, col->getColumnNo());
               context->dont_expect(Item::FIELD_ITEM);
               context->expect_no_field_result();
-              if (context->expect_mask)
+              if (! context->expecting_nothing())
               {
                 // We have not seen second argument yet
                 if (type == MYSQL_TYPE_TIME ||
@@ -8797,6 +8840,9 @@
                                               func_item);      
             context->expect(Item::STRING_ITEM);
             context->expect(Item::FIELD_ITEM);
+            context->expect_only_field_type(MYSQL_TYPE_STRING);
+            context->expect_field_type(MYSQL_TYPE_VAR_STRING);
+            context->expect_field_type(MYSQL_TYPE_VARCHAR);
             context->expect_field_result(STRING_RESULT);
             context->expect(Item::FUNC_ITEM);
             break;
@@ -8902,7 +8948,7 @@
                 NDB_ITEM_QUALIFICATION q;
                 q.value_type= Item::STRING_ITEM;
                 curr_cond->ndb_item= new Ndb_item(NDB_VALUE, q, item); 
-                if (context->expect_field_result_mask)
+                if (! context->expecting_no_field_result())
                 {
                   // We have not seen the field argument yet
                   context->expect_only(Item::FIELD_ITEM);
@@ -8932,7 +8978,7 @@
                 NDB_ITEM_QUALIFICATION q;
                 q.value_type= Item::REAL_ITEM;
                 curr_cond->ndb_item= new Ndb_item(NDB_VALUE, q, item);
-                if (context->expect_field_result_mask) 
+                if (! context->expecting_no_field_result()) 
                 {
                   // We have not seen the field argument yet
                   context->expect_only(Item::FIELD_ITEM);
@@ -8955,7 +9001,7 @@
                 NDB_ITEM_QUALIFICATION q;
                 q.value_type= Item::INT_ITEM;
                 curr_cond->ndb_item= new Ndb_item(NDB_VALUE, q, item);
-                if (context->expect_field_result_mask) 
+                if (! context->expecting_no_field_result()) 
                 {
                   // We have not seen the field argument yet
                   context->expect_only(Item::FIELD_ITEM);
@@ -8978,7 +9024,7 @@
                 NDB_ITEM_QUALIFICATION q;
                 q.value_type= Item::DECIMAL_ITEM;
                 curr_cond->ndb_item= new Ndb_item(NDB_VALUE, q, item);
-                if (context->expect_field_result_mask) 
+                if (! context->expecting_no_field_result()) 
                 {
                   // We have not seen the field argument yet
                   context->expect_only(Item::FIELD_ITEM);
@@ -9028,7 +9074,7 @@
             NDB_ITEM_QUALIFICATION q;
             q.value_type= Item::STRING_ITEM;
             curr_cond->ndb_item= new Ndb_item(NDB_VALUE, q, item);      
-            if (context->expect_field_result_mask)
+            if (! context->expecting_no_field_result())
             {
               // We have not seen the field argument yet
               context->expect_only(Item::FIELD_ITEM);
@@ -9061,7 +9107,7 @@
             NDB_ITEM_QUALIFICATION q;
             q.value_type= Item::INT_ITEM;
             curr_cond->ndb_item= new Ndb_item(NDB_VALUE, q, item);
-            if (context->expect_field_result_mask) 
+            if (! context->expecting_no_field_result()) 
             {
               // We have not seen the field argument yet
               context->expect_only(Item::FIELD_ITEM);
@@ -9088,7 +9134,7 @@
             NDB_ITEM_QUALIFICATION q;
             q.value_type= Item::REAL_ITEM;
             curr_cond->ndb_item= new Ndb_item(NDB_VALUE, q, item);
-            if (context->expect_field_result_mask) 
+            if (! context->expecting_no_field_result()) 
             {
               // We have not seen the field argument yet
               context->expect_only(Item::FIELD_ITEM);
@@ -9111,7 +9157,7 @@
             NDB_ITEM_QUALIFICATION q;
             q.value_type= Item::VARBIN_ITEM;
             curr_cond->ndb_item= new Ndb_item(NDB_VALUE, q, item);      
-            if (context->expect_field_result_mask)
+            if (! context->expecting_no_field_result())
             {
               // We have not seen the field argument yet
               context->expect_only(Item::FIELD_ITEM);
@@ -9136,7 +9182,7 @@
             NDB_ITEM_QUALIFICATION q;
             q.value_type= Item::DECIMAL_ITEM;
             curr_cond->ndb_item= new Ndb_item(NDB_VALUE, q, item);
-            if (context->expect_field_result_mask) 
+            if (! context->expecting_no_field_result()) 
             {
               // We have not seen the field argument yet
               context->expect_only(Item::FIELD_ITEM);
@@ -10422,9 +10468,12 @@
       }
 
       table->field[c++]->set_null(); // FILE_ID
+      table->field[c]->set_notnull();
       table->field[c++]->store(elt.name, strlen(elt.name),
                                system_charset_info);
+      table->field[c]->set_notnull();
       table->field[c++]->store("DATAFILE",8,system_charset_info);
+      table->field[c]->set_notnull();
       table->field[c++]->store(df.getTablespace(), strlen(df.getTablespace()),
                                system_charset_info);
       table->field[c++]->set_null(); // TABLE_CATALOG
@@ -10432,10 +10481,12 @@
       table->field[c++]->set_null(); // TABLE_NAME
 
       // LOGFILE_GROUP_NAME
+      table->field[c]->set_notnull();
       table->field[c++]->store(ts.getDefaultLogfileGroup(),
                                strlen(ts.getDefaultLogfileGroup()),
                                system_charset_info);
       table->field[c++]->set_null(); // LOGFILE_GROUP_NUMBER
+      table->field[c]->set_notnull();
       table->field[c++]->store(ndbcluster_hton_name,
                                ndbcluster_hton_name_length,
                                system_charset_info); // ENGINE
@@ -10443,11 +10494,16 @@
       table->field[c++]->set_null(); // FULLTEXT_KEYS
       table->field[c++]->set_null(); // DELETED_ROWS
       table->field[c++]->set_null(); // UPDATE_COUNT
+      table->field[c]->set_notnull();
       table->field[c++]->store(df.getFree() / ts.getExtentSize()); // FREE_EXTENTS
+      table->field[c]->set_notnull();
       table->field[c++]->store(df.getSize() / ts.getExtentSize()); // TOTAL_EXTENTS
+      table->field[c]->set_notnull();
       table->field[c++]->store(ts.getExtentSize()); // EXTENT_SIZE
 
+      table->field[c]->set_notnull();
       table->field[c++]->store(df.getSize()); // INITIAL_SIZE
+      table->field[c]->set_notnull();
       table->field[c++]->store(df.getSize()); // MAXIMUM_SIZE
       table->field[c++]->set_null(); // AUTOEXTEND_SIZE
 
@@ -10457,8 +10513,10 @@
       table->field[c++]->set_null(); // RECOVER_TIME
       table->field[c++]->set_null(); // TRANSACTION_COUNTER
 
+      table->field[c]->set_notnull();
       table->field[c++]->store(df.getObjectVersion()); // VERSION
 
+      table->field[c]->set_notnull();
       table->field[c++]->store("FIXED", 5, system_charset_info); // ROW_FORMAT
 
       table->field[c++]->set_null(); // TABLE_ROWS
@@ -10472,11 +10530,13 @@
       table->field[c++]->set_null(); // CHECK_TIME
       table->field[c++]->set_null(); // CHECKSUM
 
+      table->field[c]->set_notnull();
       table->field[c++]->store("NORMAL", 6, system_charset_info);
 
       char extra[30];
       int len= my_snprintf(extra, sizeof(extra), "CLUSTER_NODE=%u", id);
       table->field[c]->store(extra, len, system_charset_info);
+      table->field[c]->set_notnull();
       schema_table_store_record(thd, table);
     }
   }
@@ -10517,8 +10577,10 @@
 
       int c= 0;
       table->field[c++]->set_null(); // FILE_ID
+      table->field[c]->set_notnull();
       table->field[c++]->store(elt.name, strlen(elt.name),
                                system_charset_info);
+      table->field[c]->set_notnull();
       table->field[c++]->store("UNDO LOG", 8, system_charset_info);
       table->field[c++]->set_null(); // TABLESPACE NAME
       table->field[c++]->set_null(); // TABLE_CATALOG
@@ -10528,10 +10590,13 @@
       // LOGFILE_GROUP_NAME
       NdbDictionary::ObjectId objid;
       uf.getLogfileGroupId(&objid);
+      table->field[c]->set_notnull();
       table->field[c++]->store(uf.getLogfileGroup(),
                                strlen(uf.getLogfileGroup()),
                                system_charset_info);
+      table->field[c]->set_notnull();
       table->field[c++]->store(objid.getObjectId()); // LOGFILE_GROUP_NUMBER
+      table->field[c]->set_notnull();
       table->field[c++]->store(ndbcluster_hton_name,
                                ndbcluster_hton_name_length,
                                system_charset_info); // ENGINE
@@ -10539,11 +10604,15 @@
       table->field[c++]->set_null(); // FULLTEXT_KEYS
       table->field[c++]->set_null(); // DELETED_ROWS
       table->field[c++]->set_null(); // UPDATE_COUNT
-      table->field[c++]->store(lfg.getUndoFreeWords()); // FREE_EXTENTS
+      table->field[c++]->set_null(); // FREE_EXTENTS
+      table->field[c]->set_notnull();
       table->field[c++]->store(uf.getSize()/4); // TOTAL_EXTENTS
+      table->field[c]->set_notnull();
       table->field[c++]->store(4); // EXTENT_SIZE
 
+      table->field[c]->set_notnull();
       table->field[c++]->store(uf.getSize()); // INITIAL_SIZE
+      table->field[c]->set_notnull();
       table->field[c++]->store(uf.getSize()); // MAXIMUM_SIZE
       table->field[c++]->set_null(); // AUTOEXTEND_SIZE
 
@@ -10553,6 +10622,7 @@
       table->field[c++]->set_null(); // RECOVER_TIME
       table->field[c++]->set_null(); // TRANSACTION_COUNTER
 
+      table->field[c]->set_notnull();
       table->field[c++]->store(uf.getObjectVersion()); // VERSION
 
       table->field[c++]->set_null(); // ROW FORMAT
@@ -10568,17 +10638,111 @@
       table->field[c++]->set_null(); // CHECK_TIME
       table->field[c++]->set_null(); // CHECKSUM
 
+      table->field[c]->set_notnull();
       table->field[c++]->store("NORMAL", 6, system_charset_info);
 
       char extra[100];
       int len= my_snprintf(extra,sizeof(extra),"CLUSTER_NODE=%u;UNDO_BUFFER_SIZE=%lu",id,lfg.getUndoBufferSize());
+      table->field[c]->set_notnull();
       table->field[c]->store(extra, len, system_charset_info);
       schema_table_store_record(thd, table);
     }
   }
+
+  // now for LFGs
+  NdbDictionary::Dictionary::List lfglist;
+  dict->listObjects(lfglist, NdbDictionary::Object::LogfileGroup);
+  ndberr= dict->getNdbError();
+  if (ndberr.classification != NdbError::NoError)
+    ERR_RETURN(ndberr);
+
+  for (i= 0; i < lfglist.count; i++)
+  {
+    NdbDictionary::Dictionary::List::Element& elt= lfglist.elements[i];
+    unsigned id;
+
+    NdbDictionary::LogfileGroup lfg= dict->getLogfileGroup(elt.name);
+    ndberr= dict->getNdbError();
+    if (ndberr.classification != NdbError::NoError)
+    {
+      if (ndberr.classification == NdbError::SchemaError)
+        continue;
+      ERR_RETURN(ndberr);
+    }
+
+    int c= 0;
+    table->field[c++]->set_null(); // FILE_ID
+    table->field[c++]->set_null(); // name
+    table->field[c]->set_notnull();
+    table->field[c++]->store("UNDO LOG", 8, system_charset_info);
+    table->field[c++]->set_null(); // TABLESPACE NAME
+    table->field[c++]->set_null(); // TABLE_CATALOG
+    table->field[c++]->set_null(); // TABLE_SCHEMA
+    table->field[c++]->set_null(); // TABLE_NAME
+
+    // LOGFILE_GROUP_NAME
+    table->field[c]->set_notnull();
+    table->field[c++]->store(elt.name, strlen(elt.name),
+                             system_charset_info);
+    table->field[c]->set_notnull();
+    table->field[c++]->store(lfg.getObjectId()); // LOGFILE_GROUP_NUMBER
+    table->field[c]->set_notnull();
+    table->field[c++]->store(ndbcluster_hton_name,
+                             ndbcluster_hton_name_length,
+                             system_charset_info); // ENGINE
+
+    table->field[c++]->set_null(); // FULLTEXT_KEYS
+    table->field[c++]->set_null(); // DELETED_ROWS
+    table->field[c++]->set_null(); // UPDATE_COUNT
+    table->field[c]->set_notnull();
+    table->field[c++]->store(lfg.getUndoFreeWords()); // FREE_EXTENTS
+    table->field[c++]->set_null(); //store(uf.getSize()/4); // TOTAL_EXTENTS
+    table->field[c]->set_notnull();
+    table->field[c++]->store(4); // EXTENT_SIZE
+
+    table->field[c++]->set_null();//store(uf.getSize()); // INITIAL_SIZE
+    table->field[c++]->set_null(); //store(uf.getSize()); // MAXIMUM_SIZE
+    table->field[c++]->set_null(); // AUTOEXTEND_SIZE
+
+    table->field[c++]->set_null(); // CREATION_TIME
+    table->field[c++]->set_null(); // LAST_UPDATE_TIME
+    table->field[c++]->set_null(); // LAST_ACCESS_TIME
+    table->field[c++]->set_null(); // RECOVER_TIME
+    table->field[c++]->set_null(); // TRANSACTION_COUNTER
+
+    table->field[c]->set_notnull();
+    table->field[c++]->store(lfg.getObjectVersion()); // VERSION
+
+    table->field[c++]->set_null(); // ROW FORMAT
+
+    table->field[c++]->set_null(); // TABLE_ROWS
+    table->field[c++]->set_null(); // AVG_ROW_LENGTH
+    table->field[c++]->set_null(); // DATA_LENGTH
+    table->field[c++]->set_null(); // MAX_DATA_LENGTH
+    table->field[c++]->set_null(); // INDEX_LENGTH
+    table->field[c++]->set_null(); // DATA_FREE
+    table->field[c++]->set_null(); // CREATE_TIME
+    table->field[c++]->set_null(); // UPDATE_TIME
+    table->field[c++]->set_null(); // CHECK_TIME
+    table->field[c++]->set_null(); // CHECKSUM
+
+    table->field[c]->set_notnull();
+    table->field[c++]->store("NORMAL", 6, system_charset_info);
+
+    char extra[100];
+    int len= my_snprintf(extra,sizeof(extra),"UNDO_BUFFER_SIZE=%lu",id,lfg.getUndoBufferSize());
+    table->field[c]->set_notnull();
+    table->field[c]->store(extra, len, system_charset_info);
+    schema_table_store_record(thd, table);
+  }
   DBUG_RETURN(0);
 }
 
+SHOW_VAR ndb_status_variables_export[]= {
+  {"Ndb",                      (char*) &ndb_status_variables,   SHOW_ARRAY},
+  {NullS, NullS, SHOW_LONG}
+};
+
 struct st_mysql_storage_engine ndbcluster_storage_engine=
 { MYSQL_HANDLERTON_INTERFACE_VERSION, &ndbcluster_hton };
 
@@ -10592,7 +10756,9 @@
   ndbcluster_init, /* Plugin Init */
   NULL, /* Plugin Deinit */
   0x0100 /* 1.0 */,
-  0
+  ndb_status_variables_export,/* status variables                */
+  NULL,                       /* system variables                */
+  NULL                        /* config options                  */
 }
 mysql_declare_plugin_end;
 

--- 1.284.3.1/sql/ha_innodb.cc	2006-10-04 11:33:37 +02:00
+++ 1.297/storage/innobase/handler/ha_innodb.cc	2006-10-04 11:33:37 +02:00
@@ -31,8 +31,9 @@
 #pragma implementation				// gcc: Class implementation
 #endif
 
-#include "mysql_priv.h"
-#include "slave.h"
+#include <mysql_priv.h>
+
+#ifdef WITH_INNOBASE_STORAGE_ENGINE
 
 #include <m_ctype.h>
 #include <hash.h>
@@ -42,8 +43,6 @@
 
 #define MAX_ULONG_BIT ((ulong) 1 << (sizeof(ulong)*8-1))
 
-#ifdef WITH_INNOBASE_STORAGE_ENGINE
-
 #include "ha_innodb.h"
 
 pthread_mutex_t innobase_share_mutex,	/* to protect innobase_open_files */
@@ -208,6 +207,7 @@
                                         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)
@@ -311,7 +311,8 @@
   (char*) &export_vars.innodb_rows_read,		  SHOW_LONG},
   {"rows_updated",
   (char*) &export_vars.innodb_rows_updated,		  SHOW_LONG},
-  {NullS, NullS, SHOW_LONG}};
+  {NullS, NullS, SHOW_LONG}
+};
 
 /* General functions */
 
@@ -1601,21 +1602,6 @@
 	pthread_cond_init(&commit_cond, NULL);
 	innodb_inited= 1;
 
-	/* If this is a replication slave and we needed to do a crash recovery,
-	set the master binlog position to what InnoDB internally knew about
-	how far we got transactions durable inside InnoDB. There is a
-	problem here: if the user used also MyISAM tables, InnoDB might not
-	know the right position for them.
-
-	THIS DOES NOT WORK CURRENTLY because replication seems to initialize
-	glob_mi also after innobase_init. */
-
-/*	if (trx_sys_mysql_master_log_pos != -1) {
-		ut_memcpy(glob_mi.log_file_name, trx_sys_mysql_master_log_name,
-				1 + ut_strlen(trx_sys_mysql_master_log_name));
-		glob_mi.pos = trx_sys_mysql_master_log_pos;
-	}
-*/
 	DBUG_RETURN(FALSE);
 error:
 	have_innodb= SHOW_OPTION_DISABLED;	// If we couldn't use handler
@@ -1690,19 +1676,6 @@
 		return;
 	}
 
-#ifdef HAVE_REPLICATION
-	THD *thd=current_thd;
-
-	if (thd && thd->slave_thread) {
-		/* Update the replication position info inside InnoDB */
-
-		trx->mysql_master_log_file_name
-					= active_mi->rli.group_master_log_name;
-		trx->mysql_master_log_pos = ((ib_longlong)
-				active_mi->rli.future_group_master_log_pos);
-	}
-#endif /* HAVE_REPLICATION */
-
 	trx_commit_for_mysql(trx);
 }
 
@@ -2364,7 +2337,7 @@
 				"have forgotten\nto delete the corresponding "
 				".frm files of InnoDB tables, or you\n"
 				"have moved .frm files to another database?\n"
-				"See http://dev.mysql.com/doc/refman/5.0/en/innodb-troubleshooting.html\n"
+				"See http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n"
 				"how you can resolve the problem.\n",
 				norm_name);
 		free_share(share);
@@ -2381,7 +2354,7 @@
 				"Have you deleted the .ibd file from the "
 				"database directory under\nthe MySQL datadir, "
 				"or have you used DISCARD TABLESPACE?\n"
-				"See http://dev.mysql.com/doc/refman/5.0/en/innodb-troubleshooting.html\n"
+				"See http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n"
 				"how you can resolve the problem.\n",
 				norm_name);
 		free_share(share);
@@ -2914,7 +2887,6 @@
 
 			CHARSET_INFO*	cs;
 			ulint		key_len;
-			ulint		len;
 			ulint		true_len;
 			int		error=0;
 			ulint		blob_len;
@@ -3662,7 +3634,7 @@
 
 	DBUG_ENTER("ha_innobase::update_row");
 
-	ut_ad(prebuilt->trx ==
+	ut_a(prebuilt->trx ==
 		(trx_t*) current_thd->ha_data[innobase_hton.slot]);
 
 	if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
@@ -3723,7 +3695,7 @@
 
 	DBUG_ENTER("ha_innobase::delete_row");
 
-	ut_ad(prebuilt->trx ==
+	ut_a(prebuilt->trx ==
 		(trx_t*) current_thd->ha_data[innobase_hton.slot]);
 
 	if (last_query_id != user_thd->query_id) {
@@ -3821,6 +3793,9 @@
 {
 	row_prebuilt_t*	prebuilt = (row_prebuilt_t*) innobase_prebuilt;
 
+	ut_a(prebuilt->trx ==
+		(trx_t*) current_thd->ha_data[innobase_hton.slot]);
+
 	/* Row read type is set to semi consistent read if this was
 	requested by the MySQL and either innodb_locks_unsafe_for_binlog
 	option is used or this session is using READ COMMITTED isolation
@@ -3985,7 +3960,7 @@
 
 	DBUG_ENTER("index_read");
 
-	ut_ad(prebuilt->trx ==
+	ut_a(prebuilt->trx ==
 		(trx_t*) current_thd->ha_data[innobase_hton.slot]);
 
 	statistic_increment(current_thd->status_var.ha_read_key_count,
@@ -4100,7 +4075,7 @@
 	DBUG_ENTER("change_active_index");
 
 	ut_ad(user_thd == current_thd);
-	ut_ad(prebuilt->trx ==
+	ut_a(prebuilt->trx ==
 		(trx_t*) current_thd->ha_data[innobase_hton.slot]);
 
 	active_index = keynr;
@@ -4190,7 +4165,7 @@
 
 	DBUG_ENTER("general_fetch");
 
-	ut_ad(prebuilt->trx ==
+	ut_a(prebuilt->trx ==
 		(trx_t*) current_thd->ha_data[innobase_hton.slot]);
 
 	innodb_srv_conc_enter_innodb(prebuilt->trx);
@@ -4426,7 +4401,7 @@
 	statistic_increment(current_thd->status_var.ha_read_rnd_count,
 		&LOCK_status);
 
-	ut_ad(prebuilt->trx ==
+	ut_a(prebuilt->trx ==
 		(trx_t*) current_thd->ha_data[innobase_hton.slot]);
 
 	if (prebuilt->clust_index_was_generated) {
@@ -4476,7 +4451,7 @@
 	row_prebuilt_t*	prebuilt = (row_prebuilt_t*) innobase_prebuilt;
 	uint		len;
 
-	ut_ad(prebuilt->trx ==
+	ut_a(prebuilt->trx ==
 		(trx_t*) current_thd->ha_data[innobase_hton.slot]);
 
 	if (prebuilt->clust_index_was_generated) {
@@ -5004,7 +4979,6 @@
 {
 	row_prebuilt_t*	prebuilt	= (row_prebuilt_t*)innobase_prebuilt;
 	int		error;
-	trx_t*		trx;
 	THD*		thd		= current_thd;
 
 	DBUG_ENTER("ha_innobase::delete_all_rows");
@@ -5017,13 +4991,13 @@
 	}
 
 	/* Get the transaction associated with the current thd, or create one
-	if not yet created */
+	if not yet created, and update prebuilt->trx */
 
-	trx = check_trx_exists(thd);
+	update_thd(thd);
 
 	/* Truncate the table in InnoDB */
 
-	error = row_truncate_table_for_mysql(prebuilt->table, trx);
+	error = row_truncate_table_for_mysql(prebuilt->table, prebuilt->trx);
 	if (error == DB_ERROR) {
 		/* Cannot truncate; resort to ha_innobase::delete_row() */
 		goto fallback;
@@ -5306,6 +5280,9 @@
 
 	DBUG_ENTER("records_in_range");
 
+	ut_a(prebuilt->trx ==
+		(trx_t*) current_thd->ha_data[innobase_hton.slot]);
+
 	prebuilt->trx->op_info = (char*)"estimating records in index range";
 
 	/* In case MySQL calls this in the middle of a SELECT query, release
@@ -5608,7 +5585,7 @@
 						".frm file. Have you mixed up "
 						".frm files from different "
 						"installations? See "
-"http://dev.mysql.com/doc/refman/5.0/en/innodb-troubleshooting.html\n",
+"http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n",
 
 						ib_table->name);
 				break;
@@ -5622,7 +5599,7 @@
 "Index %s of %s has %lu columns unique inside InnoDB, but MySQL is asking "
 "statistics for %lu columns. Have you mixed up .frm files from different "
 "installations? "
-"See http://dev.mysql.com/doc/refman/5.0/en/innodb-troubleshooting.html\n",
+"See http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n",
 							index->name,
 							ib_table->name,
 							(unsigned long)
@@ -6028,6 +6005,10 @@
 	bool	can_switch;
 
 	DBUG_ENTER("ha_innobase::can_switch_engines");
+
+	ut_a(prebuilt->trx ==
+		(trx_t*) current_thd->ha_data[innobase_hton.slot]);
+
 	prebuilt->trx->op_info =
 			"determining if there are foreign key constraints";
 	row_mysql_lock_data_dictionary(prebuilt->trx);
@@ -6165,14 +6146,6 @@
 
 	innobase_release_stat_resources(trx);
 
-	if (trx->isolation_level <= TRX_ISO_READ_COMMITTED
-						&& trx->global_read_view) {
-		/* At low transaction isolation levels we let
-		each consistent read set its own snapshot */
-
-		read_view_close_for_mysql(trx);
-	}
-
 	prebuilt->sql_stat_start = TRUE;
 	prebuilt->hint_need_to_fetch_extra_cols = 0;
 	prebuilt->read_just_key = 0;
@@ -6431,7 +6404,7 @@
 "table %s does not exist.\n"
 "Have you deleted the .ibd file from the database directory under\n"
 "the MySQL datadir?"
-"See http://dev.mysql.com/doc/refman/5.0/en/innodb-troubleshooting.html\n"
+"See http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n"
 "how you can resolve the problem.\n",
 				prebuilt->table->name);
 		DBUG_RETURN(HA_ERR_CRASHED);
@@ -6785,13 +6758,19 @@
 						TL_IGNORE */
 {
 	row_prebuilt_t* prebuilt	= (row_prebuilt_t*) innobase_prebuilt;
-	trx_t*		trx		= prebuilt->trx;
+	trx_t*		trx;
+
+	/* Note that trx in this function is NOT necessarily prebuilt->trx
+	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);
 
-	/* NOTE: MySQL	can call this function with lock 'type' TL_IGNORE!
+	/* 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
 	only 'real' locks! */
 
-	/* If no MySQL tables is use we need to set isolation level
+	/* If no MySQL table is in use, we need to set the isolation level
 	of the transaction. */
 
 	if (lock_type != TL_IGNORE
@@ -6801,7 +6780,13 @@
 						thd->variables.tx_isolation);
 	}
 
-	if ((lock_type == TL_READ && thd->in_lock_tables) ||
+	if (thd->lex->sql_command == SQLCOM_DROP_TABLE) {
+
+		/* MySQL calls this function in DROP TABLE though this table
+		handle may belong to another thd that is running a query. Let
+		us in that case skip any changes to the prebuilt struct. */ 
+
+	} else if ((lock_type == TL_READ && thd->in_lock_tables) ||
 		(lock_type == TL_READ_HIGH_PRIORITY && thd->in_lock_tables) ||
 		lock_type == TL_READ_WITH_SHARED_LOCKS ||
 		lock_type == TL_READ_NO_INSERT ||
@@ -6902,28 +6887,28 @@
 		stored function call (MySQL does have thd->in_lock_tables
 		TRUE there). */
 
-    		if ((lock_type >= TL_WRITE_CONCURRENT_INSERT
-		    && lock_type <= TL_WRITE)
-		    && !(thd->in_lock_tables
-			    && thd->lex->sql_command == SQLCOM_LOCK_TABLES)
-		    && !thd->tablespace_op
-		    && thd->lex->sql_command != SQLCOM_TRUNCATE
-		    && thd->lex->sql_command != SQLCOM_OPTIMIZE
+		if ((lock_type >= TL_WRITE_CONCURRENT_INSERT
+		&& lock_type <= TL_WRITE)
+		&& !(thd->in_lock_tables
+			&& thd->lex->sql_command == SQLCOM_LOCK_TABLES)
+		&& !thd->tablespace_op
+		&& thd->lex->sql_command != SQLCOM_TRUNCATE
+		&& thd->lex->sql_command != SQLCOM_OPTIMIZE
+
 #ifdef __WIN__
-                /* 
-                   for alter table on win32 for succesfull operation 
-                   completion it is used TL_WRITE(=10) lock instead of
-                   TL_WRITE_ALLOW_READ(=6), however here in innodb handler
-                   TL_WRITE is lifted to TL_WRITE_ALLOW_WRITE, which causes
-                   race condition when several clients do alter table 
-                   simultaneously (bug #17264). This fix avoids the problem.
-                */
-                    && thd->lex->sql_command != SQLCOM_ALTER_TABLE
+                /* For alter table on win32 for succesful operation
+                completion it is used TL_WRITE(=10) lock instead of
+                TL_WRITE_ALLOW_READ(=6), however here in innodb handler
+                TL_WRITE is lifted to TL_WRITE_ALLOW_WRITE, which causes
+                race condition when several clients do alter table
+                simultaneously (bug #17264). This fix avoids the problem. */
+                && thd->lex->sql_command != SQLCOM_ALTER_TABLE
 #endif
-		    && thd->lex->sql_command != SQLCOM_CREATE_TABLE) {
+
+		&& thd->lex->sql_command != SQLCOM_CREATE_TABLE) {
 
 			lock_type = TL_WRITE_ALLOW_WRITE;
-      		}
+		}
 
 		/* In queries of type INSERT INTO t1 SELECT ... FROM t2 ...
 		MySQL would use the lock TL_READ_NO_INSERT on t2, and that
@@ -6970,10 +6955,11 @@
 	int		error;
 
 	ut_a(prebuilt);
-	ut_a(prebuilt->trx ==
-		(trx_t*) current_thd->ha_data[innobase_hton.slot]);
 	ut_a(prebuilt->table);
 
+	/* Prepare prebuilt->trx in the table handle */
+	update_thd(current_thd);
+
 	if (prebuilt->trx->conc_state == TRX_NOT_STARTED) {
 		trx_was_not_started = TRUE;
 	}
@@ -7058,10 +7044,16 @@
 		'found_next_number_field' below because MySQL in SHOW TABLE
 		STATUS does not seem to set 'next_number_field'. The comment
 		in table.h says that 'next_number_field' is set when it is
-		'active'. */
+		'active'.
+		Since 5.1 MySQL enforces that we announce fields which we will
+		read; as we only do a val_*() call, dbug_tmp_use_all_columns()
+		with read_set is sufficient. */
 
+		my_bitmap_map *old_map;
+		old_map= dbug_tmp_use_all_columns(table, table->read_set);
 		auto_inc = (longlong) table->found_next_number_field->
 				val_int_offset(table->s->rec_buff_length) + 1;
+		dbug_tmp_restore_column_map(table->read_set, old_map);
 	}
 
 	dict_table_autoinc_initialize(prebuilt->table, auto_inc);
@@ -7108,6 +7100,9 @@
 	longlong	nr;
 	int		error;
 
+	/* Prepare prebuilt->trx in the table handle */
+	update_thd(current_thd);
+
 	error = innobase_read_and_init_auto_inc(&nr);
 
 	if (error) {
@@ -7136,6 +7131,8 @@
 	row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
 	int		error;
 
+	update_thd(current_thd);
+
 	error = row_lock_table_autoinc_for_mysql(prebuilt);
 
 	if (error != DB_SUCCESS) {
@@ -7176,7 +7173,7 @@
 	const mysql_byte* ref2)	/* in: an (internal) primary key value in the
 				MySQL key value format */
 {
-	row_prebuilt_t*	prebuilt = (row_prebuilt_t*) innobase_prebuilt;
+	row_prebuilt_t* prebuilt	= (row_prebuilt_t*) innobase_prebuilt;
 	enum_field_types mysql_type;
 	Field*		field;
 	KEY_PART_INFO*	key_part;
@@ -7380,7 +7377,9 @@
 	int error = 0;
 	trx_t* trx = check_trx_exists(thd);
 
-	if (thd->lex->sql_command != SQLCOM_XA_PREPARE) {
+	if (thd->lex->sql_command != SQLCOM_XA_PREPARE &&
+	    (all || !(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))))
+	{
 
 		/* For ibbackup to work the order of transactions in binlog
 		and InnoDB must be the same. Consider the situation
@@ -7592,6 +7591,19 @@
 	return COMPATIBLE_DATA_YES;
 }
 
+static int show_innodb_vars(THD *thd, SHOW_VAR *var, char *buff)
+{
+  innodb_export_status();
+  var->type= SHOW_ARRAY;
+  var->value= (char *) &innodb_status_variables;
+  return 0;
+}
+
+SHOW_VAR innodb_status_variables_export[]= {
+  {"Innodb",                   (char*) &show_innodb_vars, SHOW_FUNC},
+  {NullS, NullS, SHOW_LONG}
+};
+
 struct st_mysql_storage_engine innobase_storage_engine=
 { MYSQL_HANDLERTON_INTERFACE_VERSION, &innobase_hton};
 
@@ -7605,9 +7617,10 @@
   innobase_init, /* Plugin Init */
   NULL, /* Plugin Deinit */
   0x0100 /* 1.0 */,
-  0
+  innodb_status_variables_export,/* status variables             */
+  NULL,                       /* system variables                */
+  NULL                        /* config options                  */
 }
 mysql_declare_plugin_end;
 
 #endif
-

--- 1.75/storage/ndb/src/ndbapi/ndberror.c	2006-10-04 11:33:37 +02:00
+++ 1.76/storage/ndb/src/ndbapi/ndberror.c	2006-10-04 11:33:37 +02:00
@@ -421,6 +421,9 @@
   
   { 773,  DMEC, SE, "Out of string memory, please modify StringMemory config parameter" },
   { 775,  DMEC, SE, "Create file is not supported when Diskless=1" },
+  { 776,  DMEC, AE, "Index created on temporary table must itself be temporary" },
+  { 777,  DMEC, AE, "Cannot create a temporary index on a non-temporary table" },
+  { 778,  DMEC, AE, "A temporary table or index must be specified as not logging" },
   
   /**
    * FunctionNotImplemented
@@ -611,7 +614,7 @@
   { 4272, DMEC, AE, "Table definition has undefined column" },
   { 4273, DMEC, IE, "No blob table in dict cache" },
   { 4274, DMEC, IE, "Corrupted main table PK in blob operation" },
-  { 4275, DMEC, AE, "The blob method is incompatible with operation type or lock mode" }
+  { 4275, DMEC, AE, "The blob method is incompatible with operation type or lock mode" },
 };
 
 static
Thread
bk commit into 5.1 tree (knielsen:1.2298)knielsen4 Oct